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