Commit 575a95d3 authored by tfarina@chromium.org's avatar tfarina@chromium.org

cros: Remove unneeded includes from update_library.h plus some random cleanups.

BUG=None
TEST=None

R=stevenjb@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95574 0039d316-1c4b-4281-b951-d872f2087c98
parent fc197211
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
#include "chrome/browser/chromeos/cros/update_library.h" #include "chrome/browser/chromeos/cros/update_library.h"
#include "base/basictypes.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/string_util.h" #include "base/observer_list.h"
#include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/cros/cros_library.h"
#include "content/browser/browser_thread.h" #include "content/browser/browser_thread.h"
...@@ -13,16 +14,15 @@ namespace chromeos { ...@@ -13,16 +14,15 @@ namespace chromeos {
class UpdateLibraryImpl : public UpdateLibrary { class UpdateLibraryImpl : public UpdateLibrary {
public: public:
UpdateLibraryImpl() UpdateLibraryImpl() : status_connection_(NULL) {
: status_connection_(NULL) { if (CrosLibrary::Get()->EnsureLoaded())
if (CrosLibrary::Get()->EnsureLoaded()) {
Init(); Init();
}
} }
virtual ~UpdateLibraryImpl() { virtual ~UpdateLibraryImpl() {
if (status_connection_) { if (status_connection_) {
DisconnectUpdateProgress(status_connection_); chromeos::DisconnectUpdateProgress(status_connection_);
status_connection_ = NULL;
} }
} }
...@@ -66,14 +66,13 @@ class UpdateLibraryImpl : public UpdateLibrary { ...@@ -66,14 +66,13 @@ class UpdateLibraryImpl : public UpdateLibrary {
} }
private: private:
static void ChangedHandler(void* object, static void ChangedHandler(void* object, const UpdateProgress& status) {
const UpdateProgress& status) { UpdateLibraryImpl* impl = static_cast<UpdateLibraryImpl*>(object);
UpdateLibraryImpl* updater = static_cast<UpdateLibraryImpl*>(object); impl->UpdateStatus(Status(status));
updater->UpdateStatus(Status(status));
} }
void Init() { void Init() {
status_connection_ = MonitorUpdateStatus(&ChangedHandler, this); status_connection_ = chromeos::MonitorUpdateStatus(&ChangedHandler, this);
// Asynchronously load the initial state. // Asynchronously load the initial state.
RequestUpdateStatus(&ChangedHandler, this); RequestUpdateStatus(&ChangedHandler, this);
} }
......
...@@ -8,9 +8,6 @@ ...@@ -8,9 +8,6 @@
#include <string> #include <string>
#include "base/memory/singleton.h"
#include "base/observer_list.h"
#include "base/time.h"
#include "third_party/cros/chromeos_update_engine.h" #include "third_party/cros/chromeos_update_engine.h"
namespace chromeos { namespace chromeos {
...@@ -33,19 +30,19 @@ class UpdateLibrary { ...@@ -33,19 +30,19 @@ class UpdateLibrary {
new_size(0) { new_size(0) {
} }
explicit Status(const UpdateProgress& x) : explicit Status(const UpdateProgress& o)
status(x.status_), : status(o.status_),
download_progress(x.download_progress_), download_progress(o.download_progress_),
last_checked_time(x.last_checked_time_), last_checked_time(o.last_checked_time_),
new_version(x.new_version_), new_version(o.new_version_),
new_size(x.new_size_) { new_size(o.new_size_) {
} }
UpdateStatusOperation status; UpdateStatusOperation status;
double download_progress; // 0.0 - 1.0 double download_progress; // 0.0 - 1.0
int64_t last_checked_time; // As reported by std::time(). int64_t last_checked_time; // As reported by std::time().
std::string new_version; std::string new_version;
int64_t new_size; // Valid during DOWNLOADING, in bytes. int64_t new_size; // Valid during DOWNLOADING, in bytes.
}; };
class Observer { class Observer {
......
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