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

Side by Side Diff: app/system_monitor.cc

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.h ('k') | app/system_monitor_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "app/system_monitor.h" 5 #include "app/system_monitor.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 10
(...skipping 11 matching lines...) Expand all
22 suspended_(false) { 22 suspended_(false) {
23 DCHECK(!g_system_monitor); 23 DCHECK(!g_system_monitor);
24 g_system_monitor = this; 24 g_system_monitor = this;
25 25
26 DCHECK(MessageLoop::current()); 26 DCHECK(MessageLoop::current());
27 #if defined(ENABLE_BATTERY_MONITORING) 27 #if defined(ENABLE_BATTERY_MONITORING)
28 delayed_battery_check_.Start( 28 delayed_battery_check_.Start(
29 base::TimeDelta::FromMilliseconds(kDelayedBatteryCheckMs), this, 29 base::TimeDelta::FromMilliseconds(kDelayedBatteryCheckMs), this,
30 &SystemMonitor::BatteryCheck); 30 &SystemMonitor::BatteryCheck);
31 #endif // defined(ENABLE_BATTERY_MONITORING) 31 #endif // defined(ENABLE_BATTERY_MONITORING)
32 #if defined(OS_MACOSX)
33 PlatformInit();
34 #endif
32 } 35 }
33 36
34 SystemMonitor::~SystemMonitor() { 37 SystemMonitor::~SystemMonitor() {
38 #if defined(OS_MACOSX)
39 PlatformDestroy();
40 #endif
35 DCHECK_EQ(this, g_system_monitor); 41 DCHECK_EQ(this, g_system_monitor);
36 g_system_monitor = NULL; 42 g_system_monitor = NULL;
37 } 43 }
38 44
39 // static 45 // static
40 SystemMonitor* SystemMonitor::Get() { 46 SystemMonitor* SystemMonitor::Get() {
41 return g_system_monitor; 47 return g_system_monitor;
42 } 48 }
43 49
44 void SystemMonitor::ProcessPowerMessage(PowerEvent event_id) { 50 void SystemMonitor::ProcessPowerMessage(PowerEvent event_id) {
(...skipping 26 matching lines...) Expand all
71 77
72 void SystemMonitor::AddObserver(PowerObserver* obs) { 78 void SystemMonitor::AddObserver(PowerObserver* obs) {
73 observer_list_->AddObserver(obs); 79 observer_list_->AddObserver(obs);
74 } 80 }
75 81
76 void SystemMonitor::RemoveObserver(PowerObserver* obs) { 82 void SystemMonitor::RemoveObserver(PowerObserver* obs) {
77 observer_list_->RemoveObserver(obs); 83 observer_list_->RemoveObserver(obs);
78 } 84 }
79 85
80 void SystemMonitor::NotifyPowerStateChange() { 86 void SystemMonitor::NotifyPowerStateChange() {
81 VLOG(1) << L"PowerStateChange: " << (BatteryPower() ? L"On" : L"Off") 87 VLOG(1) << "PowerStateChange: " << (BatteryPower() ? "On" : "Off")
82 << L" battery"; 88 << " battery";
83 observer_list_->Notify(&PowerObserver::OnPowerStateChange, BatteryPower()); 89 observer_list_->Notify(&PowerObserver::OnPowerStateChange, BatteryPower());
84 } 90 }
85 91
86 void SystemMonitor::NotifySuspend() { 92 void SystemMonitor::NotifySuspend() {
87 VLOG(1) << L"Power Suspending"; 93 VLOG(1) << "Power Suspending";
88 observer_list_->Notify(&PowerObserver::OnSuspend); 94 observer_list_->Notify(&PowerObserver::OnSuspend);
89 } 95 }
90 96
91 void SystemMonitor::NotifyResume() { 97 void SystemMonitor::NotifyResume() {
92 VLOG(1) << L"Power Resuming"; 98 VLOG(1) << "Power Resuming";
93 observer_list_->Notify(&PowerObserver::OnResume); 99 observer_list_->Notify(&PowerObserver::OnResume);
94 } 100 }
95 101
96 void SystemMonitor::BatteryCheck() { 102 void SystemMonitor::BatteryCheck() {
97 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); 103 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT);
98 } 104 }
OLDNEW
« no previous file with comments | « app/system_monitor.h ('k') | app/system_monitor_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698