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

Side by Side Diff: base/system_monitor.cc

Issue 164424: Simple cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 4 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 | « base/system_monitor.h ('k') | chrome/browser/safe_browsing/safe_browsing_service.h » ('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) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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 "base/system_monitor.h" 5 #include "base/system_monitor.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/singleton.h"
8 9
9 namespace base { 10 namespace base {
10 11
11 #if defined(ENABLE_BATTERY_MONITORING) 12 #if defined(ENABLE_BATTERY_MONITORING)
12 // The amount of time (in ms) to wait before running the initial 13 // The amount of time (in ms) to wait before running the initial
13 // battery check. 14 // battery check.
14 static int kDelayedBatteryCheckMs = 10 * 1000; 15 static int kDelayedBatteryCheckMs = 10 * 1000;
15 #endif // defined(ENABLE_BATTERY_MONITORING) 16 #endif // defined(ENABLE_BATTERY_MONITORING)
16 17
17 SystemMonitor::SystemMonitor() 18 SystemMonitor::SystemMonitor()
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 void SystemMonitor::NotifySuspend() { 66 void SystemMonitor::NotifySuspend() {
66 LOG(INFO) << L"Power Suspending"; 67 LOG(INFO) << L"Power Suspending";
67 observer_list_->Notify(&PowerObserver::OnSuspend, this); 68 observer_list_->Notify(&PowerObserver::OnSuspend, this);
68 } 69 }
69 70
70 void SystemMonitor::NotifyResume() { 71 void SystemMonitor::NotifyResume() {
71 LOG(INFO) << L"Power Resuming"; 72 LOG(INFO) << L"Power Resuming";
72 observer_list_->Notify(&PowerObserver::OnResume, this); 73 observer_list_->Notify(&PowerObserver::OnResume, this);
73 } 74 }
74 75
76 // static
77 SystemMonitor* SystemMonitor::Get() {
78 // Uses the LeakySingletonTrait because cleanup is optional.
79 return
80 Singleton<SystemMonitor, LeakySingletonTraits<SystemMonitor> >::get();
81 }
82
83 // static
75 void SystemMonitor::Start() { 84 void SystemMonitor::Start() {
76 #if defined(ENABLE_BATTERY_MONITORING) 85 #if defined(ENABLE_BATTERY_MONITORING)
77 DCHECK(MessageLoop::current()); // Can't call start too early. 86 DCHECK(MessageLoop::current()); // Can't call start too early.
78 SystemMonitor* monitor = Get(); 87 SystemMonitor* monitor = Get();
79 monitor->delayed_battery_check_.Start( 88 monitor->delayed_battery_check_.Start(
80 TimeDelta::FromMilliseconds(kDelayedBatteryCheckMs), monitor, 89 TimeDelta::FromMilliseconds(kDelayedBatteryCheckMs), monitor,
81 &SystemMonitor::BatteryCheck); 90 &SystemMonitor::BatteryCheck);
82 #endif // defined(ENABLE_BATTERY_MONITORING) 91 #endif // defined(ENABLE_BATTERY_MONITORING)
83 } 92 }
84 93
85 void SystemMonitor::BatteryCheck() { 94 void SystemMonitor::BatteryCheck() {
86 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); 95 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT);
87 } 96 }
88 97
89 } // namespace base 98 } // namespace base
OLDNEW
« no previous file with comments | « base/system_monitor.h ('k') | chrome/browser/safe_browsing/safe_browsing_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698