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

Side by Side Diff: base/system_monitor.h

Issue 164424: Simple cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/system_monitor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_SYSTEM_MONITOR_H_ 5 #ifndef BASE_SYSTEM_MONITOR_H_
6 #define BASE_SYSTEM_MONITOR_H_ 6 #define BASE_SYSTEM_MONITOR_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 // Windows HiRes timers drain the battery faster so we need to know the battery 10 // Windows HiRes timers drain the battery faster so we need to know the battery
11 // status. This isn't true for other platforms. 11 // status. This isn't true for other platforms.
12 #if defined(OS_WIN) 12 #if defined(OS_WIN)
13 #define ENABLE_BATTERY_MONITORING 1 13 #define ENABLE_BATTERY_MONITORING 1
14 #else 14 #else
15 #undef ENABLE_BATTERY_MONITORING 15 #undef ENABLE_BATTERY_MONITORING
16 #endif // !OS_WIN 16 #endif // !OS_WIN
17 17
18 #include "base/observer_list_threadsafe.h" 18 #include "base/observer_list_threadsafe.h"
19 #include "base/singleton.h"
20 #if defined(ENABLE_BATTERY_MONITORING) 19 #if defined(ENABLE_BATTERY_MONITORING)
21 #include "base/timer.h" 20 #include "base/timer.h"
22 #endif // defined(ENABLE_BATTERY_MONITORING) 21 #endif // defined(ENABLE_BATTERY_MONITORING)
23 22
24 namespace base { 23 namespace base {
25 24
26 // Class for monitoring various system-related subsystems 25 // Class for monitoring various system-related subsystems
27 // such as power management, network status, etc. 26 // such as power management, network status, etc.
28 // TODO(mbelshe): Add support beyond just power management. 27 // TODO(mbelshe): Add support beyond just power management.
29 class SystemMonitor { 28 class SystemMonitor {
30 public: 29 public:
31 // Access to the Singleton 30 // Retrieves the Singleton.
32 static SystemMonitor* Get() { 31 static SystemMonitor* Get();
33 // Uses the LeakySingletonTrait because cleanup is optional.
34 return
35 Singleton<SystemMonitor, LeakySingletonTraits<SystemMonitor> >::get();
36 }
37 32
38 // Start the System Monitor within a process. This method 33 // Start the System Monitor within a process. This method
39 // is provided so that the battery check can be deferred. 34 // is provided so that the battery check can be deferred.
40 // The MessageLoop must be started before calling this 35 // The MessageLoop must be started before calling this
41 // method. 36 // method.
42 // This is a no-op on platforms for which ENABLE_BATTERY_MONITORING is 37 // This is a no-op on platforms for which ENABLE_BATTERY_MONITORING is
43 // disabled. 38 // disabled.
44 static void Start(); 39 static void Start();
45 40
46 // 41 //
(...skipping 13 matching lines...) Expand all
60 SUSPEND_EVENT, // The system is being suspended. 55 SUSPEND_EVENT, // The system is being suspended.
61 RESUME_EVENT // The system is being resumed. 56 RESUME_EVENT // The system is being resumed.
62 }; 57 };
63 58
64 // Callbacks will be called on the thread which creates the SystemMonitor. 59 // Callbacks will be called on the thread which creates the SystemMonitor.
65 // During the callback, Add/RemoveObserver will block until the callbacks 60 // During the callback, Add/RemoveObserver will block until the callbacks
66 // are finished. Observers should implement quick callback functions; if 61 // are finished. Observers should implement quick callback functions; if
67 // lengthy operations are needed, the observer should take care to invoke 62 // lengthy operations are needed, the observer should take care to invoke
68 // the operation on an appropriate thread. 63 // the operation on an appropriate thread.
69 class PowerObserver { 64 class PowerObserver {
70 public: 65 public:
71 // Notification of a change in power status of the computer, such 66 // Notification of a change in power status of the computer, such
72 // as from switching between battery and A/C power. 67 // as from switching between battery and A/C power.
73 virtual void OnPowerStateChange(SystemMonitor*) = 0; 68 virtual void OnPowerStateChange(SystemMonitor*) = 0;
74 69
75 // Notification that the system is suspending. 70 // Notification that the system is suspending.
76 virtual void OnSuspend(SystemMonitor*) = 0; 71 virtual void OnSuspend(SystemMonitor*) = 0;
77 72
78 // Notification that the system is resuming. 73 // Notification that the system is resuming.
79 virtual void OnResume(SystemMonitor*) = 0; 74 virtual void OnResume(SystemMonitor*) = 0;
80 }; 75 };
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 #if defined(ENABLE_BATTERY_MONITORING) 120 #if defined(ENABLE_BATTERY_MONITORING)
126 base::OneShotTimer<SystemMonitor> delayed_battery_check_; 121 base::OneShotTimer<SystemMonitor> delayed_battery_check_;
127 #endif 122 #endif
128 123
129 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); 124 DISALLOW_COPY_AND_ASSIGN(SystemMonitor);
130 }; 125 };
131 126
132 } 127 }
133 128
134 #endif // BASE_SYSTEM_MONITOR_H_ 129 #endif // BASE_SYSTEM_MONITOR_H_
OLDNEW
« no previous file with comments | « no previous file | base/system_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698