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

Unified Diff: components/offline_pages/background/request_coordinator_unittest.cc

Issue 2317893002: [Offline Pages] Close race condition of multiple StartProcessing callers. (Closed)
Patch Set: Some unittest coverage on new is_starting_ flag 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: components/offline_pages/background/request_coordinator_unittest.cc
diff --git a/components/offline_pages/background/request_coordinator_unittest.cc b/components/offline_pages/background/request_coordinator_unittest.cc
index 61ea62fd0bdac36373e5cb1f3b6348941ab0745a..2abdb680089ab99ad5d917a8cd326d252773bcff 100644
--- a/components/offline_pages/background/request_coordinator_unittest.cc
+++ b/components/offline_pages/background/request_coordinator_unittest.cc
@@ -190,6 +190,10 @@ class RequestCoordinatorTest
return coordinator_->is_busy();
}
+ bool is_starting() {
+ return coordinator_->is_starting();
+ }
+
// Empty callback function.
void EmptyCallbackFunction(bool result) {
}
@@ -597,12 +601,15 @@ TEST_F(RequestCoordinatorTest, RequestNotPickedNonUserRequestedItemsRemain) {
base::Callback<void(bool)> callback = base::Bind(
&RequestCoordinatorTest::EmptyCallbackFunction, base::Unretained(this));
coordinator()->StartProcessing(device_conditions, callback);
+ EXPECT_TRUE(is_starting());
// Call RequestNotPicked, and make sure we pick schedule a task for non user
// requested conditions.
CallRequestNotPicked(true);
PumpLoop();
+ EXPECT_FALSE(is_starting());
+
// The scheduler should have been called to schedule the non-user requested
// task.
SchedulerStub* scheduler_stub =
@@ -671,9 +678,11 @@ TEST_F(RequestCoordinatorTest, StartProcessingThenStopProcessingImmediately) {
&RequestCoordinatorTest::EmptyCallbackFunction,
base::Unretained(this));
EXPECT_TRUE(coordinator()->StartProcessing(device_conditions, callback));
+ EXPECT_TRUE(is_starting());
// Now, quick, before it can do much (we haven't called PumpLoop), cancel it.
coordinator()->StopProcessing();
+ EXPECT_FALSE(is_starting());
// Let the async callbacks in the request coordinator run.
PumpLoop();
@@ -708,12 +717,14 @@ TEST_F(RequestCoordinatorTest, StartProcessingThenStopProcessingLater) {
&RequestCoordinatorTest::EmptyCallbackFunction,
base::Unretained(this));
EXPECT_TRUE(coordinator()->StartProcessing(device_conditions, callback));
+ EXPECT_TRUE(is_starting());
// Let all the async parts of the start processing pipeline run to completion.
PumpLoop();
// Coordinator should now be busy.
EXPECT_TRUE(is_busy());
+ EXPECT_FALSE(is_starting());
// Now we cancel it while the prerenderer is busy.
coordinator()->StopProcessing();

Powered by Google App Engine
This is Rietveld 408576698