OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "device/battery/battery_status_manager_linux.h" | 5 #include "device/battery/battery_status_manager_linux.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 ignore_result(value.release()); | 78 ignore_result(value.release()); |
79 return scoped_ptr<base::DictionaryValue>(dictionary_value); | 79 return scoped_ptr<base::DictionaryValue>(dictionary_value); |
80 } | 80 } |
81 } | 81 } |
82 return scoped_ptr<base::DictionaryValue>(); | 82 return scoped_ptr<base::DictionaryValue>(); |
83 } | 83 } |
84 | 84 |
85 scoped_ptr<PathsVector> GetPowerSourcesPaths(dbus::ObjectProxy* proxy) { | 85 scoped_ptr<PathsVector> GetPowerSourcesPaths(dbus::ObjectProxy* proxy) { |
86 scoped_ptr<PathsVector> paths(new PathsVector()); | 86 scoped_ptr<PathsVector> paths(new PathsVector()); |
87 if (!proxy) | 87 if (!proxy) |
88 return paths.Pass(); | 88 return paths; |
89 | 89 |
90 dbus::MethodCall method_call(kUPowerServiceName, kUPowerEnumerateDevices); | 90 dbus::MethodCall method_call(kUPowerServiceName, kUPowerEnumerateDevices); |
91 scoped_ptr<dbus::Response> response( | 91 scoped_ptr<dbus::Response> response( |
92 proxy->CallMethodAndBlock(&method_call, | 92 proxy->CallMethodAndBlock(&method_call, |
93 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); | 93 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); |
94 | 94 |
95 if (response) { | 95 if (response) { |
96 dbus::MessageReader reader(response.get()); | 96 dbus::MessageReader reader(response.get()); |
97 reader.PopArrayOfObjectPaths(paths.get()); | 97 reader.PopArrayOfObjectPaths(paths.get()); |
98 } | 98 } |
99 return paths.Pass();; | 99 return paths; |
100 } | 100 } |
101 | 101 |
102 void UpdateNumberBatteriesHistogram(int count) { | 102 void UpdateNumberBatteriesHistogram(int count) { |
103 UMA_HISTOGRAM_CUSTOM_COUNTS( | 103 UMA_HISTOGRAM_CUSTOM_COUNTS( |
104 "BatteryStatus.NumberBatteriesLinux", count, 1, 5, 6); | 104 "BatteryStatus.NumberBatteriesLinux", count, 1, 5, 6); |
105 } | 105 } |
106 | 106 |
107 // Class that represents a dedicated thread which communicates with DBus to | 107 // Class that represents a dedicated thread which communicates with DBus to |
108 // obtain battery information and receives battery change notifications. | 108 // obtain battery information and receives battery change notifications. |
109 class BatteryStatusNotificationThread : public base::Thread { | 109 class BatteryStatusNotificationThread : public base::Thread { |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 } | 368 } |
369 | 369 |
370 // static | 370 // static |
371 scoped_ptr<BatteryStatusManager> BatteryStatusManager::Create( | 371 scoped_ptr<BatteryStatusManager> BatteryStatusManager::Create( |
372 const BatteryStatusService::BatteryUpdateCallback& callback) { | 372 const BatteryStatusService::BatteryUpdateCallback& callback) { |
373 return scoped_ptr<BatteryStatusManager>( | 373 return scoped_ptr<BatteryStatusManager>( |
374 new BatteryStatusManagerLinux(callback)); | 374 new BatteryStatusManagerLinux(callback)); |
375 } | 375 } |
376 | 376 |
377 } // namespace device | 377 } // namespace device |
OLD | NEW |