OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/system_monitor/system_monitor.h" |
| 6 |
| 7 #import <UIKit/UIKit.h> |
| 8 |
| 9 namespace base { |
| 10 |
| 11 void SystemMonitor::AllocateSystemIOPorts() { |
| 12 } |
| 13 |
| 14 void SystemMonitor::PlatformInit() { |
| 15 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; |
| 16 id foreground = |
| 17 [nc addObserverForName:UIApplicationWillEnterForegroundNotification |
| 18 object:nil |
| 19 queue:nil |
| 20 usingBlock:^(NSNotification* notification) { |
| 21 ProcessPowerMessage(RESUME_EVENT); |
| 22 }]; |
| 23 id background = |
| 24 [nc addObserverForName:UIApplicationDidEnterBackgroundNotification |
| 25 object:nil |
| 26 queue:nil |
| 27 usingBlock:^(NSNotification* notification) { |
| 28 ProcessPowerMessage(SUSPEND_EVENT); |
| 29 }]; |
| 30 notification_observers_.push_back(foreground); |
| 31 notification_observers_.push_back(background); |
| 32 } |
| 33 |
| 34 void SystemMonitor::PlatformDestroy() { |
| 35 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; |
| 36 for (std::vector<id>::iterator it = notification_observers_.begin(); |
| 37 it != notification_observers_.end(); ++it) { |
| 38 [nc removeObserver:*it]; |
| 39 } |
| 40 notification_observers_.clear(); |
| 41 } |
| 42 |
| 43 } // namespace base |
OLD | NEW |