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

Side by Side Diff: base/system_monitor/system_monitor.h

Issue 10703120: Adds an iOS implementation of base::SystemMonitor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Review2 Created 8 years, 5 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
« no previous file with comments | « base/base.gypi ('k') | base/system_monitor/system_monitor_ios.mm » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_SYSTEM_MONITOR_H_ 5 #ifndef BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
6 #define BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ 6 #define BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/base_export.h" 12 #include "base/base_export.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/tuple.h" 14 #include "base/tuple.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 16
17 // Windows HiRes timers drain the battery faster so we need to know the battery 17 // Windows HiRes timers drain the battery faster so we need to know the battery
18 // status. This isn't true for other platforms. 18 // status. This isn't true for other platforms.
19 #if defined(OS_WIN) 19 #if defined(OS_WIN)
20 #define ENABLE_BATTERY_MONITORING 1 20 #define ENABLE_BATTERY_MONITORING 1
21 #else 21 #else
22 #undef ENABLE_BATTERY_MONITORING 22 #undef ENABLE_BATTERY_MONITORING
23 #endif // !OS_WIN 23 #endif // !OS_WIN
24 24
25 #include "base/observer_list_threadsafe.h" 25 #include "base/observer_list_threadsafe.h"
26 #if defined(ENABLE_BATTERY_MONITORING) 26 #if defined(ENABLE_BATTERY_MONITORING)
27 #include "base/timer.h" 27 #include "base/timer.h"
28 #endif // defined(ENABLE_BATTERY_MONITORING) 28 #endif // defined(ENABLE_BATTERY_MONITORING)
29 29
30 #if defined(OS_MACOSX) 30 #if defined(OS_MACOSX) && !defined(OS_IOS)
31 #include <IOKit/pwr_mgt/IOPMLib.h> 31 #include <IOKit/pwr_mgt/IOPMLib.h>
32 #include <IOKit/IOMessage.h> 32 #include <IOKit/IOMessage.h>
33 #endif // OS_MACOSX 33 #endif // OS_MACOSX && !OS_IOS
34
35 #if defined(OS_IOS)
36 #include <objc/runtime.h>
37 #endif // OS_IOS
34 38
35 class FilePath; 39 class FilePath;
36 40
37 namespace base { 41 namespace base {
38 42
39 // Class for monitoring various system-related subsystems 43 // Class for monitoring various system-related subsystems
40 // such as power management, network status, etc. 44 // such as power management, network status, etc.
41 // TODO(mbelshe): Add support beyond just power management. 45 // TODO(mbelshe): Add support beyond just power management.
42 class BASE_EXPORT SystemMonitor { 46 class BASE_EXPORT SystemMonitor {
43 public: 47 public:
(...skipping 14 matching lines...) Expand all
58 ~SystemMonitor(); 62 ~SystemMonitor();
59 63
60 // Get the application-wide SystemMonitor (if not present, returns NULL). 64 // Get the application-wide SystemMonitor (if not present, returns NULL).
61 static SystemMonitor* Get(); 65 static SystemMonitor* Get();
62 66
63 #if defined(OS_MACOSX) 67 #if defined(OS_MACOSX)
64 // Allocate system resources needed by the SystemMonitor class. 68 // Allocate system resources needed by the SystemMonitor class.
65 // 69 //
66 // This function must be called before instantiating an instance of the class 70 // This function must be called before instantiating an instance of the class
67 // and before the Sandbox is initialized. 71 // and before the Sandbox is initialized.
72 #if !defined(OS_IOS)
68 static void AllocateSystemIOPorts(); 73 static void AllocateSystemIOPorts();
69 #endif 74 #else
75 static void AllocateSystemIOPorts() {}
76 #endif // OS_IOS
77 #endif // OS_MACOSX
70 78
71 // 79 //
72 // Power-related APIs 80 // Power-related APIs
73 // 81 //
74 82
75 // Is the computer currently on battery power. 83 // Is the computer currently on battery power.
76 // Can be called on any thread. 84 // Can be called on any thread.
77 bool BatteryPower() const { 85 bool BatteryPower() const {
78 // Using a lock here is not necessary for just a bool. 86 // Using a lock here is not necessary for just a bool.
79 return battery_in_use_; 87 return battery_in_use_;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 scoped_refptr<ObserverListThreadSafe<PowerObserver> > power_observer_list_; 190 scoped_refptr<ObserverListThreadSafe<PowerObserver> > power_observer_list_;
183 scoped_refptr<ObserverListThreadSafe<DevicesChangedObserver> > 191 scoped_refptr<ObserverListThreadSafe<DevicesChangedObserver> >
184 devices_changed_observer_list_; 192 devices_changed_observer_list_;
185 bool battery_in_use_; 193 bool battery_in_use_;
186 bool suspended_; 194 bool suspended_;
187 195
188 #if defined(ENABLE_BATTERY_MONITORING) 196 #if defined(ENABLE_BATTERY_MONITORING)
189 base::OneShotTimer<SystemMonitor> delayed_battery_check_; 197 base::OneShotTimer<SystemMonitor> delayed_battery_check_;
190 #endif 198 #endif
191 199
200 #if defined(OS_IOS)
201 // Holds pointers to system event notification observers.
202 std::vector<id> notification_observers_;
203 #endif
204
192 MediaDeviceMap media_device_map_; 205 MediaDeviceMap media_device_map_;
193 206
194 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); 207 DISALLOW_COPY_AND_ASSIGN(SystemMonitor);
195 }; 208 };
196 209
197 } // namespace base 210 } // namespace base
198 211
199 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ 212 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/system_monitor/system_monitor_ios.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698