OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/power_monitor/power_monitor.h" | 5 #include "base/power_monitor/power_monitor_device_source.h" |
6 #include "base/power_monitor/power_monitor_source.h" | |
6 #include "jni/PowerMonitor_jni.h" | 7 #include "jni/PowerMonitor_jni.h" |
7 | 8 |
8 namespace base { | 9 namespace base { |
9 | 10 |
10 // A helper function which is a friend of PowerMonitor. | 11 // A helper function which is a friend of PowerMonitor. |
vandebo (ex-Chrome)
2013/06/26 21:40:33
nit: ...friend of PowerMonitorSource.
| |
11 void ProcessPowerEventHelper(PowerMonitor::PowerEvent event) { | 12 void ProcessPowerEventHelper(PowerMonitorSource::PowerEvent event) { |
12 if (base::PowerMonitor::Get()) | 13 if (base::PowerMonitor::Get()) |
13 base::PowerMonitor::Get()->ProcessPowerEvent(event); | 14 base::PowerMonitor::Get()->Source()->ProcessPowerEvent(event); |
14 } | 15 } |
15 | 16 |
16 namespace android { | 17 namespace android { |
17 | 18 |
18 // Native implementation of PowerMonitor.java. | 19 // Native implementation of PowerMonitor.java. |
19 void OnBatteryChargingChanged(JNIEnv* env, jclass clazz) { | 20 void OnBatteryChargingChanged(JNIEnv* env, jclass clazz) { |
20 ProcessPowerEventHelper(PowerMonitor::POWER_STATE_EVENT); | 21 ProcessPowerEventHelper(PowerMonitorSource::POWER_STATE_EVENT); |
21 } | 22 } |
22 | 23 |
23 void OnMainActivityResumed(JNIEnv* env, jclass clazz) { | 24 void OnMainActivityResumed(JNIEnv* env, jclass clazz) { |
24 ProcessPowerEventHelper(PowerMonitor::RESUME_EVENT); | 25 ProcessPowerEventHelper(PowerMonitorSource::RESUME_EVENT); |
25 } | 26 } |
26 | 27 |
27 void OnMainActivitySuspended(JNIEnv* env, jclass clazz) { | 28 void OnMainActivitySuspended(JNIEnv* env, jclass clazz) { |
28 ProcessPowerEventHelper(PowerMonitor::SUSPEND_EVENT); | 29 ProcessPowerEventHelper(PowerMonitorSource::SUSPEND_EVENT); |
29 } | 30 } |
30 | 31 |
31 } // namespace android | 32 } // namespace android |
32 | 33 |
33 bool PowerMonitor::IsBatteryPower() { | 34 bool PowerMonitorDeviceSource::IsBatteryPower() { |
34 JNIEnv* env = base::android::AttachCurrentThread(); | 35 JNIEnv* env = base::android::AttachCurrentThread(); |
35 return base::android::Java_PowerMonitor_isBatteryPower(env); | 36 return base::android::Java_PowerMonitor_isBatteryPower(env); |
36 } | 37 } |
37 | 38 |
38 bool RegisterPowerMonitor(JNIEnv* env) { | 39 bool RegisterPowerMonitor(JNIEnv* env) { |
39 return base::android::RegisterNativesImpl(env); | 40 return base::android::RegisterNativesImpl(env); |
40 } | 41 } |
41 | 42 |
42 } // namespace base | 43 } // namespace base |
OLD | NEW |