| OLD | NEW |
| 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/dbus/update_engine_client.h" | 5 #include "chrome/browser/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/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/browser/chromeos/system/runtime_environment.h" | 10 #include "chrome/browser/chromeos/system/runtime_environment.h" |
| 11 #include "dbus/bus.h" | 11 #include "dbus/bus.h" |
| 12 #include "dbus/message.h" | 12 #include "dbus/message.h" |
| 13 #include "dbus/object_path.h" |
| 13 #include "dbus/object_proxy.h" | 14 #include "dbus/object_proxy.h" |
| 14 #include "third_party/cros_system_api/dbus/service_constants.h" | 15 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 15 | 16 |
| 16 namespace chromeos { | 17 namespace chromeos { |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 // Returns UPDATE_STATUS_ERROR on error. | 20 // Returns UPDATE_STATUS_ERROR on error. |
| 20 UpdateEngineClient::UpdateStatusOperation UpdateStatusFromString( | 21 UpdateEngineClient::UpdateStatusOperation UpdateStatusFromString( |
| 21 const std::string& str) { | 22 const std::string& str) { |
| 22 if (str == "UPDATE_STATUS_IDLE") | 23 if (str == "UPDATE_STATUS_IDLE") |
| (...skipping 24 matching lines...) Expand all Loading... |
| 47 | 48 |
| 48 // The UpdateEngineClient implementation used in production. | 49 // The UpdateEngineClient implementation used in production. |
| 49 class UpdateEngineClientImpl : public UpdateEngineClient { | 50 class UpdateEngineClientImpl : public UpdateEngineClient { |
| 50 public: | 51 public: |
| 51 explicit UpdateEngineClientImpl(dbus::Bus* bus) | 52 explicit UpdateEngineClientImpl(dbus::Bus* bus) |
| 52 : update_engine_proxy_(NULL), | 53 : update_engine_proxy_(NULL), |
| 53 weak_ptr_factory_(this), | 54 weak_ptr_factory_(this), |
| 54 last_status_() { | 55 last_status_() { |
| 55 update_engine_proxy_ = bus->GetObjectProxy( | 56 update_engine_proxy_ = bus->GetObjectProxy( |
| 56 update_engine::kUpdateEngineServiceName, | 57 update_engine::kUpdateEngineServiceName, |
| 57 update_engine::kUpdateEngineServicePath); | 58 dbus::ObjectPath(update_engine::kUpdateEngineServicePath)); |
| 58 | 59 |
| 59 // Monitor the D-Bus signal for brightness changes. Only the power | 60 // Monitor the D-Bus signal for brightness changes. Only the power |
| 60 // manager knows the actual brightness level. We don't cache the | 61 // manager knows the actual brightness level. We don't cache the |
| 61 // brightness level in Chrome as it will make things less reliable. | 62 // brightness level in Chrome as it will make things less reliable. |
| 62 update_engine_proxy_->ConnectToSignal( | 63 update_engine_proxy_->ConnectToSignal( |
| 63 update_engine::kUpdateEngineInterface, | 64 update_engine::kUpdateEngineInterface, |
| 64 update_engine::kStatusUpdate, | 65 update_engine::kStatusUpdate, |
| 65 base::Bind(&UpdateEngineClientImpl::StatusUpdateReceived, | 66 base::Bind(&UpdateEngineClientImpl::StatusUpdateReceived, |
| 66 weak_ptr_factory_.GetWeakPtr()), | 67 weak_ptr_factory_.GetWeakPtr()), |
| 67 base::Bind(&UpdateEngineClientImpl::StatusUpdateConnected, | 68 base::Bind(&UpdateEngineClientImpl::StatusUpdateConnected, |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // static | 281 // static |
| 281 UpdateEngineClient* UpdateEngineClient::Create(dbus::Bus* bus) { | 282 UpdateEngineClient* UpdateEngineClient::Create(dbus::Bus* bus) { |
| 282 if (system::runtime_environment::IsRunningOnChromeOS()) { | 283 if (system::runtime_environment::IsRunningOnChromeOS()) { |
| 283 return new UpdateEngineClientImpl(bus); | 284 return new UpdateEngineClientImpl(bus); |
| 284 } else { | 285 } else { |
| 285 return new UpdateEngineClientStubImpl(); | 286 return new UpdateEngineClientStubImpl(); |
| 286 } | 287 } |
| 287 } | 288 } |
| 288 | 289 |
| 289 } // namespace chromeos | 290 } // namespace chromeos |
| OLD | NEW |