Commit 5fe3a5c1 authored by satorux@chromium.org's avatar satorux@chromium.org

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
parent fef74022
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "chrome/browser/chromeos/cros/network_library.h" #include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/cros/power_library.h" #include "chrome/browser/chromeos/cros/power_library.h"
#include "chrome/browser/chromeos/cros/screen_lock_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" #include "third_party/cros/chromeos_cros_api.h"
// Pass !libcros_loaded_ to GetDefaultImpl instead of use_stub_impl_ so that // Pass !libcros_loaded_ to GetDefaultImpl instead of use_stub_impl_ so that
...@@ -84,7 +83,6 @@ DEFINE_GET_LIBRARY_METHOD(Cryptohome, crypto); ...@@ -84,7 +83,6 @@ DEFINE_GET_LIBRARY_METHOD(Cryptohome, crypto);
DEFINE_GET_LIBRARY_METHOD(Network, network); DEFINE_GET_LIBRARY_METHOD(Network, network);
DEFINE_GET_LIBRARY_METHOD(Power, power); DEFINE_GET_LIBRARY_METHOD(Power, power);
DEFINE_GET_LIBRARY_METHOD(ScreenLock, screen_lock); DEFINE_GET_LIBRARY_METHOD(ScreenLock, screen_lock);
DEFINE_GET_LIBRARY_METHOD(Update, update);
bool CrosLibrary::LoadLibcros() { bool CrosLibrary::LoadLibcros() {
if (!libcros_loaded_ && !load_error_) { if (!libcros_loaded_ && !load_error_) {
...@@ -129,6 +127,5 @@ DEFINE_SET_LIBRARY_METHOD(Cryptohome, crypto); ...@@ -129,6 +127,5 @@ DEFINE_SET_LIBRARY_METHOD(Cryptohome, crypto);
DEFINE_SET_LIBRARY_METHOD(Network, network); DEFINE_SET_LIBRARY_METHOD(Network, network);
DEFINE_SET_LIBRARY_METHOD(Power, power); DEFINE_SET_LIBRARY_METHOD(Power, power);
DEFINE_SET_LIBRARY_METHOD(ScreenLock, screen_lock); DEFINE_SET_LIBRARY_METHOD(ScreenLock, screen_lock);
DEFINE_SET_LIBRARY_METHOD(Update, update);
} // namespace chromeos } // namespace chromeos
...@@ -23,7 +23,6 @@ class LibraryLoader; ...@@ -23,7 +23,6 @@ class LibraryLoader;
class NetworkLibrary; class NetworkLibrary;
class PowerLibrary; class PowerLibrary;
class ScreenLockLibrary; class ScreenLockLibrary;
class UpdateLibrary;
// This class handles access to sub-parts of ChromeOS library. it provides // This class handles access to sub-parts of ChromeOS library. it provides
// a level of indirection so individual libraries that it exposes can // a level of indirection so individual libraries that it exposes can
...@@ -49,7 +48,6 @@ class CrosLibrary { ...@@ -49,7 +48,6 @@ class CrosLibrary {
void SetNetworkLibrary(NetworkLibrary* library, bool own); void SetNetworkLibrary(NetworkLibrary* library, bool own);
void SetPowerLibrary(PowerLibrary* library, bool own); void SetPowerLibrary(PowerLibrary* library, bool own);
void SetScreenLockLibrary(ScreenLockLibrary* library, bool own); void SetScreenLockLibrary(ScreenLockLibrary* library, bool own);
void SetUpdateLibrary(UpdateLibrary* library, bool own);
private: private:
friend class CrosLibrary; friend class CrosLibrary;
...@@ -74,7 +72,6 @@ class CrosLibrary { ...@@ -74,7 +72,6 @@ class CrosLibrary {
NetworkLibrary* GetNetworkLibrary(); NetworkLibrary* GetNetworkLibrary();
PowerLibrary* GetPowerLibrary(); PowerLibrary* GetPowerLibrary();
ScreenLockLibrary* GetScreenLockLibrary(); ScreenLockLibrary* GetScreenLockLibrary();
UpdateLibrary* GetUpdateLibrary();
// Getter for Test API that gives access to internal members of this class. // Getter for Test API that gives access to internal members of this class.
TestApi* GetTestApi(); TestApi* GetTestApi();
...@@ -139,7 +136,6 @@ class CrosLibrary { ...@@ -139,7 +136,6 @@ class CrosLibrary {
Library<NetworkLibrary> network_lib_; Library<NetworkLibrary> network_lib_;
Library<PowerLibrary> power_lib_; Library<PowerLibrary> power_lib_;
Library<ScreenLockLibrary> screen_lock_lib_; Library<ScreenLockLibrary> screen_lock_lib_;
Library<UpdateLibrary> update_lib_;
// Stub implementations of the libraries should be used. // Stub implementations of the libraries should be used.
bool use_stub_impl_; bool use_stub_impl_;
......
// 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
// 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_
// 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
// 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_
...@@ -422,8 +422,6 @@ ...@@ -422,8 +422,6 @@
'browser/chromeos/cros/power_library.h', 'browser/chromeos/cros/power_library.h',
'browser/chromeos/cros/screen_lock_library.cc', 'browser/chromeos/cros/screen_lock_library.cc',
'browser/chromeos/cros/screen_lock_library.h', '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.cc',
'browser/chromeos/cros_settings.h', 'browser/chromeos/cros_settings.h',
'browser/chromeos/cros_settings_names.cc', 'browser/chromeos/cros_settings_names.cc',
......
...@@ -2480,8 +2480,6 @@ ...@@ -2480,8 +2480,6 @@
'browser/chromeos/cros/mock_power_library.h', 'browser/chromeos/cros/mock_power_library.h',
'browser/chromeos/cros/mock_screen_lock_library.cc', 'browser/chromeos/cros/mock_screen_lock_library.cc',
'browser/chromeos/cros/mock_screen_lock_library.h', '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.cc',
'browser/chromeos/disks/mock_disk_mount_manager.h', 'browser/chromeos/disks/mock_disk_mount_manager.h',
'browser/chromeos/extensions/file_browser_notifications_browsertest.cc', 'browser/chromeos/extensions/file_browser_notifications_browsertest.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment