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

Unified Diff: components/safe_browsing_db/v4_database_unittest.cc

Issue 2103693002: SafeBrowsing PVer4: Send mutable response to the database and the stores (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@02_ReadFromDisk
Patch Set: Created 4 years, 6 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/safe_browsing_db/v4_database_unittest.cc
diff --git a/components/safe_browsing_db/v4_database_unittest.cc b/components/safe_browsing_db/v4_database_unittest.cc
index 0329871674ffd1301843b46e8ea18d685f32703c..83e361f4662f4132ff24b4170eaf2cde7d39bac8 100644
--- a/components/safe_browsing_db/v4_database_unittest.cc
+++ b/components/safe_browsing_db/v4_database_unittest.cc
@@ -128,17 +128,20 @@ class SafeBrowsingV4DatabaseTest : public PlatformTest {
v4_database_ = std::move(v4_database);
}
- void PopulateFakeUpdateResponse(StoreStateMap store_state_map,
- std::vector<ListUpdateResponse>* responses) {
+ std::unique_ptr<ParsedServerResponse> CreateFakeServerResponse(
+ StoreStateMap store_state_map) {
+ std::unique_ptr<ParsedServerResponse> parsed_server_response(
+ new ParsedServerResponse);
Scott Hess - ex-Googler 2016/06/28 03:58:43 Is this your formatting or auto-formatting? Once
Nathan Parker 2016/06/28 19:00:38 I'd say if the auto-formatting is non-optimal, we
vakh (use Gerrit instead) 2016/06/28 21:34:14 I wouldn't call it a bug. It's just something that
vakh (use Gerrit instead) 2016/06/28 21:34:14 $ git cl format
Scott Hess - ex-Googler 2016/06/28 22:22:25 Acknowledged. All hail our formatting overlords.
for (const auto& store_state_iter : store_state_map) {
UpdateListIdentifier identifier = store_state_iter.first;
- ListUpdateResponse list_update_response;
- list_update_response.set_platform_type(identifier.platform_type);
- list_update_response.set_threat_entry_type(identifier.threat_entry_type);
- list_update_response.set_threat_type(identifier.threat_type);
- list_update_response.set_new_client_state(store_state_iter.second);
- responses->push_back(list_update_response);
+ ListUpdateResponse* list_update_response = new ListUpdateResponse;
+ list_update_response->set_platform_type(identifier.platform_type);
+ list_update_response->set_threat_entry_type(identifier.threat_entry_type);
+ list_update_response->set_threat_type(identifier.threat_type);
+ list_update_response->set_new_client_state(store_state_iter.second);
+ parsed_server_response->push_back(base::WrapUnique(list_update_response));
}
+ return parsed_server_response;
}
void VerifyExpectedStoresState(bool expect_new_stores) {
@@ -236,9 +239,10 @@ TEST_F(SafeBrowsingV4DatabaseTest, TestApplyUpdateWithNewStates) {
old_stores_map_[store_iter.first] = store;
}
- std::vector<ListUpdateResponse> update_response;
- PopulateFakeUpdateResponse(expected_store_state_map_, &update_response);
- v4_database_->ApplyUpdate(update_response, callback_db_updated_);
+ std::unique_ptr<ParsedServerResponse> parsed_server_response =
+ CreateFakeServerResponse(expected_store_state_map_);
+ v4_database_->ApplyUpdate(std::move(parsed_server_response),
+ callback_db_updated_);
Scott Hess - ex-Googler 2016/06/28 03:58:43 Would the following work as: v4_database_->Apply
vakh (use Gerrit instead) 2016/06/28 21:34:14 Done.
task_runner_->RunPendingTasks();
base::RunLoop().RunUntilIdle();
@@ -267,9 +271,10 @@ TEST_F(SafeBrowsingV4DatabaseTest, TestApplyUpdateWithNoNewState) {
old_stores_map_[store_iter.first] = store;
}
- std::vector<ListUpdateResponse> update_response;
- PopulateFakeUpdateResponse(expected_store_state_map_, &update_response);
- v4_database_->ApplyUpdate(update_response, callback_db_updated_);
+ std::unique_ptr<ParsedServerResponse> parsed_server_response =
+ CreateFakeServerResponse(expected_store_state_map_);
+ v4_database_->ApplyUpdate(std::move(parsed_server_response),
+ callback_db_updated_);
task_runner_->RunPendingTasks();
base::RunLoop().RunUntilIdle();
@@ -298,8 +303,10 @@ TEST_F(SafeBrowsingV4DatabaseTest, TestApplyUpdateWithEmptyUpdate) {
old_stores_map_[store_iter.first] = store;
}
- std::vector<ListUpdateResponse> update_response;
- v4_database_->ApplyUpdate(update_response, callback_db_updated_);
+ std::unique_ptr<ParsedServerResponse> parsed_server_response(
+ new ParsedServerResponse);
+ v4_database_->ApplyUpdate(std::move(parsed_server_response),
+ callback_db_updated_);
task_runner_->RunPendingTasks();
base::RunLoop().RunUntilIdle();

Powered by Google App Engine
This is Rietveld 408576698