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_PROFILER_SERVICE_H_ | |
6 #define CONTENT_BROWSER_POWER_PROFILER_POWER_PROFILER_SERVICE_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/memory/singleton.h" | |
10 #include "base/observer_list.h" | |
11 #include "base/task_runner.h" | |
12 #include "base/timer/timer.h" | |
13 #include "content/browser/power_profiler/power_data_provider.h" | |
14 #include "content/browser/power_profiler/power_profiler_observer.h" | |
15 #include "content/common/content_export.h" | |
16 | |
17 namespace content { | |
18 | |
19 // a class used to monitor the power usage and tell profiler the power data. | |
20 class CONTENT_EXPORT PowerProfilerService { | |
21 public: | |
22 static PowerProfilerService* GetInstance(); | |
23 | |
24 // Add and remove an observer. | |
25 void AddObserver(PowerProfilerObserver* observer); | |
26 void RemoveObserver(PowerProfilerObserver* observer); | |
27 | |
28 bool IsAvailable(); | |
29 | |
30 private: | |
31 enum Status { | |
32 UNINITIALIZED, // Uninitialized. | |
33 INITIALIZED, // Initialized, not in profiling. | |
34 PROFILING, // In profiling. | |
35 }; | |
36 | |
37 friend struct DefaultSingletonTraits<PowerProfilerService>; | |
38 friend class PowerProfilerServiceTest; | |
39 | |
40 PowerProfilerService(); | |
41 virtual ~PowerProfilerService() {} | |
42 | |
43 explicit PowerProfilerService(scoped_ptr<PowerDataProvider> provider, | |
qsr
2014/02/13 16:40:13
explicit is only useful if the constructor has a s
Pan
2014/02/14 07:17:02
right, I forgot to remove it, thanks.
| |
44 scoped_refptr<base::TaskRunner> task_runner, | |
45 const base::TimeDelta& delay); | |
46 | |
47 void Start(); | |
48 void Stop(); | |
49 | |
50 void QueryDataOnTaskRunner(); | |
51 void QueryData(); | |
52 | |
53 // Notify works in UI thread. | |
54 void Notify(const PowerEventVector&); | |
55 | |
56 base::RepeatingTimer<PowerProfilerService> query_power_timer_; | |
57 scoped_refptr<base::TaskRunner> task_runner_; | |
58 | |
59 Status status_; | |
60 | |
61 // Interval of reading the power data by provider. | |
62 const base::TimeDelta delay_; | |
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_BROWSER_POWER_PROFILER_POWER_PROFILER_SERVICE_H_ | |
OLD | NEW |