Index: chrome/browser/chromeos/power/cpu_data_collector.h |
diff --git a/chrome/browser/chromeos/power/cpu_data_collector.h b/chrome/browser/chromeos/power/cpu_data_collector.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..74f5322ad3d1f13150e838ed9a4320fcb06b6f09 |
--- /dev/null |
+++ b/chrome/browser/chromeos/power/cpu_data_collector.h |
@@ -0,0 +1,67 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_CHROMEOS_POWER_CPU_DATA_COLLECTOR_H_ |
+#define CHROME_BROWSER_CHROMEOS_POWER_CPU_DATA_COLLECTOR_H_ |
+ |
+#include <deque> |
+#include <string> |
+#include <vector> |
+ |
+#include "base/basictypes.h" |
+#include "base/timer/timer.h" |
+ |
+namespace chromeos { |
+ |
+class CpuDataCollector { |
+ public: |
+ struct IdleSample { |
+ base::Time time; |
+ std::map<std::string, double> state_occupancy_percent; |
+ }; |
+ |
+ struct FreqSample { |
+ base::Time time; |
+ std::map<int, double> freq_occupancy_percent; |
+ }; |
+ |
+ typedef std::deque<IdleSample> IdleSampleDeque; |
+ typedef std::deque<FreqSample> FreqSampleDeque; |
+ |
+ // 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
|
+ // occupancy percentage of each CPU in the system. The deque at index <i> |
+ // in the vector corresponds to CPU<i>. |
+ const std::vector<IdleSampleDeque>& cpu_idle_state_data() const { |
+ return cpu_idle_state_data_; |
+ } |
+ |
+ // Returns a vector whose elements correspond to a deque of frequency state |
+ // occupancy percentage of each CPU in the system. The deque at index <i> |
+ // in the vector corresponds to CPU<i>. |
+ const std::vector<FreqSampleDeque>& cpu_freq_state_data() const { |
+ return cpu_freq_state_data_; |
+ } |
+ |
+ CpuDataCollector(); |
+ |
+ void Start(); |
+ |
+ void Lock(); |
+ void Unlock(); |
+ |
+ private: |
+ void PostCollectSample(); |
+ |
+ void CollectSample(); |
+ |
+ base::RepeatingTimer<CpuDataCollector> timer_; |
+ std::vector<IdleSampleDeque> cpu_idle_state_data_; |
+ std::vector<FreqSampleDeque> cpu_freq_state_data_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CpuDataCollector); |
+}; |
+ |
+} // namespace chromeos |
+ |
+#endif // CHROME_BROWSER_CHROMEOS_POWER_CPU_DATA_COLLECTOR_H_ |