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

Side by Side Diff: chromeos/power/power_data_collector.h

Issue 101963004: [chromeos] New PowerManagerClient observer to collect power data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/power/power_data_collector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROMEOS_POWER_POWER_DATA_COLLECTOR_H_
6 #define CHROMEOS_POWER_POWER_DATA_COLLECTOR_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/time/time.h"
13 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/power_manager_client.h"
15
16 namespace power_manager {
17 class PowerSupplyProperties;
18 }
19
20 namespace chromeos {
21
22 // A class which starts collecting power metrics, like the battery charge, as
23 // soon as it is initialized via Initialize().
24 //
25 // This class is implemented as a global singleton, initialized after
26 // DBusThreadManager which it depends on.
27 class CHROMEOS_EXPORT PowerDataCollector : public PowerManagerClient::Observer {
28 public:
29 struct PowerSupplySnapshot {
30 PowerSupplySnapshot();
31
32 // Time when the snapshot was captured.
33 base::TimeTicks time;
34
35 // True if connected to external power at the time of the snapshot.
36 bool external_power;
37
38 // The battery charge as a percentage of full charge in range [0.0, 100.00].
39 double battery_percent;
40 };
41
42 const std::vector<PowerSupplySnapshot>& power_supply_data() const {
43 return power_supply_data_;
44 }
45
46 // Can be called only after DBusThreadManager is initialized.
47 static void Initialize();
48
49 // Can be called only if initialized via Initialize, and before
50 // DBusThreadManager is destroyed.
51 static void Shutdown();
52
53 // Returns the global instance of PowerDataCollector.
54 static PowerDataCollector* Get();
55
56 // PowerManagerClient::Observer implementation:
57 virtual void PowerChanged(
58 const power_manager::PowerSupplyProperties& prop) OVERRIDE;
59
60 private:
61 PowerDataCollector();
62
63 virtual ~PowerDataCollector();
64
65 std::vector<PowerSupplySnapshot> power_supply_data_;
66
67 DISALLOW_COPY_AND_ASSIGN(PowerDataCollector);
68 };
69
70 } // namespace chromeos
71
72 #endif // CHROMEOS_POWER_POWER_DATA_COLLECTOR_H_
OLDNEW
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/power/power_data_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698