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

Side by Side Diff: chrome/browser/chromeos/cros/power_library.h

Issue 8271024: chromeos: Add power supply info reading capability (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased after refactoring Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_CHROMEOS_CROS_POWER_LIBRARY_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_POWER_LIBRARY_H_
6 #define CHROME_BROWSER_CHROMEOS_CROS_POWER_LIBRARY_H_ 6 #define CHROME_BROWSER_CHROMEOS_CROS_POWER_LIBRARY_H_
7 #pragma once 7 #pragma once
8 8
9 // TODO(sque): Move to chrome/browser/chromeos/system, crosbug.com/16558 9 // TODO(sque): Move to chrome/browser/chromeos/system, crosbug.com/16558
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "chrome/browser/chromeos/dbus/power_manager_client.h"
12 13
13 namespace base { 14 namespace base {
14 class TimeDelta; 15 class TimeDelta;
15 } 16 }
16 17
17 namespace chromeos { 18 namespace chromeos {
18 19
19 typedef base::Callback<void(int64_t)> CalculateIdleTimeCallback; 20 typedef base::Callback<void(int64_t)> CalculateIdleTimeCallback;
21 struct PowerStatus;
20 22
21 struct PowerSupplyStatus { 23 struct PowerSupplyStatus {
22 bool line_power_on; 24 bool line_power_on;
23 25
24 bool battery_is_present; 26 bool battery_is_present;
25 bool battery_is_full; 27 bool battery_is_full;
26 28
27 // Time in seconds until the battery is empty or full, 0 for unknown. 29 // Time in seconds until the battery is empty or full, 0 for unknown.
28 int64 battery_seconds_to_empty; 30 int64 battery_seconds_to_empty;
29 int64 battery_seconds_to_full; 31 int64 battery_seconds_to_full;
30 32
31 double battery_percentage; 33 double battery_percentage;
32 34
33 PowerSupplyStatus() : line_power_on(false), 35 PowerSupplyStatus() : line_power_on(false),
34 battery_is_present(false), 36 battery_is_present(false),
35 battery_is_full(false), 37 battery_is_full(false),
36 battery_seconds_to_empty(0), 38 battery_seconds_to_empty(0),
37 battery_seconds_to_full(0), 39 battery_seconds_to_full(0),
38 battery_percentage(0) {} 40 battery_percentage(0) {}
41
42 const std::string& ToString() const;
39 }; 43 };
40 44
41 // This interface defines interaction with the ChromeOS power library APIs. 45 // This interface defines interaction with the ChromeOS power library APIs.
42 // Classes can add themselves as observers. Users can get an instance of this 46 // Classes can add themselves as observers. Users can get an instance of this
43 // library class like this: chromeos::CrosLibrary::Get()->GetPowerLibrary() 47 // library class like this: chromeos::CrosLibrary::Get()->GetPowerLibrary()
44 class PowerLibrary { 48 class PowerLibrary : public PowerManagerClient::Observer {
45 public: 49 public:
46 class Observer { 50 class Observer {
47 public: 51 public:
48 virtual void PowerChanged(const PowerSupplyStatus& status) = 0; 52 virtual void PowerChanged(const PowerSupplyStatus& status) = 0;
49 virtual void SystemResumed() = 0; 53 virtual void SystemResumed() = 0;
50 54
51 protected: 55 protected:
52 virtual ~Observer() {} 56 virtual ~Observer() {}
53 }; 57 };
54 58
(...skipping 13 matching lines...) Expand all
68 72
69 // Requests restart of the system. 73 // Requests restart of the system.
70 virtual void RequestRestart() = 0; 74 virtual void RequestRestart() = 0;
71 75
72 // Requests shutdown of the system. 76 // Requests shutdown of the system.
73 virtual void RequestShutdown() = 0; 77 virtual void RequestShutdown() = 0;
74 78
75 // UI initiated request for status update. 79 // UI initiated request for status update.
76 virtual void RequestStatusUpdate() = 0; 80 virtual void RequestStatusUpdate() = 0;
77 81
82 // Requests power supply info.
83 virtual void UpdatePowerStatus(const PowerStatus& status) = 0;
84
85
78 // Factory function, creates a new instance and returns ownership. 86 // Factory function, creates a new instance and returns ownership.
79 // For normal usage, access the singleton via CrosLibrary::Get(). 87 // For normal usage, access the singleton via CrosLibrary::Get().
80 static PowerLibrary* GetImpl(bool stub); 88 static PowerLibrary* GetImpl(bool stub);
81 }; 89 };
82 90
83 } // namespace chromeos 91 } // namespace chromeos
84 92
85 #endif // CHROME_BROWSER_CHROMEOS_CROS_POWER_LIBRARY_H_ 93 #endif // CHROME_BROWSER_CHROMEOS_CROS_POWER_LIBRARY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698