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

Side by Side Diff: app/system_monitor_mac.mm

Issue 6361002: Move SystemMonitor to src/chrome/common.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « app/system_monitor.cc ('k') | app/system_monitor_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <AppKit/AppKit.h>
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
28 // <http://developer.apple.com/library/mac/#qa/qa2004/qa1340.html> for more
29 // details.
30 [[[NSWorkspace sharedWorkspace] notificationCenter]
31 addObserver:self
32 selector:@selector(computerDidSleep:)
33 name:NSWorkspaceWillSleepNotification
34 object:nil];
35 [[[NSWorkspace sharedWorkspace] notificationCenter]
36 addObserver:self
37 selector:@selector(computerDidWake:)
38 name:NSWorkspaceDidWakeNotification
39 object:nil];
40 }
41 return self;
42 }
43
44 - (void)dealloc {
45 [[[NSWorkspace sharedWorkspace] notificationCenter]
46 removeObserver:self];
47 [super dealloc];
48 }
49
50 - (void)computerDidSleep:(NSNotification*)notification {
51 systemMonitor_->ProcessPowerMessage(SystemMonitor::SUSPEND_EVENT);
52 }
53
54 - (void)computerDidWake:(NSNotification*)notification {
55 systemMonitor_->ProcessPowerMessage(SystemMonitor::RESUME_EVENT);
56 }
57
58 @end
59
60 void SystemMonitor::PlatformInit() {
61 system_monitor_bridge_ =
62 [[SystemMonitorBridge alloc] initWithSystemMonitor:this];
63 }
64
65 void SystemMonitor::PlatformDestroy() {
66 [system_monitor_bridge_ release];
67 }
OLDNEW
« no previous file with comments | « app/system_monitor.cc ('k') | app/system_monitor_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698