Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/browser/chromeos/cros/update_library.cc

Issue 7891021: Use stub impl when libcros fails to load (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase with power library changes Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/cros/update_library.h" 5 #include "chrome/browser/chromeos/cros/update_library.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "chrome/browser/chromeos/cros/cros_library.h" 12 #include "chrome/browser/chromeos/cros/cros_library.h"
13 #include "content/browser/browser_thread.h" 13 #include "content/browser/browser_thread.h"
14 14
15 namespace chromeos { 15 namespace chromeos {
16 16
17 class UpdateLibraryImpl : public UpdateLibrary { 17 class UpdateLibraryImpl : public UpdateLibrary {
18 public: 18 public:
19 UpdateLibraryImpl() : status_connection_(NULL) {} 19 UpdateLibraryImpl() : status_connection_(NULL) {}
20 20
21 virtual ~UpdateLibraryImpl() { 21 virtual ~UpdateLibraryImpl() {
22 if (status_connection_) { 22 if (status_connection_) {
23 chromeos::DisconnectUpdateProgress(status_connection_); 23 chromeos::DisconnectUpdateProgress(status_connection_);
24 status_connection_ = NULL; 24 status_connection_ = NULL;
25 } 25 }
26 } 26 }
27 27
28 // Begin UpdateLibrary implementation. 28 // Begin UpdateLibrary implementation.
29 virtual void Init() OVERRIDE { 29 virtual void Init() OVERRIDE {
30 if (CrosLibrary::Get()->EnsureLoaded()) { 30 DCHECK(CrosLibrary::Get()->libcros_loaded());
31 CHECK(!status_connection_) << "Already initialized"; 31 CHECK(!status_connection_) << "Already initialized";
32 status_connection_ = 32 status_connection_ =
33 chromeos::MonitorUpdateStatus(&UpdateStatusHandler, this); 33 chromeos::MonitorUpdateStatus(&UpdateStatusHandler, this);
34 // Asynchronously load the initial state. 34 // Asynchronously load the initial state.
35 chromeos::RequestUpdateStatus(&UpdateStatusHandler, this); 35 chromeos::RequestUpdateStatus(&UpdateStatusHandler, this);
36 }
37 } 36 }
38 37
39 virtual void AddObserver(Observer* observer) OVERRIDE { 38 virtual void AddObserver(Observer* observer) OVERRIDE {
40 observers_.AddObserver(observer); 39 observers_.AddObserver(observer);
41 } 40 }
42 41
43 virtual void RemoveObserver(Observer* observer) OVERRIDE { 42 virtual void RemoveObserver(Observer* observer) OVERRIDE {
44 observers_.RemoveObserver(observer); 43 observers_.RemoveObserver(observer);
45 } 44 }
46 45
47 virtual bool HasObserver(Observer* observer) OVERRIDE { 46 virtual bool HasObserver(Observer* observer) OVERRIDE {
48 return observers_.HasObserver(observer); 47 return observers_.HasObserver(observer);
49 } 48 }
50 49
51 virtual void RequestUpdateCheck(chromeos::UpdateCallback callback, 50 virtual void RequestUpdateCheck(chromeos::UpdateCallback callback,
52 void* user_data) OVERRIDE { 51 void* user_data) OVERRIDE {
53 if (CrosLibrary::Get()->EnsureLoaded()) 52 chromeos::RequestUpdateCheck(callback, user_data);
54 chromeos::RequestUpdateCheck(callback, user_data);
55 } 53 }
56 54
57 virtual bool RebootAfterUpdate() OVERRIDE { 55 virtual bool RebootAfterUpdate() OVERRIDE {
58 if (!CrosLibrary::Get()->EnsureLoaded())
59 return false;
60
61 return RebootIfUpdated(); 56 return RebootIfUpdated();
62 } 57 }
63 58
64 virtual void SetReleaseTrack(const std::string& track) OVERRIDE { 59 virtual void SetReleaseTrack(const std::string& track) OVERRIDE {
65 if (CrosLibrary::Get()->EnsureLoaded()) 60 chromeos::SetUpdateTrack(track);
66 chromeos::SetUpdateTrack(track);
67 } 61 }
68 62
69 virtual void GetReleaseTrack(chromeos::UpdateTrackCallback callback, 63 virtual void GetReleaseTrack(chromeos::UpdateTrackCallback callback,
70 void* user_data) OVERRIDE { 64 void* user_data) OVERRIDE {
71 if (CrosLibrary::Get()->EnsureLoaded()) 65 chromeos::RequestUpdateTrack(callback, user_data);
72 chromeos::RequestUpdateTrack(callback, user_data);
73 } 66 }
74 // End UpdateLibrary implementation. 67 // End UpdateLibrary implementation.
75 68
76 const UpdateLibrary::Status& status() const { 69 const UpdateLibrary::Status& status() const {
77 return status_; 70 return status_;
78 } 71 }
79 72
80 private: 73 private:
81 static void UpdateStatusHandler(void* object, const UpdateProgress& status) { 74 static void UpdateStatusHandler(void* object, const UpdateProgress& status) {
82 UpdateLibraryImpl* impl = static_cast<UpdateLibraryImpl*>(object); 75 UpdateLibraryImpl* impl = static_cast<UpdateLibraryImpl*>(object);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 impl = new UpdateLibraryImpl(); 142 impl = new UpdateLibraryImpl();
150 impl->Init(); 143 impl->Init();
151 return impl; 144 return impl;
152 } 145 }
153 146
154 } // namespace chromeos 147 } // namespace chromeos
155 148
156 // Allows InvokeLater without adding refcounting. This class is a Singleton and 149 // Allows InvokeLater without adding refcounting. This class is a Singleton and
157 // won't be deleted until it's last InvokeLater is run. 150 // won't be deleted until it's last InvokeLater is run.
158 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::UpdateLibraryImpl); 151 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::UpdateLibraryImpl);
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/speech_synthesis_library.cc ('k') | chrome/browser/chromeos/status/power_menu_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698