Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2010 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 "app/system_monitor.h" | |
| 6 | |
| 7 #import <Cocoa/Cocoa.h> | |
|
Mark Mentovai
2010/11/24 18:52:44
Use <AppKit/AppKit.h> for this one. I’m trying to
| |
| 8 | |
| 9 @interface SystemMonitorBridge : NSObject { | |
| 10 @private | |
| 11 SystemMonitor* systemMonitor_; // weak | |
| 12 } | |
| 13 | |
| 14 - (id)initWithSystemMonitor:(SystemMonitor*)monitor; | |
| 15 - (void)computerDidSleep:(NSNotification*)notification; | |
| 16 - (void)computerDidWake:(NSNotification*)notification; | |
| 17 | |
| 18 @end | |
| 19 | |
| 20 @implementation SystemMonitorBridge | |
| 21 | |
| 22 - (id)initWithSystemMonitor:(SystemMonitor*)monitor { | |
| 23 self = [super init]; | |
| 24 if (self) { | |
| 25 systemMonitor_ = monitor; | |
| 26 | |
| 27 // See QA1340 <http://developer.apple.com/library/mac/#qa/qa2004/qa1340.html > | |
|
Mark Mentovai
2010/11/24 18:52:44
80.
Avi (use Gerrit)
2010/11/24 19:02:15
I thought we could let URLs slide? Or do we want t
Mark Mentovai
2010/11/24 19:13:35
Avi wrote:
| |
| 28 // for more details. | |
| 29 [[[NSWorkspace sharedWorkspace] notificationCenter] | |
| 30 addObserver:self | |
| 31 selector:@selector(computerDidSleep:) | |
| 32 name:NSWorkspaceWillSleepNotification | |
| 33 object:NULL]; | |
|
Mark Mentovai
2010/11/24 18:52:44
This is an |id|, use nil here and on line 38.
| |
| 34 [[[NSWorkspace sharedWorkspace] notificationCenter] | |
| 35 addObserver:self | |
| 36 selector:@selector(computerDidWake:) | |
| 37 name:NSWorkspaceDidWakeNotification | |
| 38 object:NULL]; | |
| 39 } | |
| 40 return self; | |
| 41 } | |
| 42 | |
| 43 - (void)dealloc { | |
| 44 [[[NSWorkspace sharedWorkspace] notificationCenter] | |
| 45 removeObserver:self]; | |
| 46 [super dealloc]; | |
| 47 } | |
| 48 | |
| 49 - (void)computerDidSleep:(NSNotification*)notification { | |
| 50 systemMonitor_->ProcessPowerMessage(SystemMonitor::SUSPEND_EVENT); | |
| 51 } | |
| 52 | |
| 53 - (void)computerDidWake:(NSNotification*)notification { | |
| 54 systemMonitor_->ProcessPowerMessage(SystemMonitor::RESUME_EVENT); | |
| 55 } | |
| 56 | |
| 57 @end | |
| 58 | |
| 59 static SystemMonitorBridge* g_system_monitor_bridge = nil; | |
| 60 | |
| 61 void SystemMonitor::PlatformInit() { | |
|
Mark Mentovai
2010/11/24 18:52:44
PlatformInit and PlatformDestroy aren’t static met
Avi (use Gerrit)
2010/11/24 19:02:15
Something like the
#if OBJC
@class bridge
#else
Mark Mentovai
2010/11/24 19:13:35
Avi wrote:
| |
| 62 DCHECK(!g_system_monitor_bridge); | |
| 63 g_system_monitor_bridge = | |
| 64 [[SystemMonitorBridge alloc] initWithSystemMonitor:this]; | |
| 65 } | |
| 66 | |
| 67 void SystemMonitor::PlatformDestroy() { | |
| 68 DCHECK(g_system_monitor_bridge); | |
| 69 [g_system_monitor_bridge release]; | |
| 70 g_system_monitor_bridge = nil; | |
| 71 } | |
| OLD | NEW |