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 CHROME_BROWSER_CHROMEOS_POWER_CPU_DATA_COLLECTOR_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_POWER_CPU_DATA_COLLECTOR_H_ | |
7 | |
8 #include <deque> | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/basictypes.h" | |
13 #include "base/timer/timer.h" | |
14 | |
15 namespace chromeos { | |
16 | |
17 class CpuDataCollector { | |
18 public: | |
19 struct IdleSample { | |
20 base::Time time; | |
21 std::map<std::string, double> state_occupancy_percent; | |
22 }; | |
23 | |
24 struct FreqSample { | |
25 base::Time time; | |
26 std::map<int, double> freq_occupancy_percent; | |
27 }; | |
28 | |
29 typedef std::deque<IdleSample> IdleSampleDeque; | |
30 typedef std::deque<FreqSample> FreqSampleDeque; | |
31 | |
32 // Returns a vector whose elements correspond to a deque of idle state | |
Daniel Erat
2014/01/30 15:47:51
nit: move these descriptions down to the point whe
| |
33 // occupancy percentage of each CPU in the system. The deque at index <i> | |
34 // in the vector corresponds to CPU<i>. | |
35 const std::vector<IdleSampleDeque>& cpu_idle_state_data() const { | |
36 return cpu_idle_state_data_; | |
37 } | |
38 | |
39 // Returns a vector whose elements correspond to a deque of frequency state | |
40 // occupancy percentage of each CPU in the system. The deque at index <i> | |
41 // in the vector corresponds to CPU<i>. | |
42 const std::vector<FreqSampleDeque>& cpu_freq_state_data() const { | |
43 return cpu_freq_state_data_; | |
44 } | |
45 | |
46 CpuDataCollector(); | |
47 | |
48 void Start(); | |
49 | |
50 void Lock(); | |
51 void Unlock(); | |
52 | |
53 private: | |
54 void PostCollectSample(); | |
55 | |
56 void CollectSample(); | |
57 | |
58 base::RepeatingTimer<CpuDataCollector> timer_; | |
59 std::vector<IdleSampleDeque> cpu_idle_state_data_; | |
60 std::vector<FreqSampleDeque> cpu_freq_state_data_; | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(CpuDataCollector); | |
63 }; | |
64 | |
65 } // namespace chromeos | |
66 | |
67 #endif // CHROME_BROWSER_CHROMEOS_POWER_CPU_DATA_COLLECTOR_H_ | |
OLD | NEW |