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

Side by Side Diff: app/system_monitor_mac.mm

Issue 5310005: Monitor sleep/wake on Mac. Should fix some networking issues arising after sl... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « app/system_monitor.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « app/system_monitor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698