Chromium Code Reviews| Index: app/system_monitor_mac.mm |
| =================================================================== |
| --- app/system_monitor_mac.mm (revision 0) |
| +++ app/system_monitor_mac.mm (revision 0) |
| @@ -0,0 +1,71 @@ |
| +// Copyright (c) 2010 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 "app/system_monitor.h" |
| + |
| +#import <Cocoa/Cocoa.h> |
|
Mark Mentovai
2010/11/24 18:52:44
Use <AppKit/AppKit.h> for this one. I’m trying to
|
| + |
| +@interface SystemMonitorBridge : NSObject { |
| + @private |
| + SystemMonitor* systemMonitor_; // weak |
| +} |
| + |
| +- (id)initWithSystemMonitor:(SystemMonitor*)monitor; |
| +- (void)computerDidSleep:(NSNotification*)notification; |
| +- (void)computerDidWake:(NSNotification*)notification; |
| + |
| +@end |
| + |
| +@implementation SystemMonitorBridge |
| + |
| +- (id)initWithSystemMonitor:(SystemMonitor*)monitor { |
| + self = [super init]; |
| + if (self) { |
| + systemMonitor_ = monitor; |
| + |
| + // 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:
|
| + // for more details. |
| + [[[NSWorkspace sharedWorkspace] notificationCenter] |
| + addObserver:self |
| + selector:@selector(computerDidSleep:) |
| + name:NSWorkspaceWillSleepNotification |
| + object:NULL]; |
|
Mark Mentovai
2010/11/24 18:52:44
This is an |id|, use nil here and on line 38.
|
| + [[[NSWorkspace sharedWorkspace] notificationCenter] |
| + addObserver:self |
| + selector:@selector(computerDidWake:) |
| + name:NSWorkspaceDidWakeNotification |
| + object:NULL]; |
| + } |
| + return self; |
| +} |
| + |
| +- (void)dealloc { |
| + [[[NSWorkspace sharedWorkspace] notificationCenter] |
| + removeObserver:self]; |
| + [super dealloc]; |
| +} |
| + |
| +- (void)computerDidSleep:(NSNotification*)notification { |
| + systemMonitor_->ProcessPowerMessage(SystemMonitor::SUSPEND_EVENT); |
| +} |
| + |
| +- (void)computerDidWake:(NSNotification*)notification { |
| + systemMonitor_->ProcessPowerMessage(SystemMonitor::RESUME_EVENT); |
| +} |
| + |
| +@end |
| + |
| +static SystemMonitorBridge* g_system_monitor_bridge = nil; |
| + |
| +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:
|
| + DCHECK(!g_system_monitor_bridge); |
| + g_system_monitor_bridge = |
| + [[SystemMonitorBridge alloc] initWithSystemMonitor:this]; |
| +} |
| + |
| +void SystemMonitor::PlatformDestroy() { |
| + DCHECK(g_system_monitor_bridge); |
| + [g_system_monitor_bridge release]; |
| + g_system_monitor_bridge = nil; |
| +} |
| Property changes on: app/system_monitor_mac.mm |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |