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

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

Issue 2060623002: Implementation of Device End of Life Notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase the branch Created 4 years, 6 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
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 VLOG(1) << "Requesting to get channel, get_current_channel=" 200 VLOG(1) << "Requesting to get channel, get_current_channel="
201 << get_current_channel; 201 << get_current_channel;
202 update_engine_proxy_->CallMethod( 202 update_engine_proxy_->CallMethod(
203 &method_call, 203 &method_call,
204 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 204 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
205 base::Bind(&UpdateEngineClientImpl::OnGetChannel, 205 base::Bind(&UpdateEngineClientImpl::OnGetChannel,
206 weak_ptr_factory_.GetWeakPtr(), 206 weak_ptr_factory_.GetWeakPtr(),
207 callback)); 207 callback));
208 } 208 }
209 209
210 void GetEolStatus(const GetEolStatusCallback& callback) override {
211 dbus::MethodCall method_call(update_engine::kUpdateEngineInterface,
212 update_engine::kGetEolStatus);
213
214 VLOG(1) << "Requesting to get end of life status";
215 update_engine_proxy_->CallMethod(
216 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
217 base::Bind(&UpdateEngineClientImpl::OnGetEolStatus,
218 weak_ptr_factory_.GetWeakPtr(), callback));
219 }
220
210 protected: 221 protected:
211 void Init(dbus::Bus* bus) override { 222 void Init(dbus::Bus* bus) override {
212 update_engine_proxy_ = bus->GetObjectProxy( 223 update_engine_proxy_ = bus->GetObjectProxy(
213 update_engine::kUpdateEngineServiceName, 224 update_engine::kUpdateEngineServiceName,
214 dbus::ObjectPath(update_engine::kUpdateEngineServicePath)); 225 dbus::ObjectPath(update_engine::kUpdateEngineServicePath));
215 226
216 // Monitor the D-Bus signal for brightness changes. Only the power 227 // Monitor the D-Bus signal for brightness changes. Only the power
217 // manager knows the actual brightness level. We don't cache the 228 // manager knows the actual brightness level. We don't cache the
218 // brightness level in Chrome as it will make things less reliable. 229 // brightness level in Chrome as it will make things less reliable.
219 update_engine_proxy_->ConnectToSignal( 230 update_engine_proxy_->ConnectToSignal(
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 std::string channel; 353 std::string channel;
343 if (!reader.PopString(&channel)) { 354 if (!reader.PopString(&channel)) {
344 LOG(ERROR) << "Incorrect response: " << response->ToString(); 355 LOG(ERROR) << "Incorrect response: " << response->ToString();
345 callback.Run(""); 356 callback.Run("");
346 return; 357 return;
347 } 358 }
348 VLOG(1) << "The channel received: " << channel; 359 VLOG(1) << "The channel received: " << channel;
349 callback.Run(channel); 360 callback.Run(channel);
350 } 361 }
351 362
363 // Called when a response for GetEolStatus() is received.
364 void OnGetEolStatus(const GetEolStatusCallback& callback,
365 dbus::Response* response) {
366 if (!response) {
367 LOG(ERROR) << "Failed to request getting eol status";
368 callback.Run(update_engine::EndOfLifeStatus::kSupported);
369 return;
370 }
371 dbus::MessageReader reader(response);
372 int status;
373 if (!reader.PopInt32(&status)) {
374 LOG(ERROR) << "Incorrect response: " << response->ToString();
375 callback.Run(update_engine::EndOfLifeStatus::kSupported);
376 return;
377 }
378 VLOG(1) << "Eol status received: " << status;
379 callback.Run(status);
stevenjb 2016/06/18 00:52:58 We should cast status to the correct enum type (an
xiaoyinh(OOO Sep 11-29) 2016/06/18 02:09:39 Added validation Check. Steven, mind if I change t
380 }
381
352 // Called when a status update signal is received. 382 // Called when a status update signal is received.
353 void StatusUpdateReceived(dbus::Signal* signal) { 383 void StatusUpdateReceived(dbus::Signal* signal) {
354 VLOG(1) << "Status update signal received: " << signal->ToString(); 384 VLOG(1) << "Status update signal received: " << signal->ToString();
355 dbus::MessageReader reader(signal); 385 dbus::MessageReader reader(signal);
356 int64_t last_checked_time = 0; 386 int64_t last_checked_time = 0;
357 double progress = 0.0; 387 double progress = 0.0;
358 std::string current_operation; 388 std::string current_operation;
359 std::string new_version; 389 std::string new_version;
360 int64_t new_size = 0; 390 int64_t new_size = 0;
361 if (!(reader.PopInt64(&last_checked_time) && 391 if (!(reader.PopInt64(&last_checked_time) &&
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 void GetChannel(bool get_current_channel, 460 void GetChannel(bool get_current_channel,
431 const GetChannelCallback& callback) override { 461 const GetChannelCallback& callback) override {
432 VLOG(1) << "Requesting to get channel, get_current_channel=" 462 VLOG(1) << "Requesting to get channel, get_current_channel="
433 << get_current_channel; 463 << get_current_channel;
434 if (get_current_channel) 464 if (get_current_channel)
435 callback.Run(current_channel_); 465 callback.Run(current_channel_);
436 else 466 else
437 callback.Run(target_channel_); 467 callback.Run(target_channel_);
438 } 468 }
439 469
470 void GetEolStatus(const GetEolStatusCallback& callback) override {
471 callback.Run(update_engine::EndOfLifeStatus::kSupported);
472 }
473
440 std::string current_channel_; 474 std::string current_channel_;
441 std::string target_channel_; 475 std::string target_channel_;
442 }; 476 };
443 477
444 // The UpdateEngineClient implementation used on Linux desktop, which 478 // The UpdateEngineClient implementation used on Linux desktop, which
445 // tries to emulate real update engine client. 479 // tries to emulate real update engine client.
446 class UpdateEngineClientFakeImpl : public UpdateEngineClientStubImpl { 480 class UpdateEngineClientFakeImpl : public UpdateEngineClientStubImpl {
447 public: 481 public:
448 UpdateEngineClientFakeImpl() : weak_factory_(this) { 482 UpdateEngineClientFakeImpl() : weak_factory_(this) {
449 } 483 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 auto cix = std::find(kReleaseChannelsList, 601 auto cix = std::find(kReleaseChannelsList,
568 kReleaseChannelsList + arraysize(kReleaseChannelsList), 602 kReleaseChannelsList + arraysize(kReleaseChannelsList),
569 current_channel); 603 current_channel);
570 auto tix = std::find(kReleaseChannelsList, 604 auto tix = std::find(kReleaseChannelsList,
571 kReleaseChannelsList + arraysize(kReleaseChannelsList), 605 kReleaseChannelsList + arraysize(kReleaseChannelsList),
572 target_channel); 606 target_channel);
573 return tix > cix; 607 return tix > cix;
574 } 608 }
575 609
576 } // namespace chromeos 610 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698