Chromium Code Reviews| Index: content/browser/power_profiler/power_profiler_service.h |
| diff --git a/content/browser/power_profiler/power_profiler_service.h b/content/browser/power_profiler/power_profiler_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..47e842952df50845bb9ca6d850c6e8baf3bfb02e |
| --- /dev/null |
| +++ b/content/browser/power_profiler/power_profiler_service.h |
| @@ -0,0 +1,65 @@ |
| +// Copyright 2013 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_BROWSER_POWER_PROFILER_SERVICE_H_ |
| +#define CONTENT_BROWSER_POWER_PROFILER_SERVICE_H_ |
| + |
| +#include <set> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/timer/timer.h" |
| +#include "content/browser/power_profiler/power_profiler_helper.h" |
| +#include "content/browser/power_profiler/power_profiler_host.h" |
| + |
| +namespace content { |
| + |
| +// A class used to monitor the power usage and tell profiler the power data |
| +class PowerProfilerService { |
| + public: |
| + enum Status { |
| + UNINITIALIZED, // Unitialized, |
| + INITIALIZED, // Initialized, not in profiling |
| + PROFILING, // In profiling |
| + }; |
| + |
| + PowerProfilerService(); |
| + ~PowerProfilerService(); |
| + |
| + // Add and remove an observer. |
| + void AddObserver(PowerProfilerHost* observer); |
|
pfeldman
2014/01/09 11:38:58
AddObserver(PowerProfilerObserver*)?
|
| + void RemoveObserver(PowerProfilerHost* observer); |
| + void UpdateResolution(); |
| + |
| + void Snapshot(); |
| + double GetEnergy(PowerEvent::Type); |
| + |
| + static PowerProfilerService* Get(); |
| + Status status(); |
|
Pan
2014/01/18 04:30:37
I'm thinking, Public API of PowerProfilerService s
qsr
2014/01/20 09:16:55
Mostly yes. The only one I would ask about is stat
|
| + |
| + private: |
| + void Start(); |
| + void Stop(); |
| + void ProcessData(); |
| + void Notify(PowerEvent* buffer, int count); |
| + void InitializeDelays(); |
| + |
| + void ResetAccumulationEnergies(); |
| + void AccumulateEnergies(double* energies, int count); |
|
qsr
2014/01/17 11:50:14
All of those methods await an array of the same si
|
| + |
| + scoped_ptr<base::OneShotTimer<PowerProfilerService> > query_power_timer_; |
|
qsr
2014/01/17 11:50:14
Why is that a scoped_ptr, instead of an instance v
|
| + |
| + size_t delay_; // milliseconds |
| + size_t delays_[PowerProfilerHost::TYPE_COUNT]; // kinds of delays |
| + Status status_; |
| + double accumulated_enegries_[PowerProfilerHost::TYPE_COUNT]; |
| + std::set<PowerProfilerHost* > observers_; |
| + |
| + scoped_refptr<PowerProfilerHelper> profiler_helper_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PowerProfilerService); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_POWER_PROFILER_SERVICE_H_ |