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

Side by Side Diff: base/power_monitor/power_monitor_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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/power_monitor/power_monitor.h"
6 #include "jni/PowerMonitor_jni.h"
7
8 namespace base {
9
10 // A helper function which is a friend of PowerMonitor.
11 void ProcessPowerEventHelper(PowerMonitor::PowerEvent event) {
12 if (base::PowerMonitor::Get())
13 base::PowerMonitor::Get()->ProcessPowerEvent(event);
14 }
15
16 namespace android {
17
18 // Native implementation of PowerMonitor.java.
19 void OnBatteryChargingChanged(JNIEnv* env, jclass clazz) {
20 ProcessPowerEventHelper(PowerMonitor::POWER_STATE_EVENT);
21 }
22
23 void OnMainActivityResumed(JNIEnv* env, jclass clazz) {
24 ProcessPowerEventHelper(PowerMonitor::RESUME_EVENT);
25 }
26
27 void OnMainActivitySuspended(JNIEnv* env, jclass clazz) {
28 ProcessPowerEventHelper(PowerMonitor::SUSPEND_EVENT);
29 }
30
31 } // namespace android
32
33 bool PowerMonitor::IsBatteryPower() {
34 JNIEnv* env = base::android::AttachCurrentThread();
35 return base::android::Java_PowerMonitor_isBatteryPower(env);
36 }
37
38 bool RegisterPowerMonitor(JNIEnv* env) {
39 return base::android::RegisterNativesImpl(env);
40 }
41
42 } // namespace base
OLDNEW
« no previous file with comments | « base/power_monitor/power_monitor_android.h ('k') | base/power_monitor/power_monitor_device_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698