Chromium Code Reviews| 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 // Implementation based on sample code from | |
| 6 // http://developer.apple.com/library/mac/#qa/qa1340/_index.html. | |
|
Mark Mentovai
2012/07/10 16:06:03
I don’t see anything like this code at this URL.
rohitrao (ping after 24h)
2012/07/10 16:26:44
Removed the comment.
| |
| 7 | |
| 8 #include "base/system_monitor/system_monitor.h" | |
| 9 | |
| 10 #include <UIKit/UIKit.h> | |
|
Mark Mentovai
2012/07/10 16:06:03
#import me.
rohitrao (ping after 24h)
2012/07/10 16:26:44
Done.
| |
| 11 | |
| 12 namespace base { | |
| 13 | |
| 14 void SystemMonitor::AllocateSystemIOPorts() { | |
| 15 // No need to allocate any IO ports on iOS. | |
|
Mark Mentovai
2012/07/10 16:06:03
This comment is unnecessary. There’s obviously no
rohitrao (ping after 24h)
2012/07/10 16:26:44
Removed the comment. I thought about making the e
Mark Mentovai
2012/07/10 17:06:05
rohitrao wrote:
rohitrao (ping after 24h)
2012/07/10 17:17:42
Done.
| |
| 16 } | |
| 17 | |
| 18 void SystemMonitor::PlatformInit() { | |
| 19 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; | |
| 20 id foreground = | |
| 21 [nc addObserverForName:UIApplicationWillEnterForegroundNotification | |
| 22 object:nil | |
| 23 queue:nil | |
| 24 usingBlock:^(NSNotification* notification) { | |
| 25 this->ProcessPowerMessage(RESUME_EVENT); | |
|
Mark Mentovai
2012/07/10 16:06:03
Is the “this” really necessary?
Mark Mentovai
2012/07/10 16:06:03
I do love how clean this is.
rohitrao (ping after 24h)
2012/07/10 16:26:44
Looks like it's implicit if I leave it out. From
Mark Mentovai
2012/07/10 17:06:05
rohitrao wrote:
rohitrao (ping after 24h)
2012/07/10 17:17:42
Ok, makes sense. paranoia fading.
| |
| 26 }]; | |
| 27 id background = | |
| 28 [nc addObserverForName:UIApplicationDidEnterBackgroundNotification | |
| 29 object:nil | |
| 30 queue:nil | |
| 31 usingBlock:^(NSNotification* notification) { | |
| 32 this->ProcessPowerMessage(SUSPEND_EVENT); | |
| 33 }]; | |
| 34 notification_observers_.push_back(foreground); | |
| 35 notification_observers_.push_back(background); | |
| 36 } | |
| 37 | |
| 38 void SystemMonitor::PlatformDestroy() { | |
| 39 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; | |
| 40 for (std::vector<id>::iterator it = notification_observers_.begin(); | |
| 41 it != notification_observers_.end(); ++it) { | |
| 42 [nc removeObserver:*it]; | |
| 43 } | |
| 44 notification_observers_.clear(); | |
| 45 } | |
| 46 | |
| 47 } // namespace base | |
| OLD | NEW |