| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 5 |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/test/test_simple_task_runner.h" | 9 #include "base/test/test_simple_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 const char kUrlPrefix[] = "https://prefix.com/foo"; | 31 const char kUrlPrefix[] = "https://prefix.com/foo"; |
| 32 const char kBackupConnectUrlPrefix[] = "https://alt1-prefix.com/foo"; | 32 const char kBackupConnectUrlPrefix[] = "https://alt1-prefix.com/foo"; |
| 33 const char kBackupHttpUrlPrefix[] = "https://alt2-prefix.com/foo"; | 33 const char kBackupHttpUrlPrefix[] = "https://alt2-prefix.com/foo"; |
| 34 const char kBackupNetworkUrlPrefix[] = "https://alt3-prefix.com/foo"; | 34 const char kBackupNetworkUrlPrefix[] = "https://alt3-prefix.com/foo"; |
| 35 const char kClient[] = "unittest"; | 35 const char kClient[] = "unittest"; |
| 36 const char kAppVer[] = "1.0"; | 36 const char kAppVer[] = "1.0"; |
| 37 const char kAdditionalQuery[] = "additional_query"; | 37 const char kAdditionalQuery[] = "additional_query"; |
| 38 const char kUrlSuffix[] = "&ext=0"; | 38 const char kUrlSuffix[] = "&ext=0"; |
| 39 | 39 |
| 40 #if defined(OS_ANDROID) | |
| 41 const char kDefaultPhishList[] = "goog-mobilephish-shavar"; | |
| 42 const char kDefaultMalwareList[] = "goog-mobilemalware-shavar"; | |
| 43 #else | |
| 44 const char kDefaultPhishList[] = "goog-phish-shavar"; | 40 const char kDefaultPhishList[] = "goog-phish-shavar"; |
| 45 const char kDefaultMalwareList[] = "goog-malware-shavar"; | 41 const char kDefaultMalwareList[] = "goog-malware-shavar"; |
| 46 #endif | |
| 47 | 42 |
| 48 // Add-prefix chunk with single prefix. | 43 // Add-prefix chunk with single prefix. |
| 49 const char kRawChunkPayload1[] = { | 44 const char kRawChunkPayload1[] = { |
| 50 '\0', '\0', '\0', '\x08', // 32-bit payload length in network byte order. | 45 '\0', '\0', '\0', '\x08', // 32-bit payload length in network byte order. |
| 51 '\x08', // field 1, wire format varint | 46 '\x08', // field 1, wire format varint |
| 52 '\x03', // chunk_number varint 3 | 47 '\x03', // chunk_number varint 3 |
| 53 '\x22', // field 4, wire format length-delimited | 48 '\x22', // field 4, wire format length-delimited |
| 54 '\x04', // varint 4 length | 49 '\x04', // varint 4 length |
| 55 'a', 'b', 'c', 'd' // 4-byte prefix | 50 'a', 'b', 'c', 'd' // 4-byte prefix |
| 56 }; | 51 }; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 84 | 79 |
| 85 scoped_ptr<SafeBrowsingProtocolManager> CreateProtocolManager( | 80 scoped_ptr<SafeBrowsingProtocolManager> CreateProtocolManager( |
| 86 SafeBrowsingProtocolManagerDelegate* delegate) { | 81 SafeBrowsingProtocolManagerDelegate* delegate) { |
| 87 SafeBrowsingProtocolConfig config; | 82 SafeBrowsingProtocolConfig config; |
| 88 config.client_name = kClient; | 83 config.client_name = kClient; |
| 89 config.url_prefix = kUrlPrefix; | 84 config.url_prefix = kUrlPrefix; |
| 90 config.backup_connect_error_url_prefix = kBackupConnectUrlPrefix; | 85 config.backup_connect_error_url_prefix = kBackupConnectUrlPrefix; |
| 91 config.backup_http_error_url_prefix = kBackupHttpUrlPrefix; | 86 config.backup_http_error_url_prefix = kBackupHttpUrlPrefix; |
| 92 config.backup_network_error_url_prefix = kBackupNetworkUrlPrefix; | 87 config.backup_network_error_url_prefix = kBackupNetworkUrlPrefix; |
| 93 config.version = kAppVer; | 88 config.version = kAppVer; |
| 94 #if defined(OS_ANDROID) | |
| 95 config.disable_connection_check = true; | |
| 96 #endif | |
| 97 return scoped_ptr<SafeBrowsingProtocolManager>( | 89 return scoped_ptr<SafeBrowsingProtocolManager>( |
| 98 SafeBrowsingProtocolManager::Create(delegate, NULL, config)); | 90 SafeBrowsingProtocolManager::Create(delegate, NULL, config)); |
| 99 } | 91 } |
| 100 | 92 |
| 101 void ValidateUpdateFetcherRequest(const net::TestURLFetcher* url_fetcher, | 93 void ValidateUpdateFetcherRequest(const net::TestURLFetcher* url_fetcher, |
| 102 const std::string& expected_prefix, | 94 const std::string& expected_prefix, |
| 103 const std::string& expected_suffix) { | 95 const std::string& expected_suffix) { |
| 104 ASSERT_TRUE(url_fetcher); | 96 ASSERT_TRUE(url_fetcher); |
| 105 EXPECT_EQ(net::LOAD_DISABLE_CACHE, url_fetcher->GetLoadFlags()); | 97 EXPECT_EQ(net::LOAD_DISABLE_CACHE, url_fetcher->GetLoadFlags()); |
| 106 | 98 |
| (...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 second_chunk_url_fetcher->delegate()->OnURLFetchComplete( | 1124 second_chunk_url_fetcher->delegate()->OnURLFetchComplete( |
| 1133 second_chunk_url_fetcher); | 1125 second_chunk_url_fetcher); |
| 1134 | 1126 |
| 1135 EXPECT_FALSE(pm->IsUpdateScheduled()); | 1127 EXPECT_FALSE(pm->IsUpdateScheduled()); |
| 1136 | 1128 |
| 1137 // Invoke the AddChunksCallback to finish the update. | 1129 // Invoke the AddChunksCallback to finish the update. |
| 1138 runner->RunPendingTasks(); | 1130 runner->RunPendingTasks(); |
| 1139 | 1131 |
| 1140 EXPECT_TRUE(pm->IsUpdateScheduled()); | 1132 EXPECT_TRUE(pm->IsUpdateScheduled()); |
| 1141 } | 1133 } |
| OLD | NEW |