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

Side by Side Diff: chromeos/dbus/update_engine_client.cc

Issue 21015010: Remove all traces of deprecated Get/SetReleaseTrack calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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
« no previous file with comments | « chromeos/dbus/update_engine_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chromeos/dbus/update_engine_client.h" 5 #include "chromeos/dbus/update_engine_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "dbus/bus.h" 10 #include "dbus/bus.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 update_engine::kRebootIfNeeded); 125 update_engine::kRebootIfNeeded);
126 126
127 VLOG(1) << "Requesting a reboot"; 127 VLOG(1) << "Requesting a reboot";
128 update_engine_proxy_->CallMethod( 128 update_engine_proxy_->CallMethod(
129 &method_call, 129 &method_call,
130 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 130 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
131 base::Bind(&UpdateEngineClientImpl::OnRebootAfterUpdate, 131 base::Bind(&UpdateEngineClientImpl::OnRebootAfterUpdate,
132 weak_ptr_factory_.GetWeakPtr())); 132 weak_ptr_factory_.GetWeakPtr()));
133 } 133 }
134 134
135 virtual void SetReleaseTrack(const std::string& track) OVERRIDE {
136 dbus::MethodCall method_call(
137 update_engine::kUpdateEngineInterface,
138 update_engine::kSetTrack);
139 dbus::MessageWriter writer(&method_call);
140 writer.AppendString(track);
141
142 VLOG(1) << "Requesting to set the release track to " << track;
143 update_engine_proxy_->CallMethod(
144 &method_call,
145 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
146 base::Bind(&UpdateEngineClientImpl::OnSetReleaseTrack,
147 weak_ptr_factory_.GetWeakPtr()));
148 }
149
150 virtual void GetReleaseTrack(
151 const GetReleaseTrackCallback& callback) OVERRIDE {
152 dbus::MethodCall method_call(
153 update_engine::kUpdateEngineInterface,
154 update_engine::kGetTrack);
155
156 VLOG(1) << "Requesting to get the current release track";
157 update_engine_proxy_->CallMethod(
158 &method_call,
159 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
160 base::Bind(&UpdateEngineClientImpl::OnGetReleaseTrack,
161 weak_ptr_factory_.GetWeakPtr(),
162 callback));
163 }
164
165 virtual Status GetLastStatus() OVERRIDE { 135 virtual Status GetLastStatus() OVERRIDE {
166 return last_status_; 136 return last_status_;
167 } 137 }
168 138
169 virtual void SetChannel(const std::string& target_channel, 139 virtual void SetChannel(const std::string& target_channel,
170 bool is_powerwash_allowed) OVERRIDE { 140 bool is_powerwash_allowed) OVERRIDE {
171 if (!IsValidChannel(target_channel)) { 141 if (!IsValidChannel(target_channel)) {
172 LOG(ERROR) << "Invalid channel name: " << target_channel; 142 LOG(ERROR) << "Invalid channel name: " << target_channel;
173 return; 143 return;
174 } 144 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 204 }
235 205
236 // Called when a response for RebootAfterUpdate() is received. 206 // Called when a response for RebootAfterUpdate() is received.
237 void OnRebootAfterUpdate(dbus::Response* response) { 207 void OnRebootAfterUpdate(dbus::Response* response) {
238 if (!response) { 208 if (!response) {
239 LOG(ERROR) << "Failed to request rebooting after update"; 209 LOG(ERROR) << "Failed to request rebooting after update";
240 return; 210 return;
241 } 211 }
242 } 212 }
243 213
244 // Called when a response for SetReleaseTrack() is received.
245 void OnSetReleaseTrack(dbus::Response* response) {
246 if (!response) {
247 LOG(ERROR) << "Failed to request setting release track";
248 return;
249 }
250 }
251
252 // Called when a response for GetReleaseTrack() is received.
253 void OnGetReleaseTrack(const GetReleaseTrackCallback& callback,
254 dbus::Response* response) {
255 if (!response) {
256 LOG(ERROR) << "Failed to request getting release track";
257 callback.Run("");
258 return;
259 }
260 dbus::MessageReader reader(response);
261 std::string release_track;
262 if (!reader.PopString(&release_track)) {
263 LOG(ERROR) << "Incorrect response: " << response->ToString();
264 callback.Run("");
265 return;
266 }
267 VLOG(1) << "The current release track received: " << release_track;
268 callback.Run(release_track);
269 }
270
271 // Called when a response for GetStatus is received. 214 // Called when a response for GetStatus is received.
272 void OnGetStatus(dbus::Response* response) { 215 void OnGetStatus(dbus::Response* response) {
273 if (!response) { 216 if (!response) {
274 LOG(ERROR) << "Failed to get response for GetStatus request."; 217 LOG(ERROR) << "Failed to get response for GetStatus request.";
275 return; 218 return;
276 } 219 }
277 220
278 dbus::MessageReader reader(response); 221 dbus::MessageReader reader(response);
279 std::string current_operation; 222 std::string current_operation;
280 Status status; 223 Status status;
281 if (!(reader.PopInt64(&status.last_checked_time) && 224 if (!(reader.PopInt64(&status.last_checked_time) &&
282 reader.PopDouble(&status.download_progress) && 225 reader.PopDouble(&status.download_progress) &&
283 reader.PopString(&current_operation) && 226 reader.PopString(&current_operation) &&
284 reader.PopString(&status.new_version) && 227 reader.PopString(&status.new_version) &&
285 reader.PopInt64(&status.new_size))) { 228 reader.PopInt64(&status.new_size))) {
286 LOG(ERROR) << "GetStatus had incorrect response: " 229 LOG(ERROR) << "GetStatus had incorrect response: "
287 << response->ToString(); 230 << response->ToString();
288 return; 231 return;
289 } 232 }
290 status.status = UpdateStatusFromString(current_operation); 233 status.status = UpdateStatusFromString(current_operation);
291 last_status_ = status; 234 last_status_ = status;
292 FOR_EACH_OBSERVER(Observer, observers_, UpdateStatusChanged(status)); 235 FOR_EACH_OBSERVER(Observer, observers_, UpdateStatusChanged(status));
293 } 236 }
294 237
295 // Called when GetStatus call failed. 238 // Called when GetStatus call failed.
296 void OnGetStatusError(dbus::ErrorResponse* error) { 239 void OnGetStatusError(dbus::ErrorResponse* error) {
297 LOG(ERROR) << "GetStatus request failed with error: " << error->ToString(); 240 LOG(ERROR) << "GetStatus request failed with error: " << error->ToString();
298 } 241 }
299 242
300 // Called when a response for SetReleaseTrack() is received. 243 // Called when a response for SetReleaseChannel() is received.
301 void OnSetChannel(dbus::Response* response) { 244 void OnSetChannel(dbus::Response* response) {
302 if (!response) { 245 if (!response) {
303 LOG(ERROR) << "Failed to request setting channel"; 246 LOG(ERROR) << "Failed to request setting channel";
304 return; 247 return;
305 } 248 }
306 VLOG(1) << "Succeeded to set channel"; 249 VLOG(1) << "Succeeded to set channel";
307 } 250 }
308 251
309 // Called when a response for GetChannel() is received. 252 // Called when a response for GetChannel() is received.
310 void OnGetChannel(const GetReleaseTrackCallback& callback, 253 void OnGetChannel(const GetChannelCallback& callback,
311 dbus::Response* response) { 254 dbus::Response* response) {
312 if (!response) { 255 if (!response) {
313 LOG(ERROR) << "Failed to request getting channel"; 256 LOG(ERROR) << "Failed to request getting channel";
314 callback.Run(""); 257 callback.Run("");
315 return; 258 return;
316 } 259 }
317 dbus::MessageReader reader(response); 260 dbus::MessageReader reader(response);
318 std::string channel; 261 std::string channel;
319 if (!reader.PopString(&channel)) { 262 if (!reader.PopString(&channel)) {
320 LOG(ERROR) << "Incorrect response: " << response->ToString(); 263 LOG(ERROR) << "Incorrect response: " << response->ToString();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // UpdateEngineClient implementation: 322 // UpdateEngineClient implementation:
380 virtual void AddObserver(Observer* observer) OVERRIDE {} 323 virtual void AddObserver(Observer* observer) OVERRIDE {}
381 virtual void RemoveObserver(Observer* observer) OVERRIDE {} 324 virtual void RemoveObserver(Observer* observer) OVERRIDE {}
382 virtual bool HasObserver(Observer* observer) OVERRIDE { return false; } 325 virtual bool HasObserver(Observer* observer) OVERRIDE { return false; }
383 326
384 virtual void RequestUpdateCheck( 327 virtual void RequestUpdateCheck(
385 const UpdateCheckCallback& callback) OVERRIDE { 328 const UpdateCheckCallback& callback) OVERRIDE {
386 callback.Run(UPDATE_RESULT_NOTIMPLEMENTED); 329 callback.Run(UPDATE_RESULT_NOTIMPLEMENTED);
387 } 330 }
388 virtual void RebootAfterUpdate() OVERRIDE {} 331 virtual void RebootAfterUpdate() OVERRIDE {}
389 virtual void SetReleaseTrack(const std::string& track) OVERRIDE {}
390 virtual void GetReleaseTrack(
391 const GetReleaseTrackCallback& callback) OVERRIDE {
392 callback.Run("beta-channel");
393 }
394 virtual Status GetLastStatus() OVERRIDE { return Status(); } 332 virtual Status GetLastStatus() OVERRIDE { return Status(); }
395 virtual void SetChannel(const std::string& target_channel, 333 virtual void SetChannel(const std::string& target_channel,
396 bool is_powerwash_allowed) OVERRIDE { 334 bool is_powerwash_allowed) OVERRIDE {
397 LOG(INFO) << "Requesting to set channel: " 335 LOG(INFO) << "Requesting to set channel: "
398 << "target_channel=" << target_channel << ", " 336 << "target_channel=" << target_channel << ", "
399 << "is_powerwash_allowed=" << is_powerwash_allowed; 337 << "is_powerwash_allowed=" << is_powerwash_allowed;
400 } 338 }
401 virtual void GetChannel(bool get_current_channel, 339 virtual void GetChannel(bool get_current_channel,
402 const GetChannelCallback& callback) OVERRIDE { 340 const GetChannelCallback& callback) OVERRIDE {
403 LOG(INFO) << "Requesting to get channel, get_current_channel=" 341 LOG(INFO) << "Requesting to get channel, get_current_channel="
(...skipping 18 matching lines...) Expand all
422 UpdateEngineClient* UpdateEngineClient::Create( 360 UpdateEngineClient* UpdateEngineClient::Create(
423 DBusClientImplementationType type, 361 DBusClientImplementationType type,
424 dbus::Bus* bus) { 362 dbus::Bus* bus) {
425 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 363 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
426 return new UpdateEngineClientImpl(bus); 364 return new UpdateEngineClientImpl(bus);
427 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 365 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
428 return new UpdateEngineClientStubImpl(); 366 return new UpdateEngineClientStubImpl();
429 } 367 }
430 368
431 } // namespace chromeos 369 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/update_engine_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698