| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/cros/update_library.h" | 5 #include "chrome/browser/chromeos/cros/update_library.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 void AddObserver(Observer* observer) { | 31 void AddObserver(Observer* observer) { |
| 32 observers_.AddObserver(observer); | 32 observers_.AddObserver(observer); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void RemoveObserver(Observer* observer) { | 35 void RemoveObserver(Observer* observer) { |
| 36 observers_.RemoveObserver(observer); | 36 observers_.RemoveObserver(observer); |
| 37 } | 37 } |
| 38 | 38 |
| 39 bool CheckForUpdate() { | 39 void CheckForUpdate() { |
| 40 if (!CrosLibrary::Get()->EnsureLoaded()) | 40 if (CrosLibrary::Get()->EnsureLoaded()) |
| 41 return false; | 41 RequestUpdateCheck(NULL, NULL); |
| 42 } |
| 42 | 43 |
| 43 return InitiateUpdateCheck(); | 44 void RequestUpdate(chromeos::UpdateCallback callback, void* user_data) { |
| 45 if (CrosLibrary::Get()->EnsureLoaded()) |
| 46 RequestUpdateCheck(callback, user_data); |
| 44 } | 47 } |
| 45 | 48 |
| 46 bool RebootAfterUpdate() { | 49 bool RebootAfterUpdate() { |
| 47 if (!CrosLibrary::Get()->EnsureLoaded()) | 50 if (!CrosLibrary::Get()->EnsureLoaded()) |
| 48 return false; | 51 return false; |
| 49 | 52 |
| 50 return RebootIfUpdated(); | 53 return RebootIfUpdated(); |
| 51 } | 54 } |
| 52 | 55 |
| 53 bool SetReleaseTrack(const std::string& track) { | 56 bool SetReleaseTrack(const std::string& track) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 115 |
| 113 DISALLOW_COPY_AND_ASSIGN(UpdateLibraryImpl); | 116 DISALLOW_COPY_AND_ASSIGN(UpdateLibraryImpl); |
| 114 }; | 117 }; |
| 115 | 118 |
| 116 class UpdateLibraryStubImpl : public UpdateLibrary { | 119 class UpdateLibraryStubImpl : public UpdateLibrary { |
| 117 public: | 120 public: |
| 118 UpdateLibraryStubImpl() {} | 121 UpdateLibraryStubImpl() {} |
| 119 ~UpdateLibraryStubImpl() {} | 122 ~UpdateLibraryStubImpl() {} |
| 120 void AddObserver(Observer* observer) {} | 123 void AddObserver(Observer* observer) {} |
| 121 void RemoveObserver(Observer* observer) {} | 124 void RemoveObserver(Observer* observer) {} |
| 122 bool CheckForUpdate() { return false; } | 125 void CheckForUpdate() {} |
| 126 void RequestUpdate(chromeos::UpdateCallback callback, void* user_data) { |
| 127 if (callback) |
| 128 callback(user_data, UPDATE_RESULT_FAILED, "stub update"); |
| 129 } |
| 123 bool RebootAfterUpdate() { return false; } | 130 bool RebootAfterUpdate() { return false; } |
| 124 bool SetReleaseTrack(const std::string& track) { return false; } | 131 bool SetReleaseTrack(const std::string& track) { return false; } |
| 125 std::string GetReleaseTrack() { return "beta-channel"; } | 132 std::string GetReleaseTrack() { return "beta-channel"; } |
| 126 const UpdateLibrary::Status& status() const { | 133 const UpdateLibrary::Status& status() const { |
| 127 return status_; | 134 return status_; |
| 128 } | 135 } |
| 129 | 136 |
| 130 private: | 137 private: |
| 131 Status status_; | 138 Status status_; |
| 132 | 139 |
| 133 DISALLOW_COPY_AND_ASSIGN(UpdateLibraryStubImpl); | 140 DISALLOW_COPY_AND_ASSIGN(UpdateLibraryStubImpl); |
| 134 }; | 141 }; |
| 135 | 142 |
| 136 // static | 143 // static |
| 137 UpdateLibrary* UpdateLibrary::GetImpl(bool stub) { | 144 UpdateLibrary* UpdateLibrary::GetImpl(bool stub) { |
| 138 if (stub) | 145 if (stub) |
| 139 return new UpdateLibraryStubImpl(); | 146 return new UpdateLibraryStubImpl(); |
| 140 else | 147 else |
| 141 return new UpdateLibraryImpl(); | 148 return new UpdateLibraryImpl(); |
| 142 } | 149 } |
| 143 | 150 |
| 144 } // namespace chromeos | 151 } // namespace chromeos |
| 145 | 152 |
| 146 // Allows InvokeLater without adding refcounting. This class is a Singleton and | 153 // Allows InvokeLater without adding refcounting. This class is a Singleton and |
| 147 // won't be deleted until it's last InvokeLater is run. | 154 // won't be deleted until it's last InvokeLater is run. |
| 148 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::UpdateLibraryImpl); | 155 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::UpdateLibraryImpl); |
| OLD | NEW |