Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundTask.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundTask.java b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundTask.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a8e2ec0373714beae648269f015dbce0f2846f6b |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundTask.java |
| @@ -0,0 +1,49 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.offlinepages; |
| + |
| +import android.content.Context; |
| +import android.os.Bundle; |
| + |
| +/** |
| + * Handles servicing of background offlining requests coming via the GcmNetworkManager. |
| + */ |
| +public class BackgroundTask implements BackgroundSchedulerBridge.ProcessingDoneCallback { |
| + private static final String TAG = "BackgroundTask"; |
| + /** |
| + * Triggers processing of background offlining requests. This is called when |
| + * system conditions are appropriate for background offlining, typically from the |
| + * GcmTaskService onRunTask() method. In response, we will start the |
| + * task processing by passing the call along to the C++ RequestCoordinator. |
| + * |
| + * @returns true for success |
| + */ |
| + public boolean processBackgroundRequests(Context context, Bundle bundle) { |
| + // TODO(petewil): Nothing is holding the Wake Lock. We need some solution to |
| + // keep hold of it. Options discussed so far are having a fresh set of functions |
| + // to grab and release a countdown latch, or holding onto the wake lock ourselves, |
| + // or grabbing the wake lock and then starting chrome and running startProcessing |
| + // on the UI thread. |
| + |
| + // TODO(petewil): Decode the TriggerConditions from the bundle. |
| + |
| + // Pass the activation on to the bridge to the C++ RequestCoordinator. |
| + BackgroundSchedulerBridge.startProcessing(context, this); |
|
Bernhard Bauer
2016/05/26 11:17:44
Do you actually need to pass the context to the na
Pete Williamson
2016/05/26 17:02:45
Right, I actually need the profile. I removed the
|
| + |
| + // Gather UMA data to measure how often the user's machine is amenable to background |
| + // loading when we wake to do a task. |
| + OfflinePageUtils.recordWakeupUMA(context); |
| + |
| + return true; |
| + } |
| + |
| + /** |
| + * Callback function which indicates completion of background work. |
| + * @param result - true if work was actually done (used for UMA). |
| + */ |
| + public void onProcessingDone(boolean result) { |
| + |
| + } |
| +} |