Commit 89245a01 authored by dougarnett's avatar dougarnett Committed by Commit bot

[OfflinePages] Renames StartProcessing to StartScheduledProcessing

This is preparation for exposing new api for immediate procesing.

BUG=672584

Review-Url: https://codereview.chromium.org/2572503002
Cr-Commit-Position: refs/heads/master@{#438213}
parent c6ce8aec
...@@ -81,8 +81,8 @@ public class BackgroundOfflinerTask { ...@@ -81,8 +81,8 @@ public class BackgroundOfflinerTask {
// TODO(petewil): Nothing is holding the Wake Lock. We need some solution to // 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 // 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, // to grab and release a countdown latch, or holding onto the wake lock ourselves,
// or grabbing the wake lock and then starting chrome and running startProcessing // or grabbing the wake lock and then starting chrome and running
// on the UI thread. // startScheduledProcessing on the UI thread.
// TODO(petewil): Decode the TriggerConditions from the bundle. // TODO(petewil): Decode the TriggerConditions from the bundle.
...@@ -100,7 +100,7 @@ public class BackgroundOfflinerTask { ...@@ -100,7 +100,7 @@ public class BackgroundOfflinerTask {
}; };
// Pass the activation on to the bridge to the C++ RequestCoordinator. // Pass the activation on to the bridge to the C++ RequestCoordinator.
if (!mBridge.startProcessing(deviceConditions, callback)) { if (!mBridge.startScheduledProcessing(deviceConditions, callback)) {
// Processing not started currently. Let callback know. // Processing not started currently. Let callback know.
callback.onResult(false); callback.onResult(false);
} }
......
...@@ -24,9 +24,9 @@ public class BackgroundSchedulerBridge { ...@@ -24,9 +24,9 @@ public class BackgroundSchedulerBridge {
// not receive a callback. // not receive a callback.
// TODO(dougarnett): consider adding policy check api to let caller // TODO(dougarnett): consider adding policy check api to let caller
// separately determine if not allowed by policy. // separately determine if not allowed by policy.
public static boolean startProcessing( public static boolean startScheduledProcessing(
DeviceConditions deviceConditions, Callback<Boolean> callback) { DeviceConditions deviceConditions, Callback<Boolean> callback) {
return nativeStartProcessing(deviceConditions.isPowerConnected(), return nativeStartScheduledProcessing(deviceConditions.isPowerConnected(),
deviceConditions.getBatteryPercentage(), deviceConditions.getNetConnectionType(), deviceConditions.getBatteryPercentage(), deviceConditions.getNetConnectionType(),
callback); callback);
} }
...@@ -59,6 +59,6 @@ public class BackgroundSchedulerBridge { ...@@ -59,6 +59,6 @@ public class BackgroundSchedulerBridge {
} }
/** Instructs the native RequestCoordinator to start processing. */ /** Instructs the native RequestCoordinator to start processing. */
private static native boolean nativeStartProcessing(boolean powerConnected, private static native boolean nativeStartScheduledProcessing(boolean powerConnected,
int batteryPercentage, int netConnectionType, Callback<Boolean> callback); int batteryPercentage, int netConnectionType, Callback<Boolean> callback);
} }
...@@ -13,8 +13,9 @@ import org.chromium.chrome.browser.offlinepages.interfaces.BackgroundSchedulerPr ...@@ -13,8 +13,9 @@ import org.chromium.chrome.browser.offlinepages.interfaces.BackgroundSchedulerPr
*/ */
public class BackgroundSchedulerProcessorImpl implements BackgroundSchedulerProcessor { public class BackgroundSchedulerProcessorImpl implements BackgroundSchedulerProcessor {
@Override @Override
public boolean startProcessing(DeviceConditions deviceConditions, Callback<Boolean> callback) { public boolean startScheduledProcessing(
BackgroundSchedulerBridge.startProcessing(deviceConditions, callback); DeviceConditions deviceConditions, Callback<Boolean> callback) {
BackgroundSchedulerBridge.startScheduledProcessing(deviceConditions, callback);
return true; return true;
} }
......
...@@ -18,5 +18,5 @@ public interface BackgroundSchedulerProcessor { ...@@ -18,5 +18,5 @@ public interface BackgroundSchedulerProcessor {
* terminated). If processing was already active or not able to process for some other reason, * 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. * returns false and this calling instance will not receive a callback.
*/ */
boolean startProcessing(DeviceConditions deviceConditions, Callback<Boolean> callback); boolean startScheduledProcessing(DeviceConditions deviceConditions, Callback<Boolean> callback);
} }
...@@ -20,6 +20,16 @@ import android.os.Bundle; ...@@ -20,6 +20,16 @@ import android.os.Bundle;
import com.google.android.gms.gcm.GcmNetworkManager; import com.google.android.gms.gcm.GcmNetworkManager;
import com.google.android.gms.gcm.Task; import com.google.android.gms.gcm.Task;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.internal.ShadowExtractor;
import org.chromium.base.ActivityState; import org.chromium.base.ActivityState;
import org.chromium.base.ApplicationStatus; import org.chromium.base.ApplicationStatus;
import org.chromium.base.BaseChromiumApplication; import org.chromium.base.BaseChromiumApplication;
...@@ -30,15 +40,6 @@ import org.chromium.base.metrics.RecordHistogram; ...@@ -30,15 +40,6 @@ import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.chrome.browser.ChromeBackgroundServiceWaiter; import org.chromium.chrome.browser.ChromeBackgroundServiceWaiter;
import org.chromium.net.ConnectionType; import org.chromium.net.ConnectionType;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.internal.ShadowExtractor;
/** /**
* Unit tests for BackgroundOfflinerTask. * Unit tests for BackgroundOfflinerTask.
...@@ -115,7 +116,7 @@ public class BackgroundOfflinerTaskTest { ...@@ -115,7 +116,7 @@ public class BackgroundOfflinerTaskTest {
ChromeBackgroundServiceWaiter waiter = new ChromeBackgroundServiceWaiter(1000); ChromeBackgroundServiceWaiter waiter = new ChromeBackgroundServiceWaiter(1000);
task.processBackgroundRequests(mTaskExtras, mDeviceConditions, waiter); task.processBackgroundRequests(mTaskExtras, mDeviceConditions, waiter);
// Check with ShadowBackgroundBackgroundSchedulerProcessor that it started processing. // Check with BackgroundSchedulerProcessor that it started processing.
assertTrue(mStubBackgroundSchedulerProcessor.getDidStartProcessing()); assertTrue(mStubBackgroundSchedulerProcessor.getDidStartProcessing());
assertSame(mDeviceConditions, mStubBackgroundSchedulerProcessor.getDeviceConditions()); assertSame(mDeviceConditions, mStubBackgroundSchedulerProcessor.getDeviceConditions());
...@@ -132,10 +133,10 @@ public class BackgroundOfflinerTaskTest { ...@@ -132,10 +133,10 @@ public class BackgroundOfflinerTaskTest {
ChromeBackgroundServiceWaiter waiter = new ChromeBackgroundServiceWaiter(1000); ChromeBackgroundServiceWaiter waiter = new ChromeBackgroundServiceWaiter(1000);
task.processBackgroundRequests(mTaskExtras, mDeviceConditions, waiter); task.processBackgroundRequests(mTaskExtras, mDeviceConditions, waiter);
// Check with ShadowBackgroundBackgroundSchedulerProcessor that it did not start. // Check with BackgroundSchedulerProcessor that it did not start.
assertFalse(mStubBackgroundSchedulerProcessor.getDidStartProcessing()); assertFalse(mStubBackgroundSchedulerProcessor.getDidStartProcessing());
// The waiter should not block if startProcessing returned false. // The waiter should not block if startScheduledProcessing returned false.
waiter.startWaiting(); waiter.startWaiting();
} }
...@@ -154,7 +155,7 @@ public class BackgroundOfflinerTaskTest { ...@@ -154,7 +155,7 @@ public class BackgroundOfflinerTaskTest {
assertEquals(mTriggerConditions, assertEquals(mTriggerConditions,
TaskExtrasPacker.unpackTriggerConditionsFromBundle(gcmTask.getExtras())); TaskExtrasPacker.unpackTriggerConditionsFromBundle(gcmTask.getExtras()));
// Check with ShadowBackgroundBackgroundSchedulerProcessor that startProcessing got called. // Check with BackgroundSchedulerProcessor that startScheduledProcessing got called.
assertTrue(mStubBackgroundSchedulerProcessor.getDidStartProcessing()); assertTrue(mStubBackgroundSchedulerProcessor.getDidStartProcessing());
assertSame(mDeviceConditions, mStubBackgroundSchedulerProcessor.getDeviceConditions()); assertSame(mDeviceConditions, mStubBackgroundSchedulerProcessor.getDeviceConditions());
} }
...@@ -178,7 +179,7 @@ public class BackgroundOfflinerTaskTest { ...@@ -178,7 +179,7 @@ public class BackgroundOfflinerTaskTest {
assertEquals(mTriggerConditions, assertEquals(mTriggerConditions,
TaskExtrasPacker.unpackTriggerConditionsFromBundle(gcmTask.getExtras())); TaskExtrasPacker.unpackTriggerConditionsFromBundle(gcmTask.getExtras()));
// Check that startProcessing was NOT called. // Check that startScheduledProcessing was NOT called.
assertFalse(mStubBackgroundSchedulerProcessor.getDidStartProcessing()); assertFalse(mStubBackgroundSchedulerProcessor.getDidStartProcessing());
// Now verify low battery level but with power connected will start processing. // Now verify low battery level but with power connected will start processing.
...@@ -212,7 +213,7 @@ public class BackgroundOfflinerTaskTest { ...@@ -212,7 +213,7 @@ public class BackgroundOfflinerTaskTest {
assertEquals(mTriggerConditions, assertEquals(mTriggerConditions,
TaskExtrasPacker.unpackTriggerConditionsFromBundle(gcmTask.getExtras())); TaskExtrasPacker.unpackTriggerConditionsFromBundle(gcmTask.getExtras()));
// Check that startProcessing was NOT called. // Check that startScheduledProcessing was NOT called.
assertFalse(mStubBackgroundSchedulerProcessor.getDidStartProcessing()); assertFalse(mStubBackgroundSchedulerProcessor.getDidStartProcessing());
// Now verify will start processing when Activity is stopped. // Now verify will start processing when Activity is stopped.
......
...@@ -33,7 +33,8 @@ public class StubBackgroundSchedulerProcessor implements BackgroundSchedulerProc ...@@ -33,7 +33,8 @@ public class StubBackgroundSchedulerProcessor implements BackgroundSchedulerProc
} }
@Override @Override
public boolean startProcessing(DeviceConditions deviceConditions, Callback<Boolean> callback) { public boolean startScheduledProcessing(
DeviceConditions deviceConditions, Callback<Boolean> callback) {
if (mFailToStart) { if (mFailToStart) {
return false; return false;
} }
......
...@@ -30,18 +30,19 @@ void ProcessingDoneCallback( ...@@ -30,18 +30,19 @@ void ProcessingDoneCallback(
} // namespace } // namespace
// JNI call to start request processing. // JNI call to start request processing in scheduled mode.
static jboolean StartProcessing(JNIEnv* env, static jboolean StartScheduledProcessing(
const JavaParamRef<jclass>& jcaller, JNIEnv* env,
const jboolean j_power_connected, const JavaParamRef<jclass>& jcaller,
const jint j_battery_percentage, const jboolean j_power_connected,
const jint j_net_connection_type, const jint j_battery_percentage,
const JavaParamRef<jobject>& j_callback_obj) { const jint j_net_connection_type,
const JavaParamRef<jobject>& j_callback_obj) {
ScopedJavaGlobalRef<jobject> j_callback_ref; ScopedJavaGlobalRef<jobject> j_callback_ref;
j_callback_ref.Reset(env, j_callback_obj); j_callback_ref.Reset(env, j_callback_obj);
// Lookup/create RequestCoordinator KeyedService and call StartProcessing on // Lookup/create RequestCoordinator KeyedService and call
// it with bound j_callback_obj. // StartScheduledProcessing on it with bound j_callback_obj.
Profile* profile = ProfileManager::GetLastUsedProfile(); Profile* profile = ProfileManager::GetLastUsedProfile();
RequestCoordinator* coordinator = RequestCoordinator* coordinator =
RequestCoordinatorFactory::GetInstance()-> RequestCoordinatorFactory::GetInstance()->
...@@ -51,7 +52,7 @@ static jboolean StartProcessing(JNIEnv* env, ...@@ -51,7 +52,7 @@ static jboolean StartProcessing(JNIEnv* env,
j_power_connected, j_battery_percentage, j_power_connected, j_battery_percentage,
static_cast<net::NetworkChangeNotifier::ConnectionType>( static_cast<net::NetworkChangeNotifier::ConnectionType>(
j_net_connection_type)); j_net_connection_type));
return coordinator->StartProcessing( return coordinator->StartScheduledProcessing(
device_conditions, base::Bind(&ProcessingDoneCallback, j_callback_ref)); device_conditions, base::Bind(&ProcessingDoneCallback, j_callback_ref));
} }
......
...@@ -38,8 +38,8 @@ void GetAllRequestsDone( ...@@ -38,8 +38,8 @@ void GetAllRequestsDone(
// TODO(romax) Maybe get current real condition. // TODO(romax) Maybe get current real condition.
DeviceConditions device_conditions( DeviceConditions device_conditions(
true, 0, net::NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI); true, 0, net::NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI);
coordinator->StartProcessing(device_conditions, coordinator->StartScheduledProcessing(device_conditions,
base::Bind(&ProcessingDoneCallback)); base::Bind(&ProcessingDoneCallback));
} }
} }
......
...@@ -295,7 +295,7 @@ bool OfflinePageEvaluationBridge::PushRequestProcessing( ...@@ -295,7 +295,7 @@ bool OfflinePageEvaluationBridge::PushRequestProcessing(
net::NetworkChangeNotifier::ConnectionType connection = net::NetworkChangeNotifier::ConnectionType connection =
net::NetworkChangeNotifier::GetConnectionType(); net::NetworkChangeNotifier::GetConnectionType();
DeviceConditions device_conditions(false, 0, connection); DeviceConditions device_conditions(false, 0, connection);
return request_coordinator_->StartProcessing( return request_coordinator_->StartScheduledProcessing(
device_conditions, base::Bind(&OnPushRequestsDone, j_callback_ref)); device_conditions, base::Bind(&OnPushRequestsDone, j_callback_ref));
} }
......
...@@ -509,7 +509,7 @@ void RequestCoordinator::HandleWatchdogTimeout() { ...@@ -509,7 +509,7 @@ void RequestCoordinator::HandleWatchdogTimeout() {
// Returns true if the caller should expect a callback, false otherwise. For // Returns true if the caller should expect a callback, false otherwise. For
// instance, this would return false if a request is already in progress. // instance, this would return false if a request is already in progress.
bool RequestCoordinator::StartProcessing( bool RequestCoordinator::StartScheduledProcessing(
const DeviceConditions& device_conditions, const DeviceConditions& device_conditions,
const base::Callback<void(bool)>& callback) { const base::Callback<void(bool)>& callback) {
DVLOG(2) << "Scheduled " << __func__; DVLOG(2) << "Scheduled " << __func__;
......
...@@ -103,11 +103,12 @@ class RequestCoordinator : public KeyedService, ...@@ -103,11 +103,12 @@ class RequestCoordinator : public KeyedService,
// Get all save page request items in the callback. // Get all save page request items in the callback.
void GetAllRequests(const GetRequestsCallback& callback); void GetAllRequests(const GetRequestsCallback& callback);
// Starts processing of one or more queued save page later requests. // Starts processing of one or more queued save page later requests
// in scheduled background mode.
// Returns whether processing was started and that caller should expect // Returns whether processing was started and that caller should expect
// a callback. If processing was already active, returns false. // a callback. If processing was already active, returns false.
bool StartProcessing(const DeviceConditions& device_conditions, bool StartScheduledProcessing(const DeviceConditions& device_conditions,
const base::Callback<void(bool)>& callback); const base::Callback<void(bool)>& callback);
// Stops the current request processing if active. This is a way for // Stops the current request processing if active. This is a way for
// caller to abort processing; otherwise, processing will complete on // caller to abort processing; otherwise, processing will complete on
...@@ -179,7 +180,7 @@ class RequestCoordinator : public KeyedService, ...@@ -179,7 +180,7 @@ class RequestCoordinator : public KeyedService,
bool is_starting() { return is_starting_; } bool is_starting() { return is_starting_; }
// Tracks whether the last offlining attempt got canceled. This is reset by // Tracks whether the last offlining attempt got canceled. This is reset by
// the next StartProcessing() call. // the next call to start processing.
bool is_canceled() { bool is_canceled() {
return processing_state_ == ProcessingWindowState::STOPPED; return processing_state_ == ProcessingWindowState::STOPPED;
} }
......
...@@ -397,9 +397,9 @@ SavePageRequest RequestCoordinatorTest::AddRequest2() { ...@@ -397,9 +397,9 @@ SavePageRequest RequestCoordinatorTest::AddRequest2() {
return request2; return request2;
} }
TEST_F(RequestCoordinatorTest, StartProcessingWithNoRequests) { TEST_F(RequestCoordinatorTest, StartScheduledProcessingWithNoRequests) {
EXPECT_TRUE(coordinator()->StartProcessing(device_conditions(), EXPECT_TRUE(coordinator()->StartScheduledProcessing(device_conditions(),
immediate_callback())); immediate_callback()));
PumpLoop(); PumpLoop();
EXPECT_TRUE(immediate_schedule_callback_called()); EXPECT_TRUE(immediate_schedule_callback_called());
...@@ -415,7 +415,7 @@ TEST_F(RequestCoordinatorTest, StartProcessingWithNoRequests) { ...@@ -415,7 +415,7 @@ TEST_F(RequestCoordinatorTest, StartProcessingWithNoRequests) {
} }
} }
TEST_F(RequestCoordinatorTest, StartProcessingWithRequestInProgress) { TEST_F(RequestCoordinatorTest, StartScheduledProcessingWithRequestInProgress) {
// Start processing for this request. // Start processing for this request.
EXPECT_NE(coordinator()->SavePageLater( EXPECT_NE(coordinator()->SavePageLater(
kUrl1, kClientId1, kUserRequested, kUrl1, kClientId1, kUserRequested,
...@@ -427,8 +427,8 @@ TEST_F(RequestCoordinatorTest, StartProcessingWithRequestInProgress) { ...@@ -427,8 +427,8 @@ TEST_F(RequestCoordinatorTest, StartProcessingWithRequestInProgress) {
EnableOfflinerCallback(false); EnableOfflinerCallback(false);
// Sending the request to the offliner should make it busy. // Sending the request to the offliner should make it busy.
EXPECT_TRUE(coordinator()->StartProcessing(device_conditions(), EXPECT_TRUE(coordinator()->StartScheduledProcessing(device_conditions(),
immediate_callback())); immediate_callback()));
PumpLoop(); PumpLoop();
EXPECT_TRUE(is_busy()); EXPECT_TRUE(is_busy());
...@@ -436,8 +436,8 @@ TEST_F(RequestCoordinatorTest, StartProcessingWithRequestInProgress) { ...@@ -436,8 +436,8 @@ TEST_F(RequestCoordinatorTest, StartProcessingWithRequestInProgress) {
EXPECT_FALSE(immediate_schedule_callback_called()); EXPECT_FALSE(immediate_schedule_callback_called());
// Now trying to start processing on another request should return false. // Now trying to start processing on another request should return false.
EXPECT_FALSE(coordinator()->StartProcessing(device_conditions(), EXPECT_FALSE(coordinator()->StartScheduledProcessing(device_conditions(),
immediate_callback())); immediate_callback()));
} }
TEST_F(RequestCoordinatorTest, SavePageLater) { TEST_F(RequestCoordinatorTest, SavePageLater) {
...@@ -748,7 +748,8 @@ TEST_F(RequestCoordinatorTest, OfflinerDonePrerenderingCancel) { ...@@ -748,7 +748,8 @@ TEST_F(RequestCoordinatorTest, OfflinerDonePrerenderingCancel) {
// If one item completes, and there are no more user requeted items left, // If one item completes, and there are no more user requeted items left,
// we should make a scheduler entry for a non-user requested item. // we should make a scheduler entry for a non-user requested item.
TEST_F(RequestCoordinatorTest, RequestNotPickedDisabledItemsRemain) { TEST_F(RequestCoordinatorTest, RequestNotPickedDisabledItemsRemain) {
coordinator()->StartProcessing(device_conditions(), immediate_callback()); coordinator()->StartScheduledProcessing(device_conditions(),
immediate_callback());
EXPECT_TRUE(is_starting()); EXPECT_TRUE(is_starting());
// Call RequestNotPicked, simulating a request on the disabled list. // Call RequestNotPicked, simulating a request on the disabled list.
...@@ -768,7 +769,8 @@ TEST_F(RequestCoordinatorTest, RequestNotPickedDisabledItemsRemain) { ...@@ -768,7 +769,8 @@ TEST_F(RequestCoordinatorTest, RequestNotPickedDisabledItemsRemain) {
// If one item completes, and there are no more user requeted items left, // If one item completes, and there are no more user requeted items left,
// we should make a scheduler entry for a non-user requested item. // we should make a scheduler entry for a non-user requested item.
TEST_F(RequestCoordinatorTest, RequestNotPickedNonUserRequestedItemsRemain) { TEST_F(RequestCoordinatorTest, RequestNotPickedNonUserRequestedItemsRemain) {
coordinator()->StartProcessing(device_conditions(), immediate_callback()); coordinator()->StartScheduledProcessing(device_conditions(),
immediate_callback());
EXPECT_TRUE(is_starting()); EXPECT_TRUE(is_starting());
// Call RequestNotPicked, and make sure we pick schedule a task for non user // Call RequestNotPicked, and make sure we pick schedule a task for non user
...@@ -824,14 +826,14 @@ TEST_F(RequestCoordinatorTest, SchedulerGetsLeastRestrictiveConditions) { ...@@ -824,14 +826,14 @@ TEST_F(RequestCoordinatorTest, SchedulerGetsLeastRestrictiveConditions) {
coordinator()->policy()->UnmeteredNetworkRequired(kUserRequested)); coordinator()->policy()->UnmeteredNetworkRequired(kUserRequested));
} }
TEST_F(RequestCoordinatorTest, StartProcessingWithLoadingDisabled) { TEST_F(RequestCoordinatorTest, StartScheduledProcessingWithLoadingDisabled) {
// Add a request to the queue, wait for callbacks to finish. // Add a request to the queue, wait for callbacks to finish.
AddRequest1(); AddRequest1();
PumpLoop(); PumpLoop();
DisableLoading(); DisableLoading();
EXPECT_TRUE(coordinator()->StartProcessing(device_conditions(), EXPECT_TRUE(coordinator()->StartScheduledProcessing(device_conditions(),
immediate_callback())); immediate_callback()));
// Let the async callbacks in the request coordinator run. // Let the async callbacks in the request coordinator run.
PumpLoop(); PumpLoop();
...@@ -842,14 +844,15 @@ TEST_F(RequestCoordinatorTest, StartProcessingWithLoadingDisabled) { ...@@ -842,14 +844,15 @@ TEST_F(RequestCoordinatorTest, StartProcessingWithLoadingDisabled) {
} }
// This tests a StopProcessing call before we have actually started the // This tests a StopProcessing call before we have actually started the
// prerenderer. // offliner.
TEST_F(RequestCoordinatorTest, StartProcessingThenStopProcessingImmediately) { TEST_F(RequestCoordinatorTest,
StartScheduledProcessingThenStopProcessingImmediately) {
// Add a request to the queue, wait for callbacks to finish. // Add a request to the queue, wait for callbacks to finish.
AddRequest1(); AddRequest1();
PumpLoop(); PumpLoop();
EXPECT_TRUE(coordinator()->StartProcessing(device_conditions(), EXPECT_TRUE(coordinator()->StartScheduledProcessing(device_conditions(),
immediate_callback())); immediate_callback()));
EXPECT_TRUE(is_starting()); EXPECT_TRUE(is_starting());
// Now, quick, before it can do much (we haven't called PumpLoop), cancel it. // Now, quick, before it can do much (we haven't called PumpLoop), cancel it.
...@@ -871,7 +874,8 @@ TEST_F(RequestCoordinatorTest, StartProcessingThenStopProcessingImmediately) { ...@@ -871,7 +874,8 @@ TEST_F(RequestCoordinatorTest, StartProcessingThenStopProcessingImmediately) {
} }
// This tests a StopProcessing call after the prerenderer has been started. // This tests a StopProcessing call after the prerenderer has been started.
TEST_F(RequestCoordinatorTest, StartProcessingThenStopProcessingLater) { TEST_F(RequestCoordinatorTest,
StartScheduledProcessingThenStopProcessingLater) {
// Add a request to the queue, wait for callbacks to finish. // Add a request to the queue, wait for callbacks to finish.
AddRequest1(); AddRequest1();
PumpLoop(); PumpLoop();
...@@ -879,8 +883,8 @@ TEST_F(RequestCoordinatorTest, StartProcessingThenStopProcessingLater) { ...@@ -879,8 +883,8 @@ TEST_F(RequestCoordinatorTest, StartProcessingThenStopProcessingLater) {
// Ensure the start processing request stops before the completion callback. // Ensure the start processing request stops before the completion callback.
EnableOfflinerCallback(false); EnableOfflinerCallback(false);
EXPECT_TRUE(coordinator()->StartProcessing(device_conditions(), EXPECT_TRUE(coordinator()->StartScheduledProcessing(device_conditions(),
immediate_callback())); immediate_callback()));
EXPECT_TRUE(is_starting()); EXPECT_TRUE(is_starting());
// Let all the async parts of the start processing pipeline run to completion. // Let all the async parts of the start processing pipeline run to completion.
...@@ -930,8 +934,8 @@ TEST_F(RequestCoordinatorTest, RemoveInflightRequest) { ...@@ -930,8 +934,8 @@ TEST_F(RequestCoordinatorTest, RemoveInflightRequest) {
// Ensure the start processing request stops before the completion callback. // Ensure the start processing request stops before the completion callback.
EnableOfflinerCallback(false); EnableOfflinerCallback(false);
EXPECT_TRUE(coordinator()->StartProcessing(device_conditions(), EXPECT_TRUE(coordinator()->StartScheduledProcessing(device_conditions(),
immediate_callback())); immediate_callback()));
// Let all the async parts of the start processing pipeline run to completion. // Let all the async parts of the start processing pipeline run to completion.
PumpLoop(); PumpLoop();
...@@ -1016,8 +1020,8 @@ TEST_F(RequestCoordinatorTest, WatchdogTimeoutForScheduledProcessing) { ...@@ -1016,8 +1020,8 @@ TEST_F(RequestCoordinatorTest, WatchdogTimeoutForScheduledProcessing) {
EnableOfflinerCallback(false); EnableOfflinerCallback(false);
// Sending the request to the offliner. // Sending the request to the offliner.
EXPECT_TRUE( EXPECT_TRUE(coordinator()->StartScheduledProcessing(device_conditions(),
coordinator()->StartProcessing(device_conditions(), waiting_callback())); waiting_callback()));
PumpLoop(); PumpLoop();
// Advance the mock clock far enough to cause a watchdog timeout // Advance the mock clock far enough to cause a watchdog timeout
...@@ -1090,8 +1094,8 @@ TEST_F(RequestCoordinatorTest, TimeBudgetExceeded) { ...@@ -1090,8 +1094,8 @@ TEST_F(RequestCoordinatorTest, TimeBudgetExceeded) {
PumpLoop(); PumpLoop();
// Sending the request to the offliner. // Sending the request to the offliner.
EXPECT_TRUE( EXPECT_TRUE(coordinator()->StartScheduledProcessing(device_conditions(),
coordinator()->StartProcessing(device_conditions(), waiting_callback())); waiting_callback()));
PumpLoop(); PumpLoop();
// Advance the mock clock far enough to exceed our time budget. // Advance the mock clock far enough to exceed our time budget.
...@@ -1118,12 +1122,12 @@ TEST_F(RequestCoordinatorTest, TryNextRequestWithNoNetwork) { ...@@ -1118,12 +1122,12 @@ TEST_F(RequestCoordinatorTest, TryNextRequestWithNoNetwork) {
AddRequest2(); AddRequest2();
PumpLoop(); PumpLoop();
// Set up for the call to StartProcessing. // Set up for the call to StartScheduledProcessing.
EnableOfflinerCallback(false); EnableOfflinerCallback(false);
// Sending the request to the offliner. // Sending the request to the offliner.
EXPECT_TRUE( EXPECT_TRUE(coordinator()->StartScheduledProcessing(device_conditions(),
coordinator()->StartProcessing(device_conditions(), waiting_callback())); waiting_callback()));
PumpLoop(); PumpLoop();
EXPECT_TRUE(coordinator()->is_busy()); EXPECT_TRUE(coordinator()->is_busy());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment