diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 21:13:57 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 21:13:57 +0000 |
commit | 5fe3a5c1c887bd44e0778baae398f857c1f7eb2e (patch) | |
tree | 0ae8b88a468859cb47ddba60aa1fd5cd34d71f63 | |
parent | fef740228a40dd2bb74d1f500b7477dff3a95a92 (diff) | |
download | chromium_src-5fe3a5c1c887bd44e0778baae398f857c1f7eb2e.zip chromium_src-5fe3a5c1c887bd44e0778baae398f857c1f7eb2e.tar.gz chromium_src-5fe3a5c1c887bd44e0778baae398f857c1f7eb2e.tar.bz2 |
chromeos: Remove UpdateLibrary code, which is no longer used.
This is part 3 of the UpdateLibrary to UpdateEngineClient migration.
Hopefully, this is the last step.
BUG=chromium-os:16564
TEST=chrome and tests build as before
Review URL: http://codereview.chromium.org/8637020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111215 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/cros/cros_library.cc | 3 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/cros_library.h | 4 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/mock_update_library.cc | 13 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/mock_update_library.h | 36 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/update_library.cc | 147 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/update_library.h | 88 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 2 |
8 files changed, 0 insertions, 295 deletions
diff --git a/chrome/browser/chromeos/cros/cros_library.cc b/chrome/browser/chromeos/cros/cros_library.cc index f184871..50bbf21 100644 --- a/chrome/browser/chromeos/cros/cros_library.cc +++ b/chrome/browser/chromeos/cros/cros_library.cc @@ -11,7 +11,6 @@ #include "chrome/browser/chromeos/cros/network_library.h" #include "chrome/browser/chromeos/cros/power_library.h" #include "chrome/browser/chromeos/cros/screen_lock_library.h" -#include "chrome/browser/chromeos/cros/update_library.h" #include "third_party/cros/chromeos_cros_api.h" // Pass !libcros_loaded_ to GetDefaultImpl instead of use_stub_impl_ so that @@ -84,7 +83,6 @@ DEFINE_GET_LIBRARY_METHOD(Cryptohome, crypto); DEFINE_GET_LIBRARY_METHOD(Network, network); DEFINE_GET_LIBRARY_METHOD(Power, power); DEFINE_GET_LIBRARY_METHOD(ScreenLock, screen_lock); -DEFINE_GET_LIBRARY_METHOD(Update, update); bool CrosLibrary::LoadLibcros() { if (!libcros_loaded_ && !load_error_) { @@ -129,6 +127,5 @@ DEFINE_SET_LIBRARY_METHOD(Cryptohome, crypto); DEFINE_SET_LIBRARY_METHOD(Network, network); DEFINE_SET_LIBRARY_METHOD(Power, power); DEFINE_SET_LIBRARY_METHOD(ScreenLock, screen_lock); -DEFINE_SET_LIBRARY_METHOD(Update, update); } // namespace chromeos diff --git a/chrome/browser/chromeos/cros/cros_library.h b/chrome/browser/chromeos/cros/cros_library.h index 764c143..8c28ab5 100644 --- a/chrome/browser/chromeos/cros/cros_library.h +++ b/chrome/browser/chromeos/cros/cros_library.h @@ -23,7 +23,6 @@ class LibraryLoader; class NetworkLibrary; class PowerLibrary; class ScreenLockLibrary; -class UpdateLibrary; // This class handles access to sub-parts of ChromeOS library. it provides // a level of indirection so individual libraries that it exposes can @@ -49,7 +48,6 @@ class CrosLibrary { void SetNetworkLibrary(NetworkLibrary* library, bool own); void SetPowerLibrary(PowerLibrary* library, bool own); void SetScreenLockLibrary(ScreenLockLibrary* library, bool own); - void SetUpdateLibrary(UpdateLibrary* library, bool own); private: friend class CrosLibrary; @@ -74,7 +72,6 @@ class CrosLibrary { NetworkLibrary* GetNetworkLibrary(); PowerLibrary* GetPowerLibrary(); ScreenLockLibrary* GetScreenLockLibrary(); - UpdateLibrary* GetUpdateLibrary(); // Getter for Test API that gives access to internal members of this class. TestApi* GetTestApi(); @@ -139,7 +136,6 @@ class CrosLibrary { Library<NetworkLibrary> network_lib_; Library<PowerLibrary> power_lib_; Library<ScreenLockLibrary> screen_lock_lib_; - Library<UpdateLibrary> update_lib_; // Stub implementations of the libraries should be used. bool use_stub_impl_; diff --git a/chrome/browser/chromeos/cros/mock_update_library.cc b/chrome/browser/chromeos/cros/mock_update_library.cc deleted file mode 100644 index 2049969..0000000 --- a/chrome/browser/chromeos/cros/mock_update_library.cc +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/cros/mock_update_library.h" - -namespace chromeos { - -MockUpdateLibrary::MockUpdateLibrary() {} - -MockUpdateLibrary::~MockUpdateLibrary() {} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/cros/mock_update_library.h b/chrome/browser/chromeos/cros/mock_update_library.h deleted file mode 100644 index f1cb7046..0000000 --- a/chrome/browser/chromeos/cros/mock_update_library.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_CROS_MOCK_UPDATE_LIBRARY_H_ -#define CHROME_BROWSER_CHROMEOS_CROS_MOCK_UPDATE_LIBRARY_H_ -#pragma once - -#include "base/observer_list.h" -#include "chrome/browser/chromeos/cros/update_library.h" -#include "testing/gmock/include/gmock/gmock.h" - -namespace chromeos { - -class MockUpdateLibrary : public UpdateLibrary { - public: - MockUpdateLibrary(); - virtual ~MockUpdateLibrary(); - - MOCK_METHOD0(Init, void(void)); - 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, void(void)); - MOCK_METHOD1(SetReleaseTrack, void(const std::string&)); - MOCK_METHOD2(GetReleaseTrack, void(chromeos::UpdateTrackCallback, void*)); - MOCK_CONST_METHOD0(status, const Status&(void)); - - private: - DISALLOW_COPY_AND_ASSIGN(MockUpdateLibrary); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_CROS_MOCK_UPDATE_LIBRARY_H_ diff --git a/chrome/browser/chromeos/cros/update_library.cc b/chrome/browser/chromeos/cros/update_library.cc deleted file mode 100644 index 6adae59..0000000 --- a/chrome/browser/chromeos/cros/update_library.cc +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/cros/update_library.h" - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/logging.h" -#include "base/message_loop.h" -#include "base/observer_list.h" -#include "chrome/browser/chromeos/cros/cros_library.h" -#include "content/public/browser/browser_thread.h" - -using content::BrowserThread; - -namespace chromeos { - -class UpdateLibraryImpl : public UpdateLibrary { - public: - UpdateLibraryImpl() : status_connection_(NULL) {} - - virtual ~UpdateLibraryImpl() { - if (status_connection_) { - chromeos::DisconnectUpdateProgress(status_connection_); - status_connection_ = NULL; - } - } - - // Begin UpdateLibrary implementation. - virtual void Init() OVERRIDE { - DCHECK(CrosLibrary::Get()->libcros_loaded()); - CHECK(!status_connection_) << "Already initialized"; - status_connection_ = - chromeos::MonitorUpdateStatus(&UpdateStatusHandler, this); - // Asynchronously load the initial state. - chromeos::RequestUpdateStatus(&UpdateStatusHandler, this); - } - - virtual void AddObserver(Observer* observer) OVERRIDE { - observers_.AddObserver(observer); - } - - virtual void RemoveObserver(Observer* observer) OVERRIDE { - observers_.RemoveObserver(observer); - } - - virtual bool HasObserver(Observer* observer) OVERRIDE { - return observers_.HasObserver(observer); - } - - virtual void RequestUpdateCheck(chromeos::UpdateCallback callback, - void* user_data) OVERRIDE { - chromeos::RequestUpdateCheck(callback, user_data); - } - - virtual void RebootAfterUpdate() OVERRIDE { - chromeos::RebootIfUpdated(); - } - - virtual void SetReleaseTrack(const std::string& track) OVERRIDE { - chromeos::SetUpdateTrack(track); - } - - virtual void GetReleaseTrack(chromeos::UpdateTrackCallback callback, - void* user_data) OVERRIDE { - chromeos::RequestUpdateTrack(callback, user_data); - } - // End UpdateLibrary implementation. - - virtual const UpdateLibrary::Status& status() const OVERRIDE{ - return status_; - } - - private: - static void UpdateStatusHandler(void* object, const UpdateProgress& status) { - UpdateLibraryImpl* impl = static_cast<UpdateLibraryImpl*>(object); - impl->UpdateStatus(Status(status)); - } - - void UpdateStatus(const Status& status) { - // Called from UpdateStatusHandler, a libcros callback which should - // always run on UI thread. - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - status_ = status; - FOR_EACH_OBSERVER(Observer, observers_, UpdateStatusChanged(status)); - } - - ObserverList<Observer> observers_; - - // A reference to the update api, to allow callbacks when the update - // status changes. - UpdateStatusConnection status_connection_; - - // The latest power status. - Status status_; - - DISALLOW_COPY_AND_ASSIGN(UpdateLibraryImpl); -}; - -class UpdateLibraryStubImpl : public UpdateLibrary { - public: - UpdateLibraryStubImpl() {} - virtual ~UpdateLibraryStubImpl() {} - - // Begin UpdateLibrary implementation. - virtual void Init() OVERRIDE {} - virtual void AddObserver(Observer* observer) OVERRIDE {} - virtual void RemoveObserver(Observer* observer) OVERRIDE {} - virtual bool HasObserver(Observer* observer) OVERRIDE { return false; } - virtual void RequestUpdateCheck(chromeos::UpdateCallback callback, - void* user_data) OVERRIDE { - if (callback) - callback(user_data, UPDATE_RESULT_FAILED, "stub update"); - } - virtual void RebootAfterUpdate() OVERRIDE {} - virtual void SetReleaseTrack(const std::string& track) OVERRIDE {} - virtual void GetReleaseTrack(chromeos::UpdateTrackCallback callback, - void* user_data) OVERRIDE { - if (callback) - callback(user_data, "beta-channel"); - } - // End UpdateLibrary implementation. - - virtual const UpdateLibrary::Status& status() const OVERRIDE { - return status_; - } - - private: - Status status_; - - DISALLOW_COPY_AND_ASSIGN(UpdateLibraryStubImpl); -}; - -// static -UpdateLibrary* UpdateLibrary::GetImpl(bool stub) { - UpdateLibrary* impl; - if (stub) - impl = new UpdateLibraryStubImpl(); - else - impl = new UpdateLibraryImpl(); - impl->Init(); - return impl; -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/cros/update_library.h b/chrome/browser/chromeos/cros/update_library.h deleted file mode 100644 index 3aa41e2..0000000 --- a/chrome/browser/chromeos/cros/update_library.h +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_CROS_UPDATE_LIBRARY_H_ -#define CHROME_BROWSER_CHROMEOS_CROS_UPDATE_LIBRARY_H_ -#pragma once - -#include <string> - -#include "third_party/cros/chromeos_update_engine.h" - -namespace chromeos { - -// This interface defines interaction with the ChromeOS update library APIs. -// Classes can add themselves as observers. Users can get an instance of this -// library class like this: chromeos::CrosLibrary::Get()->GetUpdateLibrary() -class UpdateLibrary { - public: - // TODO(seanparent): Should make the UpdateProgress type copyable. - // We need to copy it to bind it for a deferred notification. - // Modifying the cros library just for that, for a single use case, - // isn't worth it. Instead we define this a local Status struct that - // is copyable. - struct Status { - Status() - : status(UPDATE_STATUS_IDLE), - download_progress(0.0), - last_checked_time(0), - new_size(0) { - } - - explicit Status(const UpdateProgress& o) - : status(o.status_), - download_progress(o.download_progress_), - last_checked_time(o.last_checked_time_), - new_version(o.new_version_), - new_size(o.new_size_) { - } - - UpdateStatusOperation status; - double download_progress; // 0.0 - 1.0 - int64_t last_checked_time; // As reported by std::time(). - std::string new_version; - int64_t new_size; // Valid during DOWNLOADING, in bytes. - }; - - class Observer { - public: - virtual ~Observer() {} - - virtual void UpdateStatusChanged(const Status& status) = 0; - }; - - virtual ~UpdateLibrary() {} - - virtual void Init() = 0; - - 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, - void* user_data) = 0; - - // Reboots if update has been performed. - virtual void RebootAfterUpdate() = 0; - - // Sets the release track (channel). |track| should look like - // "beta-channel" and "dev-channel". Returns true on success. - virtual void SetReleaseTrack(const std::string& track) = 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; - - // Factory function, creates a new instance and returns ownership. - // For normal usage, access the singleton via CrosLibrary::Get(). - static UpdateLibrary* GetImpl(bool stub); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_CROS_UPDATE_LIBRARY_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 2cb50dd..02ab0d1 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -422,8 +422,6 @@ 'browser/chromeos/cros/power_library.h', 'browser/chromeos/cros/screen_lock_library.cc', 'browser/chromeos/cros/screen_lock_library.h', - 'browser/chromeos/cros/update_library.cc', - 'browser/chromeos/cros/update_library.h', 'browser/chromeos/cros_settings.cc', 'browser/chromeos/cros_settings.h', 'browser/chromeos/cros_settings_names.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 5695c91..4fab509 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2480,8 +2480,6 @@ 'browser/chromeos/cros/mock_power_library.h', 'browser/chromeos/cros/mock_screen_lock_library.cc', 'browser/chromeos/cros/mock_screen_lock_library.h', - 'browser/chromeos/cros/mock_update_library.cc', - 'browser/chromeos/cros/mock_update_library.h', 'browser/chromeos/disks/mock_disk_mount_manager.cc', 'browser/chromeos/disks/mock_disk_mount_manager.h', 'browser/chromeos/extensions/file_browser_notifications_browsertest.cc', |