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

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

Issue 6648009: Modify UpdateLibrary to use async RequestUpdateCheck call (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 9 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/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/chromeos/cros/cros_library.h" 9 #include "chrome/browser/chromeos/cros/cros_library.h"
10 #include "content/browser/browser_thread.h" 10 #include "content/browser/browser_thread.h"
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 30
31 void AddObserver(Observer* observer) { 31 void AddObserver(Observer* observer) {
32 observers_.AddObserver(observer); 32 observers_.AddObserver(observer);
33 } 33 }
34 34
35 void RemoveObserver(Observer* observer) { 35 void RemoveObserver(Observer* observer) {
36 observers_.RemoveObserver(observer); 36 observers_.RemoveObserver(observer);
37 } 37 }
38 38
39 bool CheckForUpdate() { 39 void RequestUpdateCheck(chromeos::UpdateCallback callback, void* user_data) {
40 if (!CrosLibrary::Get()->EnsureLoaded()) 40 if (CrosLibrary::Get()->EnsureLoaded())
41 return false; 41 chromeos::RequestUpdateCheck(callback, user_data);
42
43 return InitiateUpdateCheck();
44 } 42 }
45 43
46 bool RebootAfterUpdate() { 44 bool RebootAfterUpdate() {
47 if (!CrosLibrary::Get()->EnsureLoaded()) 45 if (!CrosLibrary::Get()->EnsureLoaded())
48 return false; 46 return false;
49 47
50 return RebootIfUpdated(); 48 return RebootIfUpdated();
51 } 49 }
52 50
53 bool SetReleaseTrack(const std::string& track) { 51 bool SetReleaseTrack(const std::string& track) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 110
113 DISALLOW_COPY_AND_ASSIGN(UpdateLibraryImpl); 111 DISALLOW_COPY_AND_ASSIGN(UpdateLibraryImpl);
114 }; 112 };
115 113
116 class UpdateLibraryStubImpl : public UpdateLibrary { 114 class UpdateLibraryStubImpl : public UpdateLibrary {
117 public: 115 public:
118 UpdateLibraryStubImpl() {} 116 UpdateLibraryStubImpl() {}
119 ~UpdateLibraryStubImpl() {} 117 ~UpdateLibraryStubImpl() {}
120 void AddObserver(Observer* observer) {} 118 void AddObserver(Observer* observer) {}
121 void RemoveObserver(Observer* observer) {} 119 void RemoveObserver(Observer* observer) {}
122 bool CheckForUpdate() { return false; } 120 void RequestUpdateCheck(chromeos::UpdateCallback callback, void* user_data) {
121 if (callback)
122 callback(user_data, UPDATE_RESULT_FAILED, "stub update");
123 }
123 bool RebootAfterUpdate() { return false; } 124 bool RebootAfterUpdate() { return false; }
124 bool SetReleaseTrack(const std::string& track) { return false; } 125 bool SetReleaseTrack(const std::string& track) { return false; }
125 std::string GetReleaseTrack() { return "beta-channel"; } 126 std::string GetReleaseTrack() { return "beta-channel"; }
126 const UpdateLibrary::Status& status() const { 127 const UpdateLibrary::Status& status() const {
127 return status_; 128 return status_;
128 } 129 }
129 130
130 private: 131 private:
131 Status status_; 132 Status status_;
132 133
133 DISALLOW_COPY_AND_ASSIGN(UpdateLibraryStubImpl); 134 DISALLOW_COPY_AND_ASSIGN(UpdateLibraryStubImpl);
134 }; 135 };
135 136
136 // static 137 // static
137 UpdateLibrary* UpdateLibrary::GetImpl(bool stub) { 138 UpdateLibrary* UpdateLibrary::GetImpl(bool stub) {
138 if (stub) 139 if (stub)
139 return new UpdateLibraryStubImpl(); 140 return new UpdateLibraryStubImpl();
140 else 141 else
141 return new UpdateLibraryImpl(); 142 return new UpdateLibraryImpl();
142 } 143 }
143 144
144 } // namespace chromeos 145 } // namespace chromeos
145 146
146 // Allows InvokeLater without adding refcounting. This class is a Singleton and 147 // Allows InvokeLater without adding refcounting. This class is a Singleton and
147 // won't be deleted until it's last InvokeLater is run. 148 // won't be deleted until it's last InvokeLater is run.
148 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::UpdateLibraryImpl); 149 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::UpdateLibraryImpl);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698