diff options
author | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-16 22:43:22 +0000 |
---|---|---|
committer | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-16 22:43:22 +0000 |
commit | 9b591247b018f7413a7cb96db13ab3fb071e6c5d (patch) | |
tree | 86b109c8f86b45b92fdb324360c6f5966e705fff /chrome/browser/chromeos | |
parent | 32e13a4845ed1a14a2e169128fd3414fd20d8a6a (diff) | |
download | chromium_src-9b591247b018f7413a7cb96db13ab3fb071e6c5d.zip chromium_src-9b591247b018f7413a7cb96db13ab3fb071e6c5d.tar.gz chromium_src-9b591247b018f7413a7cb96db13ab3fb071e6c5d.tar.bz2 |
Changes to use async RequestUpdateTrack and SetUpdateTrack in UpdateLibrary.
See http://codereview.chromium.org/6673061/ for libcros changes
Nore: requires updating cros.DEPS before pushing this.
BUG=chromium-os:13089
TEST=See issue.
Review URL: http://codereview.chromium.org/6694051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78452 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r-- | chrome/browser/chromeos/cros/mock_update_library.h | 5 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/update_library.cc | 30 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/update_library.h | 10 |
3 files changed, 27 insertions, 18 deletions
diff --git a/chrome/browser/chromeos/cros/mock_update_library.h b/chrome/browser/chromeos/cros/mock_update_library.h index 35af433..8abace9 100644 --- a/chrome/browser/chromeos/cros/mock_update_library.h +++ b/chrome/browser/chromeos/cros/mock_update_library.h @@ -18,10 +18,11 @@ class MockUpdateLibrary : public UpdateLibrary { virtual ~MockUpdateLibrary() {} MOCK_METHOD1(AddObserver, void(Observer*)); // NOLINT MOCK_METHOD1(RemoveObserver, void(Observer*)); // NOLINT + MOCK_METHOD1(HasObserver, bool(Observer*)); MOCK_METHOD2(RequestUpdateCheck, void(chromeos::UpdateCallback, void*)); MOCK_METHOD0(RebootAfterUpdate, bool(void)); - MOCK_METHOD1(SetReleaseTrack, bool(const std::string&)); - MOCK_METHOD0(GetReleaseTrack, std::string()); + MOCK_METHOD1(SetReleaseTrack, void(const std::string&)); + MOCK_METHOD2(GetReleaseTrack, void(chromeos::UpdateTrackCallback, void*)); MOCK_CONST_METHOD0(status, const Status&(void)); private: diff --git a/chrome/browser/chromeos/cros/update_library.cc b/chrome/browser/chromeos/cros/update_library.cc index 44c7d76..d4d48caf 100644 --- a/chrome/browser/chromeos/cros/update_library.cc +++ b/chrome/browser/chromeos/cros/update_library.cc @@ -36,6 +36,10 @@ class UpdateLibraryImpl : public UpdateLibrary { observers_.RemoveObserver(observer); } + bool HasObserver(Observer* observer) { + return observers_.HasObserver(observer); + } + void RequestUpdateCheck(chromeos::UpdateCallback callback, void* user_data) { if (CrosLibrary::Get()->EnsureLoaded()) chromeos::RequestUpdateCheck(callback, user_data); @@ -48,18 +52,15 @@ class UpdateLibraryImpl : public UpdateLibrary { return RebootIfUpdated(); } - bool SetReleaseTrack(const std::string& track) { - if (!CrosLibrary::Get()->EnsureLoaded()) - return false; - - return chromeos::SetTrack(track); + void SetReleaseTrack(const std::string& track) { + if (CrosLibrary::Get()->EnsureLoaded()) + chromeos::SetUpdateTrack(track); } - std::string GetReleaseTrack() { - if (!CrosLibrary::Get()->EnsureLoaded()) - return ""; - - return chromeos::GetTrack(); + void GetReleaseTrack(chromeos::UpdateTrackCallback callback, + void* user_data) { + if (CrosLibrary::Get()->EnsureLoaded()) + chromeos::RequestUpdateTrack(callback, user_data); } const UpdateLibrary::Status& status() const { @@ -117,13 +118,18 @@ class UpdateLibraryStubImpl : public UpdateLibrary { ~UpdateLibraryStubImpl() {} void AddObserver(Observer* observer) {} void RemoveObserver(Observer* observer) {} + bool HasObserver(Observer* observer) { return false; } void RequestUpdateCheck(chromeos::UpdateCallback callback, void* user_data) { if (callback) callback(user_data, UPDATE_RESULT_FAILED, "stub update"); } bool RebootAfterUpdate() { return false; } - bool SetReleaseTrack(const std::string& track) { return false; } - std::string GetReleaseTrack() { return "beta-channel"; } + void SetReleaseTrack(const std::string& track) { } + void GetReleaseTrack(chromeos::UpdateTrackCallback callback, + void* user_data) { + if (callback) + callback(user_data, "beta-channel"); + } const UpdateLibrary::Status& status() const { return status_; } diff --git a/chrome/browser/chromeos/cros/update_library.h b/chrome/browser/chromeos/cros/update_library.h index 8fe31cf..cf90722 100644 --- a/chrome/browser/chromeos/cros/update_library.h +++ b/chrome/browser/chromeos/cros/update_library.h @@ -61,6 +61,7 @@ class UpdateLibrary { virtual ~UpdateLibrary() {} virtual void AddObserver(Observer* observer) = 0; virtual void RemoveObserver(Observer* observer) = 0; + virtual bool HasObserver(Observer* observer) = 0; // Requests an update check and calls |callback| when completed. virtual void RequestUpdateCheck(chromeos::UpdateCallback callback, @@ -71,11 +72,12 @@ class UpdateLibrary { // Sets the release track (channel). |track| should look like // "beta-channel" and "dev-channel". Returns true on success. - virtual bool SetReleaseTrack(const std::string& track) = 0; + virtual void SetReleaseTrack(const std::string& track) = 0; - // Returns the release track (channel). On error, returns an empty - // string. - virtual std::string GetReleaseTrack() = 0; + // Calls |callback| with the release track (channel). On error, calls + // |callback| with NULL. + virtual void GetReleaseTrack(chromeos::UpdateTrackCallback callback, + void* user_data) = 0; virtual const Status& status() const = 0; |