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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerProcessor.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, 7 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
Index: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerProcessor.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerProcessor.java b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerProcessor.java
new file mode 100644
index 0000000000000000000000000000000000000000..aa7c926ca84aa6c8810193a9076b8df3978fd0c9
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerProcessor.java
@@ -0,0 +1,46 @@
+// 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.Callback;
+import org.chromium.base.VisibleForTesting;
+
+/** Class allowing for mocking out calls to BackgroundSchedulerBridge. */
+public class BackgroundSchedulerProcessor {
+ private static BackgroundSchedulerProcessor sInstance;
+
+ /** Returns a singleton instance. */
+ public static BackgroundSchedulerProcessor getInstance() {
+ if (sInstance == null) {
+ sInstance = new BackgroundSchedulerProcessor();
+ }
+ return sInstance;
+ }
+
+ @VisibleForTesting
+ static void setInstanceForTesting(BackgroundSchedulerProcessor instance) {
+ sInstance = instance;
+ }
+
+ /**
+ * 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.
+ */
+ public boolean startScheduledProcessing(
+ DeviceConditions deviceConditions, Callback<Boolean> callback) {
+ return BackgroundSchedulerBridge.startScheduledProcessing(deviceConditions, callback);
+ }
+
+ /**
+ * Stops processing background requests.
+ * @return Whether processing should be scheduled again at a later time, because there is more
+ * work.
+ */
+ public boolean stopScheduledProcessing() {
+ return BackgroundSchedulerBridge.stopScheduledProcessing();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698