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

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: address stevenjb's nits 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
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/gtest_prod_util.h"
13 #include "base/time/time.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 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 private:
57 friend class PowerDataCollectorTest;
58 FRIEND_TEST_ALL_PREFIXES(PowerDataCollectorTest, PowerChanged);
59
60 PowerDataCollector();
61
62 virtual ~PowerDataCollector();
63
64 // PowerManagerClient::Observer implementation:
65 virtual void PowerChanged(
Daniel Erat 2013/12/13 23:57:09 if you make this public, then you can get rid of t
Siva Chandra 2013/12/14 00:35:50 Yes. But are you telling me to remove? I felt it
Daniel Erat 2013/12/14 01:00:30 your call. in general, i've seen FRIEND_TEST_ALL_P
66 const power_manager::PowerSupplyProperties& prop) OVERRIDE;
67
68 private:
Daniel Erat 2013/12/13 23:57:09 remove this extra 'private' label
Siva Chandra 2013/12/14 00:35:50 Done.
69 std::vector<PowerSupplySnapshot> power_supply_data_;
70
71 DISALLOW_COPY_AND_ASSIGN(PowerDataCollector);
72 };
73
74 } // namespace chromeos
75
76 #endif // CHROMEOS_POWER_POWER_DATA_COLLECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698