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_PROFILER_SERVICE_H_ | |
6 #define CONTENT_PUBLIC_BROWSER_POWER_PROFILER_SERVICE_H_ | |
7 | |
8 #include <set> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/memory/singleton.h" | |
12 #include "base/observer_list.h" | |
13 #include "base/task_runner.h" | |
14 #include "base/timer/timer.h" | |
15 #include "content/common/content_export.h" | |
16 #include "content/public/browser/power_data_provider.h" | |
17 #include "content/public/browser/power_profiler_observer.h" | |
18 | |
19 namespace content { | |
20 | |
21 // a class used to monitor the power usage and tell profiler the power data. | |
22 class CONTENT_EXPORT PowerProfilerService { | |
23 public: | |
24 static PowerProfilerService* GetInstance(); | |
25 | |
26 // Add and remove an observer. | |
27 bool AddObserver(PowerProfilerObserver* observer); | |
28 void RemoveObserver(PowerProfilerObserver* observer); | |
29 void UpdateResolution(); | |
qsr
2014/01/23 12:50:06
Why is this method public? My guess is that it is
Pan
2014/01/25 09:35:53
right, done
| |
30 | |
31 bool IsAvailable(); | |
32 | |
33 private: | |
34 enum Status { | |
35 UNINITIALIZED, // Unitialized. | |
36 INITIALIZED, // Initialized, not in profiling. | |
37 PROFILING, // In profiling. | |
38 }; | |
39 | |
40 friend struct DefaultSingletonTraits<PowerProfilerService>; | |
41 | |
42 PowerProfilerService(); | |
qsr
2014/01/23 12:50:06
You probably want a second constructor that takes
Pan
2014/01/25 09:35:53
thanks for your help, unit test is prepared, pleas
| |
43 virtual ~PowerProfilerService() {} | |
44 | |
45 void Start(); | |
46 void Stop(); | |
47 | |
48 void OnTimer(); | |
49 void InitializeDelays(); | |
50 | |
51 // ProcessData is delegated to thread in WorkerPool. | |
52 void ProcessData(); | |
53 | |
54 // Notify works in UI thread. | |
55 void Notify(const PowerEvent&); | |
56 | |
57 base::RepeatingTimer<PowerProfilerService> query_power_timer_; | |
58 scoped_refptr<base::TaskRunner> task_runner_; | |
59 | |
60 base::TimeDelta delay_; | |
61 base::TimeDelta delays_[PowerProfilerObserver::TYPE_COUNT]; // kinds of delay. | |
62 Status status_; | |
63 ObserverList<PowerProfilerObserver> observers_; | |
64 | |
65 scoped_ptr<PowerDataProvider> data_provider_; | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(PowerProfilerService); | |
68 }; | |
69 | |
70 } // namespace content | |
71 | |
72 #endif // CONTENT_PUBLIC_BROWSER_POWER_PROFILER_SERVICE_H_ | |
OLD | NEW |