| OLD | NEW |
| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 dbus::MethodCall method_call(update_engine::kUpdateEngineInterface, | 211 dbus::MethodCall method_call(update_engine::kUpdateEngineInterface, |
| 212 update_engine::kGetEolStatus); | 212 update_engine::kGetEolStatus); |
| 213 | 213 |
| 214 VLOG(1) << "Requesting to get end of life status"; | 214 VLOG(1) << "Requesting to get end of life status"; |
| 215 update_engine_proxy_->CallMethod( | 215 update_engine_proxy_->CallMethod( |
| 216 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 216 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 217 base::Bind(&UpdateEngineClientImpl::OnGetEolStatus, | 217 base::Bind(&UpdateEngineClientImpl::OnGetEolStatus, |
| 218 weak_ptr_factory_.GetWeakPtr(), callback)); | 218 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 219 } | 219 } |
| 220 | 220 |
| 221 std::unique_ptr<dbus::Response> SetUpdateOverCellularPermission( |
| 222 bool allowed) override { |
| 223 dbus::MethodCall method_call( |
| 224 update_engine::kUpdateEngineInterface, |
| 225 update_engine::kSetUpdateOverCellularPermission); |
| 226 VLOG(1) << "Requesting UpdateEngine to " << (allowed ? "allow" : "prohibit") |
| 227 << " updates over cellular."; |
| 228 return update_engine_proxy_->CallMethodAndBlock( |
| 229 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT); |
| 230 } |
| 231 |
| 221 protected: | 232 protected: |
| 222 void Init(dbus::Bus* bus) override { | 233 void Init(dbus::Bus* bus) override { |
| 223 update_engine_proxy_ = bus->GetObjectProxy( | 234 update_engine_proxy_ = bus->GetObjectProxy( |
| 224 update_engine::kUpdateEngineServiceName, | 235 update_engine::kUpdateEngineServiceName, |
| 225 dbus::ObjectPath(update_engine::kUpdateEngineServicePath)); | 236 dbus::ObjectPath(update_engine::kUpdateEngineServicePath)); |
| 226 update_engine_proxy_->ConnectToSignal( | 237 update_engine_proxy_->ConnectToSignal( |
| 227 update_engine::kUpdateEngineInterface, | 238 update_engine::kUpdateEngineInterface, |
| 228 update_engine::kStatusUpdate, | 239 update_engine::kStatusUpdate, |
| 229 base::Bind(&UpdateEngineClientImpl::StatusUpdateReceived, | 240 base::Bind(&UpdateEngineClientImpl::StatusUpdateReceived, |
| 230 weak_ptr_factory_.GetWeakPtr()), | 241 weak_ptr_factory_.GetWeakPtr()), |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 | 453 |
| 443 DISALLOW_COPY_AND_ASSIGN(UpdateEngineClientImpl); | 454 DISALLOW_COPY_AND_ASSIGN(UpdateEngineClientImpl); |
| 444 }; | 455 }; |
| 445 | 456 |
| 446 // The UpdateEngineClient implementation used on Linux desktop, | 457 // The UpdateEngineClient implementation used on Linux desktop, |
| 447 // which does nothing. | 458 // which does nothing. |
| 448 class UpdateEngineClientStubImpl : public UpdateEngineClient { | 459 class UpdateEngineClientStubImpl : public UpdateEngineClient { |
| 449 public: | 460 public: |
| 450 UpdateEngineClientStubImpl() | 461 UpdateEngineClientStubImpl() |
| 451 : current_channel_(kReleaseChannelBeta), | 462 : current_channel_(kReleaseChannelBeta), |
| 452 target_channel_(kReleaseChannelBeta) {} | 463 target_channel_(kReleaseChannelBeta), |
| 464 method_call_("com.example.Interface", "SomeMethod") {} |
| 453 | 465 |
| 454 // UpdateEngineClient implementation: | 466 // UpdateEngineClient implementation: |
| 455 void Init(dbus::Bus* bus) override {} | 467 void Init(dbus::Bus* bus) override {} |
| 456 void AddObserver(Observer* observer) override {} | 468 void AddObserver(Observer* observer) override {} |
| 457 void RemoveObserver(Observer* observer) override {} | 469 void RemoveObserver(Observer* observer) override {} |
| 458 bool HasObserver(const Observer* observer) const override { return false; } | 470 bool HasObserver(const Observer* observer) const override { return false; } |
| 459 | 471 |
| 460 void RequestUpdateCheck(const UpdateCheckCallback& callback) override { | 472 void RequestUpdateCheck(const UpdateCheckCallback& callback) override { |
| 461 callback.Run(UPDATE_RESULT_NOTIMPLEMENTED); | 473 callback.Run(UPDATE_RESULT_NOTIMPLEMENTED); |
| 462 } | 474 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 480 if (get_current_channel) | 492 if (get_current_channel) |
| 481 callback.Run(current_channel_); | 493 callback.Run(current_channel_); |
| 482 else | 494 else |
| 483 callback.Run(target_channel_); | 495 callback.Run(target_channel_); |
| 484 } | 496 } |
| 485 | 497 |
| 486 void GetEolStatus(const GetEolStatusCallback& callback) override { | 498 void GetEolStatus(const GetEolStatusCallback& callback) override { |
| 487 callback.Run(update_engine::EndOfLifeStatus::kSupported); | 499 callback.Run(update_engine::EndOfLifeStatus::kSupported); |
| 488 } | 500 } |
| 489 | 501 |
| 502 std::unique_ptr<dbus::Response> SetUpdateOverCellularPermission( |
| 503 bool allowed) override { |
| 504 return dbus::Response::FromMethodCall(&method_call_); |
| 505 } |
| 506 |
| 490 std::string current_channel_; | 507 std::string current_channel_; |
| 491 std::string target_channel_; | 508 std::string target_channel_; |
| 509 dbus::MethodCall method_call_; |
| 492 }; | 510 }; |
| 493 | 511 |
| 494 // The UpdateEngineClient implementation used on Linux desktop, which | 512 // The UpdateEngineClient implementation used on Linux desktop, which |
| 495 // tries to emulate real update engine client. | 513 // tries to emulate real update engine client. |
| 496 class UpdateEngineClientFakeImpl : public UpdateEngineClientStubImpl { | 514 class UpdateEngineClientFakeImpl : public UpdateEngineClientStubImpl { |
| 497 public: | 515 public: |
| 498 UpdateEngineClientFakeImpl() : weak_factory_(this) { | 516 UpdateEngineClientFakeImpl() : weak_factory_(this) { |
| 499 } | 517 } |
| 500 | 518 |
| 501 ~UpdateEngineClientFakeImpl() override {} | 519 ~UpdateEngineClientFakeImpl() override {} |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 const char** cix = std::find( | 636 const char** cix = std::find( |
| 619 kReleaseChannelsList, | 637 kReleaseChannelsList, |
| 620 kReleaseChannelsList + arraysize(kReleaseChannelsList), current_channel); | 638 kReleaseChannelsList + arraysize(kReleaseChannelsList), current_channel); |
| 621 const char** tix = std::find( | 639 const char** tix = std::find( |
| 622 kReleaseChannelsList, | 640 kReleaseChannelsList, |
| 623 kReleaseChannelsList + arraysize(kReleaseChannelsList), target_channel); | 641 kReleaseChannelsList + arraysize(kReleaseChannelsList), target_channel); |
| 624 return tix > cix; | 642 return tix > cix; |
| 625 } | 643 } |
| 626 | 644 |
| 627 } // namespace chromeos | 645 } // namespace chromeos |
| OLD | NEW |