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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerBridge.java

Issue 1928813002: Adds initial JNI bridge code for Background Scheduler implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: C++ style guide change Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c3a5ba036967e4cb5a2901ddb3f25df4c6432bc5
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerBridge.java
@@ -0,0 +1,55 @@
+// 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).
+ // If processing was already active or not able to process for
+ // some other reason, returns false and this calling instance will
+ // not receive a callback.
+ // TODO(dougarnett): consider adding policy check api to let caller
+ // separately determine if not allowed by policy.
+ 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);
+}
+
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698