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

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

Issue 2317893002: [Offline Pages] Close race condition of multiple StartProcessing callers. (Closed)
Patch Set: Pete feedback - clear starting flag in deadbeat timeout case Created 4 years, 3 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/junit/src/org/chromium/chrome/browser/offlinepages/StubBackgroundSchedulerProcessor.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/StubBackgroundSchedulerProcessor.java b/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/StubBackgroundSchedulerProcessor.java
index eeab851d169eae31db32ee8e6f157bfc3297cb30..b5b48af0d122557b380cf7169082460bb7bff130 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/StubBackgroundSchedulerProcessor.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/StubBackgroundSchedulerProcessor.java
@@ -11,21 +11,36 @@ import org.chromium.chrome.browser.offlinepages.interfaces.BackgroundSchedulerPr
* Custom stub for our own BackgroundSchedulerRequestProcessor.
*/
public class StubBackgroundSchedulerProcessor implements BackgroundSchedulerProcessor {
- private boolean mStartProcessingCalled;
+ private boolean mFailToStart;
+ private boolean mDidStartProcessing;
Pete Williamson 2016/09/07 00:16:31 Should these two variables get initialized to fals
dougarnett 2016/09/07 00:41:29 Not doing this for members defaults got pounded in
private DeviceConditions mDeviceConditions;
+ private Callback<Boolean> mCallback;
- public boolean getStartProcessingCalled() {
- return mStartProcessingCalled;
+ public void setFailToStart(boolean failToStart) {
+ mFailToStart = failToStart;
+ }
+
+ public boolean getDidStartProcessing() {
+ return mDidStartProcessing;
}
public DeviceConditions getDeviceConditions() {
return mDeviceConditions;
}
+ public void callback() {
+ mCallback.onResult(true);
+ }
+
@Override
public boolean startProcessing(DeviceConditions deviceConditions, Callback<Boolean> callback) {
- mStartProcessingCalled = true;
+ if (mFailToStart) {
+ return false;
+ }
+
+ mDidStartProcessing = true;
mDeviceConditions = deviceConditions;
+ mCallback = callback;
return true;
}
}

Powered by Google App Engine
This is Rietveld 408576698