| 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);
|
| + }
|
| }
|
|
|