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

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

Issue 2325563003: [Offline Pages] Close race condition of multiple StartProcessing callers. (Closed)
Patch Set: 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
« no previous file with comments | « components/offline_pages/background/request_coordinator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 25c6311e1034c0437c628875ebec7a272b1969b7..633f47968f42a32b3a3d5b30fcad6b894c838047 100644
--- a/components/offline_pages/background/request_coordinator_unittest.cc
+++ b/components/offline_pages/background/request_coordinator_unittest.cc
@@ -190,6 +190,8 @@ class RequestCoordinatorTest
return coordinator_->is_busy();
}
+ bool is_starting() { return coordinator_->is_starting(); }
+
// Empty callback function.
void EmptyCallbackFunction(bool result) {
}
@@ -601,6 +603,7 @@ 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();
@@ -608,6 +611,8 @@ TEST_F(RequestCoordinatorTest, StartProcessingThenStopProcessingImmediately) {
// Let the async callbacks in the request coordinator run.
PumpLoop();
+ EXPECT_FALSE(is_starting());
+
// OfflinerDoneCallback will not end up getting called with status SAVED,
// since we cancelled the event before it called offliner_->LoadAndSave().
EXPECT_EQ(Offliner::RequestStatus::REQUEST_COORDINATOR_CANCELED,
@@ -638,12 +643,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();
@@ -738,6 +745,7 @@ TEST_F(RequestCoordinatorTest, WatchdogTimeout) {
WaitForCallback();
PumpLoop();
+ EXPECT_FALSE(is_starting());
EXPECT_TRUE(OfflinerWasCanceled());
EXPECT_EQ(Offliner::RequestStatus::REQUEST_COORDINATOR_CANCELED,
last_offlining_status());
« no previous file with comments | « components/offline_pages/background/request_coordinator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698