| OLD | NEW |
| 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 Loading... |
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 95 } |
| 90 | 96 |
| 91 void SystemMonitor::NotifyResume() { | 97 void SystemMonitor::NotifyResume() { |
| 92 VLOG(1) << L"Power Resuming"; | 98 VLOG(1) << L"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 } |
| OLD | NEW |