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

Side by Side Diff: app/system_monitor.h

Issue 5310005: Monitor sleep/wake on Mac. Should fix some networking issues arising after sl... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 | « app/app_base.gypi ('k') | app/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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 APP_SYSTEM_MONITOR_H_ 5 #ifndef APP_SYSTEM_MONITOR_H_
6 #define APP_SYSTEM_MONITOR_H_ 6 #define APP_SYSTEM_MONITOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 10
11 // Windows HiRes timers drain the battery faster so we need to know the battery 11 // Windows HiRes timers drain the battery faster so we need to know the battery
12 // status. This isn't true for other platforms. 12 // status. This isn't true for other platforms.
13 #if defined(OS_WIN) 13 #if defined(OS_WIN)
14 #define ENABLE_BATTERY_MONITORING 1 14 #define ENABLE_BATTERY_MONITORING 1
15 #else 15 #else
16 #undef ENABLE_BATTERY_MONITORING 16 #undef ENABLE_BATTERY_MONITORING
17 #endif // !OS_WIN 17 #endif // !OS_WIN
18 18
19 #include "base/observer_list_threadsafe.h" 19 #include "base/observer_list_threadsafe.h"
20 #if defined(ENABLE_BATTERY_MONITORING) 20 #if defined(ENABLE_BATTERY_MONITORING)
21 #include "base/timer.h" 21 #include "base/timer.h"
22 #endif // defined(ENABLE_BATTERY_MONITORING) 22 #endif // defined(ENABLE_BATTERY_MONITORING)
23 23
24 #if defined(OS_MACOSX)
25 #ifdef __OBJC__
26 @class SystemMonitorBridge;
27 #else
28 class SystemMonitorBridge;
29 #endif
30 #endif
31
24 // Class for monitoring various system-related subsystems 32 // Class for monitoring various system-related subsystems
25 // such as power management, network status, etc. 33 // such as power management, network status, etc.
26 // TODO(mbelshe): Add support beyond just power management. 34 // TODO(mbelshe): Add support beyond just power management.
27 class SystemMonitor { 35 class SystemMonitor {
28 public: 36 public:
29 // Create SystemMonitor. Only one SystemMonitor instance per application 37 // Create SystemMonitor. Only one SystemMonitor instance per application
30 // is allowed. 38 // is allowed.
31 SystemMonitor(); 39 SystemMonitor();
32 ~SystemMonitor(); 40 ~SystemMonitor();
33 41
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // Windows-specific handling of a WM_POWERBROADCAST message. 95 // Windows-specific handling of a WM_POWERBROADCAST message.
88 // Embedders of this API should hook their top-level window 96 // Embedders of this API should hook their top-level window
89 // message loop and forward WM_POWERBROADCAST through this call. 97 // message loop and forward WM_POWERBROADCAST through this call.
90 void ProcessWmPowerBroadcastMessage(int event_id); 98 void ProcessWmPowerBroadcastMessage(int event_id);
91 #endif 99 #endif
92 100
93 // Cross-platform handling of a power event. 101 // Cross-platform handling of a power event.
94 void ProcessPowerMessage(PowerEvent event_id); 102 void ProcessPowerMessage(PowerEvent event_id);
95 103
96 private: 104 private:
105 #if defined(OS_MACOSX)
106 void PlatformInit();
107 void PlatformDestroy();
108 #endif
109
97 // Platform-specific method to check whether the system is currently 110 // Platform-specific method to check whether the system is currently
98 // running on battery power. Returns true if running on batteries, 111 // running on battery power. Returns true if running on batteries,
99 // false otherwise. 112 // false otherwise.
100 bool IsBatteryPower(); 113 bool IsBatteryPower();
101 114
102 // Checks the battery status and notifies observers if the battery 115 // Checks the battery status and notifies observers if the battery
103 // status has changed. 116 // status has changed.
104 void BatteryCheck(); 117 void BatteryCheck();
105 118
106 // Functions to trigger notifications. 119 // Functions to trigger notifications.
107 void NotifyPowerStateChange(); 120 void NotifyPowerStateChange();
108 void NotifySuspend(); 121 void NotifySuspend();
109 void NotifyResume(); 122 void NotifyResume();
110 123
111 scoped_refptr<ObserverListThreadSafe<PowerObserver> > observer_list_; 124 scoped_refptr<ObserverListThreadSafe<PowerObserver> > observer_list_;
112 bool battery_in_use_; 125 bool battery_in_use_;
113 bool suspended_; 126 bool suspended_;
114 127
115 #if defined(ENABLE_BATTERY_MONITORING) 128 #if defined(ENABLE_BATTERY_MONITORING)
116 base::OneShotTimer<SystemMonitor> delayed_battery_check_; 129 base::OneShotTimer<SystemMonitor> delayed_battery_check_;
117 #endif 130 #endif
118 131
132 #if defined(OS_MACOSX)
133 SystemMonitorBridge* system_monitor_bridge_;
134 #endif
135
119 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); 136 DISALLOW_COPY_AND_ASSIGN(SystemMonitor);
120 }; 137 };
121 138
122 #endif // APP_SYSTEM_MONITOR_H_ 139 #endif // APP_SYSTEM_MONITOR_H_
OLDNEW
« no previous file with comments | « app/app_base.gypi ('k') | app/system_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698