Chromium Code Reviews| Index: content/public/browser/power_data_provider.h |
| diff --git a/content/public/browser/power_data_provider.h b/content/public/browser/power_data_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..eb1ccdf5c0684ad4d827801ab71f7c597bfcdb3a |
| --- /dev/null |
| +++ b/content/public/browser/power_data_provider.h |
| @@ -0,0 +1,54 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_PUBLIC_BROWSER_POWER_DATA_PROVIDER_H_ |
| +#define CONTENT_PUBLIC_BROWSER_POWER_DATA_PROVIDER_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/time/time.h" |
| + |
| +namespace content { |
| + |
| +// PowerEvent here is the total power of SoC, including CPU, GPU and others |
| +// on the chip, modules out of SoC such as screen is not included. |
| +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
|
| + base::TimeTicks time; // Time that power data was read. |
| + |
| + // Power value between last event to this one, in watt. |
| + // E.g, event1 {t1, v1}; event2 {t2, v2}; event3 {t3, v3}. |
| + // Suppose event1 is the first event observer received, then event2, event3. |
| + // Then v2 is average power from t1 to t2, v3 is the average power from t2 to |
| + // t3. v1 should be ignored since event1 only means the start point of power |
| + // 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
|
| + double value; |
| +}; |
| + |
| +// a class used to GET power usage. |
| +class PowerDataProvider { |
| + public: |
| + PowerDataProvider() {} |
| + virtual ~PowerDataProvider() {} |
| + |
| + // Return true when success, it fills a single PowerEvent, which should be |
| + // allocated by its caller. |
| + virtual bool GetData(PowerEvent*) = 0; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(PowerDataProvider); |
| +}; |
| + |
| +class PowerDataProviderFactory { |
| + public: |
| + // Create a provider, and transfer the ownership to PowerProfilerService. |
| + static scoped_ptr<PowerDataProvider> Create(); |
| + |
| + private: |
| + PowerDataProviderFactory() {} |
| + DISALLOW_COPY_AND_ASSIGN(PowerDataProviderFactory); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_PUBLIC_BROWSER_POWER_DATA_PROVIDER_H_ |