[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / content / browser / power_profiler / power_profiler_service.h
blob4daae28f9075322da96fcfaeba00ad6f822a786c
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.
5 #ifndef CONTENT_BROWSER_POWER_PROFILER_POWER_PROFILER_SERVICE_H_
6 #define CONTENT_BROWSER_POWER_PROFILER_POWER_PROFILER_SERVICE_H_
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"
17 namespace content {
19 // A class used to query power information and notify the observers.
20 class CONTENT_EXPORT PowerProfilerService {
21 public:
22 static PowerProfilerService* GetInstance();
24 // Add and remove an observer.
25 void AddObserver(PowerProfilerObserver* observer);
26 void RemoveObserver(PowerProfilerObserver* observer);
28 bool IsAvailable() const;
29 std::string GetAccuracyLevel() const;
31 virtual ~PowerProfilerService();
33 private:
34 enum Status {
35 UNINITIALIZED,
36 INITIALIZED, // Initialized, profiling has not started.
37 PROFILING
40 friend struct DefaultSingletonTraits<PowerProfilerService>;
41 friend class PowerProfilerServiceTest;
43 PowerProfilerService();
45 PowerProfilerService(scoped_ptr<PowerDataProvider> provider,
46 scoped_refptr<base::TaskRunner> task_runner,
47 const base::TimeDelta& sample_period);
49 void Start();
50 void Stop();
52 // Query power data from PowerDataProvider, executes on the WorkerPool thread.
53 void QueryDataOnTaskRunner();
55 // Initiate the query on the UI thread, the task is delegated to
56 // QueryDataOnTaskRunner.
57 void QueryData();
59 // Executes on the UI thread.
60 void Notify(const PowerEventVector&);
62 base::RepeatingTimer<PowerProfilerService> query_power_timer_;
63 scoped_refptr<base::TaskRunner> task_runner_;
65 Status status_;
67 // Sampling period of power data measurement.
68 base::TimeDelta sample_period_;
69 ObserverList<PowerProfilerObserver> observers_;
71 scoped_ptr<PowerDataProvider> data_provider_;
73 DISALLOW_COPY_AND_ASSIGN(PowerProfilerService);
76 } // namespace content
78 #endif // CONTENT_BROWSER_POWER_PROFILER_POWER_PROFILER_SERVICE_H_