OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 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 "content/common/power_monitor_client.h" | |
6 | |
7 namespace content { | |
8 | |
9 static PowerMonitorClient* g_power_monitor_client = NULL; | |
Ken Russell (switch to Gerrit)
2013/06/24 22:54:38
This and PowerMonitorClient::Get() should use base
| |
10 | |
11 PowerMonitorClient::PowerMonitorClient() | |
12 : observers_(new ObserverListThreadSafe<base::PowerObserver>()), | |
13 battery_in_use_(false) { | |
14 DCHECK(!g_power_monitor_client); | |
15 g_power_monitor_client = this; | |
16 } | |
17 | |
18 PowerMonitorClient::~PowerMonitorClient() { | |
19 DCHECK_EQ(this, g_power_monitor_client); | |
20 g_power_monitor_client = NULL; | |
21 } | |
22 | |
23 // static | |
24 PowerMonitorClient* PowerMonitorClient::Get() { | |
25 return g_power_monitor_client; | |
26 } | |
27 | |
28 void PowerMonitorClient::AddObserver(base::PowerObserver* obs) { | |
29 observers_->AddObserver(obs); | |
30 } | |
31 | |
32 void PowerMonitorClient::RemoveObserver(base::PowerObserver* obs) { | |
33 observers_->RemoveObserver(obs); | |
34 } | |
35 | |
36 void PowerMonitorClient::NotifyPowerStateChange(bool battery_in_use) { | |
37 battery_in_use_ = battery_in_use; | |
38 observers_->Notify(&base::PowerObserver::OnPowerStateChange, battery_in_use); | |
39 } | |
40 | |
41 void PowerMonitorClient::NotifySuspend() { | |
42 observers_->Notify(&base::PowerObserver::OnSuspend); | |
43 } | |
44 | |
45 void PowerMonitorClient::NotifyResume() { | |
46 observers_->Notify(&base::PowerObserver::OnResume); | |
47 } | |
48 | |
49 } // namespace content | |
OLD | NEW |