Commit 85c04ce4 authored by satorux@chromium.org's avatar satorux@chromium.org

chromeos: Change all clients of UpdateLibrary to use UpdateEngineClient.

This is part 2 of the UpdateLibrary to UpdateEngineClient migration.

UpdateLibrary will be removed in the next patch.

BUG=chromium-os:16564
TEST=confirm that the update works as before from chrome://settings/about and OOBE screen.

Review URL: http://codereview.chromium.org/8585025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111190 0039d316-1c4b-4281-b951-d872f2087c98
parent 5e0d181b
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
#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 "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
#include "chrome/browser/chromeos/dbus/update_engine_client.h"
#include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.h" #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.h"
#include "chrome/browser/chromeos/login/existing_user_controller.h" #include "chrome/browser/chromeos/login/existing_user_controller.h"
#include "chrome/browser/chromeos/login/login_display.h" #include "chrome/browser/chromeos/login/login_display.h"
...@@ -42,8 +43,9 @@ ...@@ -42,8 +43,9 @@
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
using chromeos::CrosLibrary; using chromeos::CrosLibrary;
using chromeos::DBusThreadManager;
using chromeos::NetworkLibrary; using chromeos::NetworkLibrary;
using chromeos::UpdateLibrary; using chromeos::UpdateEngineClient;
using chromeos::UserManager; using chromeos::UserManager;
namespace { namespace {
...@@ -83,33 +85,33 @@ base::Value* GetProxySetting(Browser* browser, ...@@ -83,33 +85,33 @@ base::Value* GetProxySetting(Browser* browser,
return NULL; return NULL;
} }
const char* UpdateStatusToString(chromeos::UpdateStatusOperation status) { const char* UpdateStatusToString(
UpdateEngineClient::UpdateStatusOperation status) {
switch (status) { switch (status) {
case chromeos::UPDATE_STATUS_IDLE: case UpdateEngineClient::UPDATE_STATUS_IDLE:
return "idle"; return "idle";
case chromeos::UPDATE_STATUS_CHECKING_FOR_UPDATE: case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE:
return "checking for update"; return "checking for update";
case chromeos::UPDATE_STATUS_UPDATE_AVAILABLE: case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE:
return "update available"; return "update available";
case chromeos::UPDATE_STATUS_DOWNLOADING: case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING:
return "downloading"; return "downloading";
case chromeos::UPDATE_STATUS_VERIFYING: case UpdateEngineClient::UPDATE_STATUS_VERIFYING:
return "verifying"; return "verifying";
case chromeos::UPDATE_STATUS_FINALIZING: case UpdateEngineClient::UPDATE_STATUS_FINALIZING:
return "finalizing"; return "finalizing";
case chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT: case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT:
return "updated need reboot"; return "updated need reboot";
case chromeos::UPDATE_STATUS_REPORTING_ERROR_EVENT: case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT:
return "reporting error event"; return "reporting error event";
default: default:
return "unknown"; return "unknown";
} }
} }
void GetReleaseTrackCallback(void* user_data, const char* track) { void GetReleaseTrackCallback(AutomationJSONReply* reply,
AutomationJSONReply* reply = static_cast<AutomationJSONReply*>(user_data); const std::string& track) {
if (track.empty()) {
if (track == NULL) {
reply->SendError("Unable to get release track."); reply->SendError("Unable to get release track.");
delete reply; delete reply;
return; return;
...@@ -118,11 +120,12 @@ void GetReleaseTrackCallback(void* user_data, const char* track) { ...@@ -118,11 +120,12 @@ void GetReleaseTrackCallback(void* user_data, const char* track) {
scoped_ptr<DictionaryValue> return_value(new DictionaryValue); scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
return_value->SetString("release_track", track); return_value->SetString("release_track", track);
UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); const UpdateEngineClient::Status& status =
const UpdateLibrary::Status& status = update_library->status(); DBusThreadManager::Get()->GetUpdateEngineClient()->GetLastStatus();
chromeos::UpdateStatusOperation update_status = status.status; UpdateEngineClient::UpdateStatusOperation update_status =
status.status;
return_value->SetString("status", UpdateStatusToString(update_status)); return_value->SetString("status", UpdateStatusToString(update_status));
if (update_status == chromeos::UPDATE_STATUS_DOWNLOADING) if (update_status == UpdateEngineClient::UPDATE_STATUS_DOWNLOADING)
return_value->SetDouble("download_progress", status.download_progress); return_value->SetDouble("download_progress", status.download_progress);
if (status.last_checked_time > 0) if (status.last_checked_time > 0)
return_value->SetInteger("last_checked_time", status.last_checked_time); return_value->SetInteger("last_checked_time", status.last_checked_time);
...@@ -133,13 +136,12 @@ void GetReleaseTrackCallback(void* user_data, const char* track) { ...@@ -133,13 +136,12 @@ void GetReleaseTrackCallback(void* user_data, const char* track) {
delete reply; delete reply;
} }
void UpdateCheckCallback(void* user_data, chromeos::UpdateResult result, void UpdateCheckCallback(AutomationJSONReply* reply,
const char* error_msg) { UpdateEngineClient::UpdateCheckResult result) {
AutomationJSONReply* reply = static_cast<AutomationJSONReply*>(user_data); if (result == UpdateEngineClient::UPDATE_RESULT_SUCCESS)
if (result == chromeos::UPDATE_RESULT_SUCCESS)
reply->SendSuccess(NULL); reply->SendSuccess(NULL);
else else
reply->SendError(error_msg); reply->SendError("update check failed");
delete reply; delete reply;
} }
...@@ -1052,17 +1054,17 @@ void TestingAutomationProvider::SetTimezone(DictionaryValue* args, ...@@ -1052,17 +1054,17 @@ void TestingAutomationProvider::SetTimezone(DictionaryValue* args,
void TestingAutomationProvider::GetUpdateInfo(DictionaryValue* args, void TestingAutomationProvider::GetUpdateInfo(DictionaryValue* args,
IPC::Message* reply_message) { IPC::Message* reply_message) {
UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary();
AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message); AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message);
update_library->GetReleaseTrack(GetReleaseTrackCallback, reply); DBusThreadManager::Get()->GetUpdateEngineClient()
->GetReleaseTrack(base::Bind(GetReleaseTrackCallback, reply));
} }
void TestingAutomationProvider::UpdateCheck( void TestingAutomationProvider::UpdateCheck(
DictionaryValue* args, DictionaryValue* args,
IPC::Message* reply_message) { IPC::Message* reply_message) {
UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary();
AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message); AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message);
update_library->RequestUpdateCheck(UpdateCheckCallback, reply); DBusThreadManager::Get()->GetUpdateEngineClient()
->RequestUpdateCheck(base::Bind(UpdateCheckCallback, reply));
} }
void TestingAutomationProvider::SetReleaseTrack(DictionaryValue* args, void TestingAutomationProvider::SetReleaseTrack(DictionaryValue* args,
...@@ -1074,8 +1076,7 @@ void TestingAutomationProvider::SetReleaseTrack(DictionaryValue* args, ...@@ -1074,8 +1076,7 @@ void TestingAutomationProvider::SetReleaseTrack(DictionaryValue* args,
return; return;
} }
UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); DBusThreadManager::Get()->GetUpdateEngineClient()->SetReleaseTrack(track);
update_library->SetReleaseTrack(track);
reply.SendSuccess(NULL); reply.SendSuccess(NULL);
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "chrome/browser/chromeos/dbus/sensors_client.h" #include "chrome/browser/chromeos/dbus/sensors_client.h"
#include "chrome/browser/chromeos/dbus/session_manager_client.h" #include "chrome/browser/chromeos/dbus/session_manager_client.h"
#include "chrome/browser/chromeos/dbus/speech_synthesizer_client.h" #include "chrome/browser/chromeos/dbus/speech_synthesizer_client.h"
#include "chrome/browser/chromeos/dbus/update_engine_client.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "dbus/bus.h" #include "dbus/bus.h"
...@@ -65,6 +66,8 @@ class DBusThreadManagerImpl : public DBusThreadManager { ...@@ -65,6 +66,8 @@ class DBusThreadManagerImpl : public DBusThreadManager {
// Create the cros-disks client. // Create the cros-disks client.
cros_disks_client_.reset( cros_disks_client_.reset(
CrosDisksClient::Create(system_bus_.get())); CrosDisksClient::Create(system_bus_.get()));
update_engine_client_.reset(
UpdateEngineClient::Create(system_bus_.get()));
} }
virtual ~DBusThreadManagerImpl() { virtual ~DBusThreadManagerImpl() {
...@@ -111,6 +114,11 @@ class DBusThreadManagerImpl : public DBusThreadManager { ...@@ -111,6 +114,11 @@ class DBusThreadManagerImpl : public DBusThreadManager {
return cros_disks_client_.get(); return cros_disks_client_.get();
} }
// DBusThreadManager override.
virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE {
return update_engine_client_.get();
}
scoped_ptr<base::Thread> dbus_thread_; scoped_ptr<base::Thread> dbus_thread_;
scoped_refptr<dbus::Bus> system_bus_; scoped_refptr<dbus::Bus> system_bus_;
scoped_ptr<CrosDBusService> cros_dbus_service_; scoped_ptr<CrosDBusService> cros_dbus_service_;
...@@ -121,6 +129,7 @@ class DBusThreadManagerImpl : public DBusThreadManager { ...@@ -121,6 +129,7 @@ class DBusThreadManagerImpl : public DBusThreadManager {
scoped_ptr<SessionManagerClient> session_manager_client_; scoped_ptr<SessionManagerClient> session_manager_client_;
scoped_ptr<SpeechSynthesizerClient> speech_synthesizer_client_; scoped_ptr<SpeechSynthesizerClient> speech_synthesizer_client_;
scoped_ptr<CrosDisksClient> cros_disks_client_; scoped_ptr<CrosDisksClient> cros_disks_client_;
scoped_ptr<UpdateEngineClient> update_engine_client_;
}; };
// static // static
......
...@@ -26,6 +26,7 @@ class PowerManagerClient; ...@@ -26,6 +26,7 @@ class PowerManagerClient;
class SessionManagerClient; class SessionManagerClient;
class SensorsClient; class SensorsClient;
class SpeechSynthesizerClient; class SpeechSynthesizerClient;
class UpdateEngineClient;
// DBusThreadManager manages the D-Bus thread, the thread dedicated to // DBusThreadManager manages the D-Bus thread, the thread dedicated to
// handling asynchronous D-Bus operations. // handling asynchronous D-Bus operations.
...@@ -101,6 +102,10 @@ class DBusThreadManager { ...@@ -101,6 +102,10 @@ class DBusThreadManager {
// down. // down.
virtual CrosDisksClient* GetCrosDisksClient() = 0; virtual CrosDisksClient* GetCrosDisksClient() = 0;
// Returns the update engine client, owned by DBusThreadManager. Do not
// cache this pointer and use it after DBusThreadManager is shut down.
virtual UpdateEngineClient* GetUpdateEngineClient() = 0;
virtual ~DBusThreadManager(); virtual ~DBusThreadManager();
protected: protected:
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "chrome/browser/chromeos/dbus/mock_sensors_client.h" #include "chrome/browser/chromeos/dbus/mock_sensors_client.h"
#include "chrome/browser/chromeos/dbus/mock_session_manager_client.h" #include "chrome/browser/chromeos/dbus/mock_session_manager_client.h"
#include "chrome/browser/chromeos/dbus/mock_speech_synthesizer_client.h" #include "chrome/browser/chromeos/dbus/mock_speech_synthesizer_client.h"
#include "chrome/browser/chromeos/dbus/mock_update_engine_client.h"
using ::testing::AnyNumber; using ::testing::AnyNumber;
using ::testing::Return; using ::testing::Return;
...@@ -25,7 +26,8 @@ MockDBusThreadManager::MockDBusThreadManager() ...@@ -25,7 +26,8 @@ MockDBusThreadManager::MockDBusThreadManager()
mock_power_manager_client_(new MockPowerManagerClient), mock_power_manager_client_(new MockPowerManagerClient),
mock_sensors_client_(new MockSensorsClient), mock_sensors_client_(new MockSensorsClient),
mock_session_manager_client_(new MockSessionManagerClient), mock_session_manager_client_(new MockSessionManagerClient),
mock_speech_synthesizer_client_(new MockSpeechSynthesizerClient) { mock_speech_synthesizer_client_(new MockSpeechSynthesizerClient),
mock_update_engine_client_(new MockUpdateEngineClient) {
EXPECT_CALL(*this, GetBluetoothAdapterClient()) EXPECT_CALL(*this, GetBluetoothAdapterClient())
.WillRepeatedly(Return(mock_bluetooth_adapter_client_.get())); .WillRepeatedly(Return(mock_bluetooth_adapter_client_.get()));
EXPECT_CALL(*this, GetBluetoothManagerClient()) EXPECT_CALL(*this, GetBluetoothManagerClient())
...@@ -40,6 +42,8 @@ MockDBusThreadManager::MockDBusThreadManager() ...@@ -40,6 +42,8 @@ MockDBusThreadManager::MockDBusThreadManager()
.WillRepeatedly(Return(mock_session_manager_client_.get())); .WillRepeatedly(Return(mock_session_manager_client_.get()));
EXPECT_CALL(*this, GetSpeechSynthesizerClient()) EXPECT_CALL(*this, GetSpeechSynthesizerClient())
.WillRepeatedly(Return(mock_speech_synthesizer_client_.get())); .WillRepeatedly(Return(mock_speech_synthesizer_client_.get()));
EXPECT_CALL(*this, GetUpdateEngineClient())
.WillRepeatedly(Return(mock_update_engine_client_.get()));
// These observers calls are used in ChromeBrowserMainPartsChromeos. // These observers calls are used in ChromeBrowserMainPartsChromeos.
EXPECT_CALL(*mock_power_manager_client_.get(), AddObserver(_)) EXPECT_CALL(*mock_power_manager_client_.get(), AddObserver(_))
......
...@@ -19,6 +19,7 @@ class MockPowerManagerClient; ...@@ -19,6 +19,7 @@ class MockPowerManagerClient;
class MockSensorsClient; class MockSensorsClient;
class MockSessionManagerClient; class MockSessionManagerClient;
class MockSpeechSynthesizerClient; class MockSpeechSynthesizerClient;
class MockUpdateEngineClient;
// This class provides a mock DBusThreadManager with mock clients // This class provides a mock DBusThreadManager with mock clients
// installed. You can customize the behaviors of mock clients with // installed. You can customize the behaviors of mock clients with
...@@ -35,6 +36,7 @@ class MockDBusThreadManager : public DBusThreadManager { ...@@ -35,6 +36,7 @@ class MockDBusThreadManager : public DBusThreadManager {
MOCK_METHOD0(GetSensorsClient, SensorsClient*(void)); MOCK_METHOD0(GetSensorsClient, SensorsClient*(void));
MOCK_METHOD0(GetSessionManagerClient, SessionManagerClient*(void)); MOCK_METHOD0(GetSessionManagerClient, SessionManagerClient*(void));
MOCK_METHOD0(GetSpeechSynthesizerClient, SpeechSynthesizerClient*(void)); MOCK_METHOD0(GetSpeechSynthesizerClient, SpeechSynthesizerClient*(void));
MOCK_METHOD0(GetUpdateEngineClient, UpdateEngineClient*(void));
MockBluetoothAdapterClient* mock_bluetooth_adapter_client() { MockBluetoothAdapterClient* mock_bluetooth_adapter_client() {
return mock_bluetooth_adapter_client_.get(); return mock_bluetooth_adapter_client_.get();
...@@ -57,6 +59,9 @@ class MockDBusThreadManager : public DBusThreadManager { ...@@ -57,6 +59,9 @@ class MockDBusThreadManager : public DBusThreadManager {
MockSpeechSynthesizerClient* mock_speech_synthesizer_client() { MockSpeechSynthesizerClient* mock_speech_synthesizer_client() {
return mock_speech_synthesizer_client_.get(); return mock_speech_synthesizer_client_.get();
} }
MockUpdateEngineClient* mock_update_engine_client() {
return mock_update_engine_client_.get();
}
private: private:
scoped_ptr<MockBluetoothAdapterClient> mock_bluetooth_adapter_client_; scoped_ptr<MockBluetoothAdapterClient> mock_bluetooth_adapter_client_;
...@@ -66,6 +71,7 @@ class MockDBusThreadManager : public DBusThreadManager { ...@@ -66,6 +71,7 @@ class MockDBusThreadManager : public DBusThreadManager {
scoped_ptr<MockSensorsClient> mock_sensors_client_; scoped_ptr<MockSensorsClient> mock_sensors_client_;
scoped_ptr<MockSessionManagerClient> mock_session_manager_client_; scoped_ptr<MockSessionManagerClient> mock_session_manager_client_;
scoped_ptr<MockSpeechSynthesizerClient> mock_speech_synthesizer_client_; scoped_ptr<MockSpeechSynthesizerClient> mock_speech_synthesizer_client_;
scoped_ptr<MockUpdateEngineClient> mock_update_engine_client_;
DISALLOW_COPY_AND_ASSIGN(MockDBusThreadManager); DISALLOW_COPY_AND_ASSIGN(MockDBusThreadManager);
}; };
......
...@@ -4,10 +4,11 @@ ...@@ -4,10 +4,11 @@
#include "chrome/browser/chromeos/login/update_screen.h" #include "chrome/browser/chromeos/login/update_screen.h"
#include "base/bind.h"
#include "base/file_util.h" #include "base/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
#include "chrome/browser/chromeos/login/screen_observer.h" #include "chrome/browser/chromeos/login/screen_observer.h"
#include "chrome/browser/chromeos/login/update_screen_actor.h" #include "chrome/browser/chromeos/login/update_screen_actor.h"
#include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/login/wizard_controller.h"
...@@ -39,14 +40,11 @@ const int kUpdateScreenHeight = 305; ...@@ -39,14 +40,11 @@ const int kUpdateScreenHeight = 305;
const char kUpdateDeadlineFile[] = "/tmp/update-check-response-deadline"; const char kUpdateDeadlineFile[] = "/tmp/update-check-response-deadline";
// Invoked from call to RequestUpdateCheck upon completion of the DBus call. // Invoked from call to RequestUpdateCheck upon completion of the DBus call.
void StartUpdateCallback(void* user_data, void StartUpdateCallback(UpdateScreen* screen,
UpdateResult result, UpdateEngineClient::UpdateCheckResult result) {
const char* msg) {
VLOG(1) << "Callback from RequestUpdateCheck, result " << result; VLOG(1) << "Callback from RequestUpdateCheck, result " << result;
DCHECK(user_data);
UpdateScreen* screen = static_cast<UpdateScreen*>(user_data);
if (UpdateScreen::HasInstance(screen)) { if (UpdateScreen::HasInstance(screen)) {
if (result == chromeos::UPDATE_RESULT_SUCCESS) if (result == UpdateEngineClient::UPDATE_RESULT_SUCCESS)
screen->SetIgnoreIdleStatus(false); screen->SetIgnoreIdleStatus(false);
else else
screen->ExitUpdate(UpdateScreen::REASON_UPDATE_INIT_FAILED); screen->ExitUpdate(UpdateScreen::REASON_UPDATE_INIT_FAILED);
...@@ -84,27 +82,29 @@ UpdateScreen::UpdateScreen(ScreenObserver* screen_observer, ...@@ -84,27 +82,29 @@ UpdateScreen::UpdateScreen(ScreenObserver* screen_observer,
} }
UpdateScreen::~UpdateScreen() { UpdateScreen::~UpdateScreen() {
CrosLibrary::Get()->GetUpdateLibrary()->RemoveObserver(this); DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this);
GetInstanceSet().erase(this); GetInstanceSet().erase(this);
if (actor_) if (actor_)
actor_->SetDelegate(NULL); actor_->SetDelegate(NULL);
} }
void UpdateScreen::UpdateStatusChanged(const UpdateLibrary::Status& status) { void UpdateScreen::UpdateStatusChanged(
const UpdateEngineClient::Status& status) {
if (is_checking_for_update_ && if (is_checking_for_update_ &&
status.status > UPDATE_STATUS_CHECKING_FOR_UPDATE) { status.status > UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE) {
is_checking_for_update_ = false; is_checking_for_update_ = false;
} }
if (ignore_idle_status_ && status.status > UPDATE_STATUS_IDLE) { if (ignore_idle_status_ && status.status >
UpdateEngineClient::UPDATE_STATUS_IDLE) {
ignore_idle_status_ = false; ignore_idle_status_ = false;
} }
switch (status.status) { switch (status.status) {
case UPDATE_STATUS_CHECKING_FOR_UPDATE: case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE:
// Do nothing in these cases, we don't want to notify the user of the // Do nothing in these cases, we don't want to notify the user of the
// check unless there is an update. // check unless there is an update.
break; break;
case UPDATE_STATUS_UPDATE_AVAILABLE: case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE:
MakeSureScreenIsShown(); MakeSureScreenIsShown();
actor_->SetProgress(kBeforeDownloadProgress); actor_->SetProgress(kBeforeDownloadProgress);
if (!HasCriticalUpdate()) { if (!HasCriticalUpdate()) {
...@@ -118,7 +118,7 @@ void UpdateScreen::UpdateStatusChanged(const UpdateLibrary::Status& status) { ...@@ -118,7 +118,7 @@ void UpdateScreen::UpdateStatusChanged(const UpdateLibrary::Status& status) {
actor_->ShowCurtain(false); actor_->ShowCurtain(false);
} }
break; break;
case UPDATE_STATUS_DOWNLOADING: case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING:
{ {
MakeSureScreenIsShown(); MakeSureScreenIsShown();
if (!is_downloading_update_) { if (!is_downloading_update_) {
...@@ -141,15 +141,15 @@ void UpdateScreen::UpdateStatusChanged(const UpdateLibrary::Status& status) { ...@@ -141,15 +141,15 @@ void UpdateScreen::UpdateStatusChanged(const UpdateLibrary::Status& status) {
actor_->SetProgress(kBeforeDownloadProgress + download_progress); actor_->SetProgress(kBeforeDownloadProgress + download_progress);
} }
break; break;
case UPDATE_STATUS_VERIFYING: case UpdateEngineClient::UPDATE_STATUS_VERIFYING:
MakeSureScreenIsShown(); MakeSureScreenIsShown();
actor_->SetProgress(kBeforeVerifyingProgress); actor_->SetProgress(kBeforeVerifyingProgress);
break; break;
case UPDATE_STATUS_FINALIZING: case UpdateEngineClient::UPDATE_STATUS_FINALIZING:
MakeSureScreenIsShown(); MakeSureScreenIsShown();
actor_->SetProgress(kBeforeFinalizingProgress); actor_->SetProgress(kBeforeFinalizingProgress);
break; break;
case UPDATE_STATUS_UPDATED_NEED_REBOOT: case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT:
MakeSureScreenIsShown(); MakeSureScreenIsShown();
// Make sure that first OOBE stage won't be shown after reboot. // Make sure that first OOBE stage won't be shown after reboot.
WizardController::MarkOobeCompleted(); WizardController::MarkOobeCompleted();
...@@ -157,7 +157,7 @@ void UpdateScreen::UpdateStatusChanged(const UpdateLibrary::Status& status) { ...@@ -157,7 +157,7 @@ void UpdateScreen::UpdateStatusChanged(const UpdateLibrary::Status& status) {
if (HasCriticalUpdate()) { if (HasCriticalUpdate()) {
actor_->ShowCurtain(false); actor_->ShowCurtain(false);
VLOG(1) << "Initiate reboot after update"; VLOG(1) << "Initiate reboot after update";
CrosLibrary::Get()->GetUpdateLibrary()->RebootAfterUpdate(); DBusThreadManager::Get()->GetUpdateEngineClient()->RebootAfterUpdate();
reboot_timer_.Start(FROM_HERE, reboot_timer_.Start(FROM_HERE,
base::TimeDelta::FromSeconds(reboot_check_delay_), base::TimeDelta::FromSeconds(reboot_check_delay_),
this, this,
...@@ -166,15 +166,15 @@ void UpdateScreen::UpdateStatusChanged(const UpdateLibrary::Status& status) { ...@@ -166,15 +166,15 @@ void UpdateScreen::UpdateStatusChanged(const UpdateLibrary::Status& status) {
ExitUpdate(REASON_UPDATE_NON_CRITICAL); ExitUpdate(REASON_UPDATE_NON_CRITICAL);
} }
break; break;
case UPDATE_STATUS_IDLE: case UpdateEngineClient::UPDATE_STATUS_IDLE:
if (ignore_idle_status_) { if (ignore_idle_status_) {
// It is first IDLE status that is sent before we initiated the check. // It is first IDLE status that is sent before we initiated the check.
break; break;
} }
// else no break // else no break
case UPDATE_STATUS_ERROR: case UpdateEngineClient::UPDATE_STATUS_ERROR:
case UPDATE_STATUS_REPORTING_ERROR_EVENT: case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT:
ExitUpdate(REASON_UPDATE_ENDED); ExitUpdate(REASON_UPDATE_ENDED);
break; break;
default: default:
...@@ -184,10 +184,10 @@ void UpdateScreen::UpdateStatusChanged(const UpdateLibrary::Status& status) { ...@@ -184,10 +184,10 @@ void UpdateScreen::UpdateStatusChanged(const UpdateLibrary::Status& status) {
} }
void UpdateScreen::StartUpdate() { void UpdateScreen::StartUpdate() {
CrosLibrary::Get()->GetUpdateLibrary()->AddObserver(this); DBusThreadManager::Get()->GetUpdateEngineClient()->AddObserver(this);
VLOG(1) << "Initiate update check"; VLOG(1) << "Initiate update check";
CrosLibrary::Get()->GetUpdateLibrary()->RequestUpdateCheck( DBusThreadManager::Get()->GetUpdateEngineClient()->RequestUpdateCheck(
StartUpdateCallback, this); base::Bind(StartUpdateCallback, this));
} }
void UpdateScreen::CancelUpdate() { void UpdateScreen::CancelUpdate() {
...@@ -211,7 +211,7 @@ void UpdateScreen::PrepareToShow() { ...@@ -211,7 +211,7 @@ void UpdateScreen::PrepareToShow() {
} }
void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) { void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) {
CrosLibrary::Get()->GetUpdateLibrary()->RemoveObserver(this); DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this);
switch (reason) { switch (reason) {
case REASON_UPDATE_CANCELED: case REASON_UPDATE_CANCELED:
...@@ -224,21 +224,22 @@ void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) { ...@@ -224,21 +224,22 @@ void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) {
case REASON_UPDATE_NON_CRITICAL: case REASON_UPDATE_NON_CRITICAL:
case REASON_UPDATE_ENDED: case REASON_UPDATE_ENDED:
{ {
UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); UpdateEngineClient* update_engine_client =
switch (update_library->status().status) { DBusThreadManager::Get()->GetUpdateEngineClient();
case UPDATE_STATUS_UPDATE_AVAILABLE: switch (update_engine_client->GetLastStatus().status) {
case UPDATE_STATUS_UPDATED_NEED_REBOOT: case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE:
case UPDATE_STATUS_DOWNLOADING: case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT:
case UPDATE_STATUS_FINALIZING: case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING:
case UPDATE_STATUS_VERIFYING: case UpdateEngineClient::UPDATE_STATUS_FINALIZING:
case UpdateEngineClient::UPDATE_STATUS_VERIFYING:
DCHECK(!HasCriticalUpdate()); DCHECK(!HasCriticalUpdate());
// Noncritical update, just exit screen as if there is no update. // Noncritical update, just exit screen as if there is no update.
// no break // no break
case UPDATE_STATUS_IDLE: case UpdateEngineClient::UPDATE_STATUS_IDLE:
get_screen_observer()->OnExit(ScreenObserver::UPDATE_NOUPDATE); get_screen_observer()->OnExit(ScreenObserver::UPDATE_NOUPDATE);
break; break;
case UPDATE_STATUS_ERROR: case UpdateEngineClient::UPDATE_STATUS_ERROR:
case UPDATE_STATUS_REPORTING_ERROR_EVENT: case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT:
get_screen_observer()->OnExit(is_checking_for_update_ ? get_screen_observer()->OnExit(is_checking_for_update_ ?
ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE : ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE :
ScreenObserver::UPDATE_ERROR_UPDATING); ScreenObserver::UPDATE_ERROR_UPDATING);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/timer.h" #include "base/timer.h"
#include "chrome/browser/chromeos/cros/update_library.h" #include "chrome/browser/chromeos/dbus/update_engine_client.h"
#include "chrome/browser/chromeos/login/update_screen_actor.h" #include "chrome/browser/chromeos/login/update_screen_actor.h"
#include "chrome/browser/chromeos/login/wizard_screen.h" #include "chrome/browser/chromeos/login/wizard_screen.h"
...@@ -22,7 +22,7 @@ class ScreenObserver; ...@@ -22,7 +22,7 @@ class ScreenObserver;
// Controller for the update screen. It does not depend on the specific // Controller for the update screen. It does not depend on the specific
// implementation of the screen showing (Views of WebUI based), the dependency // implementation of the screen showing (Views of WebUI based), the dependency
// is moved to the UpdateScreenActor instead. // is moved to the UpdateScreenActor instead.
class UpdateScreen: public UpdateLibrary::Observer, class UpdateScreen: public UpdateEngineClient::Observer,
public UpdateScreenActor::Delegate, public UpdateScreenActor::Delegate,
public WizardScreen { public WizardScreen {
public: public:
...@@ -60,8 +60,9 @@ class UpdateScreen: public UpdateLibrary::Observer, ...@@ -60,8 +60,9 @@ class UpdateScreen: public UpdateLibrary::Observer,
// Reports update results to the ScreenObserver. // Reports update results to the ScreenObserver.
virtual void ExitUpdate(ExitReason reason); virtual void ExitUpdate(ExitReason reason);
// UpdateLibrary::Observer implementation: // UpdateEngineClient::Observer implementation:
virtual void UpdateStatusChanged(const UpdateLibrary::Status& status); virtual void UpdateStatusChanged(
const UpdateEngineClient::Status& status) OVERRIDE;
private: private:
FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestBasic); FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestBasic);
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
#include "base/message_loop.h" #include "base/message_loop.h"
#include "chrome/browser/chromeos/cros/mock_network_library.h" #include "chrome/browser/chromeos/cros/mock_network_library.h"
#include "chrome/browser/chromeos/cros/mock_update_library.h"
#include "chrome/browser/chromeos/dbus/mock_dbus_thread_manager.h" #include "chrome/browser/chromeos/dbus/mock_dbus_thread_manager.h"
#include "chrome/browser/chromeos/dbus/mock_session_manager_client.h" #include "chrome/browser/chromeos/dbus/mock_session_manager_client.h"
#include "chrome/browser/chromeos/dbus/mock_update_engine_client.h"
#include "chrome/browser/chromeos/login/mock_screen_observer.h" #include "chrome/browser/chromeos/login/mock_screen_observer.h"
#include "chrome/browser/chromeos/login/update_screen.h" #include "chrome/browser/chromeos/login/update_screen.h"
#include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/login/wizard_controller.h"
...@@ -20,15 +20,17 @@ using ::testing::AtLeast; ...@@ -20,15 +20,17 @@ using ::testing::AtLeast;
using ::testing::Return; using ::testing::Return;
using ::testing::ReturnRef; using ::testing::ReturnRef;
using ::testing::Invoke; using ::testing::Invoke;
using chromeos::UpdateEngineClient;
static void RequestUpdateCheckSuccess(UpdateCallback callback, void* userdata) { static void RequestUpdateCheckSuccess(
callback(userdata, chromeos::UPDATE_RESULT_SUCCESS, NULL); UpdateEngineClient::UpdateCheckCallback callback) {
callback.Run(UpdateEngineClient::UPDATE_RESULT_SUCCESS);
} }
class UpdateScreenTest : public WizardInProcessBrowserTest { class UpdateScreenTest : public WizardInProcessBrowserTest {
public: public:
UpdateScreenTest() : WizardInProcessBrowserTest("update"), UpdateScreenTest() : WizardInProcessBrowserTest("update"),
mock_update_library_(NULL), mock_update_engine_client_(NULL),
mock_network_library_(NULL) {} mock_network_library_(NULL) {}
protected: protected:
...@@ -45,17 +47,17 @@ class UpdateScreenTest : public WizardInProcessBrowserTest { ...@@ -45,17 +47,17 @@ class UpdateScreenTest : public WizardInProcessBrowserTest {
EXPECT_CALL(*mock_session_manager_client, EmitLoginPromptReady()) EXPECT_CALL(*mock_session_manager_client, EmitLoginPromptReady())
.Times(1); .Times(1);
mock_update_library_ = new MockUpdateLibrary(); mock_update_engine_client_
cros_mock_->test_api()->SetUpdateLibrary(mock_update_library_, true); = mock_dbus_thread_manager->mock_update_engine_client();
// UpdateScreen::StartUpdate() will be called by the WizardController // UpdateScreen::StartUpdate() will be called by the WizardController
// just after creating the update screen, so the expectations for that // just after creating the update screen, so the expectations for that
// should be set up here. // should be set up here.
EXPECT_CALL(*mock_update_library_, AddObserver(_)) EXPECT_CALL(*mock_update_engine_client_, AddObserver(_))
.Times(AtLeast(1)); .Times(AtLeast(1));
EXPECT_CALL(*mock_update_library_, RemoveObserver(_)) EXPECT_CALL(*mock_update_engine_client_, RemoveObserver(_))
.Times(AtLeast(1)); .Times(AtLeast(1));
EXPECT_CALL(*mock_update_library_, RequestUpdateCheck(_,_)) EXPECT_CALL(*mock_update_engine_client_, RequestUpdateCheck(_))
.Times(1) .Times(1)
.WillOnce(Invoke(RequestUpdateCheckSuccess)); .WillOnce(Invoke(RequestUpdateCheckSuccess));
...@@ -84,12 +86,11 @@ class UpdateScreenTest : public WizardInProcessBrowserTest { ...@@ -84,12 +86,11 @@ class UpdateScreenTest : public WizardInProcessBrowserTest {
virtual void TearDownInProcessBrowserTestFixture() { virtual void TearDownInProcessBrowserTestFixture() {
update_screen_->screen_observer_ = (controller()); update_screen_->screen_observer_ = (controller());
cros_mock_->test_api()->SetUpdateLibrary(NULL, true);
WizardInProcessBrowserTest::TearDownInProcessBrowserTestFixture(); WizardInProcessBrowserTest::TearDownInProcessBrowserTestFixture();
DBusThreadManager::Shutdown(); DBusThreadManager::Shutdown();
} }
MockUpdateLibrary* mock_update_library_; MockUpdateEngineClient* mock_update_engine_client_;
MockNetworkLibrary* mock_network_library_; MockNetworkLibrary* mock_network_library_;
scoped_ptr<MockScreenObserver> mock_screen_observer_; scoped_ptr<MockScreenObserver> mock_screen_observer_;
...@@ -105,17 +106,17 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestBasic) { ...@@ -105,17 +106,17 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestBasic) {
IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestNoUpdate) { IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestNoUpdate) {
update_screen_->SetIgnoreIdleStatus(true); update_screen_->SetIgnoreIdleStatus(true);
UpdateLibrary::Status status; UpdateEngineClient::Status status;
status.status = UPDATE_STATUS_IDLE; status.status = UpdateEngineClient::UPDATE_STATUS_IDLE;
update_screen_->UpdateStatusChanged(status); update_screen_->UpdateStatusChanged(status);
status.status = UPDATE_STATUS_CHECKING_FOR_UPDATE; status.status = UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE;
update_screen_->UpdateStatusChanged(status); update_screen_->UpdateStatusChanged(status);
status.status = UPDATE_STATUS_IDLE; status.status = UpdateEngineClient::UPDATE_STATUS_IDLE;
// status() will be called via ExitUpdate() called from // GetLastStatus() will be called via ExitUpdate() called from
// UpdateStatusChanged(). // UpdateStatusChanged().
EXPECT_CALL(*mock_update_library_, status()) EXPECT_CALL(*mock_update_engine_client_, GetLastStatus())
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(ReturnRef(status)); .WillRepeatedly(Return(status));
EXPECT_CALL(*mock_screen_observer_, OnExit(ScreenObserver::UPDATE_NOUPDATE)) EXPECT_CALL(*mock_screen_observer_, OnExit(ScreenObserver::UPDATE_NOUPDATE))
.Times(1); .Times(1);
update_screen_->UpdateStatusChanged(status); update_screen_->UpdateStatusChanged(status);
...@@ -124,12 +125,12 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestNoUpdate) { ...@@ -124,12 +125,12 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestNoUpdate) {
IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestUpdateAvailable) { IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestUpdateAvailable) {
update_screen_->is_ignore_update_deadlines_ = true; update_screen_->is_ignore_update_deadlines_ = true;
UpdateLibrary::Status status; UpdateEngineClient::Status status;
status.status = UPDATE_STATUS_UPDATE_AVAILABLE; status.status = UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE;
status.new_version = "latest and greatest"; status.new_version = "latest and greatest";
update_screen_->UpdateStatusChanged(status); update_screen_->UpdateStatusChanged(status);
status.status = UPDATE_STATUS_DOWNLOADING; status.status = UpdateEngineClient::UPDATE_STATUS_DOWNLOADING;
status.download_progress = 0.0; status.download_progress = 0.0;
update_screen_->UpdateStatusChanged(status); update_screen_->UpdateStatusChanged(status);
...@@ -139,20 +140,21 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestUpdateAvailable) { ...@@ -139,20 +140,21 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestUpdateAvailable) {
status.download_progress = 1.0; status.download_progress = 1.0;
update_screen_->UpdateStatusChanged(status); update_screen_->UpdateStatusChanged(status);
status.status = UPDATE_STATUS_VERIFYING; status.status = UpdateEngineClient::UPDATE_STATUS_VERIFYING;
update_screen_->UpdateStatusChanged(status); update_screen_->UpdateStatusChanged(status);
status.status = UPDATE_STATUS_FINALIZING; status.status = UpdateEngineClient::UPDATE_STATUS_FINALIZING;
update_screen_->UpdateStatusChanged(status); update_screen_->UpdateStatusChanged(status);
status.status = UPDATE_STATUS_UPDATED_NEED_REBOOT; status.status = UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT;
EXPECT_CALL(*mock_update_library_, RebootAfterUpdate()) EXPECT_CALL(*mock_update_engine_client_, RebootAfterUpdate())
.Times(1); .Times(1);
update_screen_->UpdateStatusChanged(status); update_screen_->UpdateStatusChanged(status);
} }
static void RequestUpdateCheckFail(UpdateCallback callback, void* userdata) { static void RequestUpdateCheckFail(
callback(userdata, chromeos::UPDATE_RESULT_FAILED, NULL); UpdateEngineClient::UpdateCheckCallback callback) {
callback.Run(chromeos::UpdateEngineClient::UPDATE_RESULT_FAILED);
} }
IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorIssuingUpdateCheck) { IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorIssuingUpdateCheck) {
...@@ -164,11 +166,11 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorIssuingUpdateCheck) { ...@@ -164,11 +166,11 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorIssuingUpdateCheck) {
// Run UpdateScreen::StartUpdate() again, but CheckForUpdate() will fail // Run UpdateScreen::StartUpdate() again, but CheckForUpdate() will fail
// issuing the update check this time. // issuing the update check this time.
EXPECT_CALL(*mock_update_library_, AddObserver(_)) EXPECT_CALL(*mock_update_engine_client_, AddObserver(_))
.Times(1); .Times(1);
EXPECT_CALL(*mock_update_library_, RemoveObserver(_)) EXPECT_CALL(*mock_update_engine_client_, RemoveObserver(_))
.Times(AtLeast(1)); .Times(AtLeast(1));
EXPECT_CALL(*mock_update_library_, RequestUpdateCheck(_,_)) EXPECT_CALL(*mock_update_engine_client_, RequestUpdateCheck(_))
.Times(1) .Times(1)
.WillOnce(Invoke(RequestUpdateCheckFail)); .WillOnce(Invoke(RequestUpdateCheckFail));
EXPECT_CALL(*mock_screen_observer_, EXPECT_CALL(*mock_screen_observer_,
...@@ -178,13 +180,13 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorIssuingUpdateCheck) { ...@@ -178,13 +180,13 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorIssuingUpdateCheck) {
} }
IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorCheckingForUpdate) { IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorCheckingForUpdate) {
UpdateLibrary::Status status; UpdateEngineClient::Status status;
status.status = UPDATE_STATUS_ERROR; status.status = UpdateEngineClient::UPDATE_STATUS_ERROR;
// status() will be called via ExitUpdate() called from // GetLastStatus() will be called via ExitUpdate() called from
// UpdateStatusChanged(). // UpdateStatusChanged().
EXPECT_CALL(*mock_update_library_, status()) EXPECT_CALL(*mock_update_engine_client_, GetLastStatus())
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(ReturnRef(status)); .WillRepeatedly(Return(status));
EXPECT_CALL(*mock_screen_observer_, EXPECT_CALL(*mock_screen_observer_,
OnExit(ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE)) OnExit(ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE))
.Times(1); .Times(1);
...@@ -192,22 +194,22 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorCheckingForUpdate) { ...@@ -192,22 +194,22 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorCheckingForUpdate) {
} }
IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorUpdating) { IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorUpdating) {
UpdateLibrary::Status status; UpdateEngineClient::Status status;
status.status = UPDATE_STATUS_UPDATE_AVAILABLE; status.status = UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE;
status.new_version = "latest and greatest"; status.new_version = "latest and greatest";
// status() will be called via ExitUpdate() called from // GetLastStatus() will be called via ExitUpdate() called from
// UpdateStatusChanged(). // UpdateStatusChanged().
EXPECT_CALL(*mock_update_library_, status()) EXPECT_CALL(*mock_update_engine_client_, GetLastStatus())
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(ReturnRef(status)); .WillRepeatedly(Return(status));
update_screen_->UpdateStatusChanged(status); update_screen_->UpdateStatusChanged(status);
status.status = UPDATE_STATUS_ERROR; status.status = UpdateEngineClient::UPDATE_STATUS_ERROR;
// status() will be called via ExitUpdate() called from // GetLastStatus() will be called via ExitUpdate() called from
// UpdateStatusChanged(). // UpdateStatusChanged().
EXPECT_CALL(*mock_update_library_, status()) EXPECT_CALL(*mock_update_engine_client_, GetLastStatus())
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(ReturnRef(status)); .WillRepeatedly(Return(status));
EXPECT_CALL(*mock_screen_observer_, EXPECT_CALL(*mock_screen_observer_,
OnExit(ScreenObserver::UPDATE_ERROR_UPDATING)) OnExit(ScreenObserver::UPDATE_ERROR_UPDATING))
.Times(1); .Times(1);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "chrome/browser/chromeos/upgrade_detector_chromeos.h" #include "chrome/browser/chromeos/upgrade_detector_chromeos.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
namespace { namespace {
...@@ -15,6 +15,9 @@ const int kNotifyCycleTimeMs = 20 * 60 * 1000; // 20 minutes. ...@@ -15,6 +15,9 @@ const int kNotifyCycleTimeMs = 20 * 60 * 1000; // 20 minutes.
} // namespace } // namespace
using chromeos::DBusThreadManager;
using chromeos::UpdateEngineClient;
UpgradeDetectorChromeos::UpgradeDetectorChromeos() : initialized_(false) { UpgradeDetectorChromeos::UpgradeDetectorChromeos() : initialized_(false) {
} }
...@@ -22,22 +25,20 @@ UpgradeDetectorChromeos::~UpgradeDetectorChromeos() { ...@@ -22,22 +25,20 @@ UpgradeDetectorChromeos::~UpgradeDetectorChromeos() {
} }
void UpgradeDetectorChromeos::Init() { void UpgradeDetectorChromeos::Init() {
if (chromeos::CrosLibrary::Get()) DBusThreadManager::Get()->GetUpdateEngineClient()->AddObserver(this);
chromeos::CrosLibrary::Get()->GetUpdateLibrary()->AddObserver(this);
initialized_ = true; initialized_ = true;
} }
void UpgradeDetectorChromeos::Shutdown() { void UpgradeDetectorChromeos::Shutdown() {
// Init() may not be called from tests (ex. BrowserMainTest). // Init() may not be called from tests.
if (!initialized_) if (!initialized_)
return; return;
if (chromeos::CrosLibrary::Get()) DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this);
chromeos::CrosLibrary::Get()->GetUpdateLibrary()->RemoveObserver(this);
} }
void UpgradeDetectorChromeos::UpdateStatusChanged( void UpgradeDetectorChromeos::UpdateStatusChanged(
const chromeos::UpdateLibrary::Status& status) { const UpdateEngineClient::Status& status) {
if (status.status != chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT) if (status.status != UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT)
return; return;
NotifyUpgradeDetected(); NotifyUpgradeDetected();
......
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
#pragma once #pragma once
#include "base/timer.h" #include "base/timer.h"
#include "chrome/browser/chromeos/cros/update_library.h" #include "chrome/browser/chromeos/dbus/update_engine_client.h"
#include "chrome/browser/upgrade_detector.h" #include "chrome/browser/upgrade_detector.h"
template <typename T> struct DefaultSingletonTraits; template <typename T> struct DefaultSingletonTraits;
class UpgradeDetectorChromeos : public UpgradeDetector, class UpgradeDetectorChromeos : public UpgradeDetector,
public chromeos::UpdateLibrary::Observer { public chromeos::UpdateEngineClient::Observer {
public: public:
virtual ~UpgradeDetectorChromeos(); virtual ~UpgradeDetectorChromeos();
...@@ -32,9 +32,9 @@ class UpgradeDetectorChromeos : public UpgradeDetector, ...@@ -32,9 +32,9 @@ class UpgradeDetectorChromeos : public UpgradeDetector,
UpgradeDetectorChromeos(); UpgradeDetectorChromeos();
// chromeos::UpdateLibrary::Observer implementation. // chromeos::UpdateEngineClient::Observer implementation.
virtual void UpdateStatusChanged( virtual void UpdateStatusChanged(
const chromeos::UpdateLibrary::Status& status); const chromeos::UpdateEngineClient::Status& status) OVERRIDE;
// The function that sends out a notification (after a certain time has // The function that sends out a notification (after a certain time has
// elapsed) that lets the rest of the UI know we should start notifying the // elapsed) that lets the rest of the UI know we should start notifying the
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
#include "chrome/browser/chromeos/cros/update_library.h" #include "chrome/browser/chromeos/dbus/update_engine_client.h"
#include "chrome/browser/chromeos/login/ownership_service.h" #include "chrome/browser/chromeos/login/ownership_service.h"
#include "chrome/browser/chromeos/user_cros_settings_provider.h" #include "chrome/browser/chromeos/user_cros_settings_provider.h"
#include "chrome/browser/policy/cloud_policy_data_store.h" #include "chrome/browser/policy/cloud_policy_data_store.h"
...@@ -350,7 +350,8 @@ void DevicePolicyCache::DecodeDevicePolicy( ...@@ -350,7 +350,8 @@ void DevicePolicyCache::DecodeDevicePolicy(
// TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't
// have to pass the channel in here, only ping the update engine to tell // have to pass the channel in here, only ping the update engine to tell
// it to fetch the channel from the policy. // it to fetch the channel from the policy.
chromeos::CrosLibrary::Get()->GetUpdateLibrary()->SetReleaseTrack(channel); chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()
->SetReleaseTrack(channel);
} }
if (policy.has_open_network_configuration() && if (policy.has_open_network_configuration() &&
......
...@@ -31,10 +31,9 @@ ...@@ -31,10 +31,9 @@
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/boot_times_loader.h" #include "chrome/browser/chromeos/boot_times_loader.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/update_library.h"
#include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
#include "chrome/browser/chromeos/dbus/session_manager_client.h" #include "chrome/browser/chromeos/dbus/session_manager_client.h"
#include "chrome/browser/chromeos/dbus/update_engine_client.h"
#include "chrome/browser/chromeos/system/runtime_environment.h" #include "chrome/browser/chromeos/system/runtime_environment.h"
#if defined(TOOLKIT_USES_GTK) #if defined(TOOLKIT_USES_GTK)
#include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h" #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h"
...@@ -334,11 +333,12 @@ void BrowserList::NotifyAndTerminate(bool fast_path) { ...@@ -334,11 +333,12 @@ void BrowserList::NotifyAndTerminate(bool fast_path) {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
NotifyWindowManagerAboutSignout(); NotifyWindowManagerAboutSignout();
if (chromeos::system::runtime_environment::IsRunningOnChromeOS()) { if (chromeos::system::runtime_environment::IsRunningOnChromeOS()) {
chromeos::UpdateEngineClient* update_engine_client
= chromeos::DBusThreadManager::Get()->GetUpdateEngineClient();
// If update has been installed, reboot, otherwise, sign out. // If update has been installed, reboot, otherwise, sign out.
chromeos::CrosLibrary* cros_library = chromeos::CrosLibrary::Get(); if (update_engine_client->GetLastStatus().status ==
if (cros_library->GetUpdateLibrary()->status().status == chromeos::UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT) {
chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT) { update_engine_client->RebootAfterUpdate();
cros_library->GetUpdateLibrary()->RebootAfterUpdate();
} else { } else {
chromeos::DBusThreadManager::Get()->GetSessionManagerClient() chromeos::DBusThreadManager::Get()->GetSessionManagerClient()
->StopSession(); ->StopSession();
......
...@@ -16,10 +16,9 @@ ...@@ -16,10 +16,9 @@
#include "base/time.h" #include "base/time.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/update_library.h"
#include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
#include "chrome/browser/chromeos/dbus/power_manager_client.h" #include "chrome/browser/chromeos/dbus/power_manager_client.h"
#include "chrome/browser/chromeos/dbus/update_engine_client.h"
#include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/user_cros_settings_provider.h" #include "chrome/browser/chromeos/user_cros_settings_provider.h"
...@@ -64,7 +63,7 @@ std::string StringSubRange(const std::string& text, size_t start, ...@@ -64,7 +63,7 @@ std::string StringSubRange(const std::string& text, size_t start,
namespace chromeos { namespace chromeos {
class AboutPageHandler::UpdateObserver class AboutPageHandler::UpdateObserver
: public UpdateLibrary::Observer { : public UpdateEngineClient::Observer {
public: public:
explicit UpdateObserver(AboutPageHandler* handler) : page_handler_(handler) {} explicit UpdateObserver(AboutPageHandler* handler) : page_handler_(handler) {}
virtual ~UpdateObserver() {} virtual ~UpdateObserver() {}
...@@ -72,7 +71,8 @@ class AboutPageHandler::UpdateObserver ...@@ -72,7 +71,8 @@ class AboutPageHandler::UpdateObserver
AboutPageHandler* page_handler() const { return page_handler_; } AboutPageHandler* page_handler() const { return page_handler_; }
private: private:
virtual void UpdateStatusChanged(const UpdateLibrary::Status& status) { virtual void UpdateStatusChanged(
const UpdateEngineClient::Status& status) OVERRIDE {
page_handler_->UpdateStatus(status); page_handler_->UpdateStatus(status);
} }
...@@ -89,7 +89,7 @@ AboutPageHandler::AboutPageHandler() ...@@ -89,7 +89,7 @@ AboutPageHandler::AboutPageHandler()
AboutPageHandler::~AboutPageHandler() { AboutPageHandler::~AboutPageHandler() {
if (update_observer_.get()) { if (update_observer_.get()) {
CrosLibrary::Get()->GetUpdateLibrary()-> DBusThreadManager::Get()->GetUpdateEngineClient()->
RemoveObserver(update_observer_.get()); RemoveObserver(update_observer_.get());
} }
} }
...@@ -256,14 +256,14 @@ void AboutPageHandler::PageReady(const ListValue* args) { ...@@ -256,14 +256,14 @@ void AboutPageHandler::PageReady(const ListValue* args) {
base::Bind(&AboutPageHandler::OnOSFirmware, base::Bind(&AboutPageHandler::OnOSFirmware,
base::Unretained(this))); base::Unretained(this)));
UpdateLibrary* update_library = UpdateEngineClient* update_engine_client =
CrosLibrary::Get()->GetUpdateLibrary(); DBusThreadManager::Get()->GetUpdateEngineClient();
update_observer_.reset(new UpdateObserver(this)); update_observer_.reset(new UpdateObserver(this));
update_library->AddObserver(update_observer_.get()); update_engine_client->AddObserver(update_observer_.get());
// Update the WebUI page with the current status. See comments below. // Update the WebUI page with the current status. See comments below.
UpdateStatus(update_library->status()); UpdateStatus(update_engine_client->GetLastStatus());
// Initiate update check. UpdateStatus() below will be called when we // Initiate update check. UpdateStatus() below will be called when we
// get update status via update_observer_. If the update has been // get update status via update_observer_. If the update has been
...@@ -273,8 +273,8 @@ void AboutPageHandler::PageReady(const ListValue* args) { ...@@ -273,8 +273,8 @@ void AboutPageHandler::PageReady(const ListValue* args) {
// Request the channel information. Use the observer to track the about // Request the channel information. Use the observer to track the about
// page handler and ensure it does not get deleted before the callback. // page handler and ensure it does not get deleted before the callback.
update_library->GetReleaseTrack(UpdateSelectedChannel, update_engine_client->GetReleaseTrack(
update_observer_.get()); base::Bind(UpdateSelectedChannel, update_observer_.get()));
} }
void AboutPageHandler::SetReleaseTrack(const ListValue* args) { void AboutPageHandler::SetReleaseTrack(const ListValue* args) {
...@@ -283,16 +283,15 @@ void AboutPageHandler::SetReleaseTrack(const ListValue* args) { ...@@ -283,16 +283,15 @@ void AboutPageHandler::SetReleaseTrack(const ListValue* args) {
return; return;
} }
const std::string channel = UTF16ToUTF8(ExtractStringValue(args)); const std::string channel = UTF16ToUTF8(ExtractStringValue(args));
CrosLibrary::Get()->GetUpdateLibrary()->SetReleaseTrack(channel); DBusThreadManager::Get()->GetUpdateEngineClient()->SetReleaseTrack(channel);
} }
void AboutPageHandler::CheckNow(const ListValue* args) { void AboutPageHandler::CheckNow(const ListValue* args) {
// Make sure that libcros is loaded and OOBE is complete. // Make sure that libcros is loaded and OOBE is complete.
if (!WizardController::default_controller() || if (!WizardController::default_controller() ||
WizardController::IsDeviceRegistered()) { WizardController::IsDeviceRegistered()) {
CrosLibrary::Get()->GetUpdateLibrary()-> DBusThreadManager::Get()->GetUpdateEngineClient()->
RequestUpdateCheck(NULL, // no callback RequestUpdateCheck(UpdateEngineClient::EmptyUpdateCheckCallback());
NULL); // no userdata
} }
} }
...@@ -301,28 +300,28 @@ void AboutPageHandler::RestartNow(const ListValue* args) { ...@@ -301,28 +300,28 @@ void AboutPageHandler::RestartNow(const ListValue* args) {
} }
void AboutPageHandler::UpdateStatus( void AboutPageHandler::UpdateStatus(
const UpdateLibrary::Status& status) { const UpdateEngineClient::Status& status) {
string16 message; string16 message;
std::string image = "up-to-date"; std::string image = "up-to-date";
bool enabled = false; bool enabled = false;
switch (status.status) { switch (status.status) {
case UPDATE_STATUS_IDLE: case UpdateEngineClient::UPDATE_STATUS_IDLE:
if (!sticky_) { if (!sticky_) {
message = l10n_util::GetStringFUTF16(IDS_UPGRADE_ALREADY_UP_TO_DATE, message = l10n_util::GetStringFUTF16(IDS_UPGRADE_ALREADY_UP_TO_DATE,
l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME)); l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME));
enabled = true; enabled = true;
} }
break; break;
case UPDATE_STATUS_CHECKING_FOR_UPDATE: case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE:
message = l10n_util::GetStringUTF16(IDS_UPGRADE_CHECK_STARTED); message = l10n_util::GetStringUTF16(IDS_UPGRADE_CHECK_STARTED);
sticky_ = false; sticky_ = false;
break; break;
case UPDATE_STATUS_UPDATE_AVAILABLE: case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE:
message = l10n_util::GetStringUTF16(IDS_UPDATE_AVAILABLE); message = l10n_util::GetStringUTF16(IDS_UPDATE_AVAILABLE);
started_ = true; started_ = true;
break; break;
case UPDATE_STATUS_DOWNLOADING: case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING:
{ {
int progress = static_cast<int>(status.download_progress * 100.0); int progress = static_cast<int>(status.download_progress * 100.0);
if (progress != progress_) { if (progress != progress_) {
...@@ -333,22 +332,22 @@ void AboutPageHandler::UpdateStatus( ...@@ -333,22 +332,22 @@ void AboutPageHandler::UpdateStatus(
started_ = true; started_ = true;
} }
break; break;
case UPDATE_STATUS_VERIFYING: case UpdateEngineClient::UPDATE_STATUS_VERIFYING:
message = l10n_util::GetStringUTF16(IDS_UPDATE_VERIFYING); message = l10n_util::GetStringUTF16(IDS_UPDATE_VERIFYING);
started_ = true; started_ = true;
break; break;
case UPDATE_STATUS_FINALIZING: case UpdateEngineClient::UPDATE_STATUS_FINALIZING:
message = l10n_util::GetStringUTF16(IDS_UPDATE_FINALIZING); message = l10n_util::GetStringUTF16(IDS_UPDATE_FINALIZING);
started_ = true; started_ = true;
break; break;
case UPDATE_STATUS_UPDATED_NEED_REBOOT: case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT:
message = l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED); message = l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED);
image = "available"; image = "available";
sticky_ = true; sticky_ = true;
break; break;
default: default:
// case UPDATE_STATUS_ERROR: // case UpdateEngineClient::UPDATE_STATUS_ERROR:
// case UPDATE_STATUS_REPORTING_ERROR_EVENT: // case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT:
// The error is only displayed if we were able to determine an // The error is only displayed if we were able to determine an
// update was available. // update was available.
...@@ -366,7 +365,8 @@ void AboutPageHandler::UpdateStatus( ...@@ -366,7 +365,8 @@ void AboutPageHandler::UpdateStatus(
// "Checking for update..." needs to be shown for a while, so users // "Checking for update..." needs to be shown for a while, so users
// can read it, hence insert delay for this. // can read it, hence insert delay for this.
scoped_ptr<Value> insert_delay(Value::CreateBooleanValue( scoped_ptr<Value> insert_delay(Value::CreateBooleanValue(
status.status == UPDATE_STATUS_CHECKING_FOR_UPDATE)); status.status ==
UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE));
web_ui_->CallJavascriptFunction("AboutPage.updateStatusCallback", web_ui_->CallJavascriptFunction("AboutPage.updateStatusCallback",
*update_message, *insert_delay); *update_message, *insert_delay);
...@@ -379,7 +379,7 @@ void AboutPageHandler::UpdateStatus( ...@@ -379,7 +379,7 @@ void AboutPageHandler::UpdateStatus(
*image_string); *image_string);
} }
// We'll change the "Check For Update" button to "Restart" button. // We'll change the "Check For Update" button to "Restart" button.
if (status.status == UPDATE_STATUS_UPDATED_NEED_REBOOT) { if (status.status == UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT) {
web_ui_->CallJavascriptFunction("AboutPage.changeToRestartButton"); web_ui_->CallJavascriptFunction("AboutPage.changeToRestartButton");
} }
} }
...@@ -404,15 +404,12 @@ void AboutPageHandler::OnOSFirmware(VersionLoader::Handle handle, ...@@ -404,15 +404,12 @@ void AboutPageHandler::OnOSFirmware(VersionLoader::Handle handle,
// Callback from UpdateEngine with channel information. // Callback from UpdateEngine with channel information.
// static // static
void AboutPageHandler::UpdateSelectedChannel(void* user_data, void AboutPageHandler::UpdateSelectedChannel(UpdateObserver* observer,
const char* channel) { const std::string& channel) {
if (!user_data || !channel) { if (DBusThreadManager::Get()->GetUpdateEngineClient()
LOG(WARNING) << "UpdateSelectedChannel returned NULL."; ->HasObserver(observer)) {
return; // If UpdateEngineClient still has the observer, then the page handler
} // is valid.
UpdateObserver* observer = static_cast<UpdateObserver*>(user_data);
if (CrosLibrary::Get()->GetUpdateLibrary()->HasObserver(observer)) {
// If UpdateLibrary still has the observer, then the page handler is valid.
AboutPageHandler* handler = observer->page_handler(); AboutPageHandler* handler = observer->page_handler();
scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); scoped_ptr<Value> channel_string(Value::CreateStringValue(channel));
handler->web_ui_->CallJavascriptFunction( handler->web_ui_->CallJavascriptFunction(
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <string> #include <string>
#include "chrome/browser/ui/webui/options/options_ui.h" #include "chrome/browser/ui/webui/options/options_ui.h"
#include "chrome/browser/chromeos/cros/update_library.h" #include "chrome/browser/chromeos/dbus/update_engine_client.h"
#include "chrome/browser/chromeos/version_loader.h" #include "chrome/browser/chromeos/version_loader.h"
namespace chromeos { namespace chromeos {
...@@ -25,6 +25,8 @@ class AboutPageHandler : public OptionsPageUIHandler { ...@@ -25,6 +25,8 @@ class AboutPageHandler : public OptionsPageUIHandler {
virtual void RegisterMessages(); virtual void RegisterMessages();
private: private:
class UpdateObserver;
// The function is called from JavaScript when the about page is ready. // The function is called from JavaScript when the about page is ready.
void PageReady(const base::ListValue* args); void PageReady(const base::ListValue* args);
...@@ -43,10 +45,11 @@ class AboutPageHandler : public OptionsPageUIHandler { ...@@ -43,10 +45,11 @@ class AboutPageHandler : public OptionsPageUIHandler {
std::string version); std::string version);
void OnOSFirmware(VersionLoader::Handle handle, void OnOSFirmware(VersionLoader::Handle handle,
std::string firmware); std::string firmware);
void UpdateStatus(const UpdateLibrary::Status& status); void UpdateStatus(const UpdateEngineClient::Status& status);
// UpdateEngine Callback handler. // UpdateEngine Callback handler.
static void UpdateSelectedChannel(void* user_data, const char* channel); static void UpdateSelectedChannel(UpdateObserver* observer,
const std::string& channel);
// Handles asynchronously loading the version. // Handles asynchronously loading the version.
VersionLoader loader_; VersionLoader loader_;
...@@ -55,7 +58,6 @@ class AboutPageHandler : public OptionsPageUIHandler { ...@@ -55,7 +58,6 @@ class AboutPageHandler : public OptionsPageUIHandler {
CancelableRequestConsumer consumer_; CancelableRequestConsumer consumer_;
// Update Observer // Update Observer
class UpdateObserver;
scoped_ptr<UpdateObserver> update_observer_; scoped_ptr<UpdateObserver> update_observer_;
int progress_; int progress_;
......
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