OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_PUBLIC_BROWSER_POWER_DATA_PROVIDER_H_ | |
6 #define CONTENT_PUBLIC_BROWSER_POWER_DATA_PROVIDER_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/time/time.h" | |
11 | |
12 namespace content { | |
13 | |
14 // PowerEvent here is the total power of SoC, including CPU, GPU and others | |
15 // on the chip, modules out of SoC such as screen is not included. | |
16 struct PowerEvent { | |
jeremy
2014/01/28 19:45:43
So this API only provides power usage for the SoC
Pan
2014/01/29 00:29:22
@jeremy, you are welcome, this CL is a start, GPU
| |
17 base::TimeTicks time; // Time that power data was read. | |
18 | |
19 // Power value between last event to this one, in watt. | |
20 // E.g, event1 {t1, v1}; event2 {t2, v2}; event3 {t3, v3}. | |
21 // Suppose event1 is the first event observer received, then event2, event3. | |
22 // Then v2 is average power from t1 to t2, v3 is the average power from t2 to | |
23 // t3. v1 should be ignored since event1 only means the start point of power | |
24 // profiling. | |
jeremy
2014/01/28 19:45:43
Does the hardware measure cumulative power usage o
Pan
2014/01/29 00:29:22
it is a 32bit MSR on hardware, register updated pe
| |
25 double value; | |
26 }; | |
27 | |
28 // a class used to GET power usage. | |
29 class PowerDataProvider { | |
30 public: | |
31 PowerDataProvider() {} | |
32 virtual ~PowerDataProvider() {} | |
33 | |
34 // Return true when success, it fills a single PowerEvent, which should be | |
35 // allocated by its caller. | |
36 virtual bool GetData(PowerEvent*) = 0; | |
37 | |
38 private: | |
39 DISALLOW_COPY_AND_ASSIGN(PowerDataProvider); | |
40 }; | |
41 | |
42 class PowerDataProviderFactory { | |
43 public: | |
44 // Create a provider, and transfer the ownership to PowerProfilerService. | |
45 static scoped_ptr<PowerDataProvider> Create(); | |
46 | |
47 private: | |
48 PowerDataProviderFactory() {} | |
49 DISALLOW_COPY_AND_ASSIGN(PowerDataProviderFactory); | |
50 }; | |
51 | |
52 } // namespace content | |
53 | |
54 #endif // CONTENT_PUBLIC_BROWSER_POWER_DATA_PROVIDER_H_ | |
OLD | NEW |