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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java

Issue 2094013003: Uses TriggerConditions in the BackgroundScheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some naming and improved documentation on the backup scheduling Created 4 years, 6 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: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java
index 1c0759ca5e0dcebba77083f71809587568282da5..cd416e25317e5ed7cbe78df2d0041441aa946ab8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java
@@ -213,15 +213,7 @@ public class OfflinePageUtils {
}
public static DeviceConditions getDeviceConditions(Context context) {
- IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
- // Note this is a sticky intent, so we aren't really registering a receiver, just getting
- // the sticky intent. That means that we don't need to unregister the filter later.
- Intent batteryStatus = context.registerReceiver(null, filter);
- if (batteryStatus == null) return null;
-
- return new DeviceConditions(isPowerConnected(batteryStatus),
- batteryPercentage(batteryStatus),
- NetworkChangeNotifier.getInstance().getCurrentConnectionType());
+ return getInstance().getDeviceConditionsImpl(context);
}
/**
@@ -280,6 +272,19 @@ public class OfflinePageUtils {
return OfflinePageBridge.getForProfile(profile);
}
+ /** Returns the current device conditions. May be overridden for testing. */
+ protected DeviceConditions getDeviceConditionsImpl(Context context) {
+ IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
+ // Note this is a sticky intent, so we aren't really registering a receiver, just getting
+ // the sticky intent. That means that we don't need to unregister the filter later.
+ Intent batteryStatus = context.registerReceiver(null, filter);
+ if (batteryStatus == null) return null;
+
+ return new DeviceConditions(isPowerConnected(batteryStatus),
+ batteryPercentage(batteryStatus),
+ NetworkChangeNotifier.getInstance().getCurrentConnectionType());
+ }
+
@VisibleForTesting
static void setInstanceForTesting(OfflinePageUtils instance) {
sInstance = instance;

Powered by Google App Engine
This is Rietveld 408576698