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/task_runner.h" | |
13 #include "base/timer/timer.h" | |
14 #include "content/common/content_export.h" | |
15 #include "content/public/browser/power_data_provider.h" | |
16 #include "content/public/browser/power_profiler_observer.h" | |
17 | |
18 namespace content { | |
19 | |
20 // A class used to monitor the power usage and tell profiler the power data | |
21 class CONTENT_EXPORT PowerProfilerService { | |
22 public: | |
23 static PowerProfilerService* GetInstance(); | |
24 | |
25 // Add and remove an observer. | |
26 void AddObserver(PowerProfilerObserver* observer); | |
27 void RemoveObserver(PowerProfilerObserver* observer); | |
28 void UpdateResolution(); | |
29 | |
30 bool IsAvailable() { return status_ != UNINITIALIZED; } | |
qsr
2014/01/22 15:30:01
This is not a simple getter, so should not be inli
| |
31 | |
32 private: | |
33 enum Status { | |
34 UNINITIALIZED, // Unitialized, | |
35 INITIALIZED, // Initialized, not in profiling | |
36 PROFILING, // In profiling | |
37 }; | |
38 | |
39 friend struct DefaultSingletonTraits<PowerProfilerService>; | |
40 | |
41 PowerProfilerService(); | |
42 virtual ~PowerProfilerService(); | |
43 | |
44 void Start(); | |
45 void Stop(); | |
46 | |
47 void OnTimer(); | |
48 void InitializeDelays(); | |
49 | |
50 // ProcessData and Notify are delegated to thread in WorkerPool | |
51 void ProcessData(); | |
52 void Notify(PowerEvent* event); | |
53 | |
54 base::RepeatingTimer<PowerProfilerService> query_power_timer_; | |
55 scoped_refptr<base::TaskRunner> task_runner_; | |
56 | |
57 size_t delay_; // milliseconds | |
qsr
2014/01/22 15:30:01
Use directly a base::TimeTicks
| |
58 size_t delays_[PowerProfilerObserver::TYPE_COUNT]; // kinds of delays | |
qsr
2014/01/22 15:30:01
Same here.
| |
59 Status status_; | |
60 std::set<PowerProfilerObserver* > observers_; | |
qsr
2014/01/22 15:30:01
Use base/observer_list.h
| |
61 | |
62 scoped_ptr<PowerDataProvider> data_provider_; | |
63 | |
64 DISALLOW_COPY_AND_ASSIGN(PowerProfilerService); | |
65 }; | |
66 | |
67 } // namespace content | |
68 | |
69 #endif // CONTENT_PUBLIC_BROWSER_POWER_PROFILER_SERVICE_H_ | |
OLD | NEW |