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

Unified Diff: base/android/java/src/org/chromium/base/PowerMonitor.java

Issue 10959020: SystemMonitor refactoring: move power state monitor into a separate class called PowerMonitor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Use holder class for lazy initialization on Android Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: base/android/java/src/org/chromium/base/PowerMonitor.java
diff --git a/base/android/java/src/org/chromium/base/SystemMonitor.java b/base/android/java/src/org/chromium/base/PowerMonitor.java
similarity index 89%
rename from base/android/java/src/org/chromium/base/SystemMonitor.java
rename to base/android/java/src/org/chromium/base/PowerMonitor.java
index 138ae28d3f6cb236ceef887c0d79a619a86785b8..b7a691e3ce3bccf7363c5248a3ddf617a020b9e5 100644
--- a/base/android/java/src/org/chromium/base/SystemMonitor.java
+++ b/base/android/java/src/org/chromium/base/PowerMonitor.java
@@ -13,12 +13,15 @@ import android.os.Looper;
/**
- * Integrates native SystemMonitor with the java side.
+ * Integrates native PowerMonitor with the java side.
*/
@JNINamespace("base::android")
-public class SystemMonitor implements ActivityStatus.StateListener {
+public class PowerMonitor implements ActivityStatus.StateListener {
private static final long SUSPEND_DELAY_MS = 1 * 60 * 1000; // 1 minute.
- private static SystemMonitor sInstance;
+ private static class LazyHolder {
+ private static final PowerMonitor INSTANCE = new PowerMonitor();
+ }
+ private static PowerMonitor sInstance;
private boolean mIsBatteryPower;
private final Handler mHandler = new Handler(Looper.getMainLooper());
@@ -38,12 +41,12 @@ public class SystemMonitor implements ActivityStatus.StateListener {
// Applications will create this once the JNI side has been fully wired up both sides. For
// tests, we just need native -> java, that is, we don't need to notify java -> native on
// creation.
- sInstance = new SystemMonitor();
+ sInstance = LazyHolder.INSTANCE;
}
public static void create(Context context) {
if (sInstance == null) {
- sInstance = new SystemMonitor();
+ sInstance = LazyHolder.INSTANCE;
ActivityStatus.registerStateListener(sInstance);
IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
Intent batteryStatusIntent = context.registerReceiver(null, ifilter);
@@ -51,7 +54,7 @@ public class SystemMonitor implements ActivityStatus.StateListener {
}
}
- private SystemMonitor() {
+ private PowerMonitor() {
}
public static void onBatteryChargingChanged(Intent intent) {
« no previous file with comments | « base/android/base_jni_registrar.cc ('k') | base/android/java/src/org/chromium/base/PowerStatusReceiver.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698