| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/safe_browsing_db/v4_update_protocol_manager.h" | 5 #include "components/safe_browsing_db/v4_update_protocol_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 return V4UpdateProtocolManager::Create( | 69 return V4UpdateProtocolManager::Create( |
| 70 NULL, config, current_list_states, | 70 NULL, config, current_list_states, |
| 71 base::Bind(&V4UpdateProtocolManagerTest::ValidateGetUpdatesResults, | 71 base::Bind(&V4UpdateProtocolManagerTest::ValidateGetUpdatesResults, |
| 72 base::Unretained(this), expected_lurs)); | 72 base::Unretained(this), expected_lurs)); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void SetupCurrentListStates( | 75 void SetupCurrentListStates( |
| 76 base::hash_map<UpdateListIdentifier, std::string>* current_list_states) { | 76 base::hash_map<UpdateListIdentifier, std::string>* current_list_states) { |
| 77 UpdateListIdentifier list_identifier; | 77 UpdateListIdentifier list_identifier; |
| 78 list_identifier.platform_type = WINDOWS_PLATFORM; | 78 list_identifier.platform_type = WINDOWS_PLATFORM; |
| 79 list_identifier.threat_entry_type = URL_EXPRESSION; | 79 list_identifier.threat_entry_type = URL; |
| 80 list_identifier.threat_type = MALWARE_THREAT; | 80 list_identifier.threat_type = MALWARE_THREAT; |
| 81 current_list_states->insert({list_identifier, "initial_state_1"}); | 81 current_list_states->insert({list_identifier, "initial_state_1"}); |
| 82 | 82 |
| 83 list_identifier.platform_type = WINDOWS_PLATFORM; | 83 list_identifier.platform_type = WINDOWS_PLATFORM; |
| 84 list_identifier.threat_entry_type = URL_EXPRESSION; | 84 list_identifier.threat_entry_type = URL; |
| 85 list_identifier.threat_type = UNWANTED_SOFTWARE; | 85 list_identifier.threat_type = UNWANTED_SOFTWARE; |
| 86 current_list_states->insert({list_identifier, "initial_state_2"}); | 86 current_list_states->insert({list_identifier, "initial_state_2"}); |
| 87 | 87 |
| 88 list_identifier.platform_type = WINDOWS_PLATFORM; | 88 list_identifier.platform_type = WINDOWS_PLATFORM; |
| 89 list_identifier.threat_entry_type = BINARY_DIGEST; | 89 list_identifier.threat_entry_type = BINARY_DIGEST; |
| 90 list_identifier.threat_type = MALWARE_THREAT; | 90 list_identifier.threat_type = MALWARE_THREAT; |
| 91 current_list_states->insert({list_identifier, "initial_state_3"}); | 91 current_list_states->insert({list_identifier, "initial_state_3"}); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void SetupExpectedListUpdateResponse( | 94 void SetupExpectedListUpdateResponse( |
| 95 std::vector<ListUpdateResponse>* expected_lurs) { | 95 std::vector<ListUpdateResponse>* expected_lurs) { |
| 96 ListUpdateResponse lur; | 96 ListUpdateResponse lur; |
| 97 lur.set_platform_type(WINDOWS_PLATFORM); | 97 lur.set_platform_type(WINDOWS_PLATFORM); |
| 98 lur.set_response_type(ListUpdateResponse::PARTIAL_UPDATE); | 98 lur.set_response_type(ListUpdateResponse::PARTIAL_UPDATE); |
| 99 lur.set_threat_entry_type(URL_EXPRESSION); | 99 lur.set_threat_entry_type(URL); |
| 100 lur.set_threat_type(MALWARE_THREAT); | 100 lur.set_threat_type(MALWARE_THREAT); |
| 101 lur.set_new_client_state("new_state_1"); | 101 lur.set_new_client_state("new_state_1"); |
| 102 expected_lurs->push_back(lur); | 102 expected_lurs->push_back(lur); |
| 103 | 103 |
| 104 lur.set_platform_type(WINDOWS_PLATFORM); | 104 lur.set_platform_type(WINDOWS_PLATFORM); |
| 105 lur.set_response_type(ListUpdateResponse::PARTIAL_UPDATE); | 105 lur.set_response_type(ListUpdateResponse::PARTIAL_UPDATE); |
| 106 lur.set_threat_entry_type(URL_EXPRESSION); | 106 lur.set_threat_entry_type(URL); |
| 107 lur.set_threat_type(UNWANTED_SOFTWARE); | 107 lur.set_threat_type(UNWANTED_SOFTWARE); |
| 108 lur.set_new_client_state("new_state_2"); | 108 lur.set_new_client_state("new_state_2"); |
| 109 expected_lurs->push_back(lur); | 109 expected_lurs->push_back(lur); |
| 110 | 110 |
| 111 lur.set_platform_type(WINDOWS_PLATFORM); | 111 lur.set_platform_type(WINDOWS_PLATFORM); |
| 112 lur.set_response_type(ListUpdateResponse::FULL_UPDATE); | 112 lur.set_response_type(ListUpdateResponse::FULL_UPDATE); |
| 113 lur.set_threat_entry_type(BINARY_DIGEST); | 113 lur.set_threat_entry_type(BINARY_DIGEST); |
| 114 lur.set_threat_type(MALWARE_THREAT); | 114 lur.set_threat_type(MALWARE_THREAT); |
| 115 lur.set_new_client_state("new_state_3"); | 115 lur.set_new_client_state("new_state_3"); |
| 116 expected_lurs->push_back(lur); | 116 expected_lurs->push_back(lur); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 fetcher->SetResponseString(GetExpectedV4UpdateResponse(expected_lurs)); | 292 fetcher->SetResponseString(GetExpectedV4UpdateResponse(expected_lurs)); |
| 293 fetcher->delegate()->OnURLFetchComplete(fetcher); | 293 fetcher->delegate()->OnURLFetchComplete(fetcher); |
| 294 | 294 |
| 295 // No error, back off multiplier is unchanged. | 295 // No error, back off multiplier is unchanged. |
| 296 EXPECT_EQ(0ul, pm->update_error_count_); | 296 EXPECT_EQ(0ul, pm->update_error_count_); |
| 297 EXPECT_EQ(1ul, pm->update_back_off_mult_); | 297 EXPECT_EQ(1ul, pm->update_back_off_mult_); |
| 298 EXPECT_TRUE(pm->IsUpdateScheduled()); | 298 EXPECT_TRUE(pm->IsUpdateScheduled()); |
| 299 } | 299 } |
| 300 | 300 |
| 301 } // namespace safe_browsing | 301 } // namespace safe_browsing |
| OLD | NEW |