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

Side by Side Diff: chrome/browser/chromeos/dbus/power_manager_client.cc

Issue 9837075: Move power_supply_status.* from src/ash to src/chromeos (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 8 years, 8 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
« no previous file with comments | « chrome/browser/chromeos/dbus/power_manager_client.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/chromeos/dbus/power_manager_client.h" 5 #include "chrome/browser/chromeos/dbus/power_manager_client.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/format_macros.h" 11 #include "base/format_macros.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
15 #include "base/time.h" 15 #include "base/time.h"
16 #include "base/timer.h" 16 #include "base/timer.h"
17 #include "chrome/browser/chromeos/dbus/power_supply_properties.pb.h" 17 #include "chrome/browser/chromeos/dbus/power_supply_properties.pb.h"
18 #include "chrome/browser/chromeos/dbus/power_state_control.pb.h" 18 #include "chrome/browser/chromeos/dbus/power_state_control.pb.h"
19 #include "dbus/bus.h" 19 #include "dbus/bus.h"
20 #include "dbus/message.h" 20 #include "dbus/message.h"
21 #include "dbus/object_path.h" 21 #include "dbus/object_path.h"
22 #include "dbus/object_proxy.h" 22 #include "dbus/object_proxy.h"
23 #include "third_party/cros_system_api/dbus/service_constants.h" 23 #include "third_party/cros_system_api/dbus/service_constants.h"
24 24
25 namespace chromeos { 25 namespace chromeos {
26 26
27 #if !defined(USE_ASH)
28 PowerSupplyStatus::PowerSupplyStatus()
29 : line_power_on(false),
30 battery_is_present(false),
31 battery_is_full(false),
32 battery_seconds_to_empty(0),
33 battery_seconds_to_full(0),
34 battery_percentage(0) {
35 }
36
37 std::string PowerSupplyStatus::ToString() const {
38 std::string result;
39 base::StringAppendF(&result,
40 "line_power_on = %s ",
41 line_power_on ? "true" : "false");
42 base::StringAppendF(&result,
43 "battery_is_present = %s ",
44 battery_is_present ? "true" : "false");
45 base::StringAppendF(&result,
46 "battery_is_full = %s ",
47 battery_is_full ? "true" : "false");
48 base::StringAppendF(&result,
49 "battery_percentage = %f ",
50 battery_percentage);
51 base::StringAppendF(&result,
52 "battery_seconds_to_empty = %"PRId64" ",
53 battery_seconds_to_empty);
54 base::StringAppendF(&result,
55 "battery_seconds_to_full = %"PRId64" ",
56 battery_seconds_to_full);
57 return result;
58 }
59 #endif // !defined(USE_ASH)
60
61 // The PowerManagerClient implementation used in production. 27 // The PowerManagerClient implementation used in production.
62 class PowerManagerClientImpl : public PowerManagerClient { 28 class PowerManagerClientImpl : public PowerManagerClient {
63 public: 29 public:
64 explicit PowerManagerClientImpl(dbus::Bus* bus) 30 explicit PowerManagerClientImpl(dbus::Bus* bus)
65 : power_manager_proxy_(NULL), 31 : power_manager_proxy_(NULL),
66 weak_ptr_factory_(this) { 32 weak_ptr_factory_(this) {
67 power_manager_proxy_ = bus->GetObjectProxy( 33 power_manager_proxy_ = bus->GetObjectProxy(
68 power_manager::kPowerManagerServiceName, 34 power_manager::kPowerManagerServiceName,
69 dbus::ObjectPath(power_manager::kPowerManagerServicePath)); 35 dbus::ObjectPath(power_manager::kPowerManagerServicePath));
70 36
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 PowerManagerClient* PowerManagerClient::Create( 607 PowerManagerClient* PowerManagerClient::Create(
642 DBusClientImplementationType type, 608 DBusClientImplementationType type,
643 dbus::Bus* bus) { 609 dbus::Bus* bus) {
644 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 610 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
645 return new PowerManagerClientImpl(bus); 611 return new PowerManagerClientImpl(bus);
646 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 612 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
647 return new PowerManagerClientStubImpl(); 613 return new PowerManagerClientStubImpl();
648 } 614 }
649 615
650 } // namespace chromeos 616 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/dbus/power_manager_client.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698