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