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

Unified Diff: components/safe_browsing_db/v4_local_database_manager_unittest.cc

Issue 2616653002: Have a list of pending checks instead of pending clients (Closed)
Patch Set: git rebase manually! ugh. Created 3 years, 11 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/safe_browsing_db/v4_local_database_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/safe_browsing_db/v4_local_database_manager_unittest.cc
diff --git a/components/safe_browsing_db/v4_local_database_manager_unittest.cc b/components/safe_browsing_db/v4_local_database_manager_unittest.cc
index acf25b7a9b74c32f0fa06125e3b3b5f7f0726a75..958fb2da0b25528106aa62d16e6f91fa2e4ce97e 100644
--- a/components/safe_browsing_db/v4_local_database_manager_unittest.cc
+++ b/components/safe_browsing_db/v4_local_database_manager_unittest.cc
@@ -641,6 +641,39 @@ TEST_F(V4LocalDatabaseManagerTest, TestMatchModuleWhitelist) {
v4_local_database_manager_));
}
+// This verifies the fix for race in http://crbug.com/660293
+TEST_F(V4LocalDatabaseManagerTest, TestCheckBrowseUrlWithSameClientAndCancel) {
+ ScopedFakeGetHashProtocolManagerFactory pin;
+ // Reset the database manager so it picks up the replacement protocol manager.
+ ResetLocalDatabaseManager();
+ WaitForTasksOnTaskRunner();
+
+ StoreAndHashPrefixes store_and_hash_prefixes;
+ store_and_hash_prefixes.emplace_back(GetUrlMalwareId(),
+ HashPrefix("sن\340\t\006_"));
+ ReplaceV4Database(store_and_hash_prefixes);
+
+ GURL first_url("http://example.com/a");
+ GURL second_url("http://example.com/");
+ TestClient client(SB_THREAT_TYPE_SAFE, first_url);
+ // The fake database returns a matched hash prefix.
+ EXPECT_FALSE(v4_local_database_manager_->CheckBrowseUrl(first_url, &client));
+
+ // That check gets queued. Now, let's cancel the check. After this, we should
+ // not receive a call for |OnCheckBrowseUrlResult| with |first_url|.
+ v4_local_database_manager_->CancelCheck(&client);
+
+ // Now, re-use that client but for |second_url|.
+ client.expected_url = second_url;
+ EXPECT_FALSE(v4_local_database_manager_->CheckBrowseUrl(second_url, &client));
+
+ // Wait for PerformFullHashCheck to complete.
+ WaitForTasksOnTaskRunner();
+ // |result_received_| is true only if OnCheckBrowseUrlResult gets called with
+ // the |url| equal to |expected_url|, which is |second_url| in this test.
+ EXPECT_TRUE(client.result_received_);
+}
+
// TODO(nparker): Add tests for
// CheckDownloadUrl()
// CheckExtensionIDs()
« no previous file with comments | « components/safe_browsing_db/v4_local_database_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698