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

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

Issue 2073993003: Performs saftey schedule of another task in BackgroundOfflinerTask in case processing killed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundScheduler.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.content.Context; 7 import android.content.Context;
8 import android.os.Bundle; 8 import android.os.Bundle;
9 9
10 import org.chromium.base.Callback; 10 import org.chromium.base.Callback;
11 import org.chromium.base.Log; 11 import org.chromium.base.Log;
12 import org.chromium.base.VisibleForTesting; 12 import org.chromium.base.VisibleForTesting;
13 import org.chromium.chrome.browser.ChromeBackgroundServiceWaiter; 13 import org.chromium.chrome.browser.ChromeBackgroundServiceWaiter;
14 import org.chromium.chrome.browser.offlinepages.interfaces.BackgroundSchedulerPr ocessor; 14 import org.chromium.chrome.browser.offlinepages.interfaces.BackgroundSchedulerPr ocessor;
15 15
16 /** 16 /**
17 * Handles servicing of background offlining requests coming via the GcmNetworkM anager. 17 * Handles servicing of background offlining requests coming via the GcmNetworkM anager.
18 */ 18 */
19 public class BackgroundOfflinerTask { 19 public class BackgroundOfflinerTask {
20 private static final String TAG = "BGOfflinerTask"; 20 private static final String TAG = "BGOfflinerTask";
21 private static final long DEFER_START_SECONDS = 5 * 60;
21 22
22 public BackgroundOfflinerTask(BackgroundSchedulerProcessor bridge) { 23 public BackgroundOfflinerTask(BackgroundSchedulerProcessor bridge) {
23 mBridge = bridge; 24 mBridge = bridge;
24 } 25 }
25 26
26 private final BackgroundSchedulerProcessor mBridge; 27 private final BackgroundSchedulerProcessor mBridge;
27 28
28 /** 29 /**
29 * Triggers processing of background offlining requests. This is called whe n 30 * Triggers processing of background offlining requests. This is called whe n
30 * system conditions are appropriate for background offlining, typically fro m the 31 * system conditions are appropriate for background offlining, typically fro m the
31 * GcmTaskService onRunTask() method. In response, we will start the 32 * GcmTaskService onRunTask() method. In response, we will start the
32 * task processing by passing the call along to the C++ RequestCoordinator. 33 * task processing by passing the call along to the C++ RequestCoordinator.
33 * Also starts UMA collection. 34 * Also starts UMA collection.
34 * 35 *
35 * @returns true for success 36 * @returns true for success
36 */ 37 */
37 public boolean startBackgroundRequests(Context context, Bundle bundle, 38 public boolean startBackgroundRequests(Context context, Bundle bundle,
38 ChromeBackgroundServiceWaiter waiter) { 39 ChromeBackgroundServiceWaiter waiter) {
40 // Set up backup scheduled task in case processing is killed before Requ estCoordinator
41 // has a chance to reschedule base on remaining work.
42 BackgroundScheduler.schedule(context, DEFER_START_SECONDS);
43
44 // Now initiate processing.
39 processBackgroundRequests(bundle, OfflinePageUtils.getDeviceConditions(c ontext), waiter); 45 processBackgroundRequests(bundle, OfflinePageUtils.getDeviceConditions(c ontext), waiter);
40 46
41 // Gather UMA data to measure how often the user's machine is amenable t o background 47 // Gather UMA data to measure how often the user's machine is amenable t o background
42 // loading when we wake to do a task. 48 // loading when we wake to do a task.
43 long taskScheduledTimeMillis = TaskExtrasPacker.unpackTimeFromBundle(bun dle); 49 long taskScheduledTimeMillis = TaskExtrasPacker.unpackTimeFromBundle(bun dle);
44 OfflinePageUtils.recordWakeupUMA(context, taskScheduledTimeMillis); 50 OfflinePageUtils.recordWakeupUMA(context, taskScheduledTimeMillis);
45 51
46 return true; 52 return true;
47 } 53 }
48 54
(...skipping 24 matching lines...) Expand all
73 // Release the wake lock. 79 // Release the wake lock.
74 Log.d(TAG, "onProcessingDone"); 80 Log.d(TAG, "onProcessingDone");
75 waiter.onWaitDone(); 81 waiter.onWaitDone();
76 } 82 }
77 }; 83 };
78 84
79 // Pass the activation on to the bridge to the C++ RequestCoordinator. 85 // Pass the activation on to the bridge to the C++ RequestCoordinator.
80 mBridge.startProcessing(deviceConditions, callback); 86 mBridge.startProcessing(deviceConditions, callback);
81 } 87 }
82 } 88 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundScheduler.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698