Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerBridge.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerBridge.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dc6e0cec2407258540701b569cf892add8ac4a75 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerBridge.java |
| @@ -0,0 +1,52 @@ |
| +// 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 org.chromium.base.annotations.CalledByNative; |
| +import org.chromium.base.annotations.JNINamespace; |
| +import org.chromium.chrome.browser.profiles.Profile; |
| + |
| +/** |
| + * Provides Java scheduling support from native offlining code as |
| + * well as JNI interface to tell native code to start processing |
| + * queued requests. |
| + */ |
| +@JNINamespace("offline_pages::android") |
| +public class BackgroundSchedulerBridge { |
| + |
| + /** |
| + * Callback used to determine when request processing is done. |
| + */ |
| + public interface ProcessingDoneCallback { |
| + @CalledByNative("ProcessingDoneCallback") |
| + void onProcessingDone(boolean result); |
| + } |
| + |
| + // Starts processing of one or more queued background requests. |
| + // Returns whether processing was started and that caller should |
| + // expect a callback (once processing has completed or terminated).i |
|
fgorski
2016/04/29 04:50:41
there might be a typo at the end.
dougarnett
2016/04/29 15:59:07
Done.
|
| + // If processing was already active, returns false and this calling |
|
fgorski
2016/04/29 04:50:41
would that be the only reason to not start the pro
dougarnett
2016/04/29 15:59:07
Opened up to any undefined reason not accepted and
|
| + // instance will not receive a callback. |
| + public static boolean startProcessing( |
| + Profile profile, ProcessingDoneCallback callback) { |
| + return nativeStartProcessing(profile, callback); |
| + } |
| + |
| + @CalledByNative |
| + private static void schedule() { |
| + // TODO(dougarnett): call GcmNetworkManager to schedule for |
| + // OfflinePageUtils.TASK_TAG. |
| + } |
| + |
| + @CalledByNative |
| + private static void unschedule() { |
| + // TODO(dougarnett): call GcmNetworkManager to unschedule for |
| + // OfflinePageUtils.TASK_TAG. |
| + } |
| + |
| + private static native boolean nativeStartProcessing( |
| + Profile profile, ProcessingDoneCallback callback); |
| +} |
| + |