summaryrefslogtreecommitdiffstats
path: root/chromium/base/power_monitor
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@theqtcompany.com>2014-12-05 15:04:29 +0100
committerAndras Becsi <andras.becsi@theqtcompany.com>2014-12-09 10:49:28 +0100
commitaf6588f8d723931a298c995fa97259bb7f7deb55 (patch)
tree060ca707847ba1735f01af2372e0d5e494dc0366 /chromium/base/power_monitor
parent2fff84d821cc7b1c785f6404e0f8091333283e74 (diff)
BASELINE: Update chromium to 40.0.2214.28 and ninja to 1.5.3.
Change-Id: I759465284fd64d59ad120219cbe257f7402c4181 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'chromium/base/power_monitor')
-rw-r--r--chromium/base/power_monitor/power_monitor_device_source.h14
-rw-r--r--chromium/base/power_monitor/power_monitor_device_source_chromeos.cc40
2 files changed, 52 insertions, 2 deletions
diff --git a/chromium/base/power_monitor/power_monitor_device_source.h b/chromium/base/power_monitor/power_monitor_device_source.h
index 37b065a77c6..29f17c2a7d9 100644
--- a/chromium/base/power_monitor/power_monitor_device_source.h
+++ b/chromium/base/power_monitor/power_monitor_device_source.h
@@ -37,7 +37,7 @@ namespace base {
class BASE_EXPORT PowerMonitorDeviceSource : public PowerMonitorSource {
public:
PowerMonitorDeviceSource();
- virtual ~PowerMonitorDeviceSource();
+ ~PowerMonitorDeviceSource() override;
#if defined(OS_MACOSX)
// Allocate system resources needed by the PowerMonitor class.
@@ -51,6 +51,16 @@ class BASE_EXPORT PowerMonitorDeviceSource : public PowerMonitorSource {
#endif // OS_IOS
#endif // OS_MACOSX
+#if defined(OS_CHROMEOS)
+ // On Chrome OS, Chrome receives power-related events from powerd, the system
+ // power daemon, via D-Bus signals received on the UI thread. base can't
+ // directly depend on that code, so this class instead exposes static methods
+ // so that events can be passed in.
+ static void SetPowerSource(bool on_battery);
+ static void HandleSystemSuspending();
+ static void HandleSystemResumed();
+#endif
+
private:
#if defined(OS_WIN)
// Represents a message-only window for power message handling on Windows.
@@ -80,7 +90,7 @@ class BASE_EXPORT PowerMonitorDeviceSource : public PowerMonitorSource {
// Platform-specific method to check whether the system is currently
// running on battery power. Returns true if running on batteries,
// false otherwise.
- virtual bool IsOnBatteryPowerImpl() OVERRIDE;
+ bool IsOnBatteryPowerImpl() override;
// Checks the battery status and notifies observers if the battery
// status has changed.
diff --git a/chromium/base/power_monitor/power_monitor_device_source_chromeos.cc b/chromium/base/power_monitor/power_monitor_device_source_chromeos.cc
new file mode 100644
index 00000000000..c3466ee15a1
--- /dev/null
+++ b/chromium/base/power_monitor/power_monitor_device_source_chromeos.cc
@@ -0,0 +1,40 @@
+// Copyright 2014 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 "base/power_monitor/power_monitor.h"
+#include "base/power_monitor/power_monitor_device_source.h"
+#include "base/power_monitor/power_monitor_source.h"
+
+namespace base {
+
+namespace {
+
+// The most-recently-seen power source.
+bool g_on_battery = false;
+
+} // namespace
+
+// static
+void PowerMonitorDeviceSource::SetPowerSource(bool on_battery) {
+ if (on_battery != g_on_battery) {
+ g_on_battery = on_battery;
+ ProcessPowerEvent(POWER_STATE_EVENT);
+ }
+}
+
+// static
+void PowerMonitorDeviceSource::HandleSystemSuspending() {
+ ProcessPowerEvent(SUSPEND_EVENT);
+}
+
+// static
+void PowerMonitorDeviceSource::HandleSystemResumed() {
+ ProcessPowerEvent(RESUME_EVENT);
+}
+
+bool PowerMonitorDeviceSource::IsOnBatteryPowerImpl() {
+ return g_on_battery;
+}
+
+} // namespace base