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

Side by Side Diff: base/system_monitor/system_monitor_ios.mm

Issue 10703120: Adds an iOS implementation of base::SystemMonitor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Review. 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
OLDNEW
(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
OLDNEW
« base/system_monitor/system_monitor.h ('K') | « base/system_monitor/system_monitor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698