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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/TaskExtrasPacker.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/TaskExtrasPacker.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/TaskExtrasPacker.java b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/TaskExtrasPacker.java
index d6dbf6d5a09022e7516593aa2930dc95c3f81f1b..563f62a6ecaf343a62f8ee5390e478fcdf373296 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/TaskExtrasPacker.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/TaskExtrasPacker.java
@@ -15,6 +15,11 @@ public class TaskExtrasPacker {
/** Bundle key for the timestamp in milliseconds when the request started. */
public static final String SCHEDULED_TIME_TAG = "ScheduleTime";
+ // Trigger condition tags.
+ private static final String POWER_CONNECTED_TAG = "PowerConnected";
+ private static final String BATTERY_PERCENTAGE_TAG = "BatteryPercentage";
+ private static final String UNMETERED_NETWORK_TAG = "UnmeteredNetwork";
+
/** Puts current time into the input bundle. */
public static void packTimeInBundle(Bundle bundle) {
bundle.putLong(SCHEDULED_TIME_TAG, System.currentTimeMillis());
@@ -25,4 +30,20 @@ public class TaskExtrasPacker {
public static long unpackTimeFromBundle(Bundle bundle) {
return bundle.getLong(SCHEDULED_TIME_TAG);
}
+
+ /** Puts trigger conditions into the input bundle. */
+ public static void packTriggerConditionsInBundle(Bundle bundle, TriggerConditions conditions) {
+ bundle.putBoolean(POWER_CONNECTED_TAG, conditions.requirePowerConnected());
+ bundle.putInt(BATTERY_PERCENTAGE_TAG, conditions.getMinimumBatteryPercentage());
+ bundle.putBoolean(UNMETERED_NETWORK_TAG, conditions.requireUnmeteredNetwork());
+ }
+
+ /** Extracts the trigger conditions we put into the bundle. */
+ public static TriggerConditions unpackTriggerConditionsFromBundle(Bundle bundle) {
+ boolean requirePowerConnected = bundle.getBoolean(POWER_CONNECTED_TAG, true);
+ int minimumBatteryPercentage = bundle.getInt(BATTERY_PERCENTAGE_TAG, 100);
+ boolean requireUnmeteredNetwork = bundle.getBoolean(UNMETERED_NETWORK_TAG, true);
+ return new TriggerConditions(
+ requirePowerConnected, minimumBatteryPercentage, requireUnmeteredNetwork);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698