| 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 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 #endif | 10 #endif |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 EXPECT_LE(load_timing_info.proxy_resolve_start, | 154 EXPECT_LE(load_timing_info.proxy_resolve_start, |
| 155 load_timing_info.proxy_resolve_end); | 155 load_timing_info.proxy_resolve_end); |
| 156 EXPECT_LE(load_timing_info.proxy_resolve_end, | 156 EXPECT_LE(load_timing_info.proxy_resolve_end, |
| 157 load_timing_info.send_start); | 157 load_timing_info.send_start); |
| 158 EXPECT_LE(load_timing_info.send_start, load_timing_info.send_end); | 158 EXPECT_LE(load_timing_info.send_start, load_timing_info.send_end); |
| 159 EXPECT_LE(load_timing_info.send_end, load_timing_info.receive_headers_end); | 159 EXPECT_LE(load_timing_info.send_end, load_timing_info.receive_headers_end); |
| 160 } | 160 } |
| 161 | 161 |
| 162 // Tests load timing information in the case of a cache hit, when no cache | 162 // Tests load timing information in the case of a cache hit, when no cache |
| 163 // validation request was sent over the wire. | 163 // validation request was sent over the wire. |
| 164 base::StringPiece TestNetResourceProvider(int key) { |
| 165 return "header"; |
| 166 } |
| 167 |
| 168 void FillBuffer(char* buffer, size_t len) { |
| 169 static bool called = false; |
| 170 if (!called) { |
| 171 called = true; |
| 172 int seed = static_cast<int>(Time::Now().ToInternalValue()); |
| 173 srand(seed); |
| 174 } |
| 175 |
| 176 for (size_t i = 0; i < len; i++) { |
| 177 buffer[i] = static_cast<char>(rand()); |
| 178 if (!buffer[i]) |
| 179 buffer[i] = 'g'; |
| 180 } |
| 181 } |
| 182 |
| 183 #if !defined(OS_IOS) |
| 164 void TestLoadTimingCacheHitNoNetwork( | 184 void TestLoadTimingCacheHitNoNetwork( |
| 165 const net::LoadTimingInfo& load_timing_info) { | 185 const net::LoadTimingInfo& load_timing_info) { |
| 166 EXPECT_FALSE(load_timing_info.socket_reused); | 186 EXPECT_FALSE(load_timing_info.socket_reused); |
| 167 EXPECT_EQ(net::NetLog::Source::kInvalidId, load_timing_info.socket_log_id); | 187 EXPECT_EQ(net::NetLog::Source::kInvalidId, load_timing_info.socket_log_id); |
| 168 | 188 |
| 169 EXPECT_FALSE(load_timing_info.request_start_time.is_null()); | 189 EXPECT_FALSE(load_timing_info.request_start_time.is_null()); |
| 170 EXPECT_FALSE(load_timing_info.request_start.is_null()); | 190 EXPECT_FALSE(load_timing_info.request_start.is_null()); |
| 171 | 191 |
| 172 ExpectConnectTimingHasNoTimes(load_timing_info.connect_timing); | 192 ExpectConnectTimingHasNoTimes(load_timing_info.connect_timing); |
| 173 EXPECT_LE(load_timing_info.request_start, load_timing_info.send_start); | 193 EXPECT_LE(load_timing_info.request_start, load_timing_info.send_start); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 191 | 211 |
| 192 ExpectConnectTimingHasNoTimes(load_timing_info.connect_timing); | 212 ExpectConnectTimingHasNoTimes(load_timing_info.connect_timing); |
| 193 | 213 |
| 194 EXPECT_TRUE(load_timing_info.proxy_resolve_start.is_null()); | 214 EXPECT_TRUE(load_timing_info.proxy_resolve_start.is_null()); |
| 195 EXPECT_TRUE(load_timing_info.proxy_resolve_end.is_null()); | 215 EXPECT_TRUE(load_timing_info.proxy_resolve_end.is_null()); |
| 196 EXPECT_TRUE(load_timing_info.send_start.is_null()); | 216 EXPECT_TRUE(load_timing_info.send_start.is_null()); |
| 197 EXPECT_TRUE(load_timing_info.send_end.is_null()); | 217 EXPECT_TRUE(load_timing_info.send_end.is_null()); |
| 198 EXPECT_TRUE(load_timing_info.receive_headers_end.is_null()); | 218 EXPECT_TRUE(load_timing_info.receive_headers_end.is_null()); |
| 199 } | 219 } |
| 200 | 220 |
| 201 base::StringPiece TestNetResourceProvider(int key) { | |
| 202 return "header"; | |
| 203 } | |
| 204 | |
| 205 // Do a case-insensitive search through |haystack| for |needle|. | 221 // Do a case-insensitive search through |haystack| for |needle|. |
| 206 bool ContainsString(const std::string& haystack, const char* needle) { | 222 bool ContainsString(const std::string& haystack, const char* needle) { |
| 207 std::string::const_iterator it = | 223 std::string::const_iterator it = |
| 208 std::search(haystack.begin(), | 224 std::search(haystack.begin(), |
| 209 haystack.end(), | 225 haystack.end(), |
| 210 needle, | 226 needle, |
| 211 needle + strlen(needle), | 227 needle + strlen(needle), |
| 212 base::CaseInsensitiveCompare<char>()); | 228 base::CaseInsensitiveCompare<char>()); |
| 213 return it != haystack.end(); | 229 return it != haystack.end(); |
| 214 } | 230 } |
| 215 | 231 |
| 216 void FillBuffer(char* buffer, size_t len) { | |
| 217 static bool called = false; | |
| 218 if (!called) { | |
| 219 called = true; | |
| 220 int seed = static_cast<int>(Time::Now().ToInternalValue()); | |
| 221 srand(seed); | |
| 222 } | |
| 223 | |
| 224 for (size_t i = 0; i < len; i++) { | |
| 225 buffer[i] = static_cast<char>(rand()); | |
| 226 if (!buffer[i]) | |
| 227 buffer[i] = 'g'; | |
| 228 } | |
| 229 } | |
| 230 | |
| 231 UploadDataStream* CreateSimpleUploadData(const char* data) { | 232 UploadDataStream* CreateSimpleUploadData(const char* data) { |
| 232 scoped_ptr<UploadElementReader> reader( | 233 scoped_ptr<UploadElementReader> reader( |
| 233 new UploadBytesElementReader(data, strlen(data))); | 234 new UploadBytesElementReader(data, strlen(data))); |
| 234 return UploadDataStream::CreateWithReader(reader.Pass(), 0); | 235 return UploadDataStream::CreateWithReader(reader.Pass(), 0); |
| 235 } | 236 } |
| 236 | 237 |
| 237 // Verify that the SSLInfo of a successful SSL connection has valid values. | 238 // Verify that the SSLInfo of a successful SSL connection has valid values. |
| 238 void CheckSSLInfo(const SSLInfo& ssl_info) { | 239 void CheckSSLInfo(const SSLInfo& ssl_info) { |
| 239 // Allow ChromeFrame fake SSLInfo to get through. | 240 // Allow ChromeFrame fake SSLInfo to get through. |
| 240 if (ssl_info.cert.get() && | 241 if (ssl_info.cert.get() && |
| (...skipping 29 matching lines...) Expand all Loading... |
| 270 if (size != b.size()) | 271 if (size != b.size()) |
| 271 return false; | 272 return false; |
| 272 | 273 |
| 273 for (size_t i = 0; i < size; ++i) { | 274 for (size_t i = 0; i < size; ++i) { |
| 274 if (!a[i].Equals(b[i])) | 275 if (!a[i].Equals(b[i])) |
| 275 return false; | 276 return false; |
| 276 } | 277 } |
| 277 | 278 |
| 278 return true; | 279 return true; |
| 279 } | 280 } |
| 281 #endif // !defined(OS_IOS) |
| 280 | 282 |
| 281 // A network delegate that allows the user to choose a subset of request stages | 283 // A network delegate that allows the user to choose a subset of request stages |
| 282 // to block in. When blocking, the delegate can do one of the following: | 284 // to block in. When blocking, the delegate can do one of the following: |
| 283 // * synchronously return a pre-specified error code, or | 285 // * synchronously return a pre-specified error code, or |
| 284 // * asynchronously return that value via an automatically called callback, | 286 // * asynchronously return that value via an automatically called callback, |
| 285 // or | 287 // or |
| 286 // * block and wait for the user to do a callback. | 288 // * block and wait for the user to do a callback. |
| 287 // Additionally, the user may also specify a redirect URL -- then each request | 289 // Additionally, the user may also specify a redirect URL -- then each request |
| 288 // with the current URL different from the redirect target will be redirected | 290 // with the current URL different from the redirect target will be redirected |
| 289 // to that target, in the on-before-URL-request stage, independent of whether | 291 // to that target, in the on-before-URL-request stage, independent of whether |
| (...skipping 6991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7281 | 7283 |
| 7282 EXPECT_FALSE(r.is_pending()); | 7284 EXPECT_FALSE(r.is_pending()); |
| 7283 EXPECT_EQ(1, d->response_started_count()); | 7285 EXPECT_EQ(1, d->response_started_count()); |
| 7284 EXPECT_FALSE(d->received_data_before_response()); | 7286 EXPECT_FALSE(d->received_data_before_response()); |
| 7285 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 7287 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
| 7286 } | 7288 } |
| 7287 } | 7289 } |
| 7288 #endif // !defined(DISABLE_FTP_SUPPORT) | 7290 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 7289 | 7291 |
| 7290 } // namespace net | 7292 } // namespace net |
| OLD | NEW |