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

Unified Diff: base/power_monitor/power_monitor_android.cc

Issue 10959020: SystemMonitor refactoring: move power state monitor into a separate class called PowerMonitor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add PlatformInit/Destory for all platforms Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: base/power_monitor/power_monitor_android.cc
diff --git a/base/system_monitor/system_monitor_android.cc b/base/power_monitor/power_monitor_android.cc
similarity index 57%
rename from base/system_monitor/system_monitor_android.cc
rename to base/power_monitor/power_monitor_android.cc
index 4e1a16b3e91f379f26bd829b55f62f08ca9cba46..eaf72ac249af1efdea2d23f57f8ebeaebd403532 100644
--- a/base/system_monitor/system_monitor_android.cc
+++ b/base/power_monitor/power_monitor_android.cc
@@ -2,22 +2,39 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/system_monitor/system_monitor.h"
+#include "base/power_monitor/power_monitor.h"
#include "jni/SystemMonitor_jni.h"
namespace base {
+namespace {
+
+static PowerMonitor::Signaler* g_power_signaler = NULL;
+
+}
+
namespace android {
// Native implementation of SystemMonitor.java.
void OnBatteryChargingChanged(JNIEnv* env,
jclass clazz) {
- SystemMonitor::Get()->ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT);
+ CHECK(g_power_signaler);
vandebo (ex-Chrome) 2012/11/01 16:50:26 There doesn't seem to be anything unregistering th
Hongbo Min 2012/11/02 00:29:07 Done.
+ g_power_signaler->ProcessPowerEvent(PowerMonitor::POWER_STATE_EVENT);
}
} // namespace android
-bool SystemMonitor::IsBatteryPower() {
+void PowerMonitor::PlatformInit() {
+ CHECK(!g_power_signaler);
+ g_power_signaler = PowerMonitor::Get()->GetSignalerOnce();
+}
+
+void PowerMonitor::PlatformDestroy() {
+ delete g_power_signaler;
+ g_power_signaler = NULL;
+}
+
+bool PowerMonitor::IsBatteryPower() {
JNIEnv* env = base::android::AttachCurrentThread();
return base::android::Java_SystemMonitor_isBatteryPower(env);
}

Powered by Google App Engine
This is Rietveld 408576698