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 53% |
rename from base/system_monitor/system_monitor_android.cc |
rename to base/power_monitor/power_monitor_android.cc |
index f29b7b0380279ac59461f02369142a687a24c297..786f07bd2d887f29c0e85d46deb16e15ace1542c 100644 |
--- a/base/system_monitor/system_monitor_android.cc |
+++ b/base/power_monitor/power_monitor_android.cc |
@@ -1,34 +1,41 @@ |
-// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// 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 "base/system_monitor/system_monitor.h" |
+#include "base/power_monitor/power_monitor.h" |
#include "jni/SystemMonitor_jni.h" |
vandebo (ex-Chrome)
2013/03/19 23:36:04
SysMon->PowMon
Hongbo Min
2013/03/20 13:01:50
Done.
|
namespace base { |
+// A helper function which is a friend of PowerMonitor. |
+void ProcessPowerEventHelper(PowerMonitor::PowerEvent event) { |
+ if (base::PowerMonitor::Get()) |
+ base::PowerMonitor::Get()->ProcessPowerEvent(event); |
+} |
+ |
namespace android { |
// Native implementation of SystemMonitor.java. |
void OnBatteryChargingChanged(JNIEnv* env, jclass clazz) { |
- SystemMonitor::Get()->ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); |
+ ProcessPowerEventHelper(PowerMonitor::POWER_STATE_EVENT); |
} |
void OnMainActivityResumed(JNIEnv* env, jclass clazz) { |
- SystemMonitor::Get()->ProcessPowerMessage(SystemMonitor::RESUME_EVENT); |
+ ProcessPowerEventHelper(PowerMonitor::RESUME_EVENT); |
} |
void OnMainActivitySuspended(JNIEnv* env, jclass clazz) { |
- SystemMonitor::Get()->ProcessPowerMessage(SystemMonitor::SUSPEND_EVENT); |
+ ProcessPowerEventHelper(PowerMonitor::SUSPEND_EVENT); |
} |
} // namespace android |
-bool SystemMonitor::IsBatteryPower() { |
+bool PowerMonitor::IsBatteryPower() { |
JNIEnv* env = base::android::AttachCurrentThread(); |
return base::android::Java_SystemMonitor_isBatteryPower(env); |
} |
+// TODO(hmin): Rename it to RegisterPowerMonitor. |
vandebo (ex-Chrome)
2013/03/19 23:36:04
Do this in this CL.
Hongbo Min
2013/03/20 13:01:50
Done.
|
bool RegisterSystemMonitor(JNIEnv* env) { |
return base::android::RegisterNativesImpl(env); |
} |