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

Side by Side Diff: base/power_monitor/power_monitor_device_source_android.cc

Issue 17074009: Created multi-process-friendly PowerMonitor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing windows unit test errors Created 7 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_device_source_android.h"
6
5 #include "base/power_monitor/power_monitor.h" 7 #include "base/power_monitor/power_monitor.h"
8 #include "base/power_monitor/power_monitor_device_source.h"
9 #include "base/power_monitor/power_monitor_source.h"
6 #include "jni/PowerMonitor_jni.h" 10 #include "jni/PowerMonitor_jni.h"
7 11
8 namespace base { 12 namespace base {
9 13
10 // A helper function which is a friend of PowerMonitor. 14 // A helper function which is a friend of PowerMonitorSource.
11 void ProcessPowerEventHelper(PowerMonitor::PowerEvent event) { 15 void ProcessPowerEventHelper(PowerMonitorSource::PowerEvent event) {
12 if (base::PowerMonitor::Get()) 16 PowerMonitorSource::ProcessPowerEvent(event);
13 base::PowerMonitor::Get()->ProcessPowerEvent(event);
14 } 17 }
15 18
16 namespace android { 19 namespace android {
17 20
18 // Native implementation of PowerMonitor.java. 21 // Native implementation of PowerMonitor.java.
19 void OnBatteryChargingChanged(JNIEnv* env, jclass clazz) { 22 void OnBatteryChargingChanged(JNIEnv* env, jclass clazz) {
20 ProcessPowerEventHelper(PowerMonitor::POWER_STATE_EVENT); 23 ProcessPowerEventHelper(PowerMonitorSource::POWER_STATE_EVENT);
21 } 24 }
22 25
23 void OnMainActivityResumed(JNIEnv* env, jclass clazz) { 26 void OnMainActivityResumed(JNIEnv* env, jclass clazz) {
24 ProcessPowerEventHelper(PowerMonitor::RESUME_EVENT); 27 ProcessPowerEventHelper(PowerMonitorSource::RESUME_EVENT);
25 } 28 }
26 29
27 void OnMainActivitySuspended(JNIEnv* env, jclass clazz) { 30 void OnMainActivitySuspended(JNIEnv* env, jclass clazz) {
28 ProcessPowerEventHelper(PowerMonitor::SUSPEND_EVENT); 31 ProcessPowerEventHelper(PowerMonitorSource::SUSPEND_EVENT);
29 } 32 }
30 33
31 } // namespace android 34 } // namespace android
32 35
33 bool PowerMonitor::IsBatteryPower() { 36 bool PowerMonitorDeviceSource::IsOnBatteryPowerImpl() {
34 JNIEnv* env = base::android::AttachCurrentThread(); 37 JNIEnv* env = base::android::AttachCurrentThread();
35 return base::android::Java_PowerMonitor_isBatteryPower(env); 38 return base::android::Java_PowerMonitor_isBatteryPower(env);
36 } 39 }
37 40
38 bool RegisterPowerMonitor(JNIEnv* env) { 41 bool RegisterPowerMonitor(JNIEnv* env) {
39 return base::android::RegisterNativesImpl(env); 42 return base::android::RegisterNativesImpl(env);
40 } 43 }
41 44
42 } // namespace base 45 } // namespace base
OLDNEW
« no previous file with comments | « base/power_monitor/power_monitor_device_source_android.h ('k') | base/power_monitor/power_monitor_device_source_ios.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698