Index: content/common/power_monitor_client.cc |
diff --git a/content/common/power_monitor_client.cc b/content/common/power_monitor_client.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f841af1e14618fcdc03332391526cec5a5bda8ee |
--- /dev/null |
+++ b/content/common/power_monitor_client.cc |
@@ -0,0 +1,49 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/common/power_monitor_client.h" |
+ |
+namespace content { |
+ |
+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
|
+ |
+PowerMonitorClient::PowerMonitorClient() |
+ : observers_(new ObserverListThreadSafe<base::PowerObserver>()), |
+ battery_in_use_(false) { |
+ DCHECK(!g_power_monitor_client); |
+ g_power_monitor_client = this; |
+} |
+ |
+PowerMonitorClient::~PowerMonitorClient() { |
+ DCHECK_EQ(this, g_power_monitor_client); |
+ g_power_monitor_client = NULL; |
+} |
+ |
+// static |
+PowerMonitorClient* PowerMonitorClient::Get() { |
+ return g_power_monitor_client; |
+} |
+ |
+void PowerMonitorClient::AddObserver(base::PowerObserver* obs) { |
+ observers_->AddObserver(obs); |
+} |
+ |
+void PowerMonitorClient::RemoveObserver(base::PowerObserver* obs) { |
+ observers_->RemoveObserver(obs); |
+} |
+ |
+void PowerMonitorClient::NotifyPowerStateChange(bool battery_in_use) { |
+ battery_in_use_ = battery_in_use; |
+ observers_->Notify(&base::PowerObserver::OnPowerStateChange, battery_in_use); |
+} |
+ |
+void PowerMonitorClient::NotifySuspend() { |
+ observers_->Notify(&base::PowerObserver::OnSuspend); |
+} |
+ |
+void PowerMonitorClient::NotifyResume() { |
+ observers_->Notify(&base::PowerObserver::OnResume); |
+} |
+ |
+} // namespace content |