Index: content/public/browser/power_profiler_service.h |
diff --git a/content/public/browser/power_profiler_service.h b/content/public/browser/power_profiler_service.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e920b1677898861dc6c4daf4a0173cdd6ec14406 |
--- /dev/null |
+++ b/content/public/browser/power_profiler_service.h |
@@ -0,0 +1,72 @@ |
+// 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 CONTENT_PUBLIC_BROWSER_POWER_PROFILER_SERVICE_H_ |
+#define CONTENT_PUBLIC_BROWSER_POWER_PROFILER_SERVICE_H_ |
+ |
+#include <set> |
+ |
+#include "base/basictypes.h" |
+#include "base/memory/singleton.h" |
+#include "base/observer_list.h" |
+#include "base/task_runner.h" |
+#include "base/timer/timer.h" |
+#include "content/common/content_export.h" |
+#include "content/public/browser/power_data_provider.h" |
+#include "content/public/browser/power_profiler_observer.h" |
+ |
+namespace content { |
+ |
+// a class used to monitor the power usage and tell profiler the power data. |
+class CONTENT_EXPORT PowerProfilerService { |
+ public: |
+ static PowerProfilerService* GetInstance(); |
+ |
+ // Add and remove an observer. |
+ bool AddObserver(PowerProfilerObserver* observer); |
+ void RemoveObserver(PowerProfilerObserver* observer); |
+ 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
|
+ |
+ bool IsAvailable(); |
+ |
+ private: |
+ enum Status { |
+ UNINITIALIZED, // Unitialized. |
+ INITIALIZED, // Initialized, not in profiling. |
+ PROFILING, // In profiling. |
+ }; |
+ |
+ friend struct DefaultSingletonTraits<PowerProfilerService>; |
+ |
+ 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
|
+ virtual ~PowerProfilerService() {} |
+ |
+ void Start(); |
+ void Stop(); |
+ |
+ void OnTimer(); |
+ void InitializeDelays(); |
+ |
+ // ProcessData is delegated to thread in WorkerPool. |
+ void ProcessData(); |
+ |
+ // Notify works in UI thread. |
+ void Notify(const PowerEvent&); |
+ |
+ base::RepeatingTimer<PowerProfilerService> query_power_timer_; |
+ scoped_refptr<base::TaskRunner> task_runner_; |
+ |
+ base::TimeDelta delay_; |
+ base::TimeDelta delays_[PowerProfilerObserver::TYPE_COUNT]; // kinds of delay. |
+ Status status_; |
+ ObserverList<PowerProfilerObserver> observers_; |
+ |
+ scoped_ptr<PowerDataProvider> data_provider_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PowerProfilerService); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_PUBLIC_BROWSER_POWER_PROFILER_SERVICE_H_ |