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

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

Issue 2030773002: Add unit tests for the Background Scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/BackgroundOfflinerTask.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundOfflinerTask.java b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundOfflinerTask.java
index 49dcf107f2addeb5bec95c24737230d627b7ffad..7c60f1263574d16374a2dfdab5c2a8c07eef6483 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundOfflinerTask.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/BackgroundOfflinerTask.java
@@ -7,12 +7,20 @@ package org.chromium.chrome.browser.offlinepages;
import android.content.Context;
import android.os.Bundle;
+import org.chromium.chrome.browser.offlinepages.interfaces.SchedulerBridgeInterface;
+
/**
* Handles servicing of background offlining requests coming via the GcmNetworkManager.
*/
-public class BackgroundOfflinerTask implements BackgroundSchedulerBridge.ProcessingDoneCallback {
+public class BackgroundOfflinerTask implements SchedulerBridgeInterface.ProcessingDoneCallback {
private static final String TAG = "BackgroundTask";
+ public BackgroundOfflinerTask(SchedulerBridgeInterface bridge) {
+ mBridge = bridge;
+ }
+
+ private final SchedulerBridgeInterface mBridge;
+
/**
* Triggers processing of background offlining requests. This is called when
* system conditions are appropriate for background offlining, typically from the
@@ -22,9 +30,8 @@ public class BackgroundOfflinerTask implements BackgroundSchedulerBridge.Process
*
* @returns true for success
*/
- public static boolean startBackgroundRequests(Context context, Bundle bundle) {
- BackgroundOfflinerTask task = new BackgroundOfflinerTask();
- task.processBackgroundRequests(bundle);
+ public boolean startBackgroundRequests(Context context, Bundle bundle) {
+ processBackgroundRequests(bundle);
// Gather UMA data to measure how often the user's machine is amenable to background
// loading when we wake to do a task.
@@ -36,7 +43,9 @@ public class BackgroundOfflinerTask implements BackgroundSchedulerBridge.Process
/**
* Triggers processing of background offlining requests.
*/
- private void processBackgroundRequests(Bundle bundle) {
+ // TODO(petewil): Change back to private when UMA works in the test, and test
dougarnett 2016/06/02 00:14:45 So @VisibleForTesting here then?
Pete Williamson 2016/06/02 00:42:06 Done.
+ // startBackgroundRequests insteasd of this method.
dougarnett 2016/06/02 00:14:45 spellign
Pete Williamson 2016/06/02 00:42:06 Done.
+ public void processBackgroundRequests(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,
@@ -47,7 +56,7 @@ public class BackgroundOfflinerTask implements BackgroundSchedulerBridge.Process
// Pass the activation on to the bridge to the C++ RequestCoordinator.
// Callback will hold onto the reference keeping this instance alive.
- BackgroundSchedulerBridge.startProcessing(this);
+ mBridge.startProcessing(this);
}
/**

Powered by Google App Engine
This is Rietveld 408576698