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_BROWSER_POWER_PROFILER_POWER_DATA_PROVIDER_H_ |
| 6 #define CONTENT_BROWSER_POWER_PROFILER_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 struct PowerEvent { |
| 15 enum Type { |
| 16 // Total power of SoC. including CPU, GT and others on the chip, |
| 17 // modules out of SoC such as screen is not included. |
| 18 SOC_PACKAGE, |
| 19 |
| 20 // Count the number of known PowerEvent. |
| 21 ID_COUNT |
| 22 }; |
| 23 |
| 24 Type type; |
| 25 |
| 26 base::TimeTicks time; // Time that power data was read. |
| 27 |
| 28 // Power value between last event to this one, in watt. |
| 29 // E.g, event1 {t1, v1}; event2 {t2, v2}; event3 {t3, v3}. |
| 30 // Suppose event1 is the first event observer received, then event2, event3. |
| 31 // Then v2 is average power from t1 to t2, v3 is the average power from t2 to |
| 32 // t3. v1 should be ignored since event1 only means the start point of power |
| 33 // profiling. |
| 34 double value; |
| 35 }; |
| 36 |
| 37 // a class used to GET power usage. |
| 38 class PowerDataProvider { |
| 39 public: |
| 40 PowerDataProvider() {} |
| 41 virtual ~PowerDataProvider() {} |
| 42 |
| 43 // Return true when success, it fills a single PowerEvent, which should be |
| 44 // allocated by its caller. |
| 45 virtual bool GetData(PowerEvent*) = 0; |
| 46 |
| 47 private: |
| 48 DISALLOW_COPY_AND_ASSIGN(PowerDataProvider); |
| 49 }; |
| 50 |
| 51 class PowerDataProviderFactory { |
| 52 public: |
| 53 // Create a provider, and transfer the ownership to PowerProfilerService. |
| 54 static scoped_ptr<PowerDataProvider> Create(); |
| 55 |
| 56 private: |
| 57 PowerDataProviderFactory() {} |
| 58 DISALLOW_COPY_AND_ASSIGN(PowerDataProviderFactory); |
| 59 }; |
| 60 |
| 61 } // namespace content |
| 62 |
| 63 #endif // CONTENT_BROWSER_POWER_PROFILER_POWER_DATA_PROVIDER_H_ |
OLD | NEW |