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) { |