Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 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 CONTENT_BROWSER_POWER_PROFILER_SERVICE_H_ | |
| 6 #define CONTENT_BROWSER_POWER_PROFILER_SERVICE_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/timer/timer.h" | |
| 12 #include "content/browser/power_profiler/power_profiler_helper.h" | |
| 13 #include "content/browser/power_profiler/power_profiler_host.h" | |
| 14 | |
| 15 namespace content { | |
| 16 | |
| 17 // A class used to monitor the power usage and tell profiler the power data | |
| 18 class PowerProfilerService { | |
| 19 public: | |
| 20 enum Status { | |
| 21 UNINITIALIZED, // Unitialized, | |
| 22 INITIALIZED, // Initialized, not in profiling | |
| 23 PROFILING, // In profiling | |
| 24 }; | |
| 25 | |
| 26 PowerProfilerService(); | |
| 27 ~PowerProfilerService(); | |
| 28 | |
| 29 // Add and remove an observer. | |
| 30 void AddObserver(PowerProfilerHost* observer); | |
|
pfeldman
2014/01/09 11:38:58
AddObserver(PowerProfilerObserver*)?
| |
| 31 void RemoveObserver(PowerProfilerHost* observer); | |
| 32 void UpdateResolution(); | |
| 33 | |
| 34 void Snapshot(); | |
| 35 double GetEnergy(PowerEvent::Type); | |
| 36 | |
| 37 static PowerProfilerService* Get(); | |
| 38 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
| |
| 39 | |
| 40 private: | |
| 41 void Start(); | |
| 42 void Stop(); | |
| 43 void ProcessData(); | |
| 44 void Notify(PowerEvent* buffer, int count); | |
| 45 void InitializeDelays(); | |
| 46 | |
| 47 void ResetAccumulationEnergies(); | |
| 48 void AccumulateEnergies(double* energies, int count); | |
|
qsr
2014/01/17 11:50:14
All of those methods await an array of the same si
| |
| 49 | |
| 50 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
| |
| 51 | |
| 52 size_t delay_; // milliseconds | |
| 53 size_t delays_[PowerProfilerHost::TYPE_COUNT]; // kinds of delays | |
| 54 Status status_; | |
| 55 double accumulated_enegries_[PowerProfilerHost::TYPE_COUNT]; | |
| 56 std::set<PowerProfilerHost* > observers_; | |
| 57 | |
| 58 scoped_refptr<PowerProfilerHelper> profiler_helper_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(PowerProfilerService); | |
| 61 }; | |
| 62 | |
| 63 } // namespace content | |
| 64 | |
| 65 #endif // CONTENT_BROWSER_POWER_PROFILER_SERVICE_H_ | |
| OLD | NEW |