Commit 250ce03c authored by rohitrao@chromium.org's avatar rohitrao@chromium.org

Adds an iOS implementation of base::SystemMonitor.

BUG=None
TEST=None


Review URL: https://chromiumcodereview.appspot.com/10703120

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145929 0039d316-1c4b-4281-b951-d872f2087c98
parent 648e0a52
......@@ -348,6 +348,7 @@
'system_monitor/system_monitor.cc',
'system_monitor/system_monitor.h',
'system_monitor/system_monitor_android.cc',
'system_monitor/system_monitor_ios.mm',
'system_monitor/system_monitor_mac.mm',
'system_monitor/system_monitor_posix.cc',
'system_monitor/system_monitor_win.cc',
......@@ -575,7 +576,6 @@
['exclude', '^json'],
['exclude', '^message_pump'],
['exclude', '^process_util'],
['exclude', '^system_monitor'],
['exclude', '^values'],
],
}],
......
......@@ -27,10 +27,14 @@
#include "base/timer.h"
#endif // defined(ENABLE_BATTERY_MONITORING)
#if defined(OS_MACOSX)
#if defined(OS_MACOSX) && !defined(OS_IOS)
#include <IOKit/pwr_mgt/IOPMLib.h>
#include <IOKit/IOMessage.h>
#endif // OS_MACOSX
#endif // OS_MACOSX && !OS_IOS
#if defined(OS_IOS)
#include <objc/runtime.h>
#endif // OS_IOS
class FilePath;
......@@ -65,8 +69,12 @@ class BASE_EXPORT SystemMonitor {
//
// This function must be called before instantiating an instance of the class
// and before the Sandbox is initialized.
#if !defined(OS_IOS)
static void AllocateSystemIOPorts();
#endif
#else
static void AllocateSystemIOPorts() {}
#endif // OS_IOS
#endif // OS_MACOSX
//
// Power-related APIs
......@@ -189,6 +197,11 @@ class BASE_EXPORT SystemMonitor {
base::OneShotTimer<SystemMonitor> delayed_battery_check_;
#endif
#if defined(OS_IOS)
// Holds pointers to system event notification observers.
std::vector<id> notification_observers_;
#endif
MediaDeviceMap media_device_map_;
DISALLOW_COPY_AND_ASSIGN(SystemMonitor);
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/system_monitor/system_monitor.h"
#import <UIKit/UIKit.h>
namespace base {
void SystemMonitor::PlatformInit() {
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
id foreground =
[nc addObserverForName:UIApplicationWillEnterForegroundNotification
object:nil
queue:nil
usingBlock:^(NSNotification* notification) {
ProcessPowerMessage(RESUME_EVENT);
}];
id background =
[nc addObserverForName:UIApplicationDidEnterBackgroundNotification
object:nil
queue:nil
usingBlock:^(NSNotification* notification) {
ProcessPowerMessage(SUSPEND_EVENT);
}];
notification_observers_.push_back(foreground);
notification_observers_.push_back(background);
}
void SystemMonitor::PlatformDestroy() {
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
for (std::vector<id>::iterator it = notification_observers_.begin();
it != notification_observers_.end(); ++it) {
[nc removeObserver:*it];
}
notification_observers_.clear();
}
} // namespace base
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment