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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/TaskExtrasPacker.java

Issue 2830843002: [Offline pages] Updates to background scheduling to use BTS (Closed)
Patch Set: Fixing the crash on NCN not being initialized Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.offlinepages; 5 package org.chromium.chrome.browser.offlinepages;
6 6
7 import android.os.Bundle; 7 import android.os.Bundle;
8 8
9 import org.chromium.chrome.browser.ChromeBackgroundService;
10
11 /** 9 /**
12 * Class to put our custom task information into the task bundle. 10 * Class to put our custom task information into the task bundle.
13 */ 11 */
14 public class TaskExtrasPacker { 12 public class TaskExtrasPacker {
15 /** Bundle key for the timestamp in milliseconds when the request started. * / 13 /** Bundle key for the timestamp in milliseconds when the request started. * /
16 public static final String SCHEDULED_TIME_TAG = "ScheduleTime"; 14 public static final String SCHEDULED_TIME_TAG = "ScheduleTime";
17 15
18 // Trigger condition tags. 16 // Trigger condition tags.
19 private static final String POWER_CONNECTED_TAG = "PowerConnected"; 17 private static final String POWER_CONNECTED_TAG = "PowerConnected";
20 private static final String BATTERY_PERCENTAGE_TAG = "BatteryPercentage"; 18 private static final String BATTERY_PERCENTAGE_TAG = "BatteryPercentage";
21 private static final String UNMETERED_NETWORK_TAG = "UnmeteredNetwork"; 19 private static final String UNMETERED_NETWORK_TAG = "UnmeteredNetwork";
22 20
23 /** Puts requirement to hold a wakelock in the bundle. */
24 public static void packHoldWakelock(Bundle bundle) {
25 bundle.putBoolean(ChromeBackgroundService.HOLD_WAKELOCK, true);
26 }
27
28 /** Puts current time into the input bundle. */ 21 /** Puts current time into the input bundle. */
29 public static void packTimeInBundle(Bundle bundle) { 22 public static void packTimeInBundle(Bundle bundle) {
30 bundle.putLong(SCHEDULED_TIME_TAG, System.currentTimeMillis()); 23 bundle.putLong(SCHEDULED_TIME_TAG, System.currentTimeMillis());
31 } 24 }
32 25
33 /** Extracts the time we put into the bundle. */ 26 /** Extracts the time we put into the bundle. */
34 public static long unpackTimeFromBundle(Bundle bundle) { 27 public static long unpackTimeFromBundle(Bundle bundle) {
35 return bundle.getLong(SCHEDULED_TIME_TAG); 28 return bundle.getLong(SCHEDULED_TIME_TAG);
36 } 29 }
37 30
38 /** Puts trigger conditions into the input bundle. */ 31 /** Puts trigger conditions into the input bundle. */
39 public static void packTriggerConditionsInBundle(Bundle bundle, TriggerCondi tions conditions) { 32 public static void packTriggerConditionsInBundle(Bundle bundle, TriggerCondi tions conditions) {
40 bundle.putBoolean(POWER_CONNECTED_TAG, conditions.requirePowerConnected( )); 33 bundle.putBoolean(POWER_CONNECTED_TAG, conditions.requirePowerConnected( ));
41 bundle.putInt(BATTERY_PERCENTAGE_TAG, conditions.getMinimumBatteryPercen tage()); 34 bundle.putInt(BATTERY_PERCENTAGE_TAG, conditions.getMinimumBatteryPercen tage());
42 bundle.putBoolean(UNMETERED_NETWORK_TAG, conditions.requireUnmeteredNetw ork()); 35 bundle.putBoolean(UNMETERED_NETWORK_TAG, conditions.requireUnmeteredNetw ork());
43 } 36 }
44 37
45 /** Extracts the trigger conditions we put into the bundle. */ 38 /** Extracts the trigger conditions we put into the bundle. */
46 public static TriggerConditions unpackTriggerConditionsFromBundle(Bundle bun dle) { 39 public static TriggerConditions unpackTriggerConditionsFromBundle(Bundle bun dle) {
47 boolean requirePowerConnected = bundle.getBoolean(POWER_CONNECTED_TAG, t rue); 40 boolean requirePowerConnected = bundle.getBoolean(POWER_CONNECTED_TAG, t rue);
48 int minimumBatteryPercentage = bundle.getInt(BATTERY_PERCENTAGE_TAG, 100 ); 41 int minimumBatteryPercentage = bundle.getInt(BATTERY_PERCENTAGE_TAG, 100 );
49 boolean requireUnmeteredNetwork = bundle.getBoolean(UNMETERED_NETWORK_TA G, true); 42 boolean requireUnmeteredNetwork = bundle.getBoolean(UNMETERED_NETWORK_TA G, true);
50 return new TriggerConditions( 43 return new TriggerConditions(
51 requirePowerConnected, minimumBatteryPercentage, requireUnmetere dNetwork); 44 requirePowerConnected, minimumBatteryPercentage, requireUnmetere dNetwork);
52 } 45 }
53 } 46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698