Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/system_monitor/system_monitor.h" | 5 #include "base/power_monitor/power_monitor.h" |
| 6 #include "jni/SystemMonitor_jni.h" | 6 #include "jni/SystemMonitor_jni.h" |
| 7 | 7 |
| 8 namespace base { | 8 namespace base { |
| 9 | 9 |
| 10 static PowerMonitor::Signaler* g_power_signaler = NULL; | |
|
vandebo (ex-Chrome)
2012/10/29 18:04:38
This should go in an anonymous namespace.
Hongbo Min
2012/10/30 14:33:47
Done.
| |
| 11 | |
| 10 namespace android { | 12 namespace android { |
| 11 | 13 |
| 12 // Native implementation of SystemMonitor.java. | 14 // Native implementation of SystemMonitor.java. |
| 13 void OnBatteryChargingChanged(JNIEnv* env, | 15 void OnBatteryChargingChanged(JNIEnv* env, |
| 14 jclass clazz) { | 16 jclass clazz) { |
| 15 SystemMonitor::Get()->ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); | 17 CHECK(g_power_signaler); |
| 18 g_power_signaler->ProcessPowerEvent(PowerMonitor::POWER_STATE_EVENT); | |
| 16 } | 19 } |
| 17 | 20 |
| 18 } // namespace android | 21 } // namespace android |
| 19 | 22 |
| 20 bool SystemMonitor::IsBatteryPower() { | 23 bool PowerMonitor::IsBatteryPower() { |
| 21 JNIEnv* env = base::android::AttachCurrentThread(); | 24 JNIEnv* env = base::android::AttachCurrentThread(); |
| 22 return base::android::Java_SystemMonitor_isBatteryPower(env); | 25 return base::android::Java_SystemMonitor_isBatteryPower(env); |
| 23 } | 26 } |
| 24 | 27 |
| 25 bool RegisterSystemMonitor(JNIEnv* env) { | 28 bool RegisterSystemMonitor(JNIEnv* env) { |
| 29 CHECK(!g_power_signaler); | |
| 30 g_power_signaler = PowerMonitor::Get()->GetSignalerOnce(); | |
| 26 return base::android::RegisterNativesImpl(env); | 31 return base::android::RegisterNativesImpl(env); |
| 27 } | 32 } |
| 28 | 33 |
| 29 } // namespace base | 34 } // namespace base |
| OLD | NEW |