Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Side by Side Diff: content/browser/power_profiler/power_profiler_service.h

Issue 140583003: Chrome power profiler service (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Move complex destructor impl to .cc Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_BROWSER_POWER_PROFILER_POWER_PROFILER_SERVICE_H_
6 #define CONTENT_BROWSER_POWER_PROFILER_POWER_PROFILER_SERVICE_H_
7
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"
16
17 namespace content {
18
19 // A class used to query power information and notify the observers.
20 class CONTENT_EXPORT PowerProfilerService {
21 public:
22 static PowerProfilerService* GetInstance();
23
24 // Add and remove an observer.
25 void AddObserver(PowerProfilerObserver* observer);
26 void RemoveObserver(PowerProfilerObserver* observer);
27
28 bool IsAvailable();
29
30 private:
31 enum Status {
32 UNINITIALIZED, // Uninitialized.
jeremy 2014/02/17 06:31:13 comment is redundant.
Pan 2014/02/17 07:53:37 Done.
33 INITIALIZED, // Initialized, not in profiling.
jeremy 2014/02/17 06:31:13 not in profiling -> profiling has not started.
Pan 2014/02/17 07:53:37 Done.
34 PROFILING, // In profiling.
jeremy 2014/02/17 06:31:13 I think you can remove this comment.
Pan 2014/02/17 07:53:37 Done.
35 };
36
37 friend struct DefaultSingletonTraits<PowerProfilerService>;
38 friend class PowerProfilerServiceTest;
39
40 PowerProfilerService();
41 virtual ~PowerProfilerService();
42
43 PowerProfilerService(scoped_ptr<PowerDataProvider> provider,
44 scoped_refptr<base::TaskRunner> task_runner,
45 const base::TimeDelta& delay);
46
47 void Start();
48 void Stop();
49
50 // Query power data by PowerDataProvider, executes on the WorkerPool thread.
jeremy 2014/02/17 06:31:13 by -> from
Pan 2014/02/17 07:53:37 Done.
51 void QueryDataOnTaskRunner();
52
53 // Initiate the query on the UI thread, the task is delegated to
54 // QueryDataOnTaskRunner.
55 void QueryData();
56
57 // Notify executes on the UI thread.
jeremy 2014/02/17 06:31:13 Notify executes -> Executes
Pan 2014/02/17 07:53:37 Done.
58 void Notify(const PowerEventVector&);
59
60 base::RepeatingTimer<PowerProfilerService> query_power_timer_;
61 scoped_refptr<base::TaskRunner> task_runner_;
62
63 Status status_;
64
65 // Interval of reading the power data by provider.
jeremy 2014/02/17 06:31:13 // Sampling period of power data measurement.
Pan 2014/02/17 07:53:37 Done.
66 const base::TimeDelta sample_period_;
67 ObserverList<PowerProfilerObserver> observers_;
68
69 scoped_ptr<PowerDataProvider> data_provider_;
70
71 DISALLOW_COPY_AND_ASSIGN(PowerProfilerService);
72 };
73
74 } // namespace content
75
76 #endif // CONTENT_BROWSER_POWER_PROFILER_POWER_PROFILER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698