OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "net/proxy/proxy_resolver_v8_tracing_wrapper.h" | 5 #include "net/proxy/proxy_resolver_v8_tracing_wrapper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 BoundTestNetLog request_log; | 129 BoundTestNetLog request_log; |
130 MockCachingHostResolver host_resolver; | 130 MockCachingHostResolver host_resolver; |
131 MockErrorObserver* error_observer = new MockErrorObserver; | 131 MockErrorObserver* error_observer = new MockErrorObserver; |
132 | 132 |
133 std::unique_ptr<ProxyResolver> resolver = CreateResolver( | 133 std::unique_ptr<ProxyResolver> resolver = CreateResolver( |
134 &log, &host_resolver, base::WrapUnique(error_observer), "simple.js"); | 134 &log, &host_resolver, base::WrapUnique(error_observer), "simple.js"); |
135 | 135 |
136 TestCompletionCallback callback; | 136 TestCompletionCallback callback; |
137 ProxyInfo proxy_info; | 137 ProxyInfo proxy_info; |
138 | 138 |
| 139 std::unique_ptr<ProxyResolver::Request> req; |
139 int rv = | 140 int rv = |
140 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, | 141 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, |
141 callback.callback(), NULL, request_log.bound()); | 142 callback.callback(), &req, request_log.bound()); |
142 | 143 |
143 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 144 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
144 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 145 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
145 | 146 |
146 EXPECT_EQ("foo:99", proxy_info.proxy_server().ToURI()); | 147 EXPECT_EQ("foo:99", proxy_info.proxy_server().ToURI()); |
147 | 148 |
148 EXPECT_EQ(0u, host_resolver.num_resolve()); | 149 EXPECT_EQ(0u, host_resolver.num_resolve()); |
149 | 150 |
150 // There were no errors. | 151 // There were no errors. |
151 EXPECT_EQ("", error_observer->GetOutput()); | 152 EXPECT_EQ("", error_observer->GetOutput()); |
152 | 153 |
153 // Check the NetLogs -- nothing was logged. | 154 // Check the NetLogs -- nothing was logged. |
154 EXPECT_EQ(0u, log.GetSize()); | 155 EXPECT_EQ(0u, log.GetSize()); |
155 EXPECT_EQ(0u, request_log.GetSize()); | 156 EXPECT_EQ(0u, request_log.GetSize()); |
156 } | 157 } |
157 | 158 |
158 TEST_F(ProxyResolverV8TracingWrapperTest, JavascriptError) { | 159 TEST_F(ProxyResolverV8TracingWrapperTest, JavascriptError) { |
159 TestNetLog log; | 160 TestNetLog log; |
160 BoundTestNetLog request_log; | 161 BoundTestNetLog request_log; |
161 MockCachingHostResolver host_resolver; | 162 MockCachingHostResolver host_resolver; |
162 MockErrorObserver* error_observer = new MockErrorObserver; | 163 MockErrorObserver* error_observer = new MockErrorObserver; |
163 | 164 |
164 std::unique_ptr<ProxyResolver> resolver = CreateResolver( | 165 std::unique_ptr<ProxyResolver> resolver = CreateResolver( |
165 &log, &host_resolver, base::WrapUnique(error_observer), "error.js"); | 166 &log, &host_resolver, base::WrapUnique(error_observer), "error.js"); |
166 | 167 |
167 TestCompletionCallback callback; | 168 TestCompletionCallback callback; |
168 ProxyInfo proxy_info; | 169 ProxyInfo proxy_info; |
169 | 170 |
| 171 std::unique_ptr<ProxyResolver::Request> req; |
170 int rv = | 172 int rv = |
171 resolver->GetProxyForURL(GURL("http://throw-an-error/"), &proxy_info, | 173 resolver->GetProxyForURL(GURL("http://throw-an-error/"), &proxy_info, |
172 callback.callback(), NULL, request_log.bound()); | 174 callback.callback(), &req, request_log.bound()); |
173 | 175 |
174 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 176 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
175 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_PAC_SCRIPT_FAILED)); | 177 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_PAC_SCRIPT_FAILED)); |
176 | 178 |
177 EXPECT_EQ(0u, host_resolver.num_resolve()); | 179 EXPECT_EQ(0u, host_resolver.num_resolve()); |
178 | 180 |
179 EXPECT_EQ( | 181 EXPECT_EQ( |
180 "Error: line 5: Uncaught TypeError: Cannot read property 'split' " | 182 "Error: line 5: Uncaught TypeError: Cannot read property 'split' " |
181 "of null\n", | 183 "of null\n", |
182 error_observer->GetOutput()); | 184 error_observer->GetOutput()); |
(...skipping 28 matching lines...) Expand all Loading... |
211 MockCachingHostResolver host_resolver; | 213 MockCachingHostResolver host_resolver; |
212 MockErrorObserver* error_observer = new MockErrorObserver; | 214 MockErrorObserver* error_observer = new MockErrorObserver; |
213 | 215 |
214 std::unique_ptr<ProxyResolver> resolver = | 216 std::unique_ptr<ProxyResolver> resolver = |
215 CreateResolver(&log, &host_resolver, base::WrapUnique(error_observer), | 217 CreateResolver(&log, &host_resolver, base::WrapUnique(error_observer), |
216 "too_many_alerts.js"); | 218 "too_many_alerts.js"); |
217 | 219 |
218 TestCompletionCallback callback; | 220 TestCompletionCallback callback; |
219 ProxyInfo proxy_info; | 221 ProxyInfo proxy_info; |
220 | 222 |
| 223 std::unique_ptr<ProxyResolver::Request> req; |
221 int rv = | 224 int rv = |
222 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, | 225 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, |
223 callback.callback(), NULL, request_log.bound()); | 226 callback.callback(), &req, request_log.bound()); |
224 | 227 |
225 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 228 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
226 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 229 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
227 | 230 |
228 // Iteration1 does a DNS resolve | 231 // Iteration1 does a DNS resolve |
229 // Iteration2 exceeds the alert buffer | 232 // Iteration2 exceeds the alert buffer |
230 // Iteration3 runs in blocking mode and completes | 233 // Iteration3 runs in blocking mode and completes |
231 EXPECT_EQ("foo:3", proxy_info.proxy_server().ToURI()); | 234 EXPECT_EQ("foo:3", proxy_info.proxy_server().ToURI()); |
232 | 235 |
233 EXPECT_EQ(1u, host_resolver.num_resolve()); | 236 EXPECT_EQ(1u, host_resolver.num_resolve()); |
(...skipping 26 matching lines...) Expand all Loading... |
260 MockCachingHostResolver host_resolver; | 263 MockCachingHostResolver host_resolver; |
261 MockErrorObserver* error_observer = new MockErrorObserver; | 264 MockErrorObserver* error_observer = new MockErrorObserver; |
262 | 265 |
263 std::unique_ptr<ProxyResolver> resolver = | 266 std::unique_ptr<ProxyResolver> resolver = |
264 CreateResolver(&log, &host_resolver, base::WrapUnique(error_observer), | 267 CreateResolver(&log, &host_resolver, base::WrapUnique(error_observer), |
265 "too_many_empty_alerts.js"); | 268 "too_many_empty_alerts.js"); |
266 | 269 |
267 TestCompletionCallback callback; | 270 TestCompletionCallback callback; |
268 ProxyInfo proxy_info; | 271 ProxyInfo proxy_info; |
269 | 272 |
| 273 std::unique_ptr<ProxyResolver::Request> req; |
270 int rv = | 274 int rv = |
271 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, | 275 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, |
272 callback.callback(), NULL, request_log.bound()); | 276 callback.callback(), &req, request_log.bound()); |
273 | 277 |
274 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 278 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
275 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 279 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
276 | 280 |
277 EXPECT_EQ("foo:3", proxy_info.proxy_server().ToURI()); | 281 EXPECT_EQ("foo:3", proxy_info.proxy_server().ToURI()); |
278 | 282 |
279 EXPECT_EQ(1u, host_resolver.num_resolve()); | 283 EXPECT_EQ(1u, host_resolver.num_resolve()); |
280 | 284 |
281 // No errors. | 285 // No errors. |
282 EXPECT_EQ("", error_observer->GetOutput()); | 286 EXPECT_EQ("", error_observer->GetOutput()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 host_resolver.rules()->AddRuleForAddressFamily("*", ADDRESS_FAMILY_IPV4, | 322 host_resolver.rules()->AddRuleForAddressFamily("*", ADDRESS_FAMILY_IPV4, |
319 "122.133.144.155"); | 323 "122.133.144.155"); |
320 host_resolver.rules()->AddRule("*", "133.122.100.200"); | 324 host_resolver.rules()->AddRule("*", "133.122.100.200"); |
321 | 325 |
322 std::unique_ptr<ProxyResolver> resolver = CreateResolver( | 326 std::unique_ptr<ProxyResolver> resolver = CreateResolver( |
323 &log, &host_resolver, base::WrapUnique(error_observer), "dns.js"); | 327 &log, &host_resolver, base::WrapUnique(error_observer), "dns.js"); |
324 | 328 |
325 TestCompletionCallback callback; | 329 TestCompletionCallback callback; |
326 ProxyInfo proxy_info; | 330 ProxyInfo proxy_info; |
327 | 331 |
| 332 std::unique_ptr<ProxyResolver::Request> req; |
328 int rv = | 333 int rv = |
329 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, | 334 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, |
330 callback.callback(), NULL, request_log.bound()); | 335 callback.callback(), &req, request_log.bound()); |
331 | 336 |
332 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 337 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
333 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 338 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
334 | 339 |
335 // The test does 13 DNS resolution, however only 7 of them are unique. | 340 // The test does 13 DNS resolution, however only 7 of them are unique. |
336 EXPECT_EQ(7u, host_resolver.num_resolve()); | 341 EXPECT_EQ(7u, host_resolver.num_resolve()); |
337 | 342 |
338 const char* kExpectedResult = | 343 const char* kExpectedResult = |
339 "122.133.144.155-" // myIpAddress() | 344 "122.133.144.155-" // myIpAddress() |
340 "null-" // dnsResolve('') | 345 "null-" // dnsResolve('') |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 host_resolver.rules()->AddRule("foopy", "166.155.144.11"); | 389 host_resolver.rules()->AddRule("foopy", "166.155.144.11"); |
385 host_resolver.rules()->AddRule("*", "122.133.144.155"); | 390 host_resolver.rules()->AddRule("*", "122.133.144.155"); |
386 | 391 |
387 std::unique_ptr<ProxyResolver> resolver = CreateResolver( | 392 std::unique_ptr<ProxyResolver> resolver = CreateResolver( |
388 &log, &host_resolver, base::WrapUnique(error_observer), "simple_dns.js"); | 393 &log, &host_resolver, base::WrapUnique(error_observer), "simple_dns.js"); |
389 | 394 |
390 TestCompletionCallback callback1; | 395 TestCompletionCallback callback1; |
391 TestCompletionCallback callback2; | 396 TestCompletionCallback callback2; |
392 ProxyInfo proxy_info; | 397 ProxyInfo proxy_info; |
393 | 398 |
| 399 std::unique_ptr<ProxyResolver::Request> req; |
394 int rv = | 400 int rv = |
395 resolver->GetProxyForURL(GURL("http://foopy/req1"), &proxy_info, | 401 resolver->GetProxyForURL(GURL("http://foopy/req1"), &proxy_info, |
396 callback1.callback(), NULL, request_log.bound()); | 402 callback1.callback(), &req, request_log.bound()); |
397 | 403 |
398 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 404 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
399 EXPECT_THAT(callback1.WaitForResult(), IsOk()); | 405 EXPECT_THAT(callback1.WaitForResult(), IsOk()); |
400 | 406 |
401 // The test does 2 DNS resolutions. | 407 // The test does 2 DNS resolutions. |
402 EXPECT_EQ(2u, host_resolver.num_resolve()); | 408 EXPECT_EQ(2u, host_resolver.num_resolve()); |
403 | 409 |
404 // The first request took 2 restarts, hence on g_iteration=3. | 410 // The first request took 2 restarts, hence on g_iteration=3. |
405 EXPECT_EQ("166.155.144.11:3", proxy_info.proxy_server().ToURI()); | 411 EXPECT_EQ("166.155.144.11:3", proxy_info.proxy_server().ToURI()); |
406 | 412 |
407 rv = | 413 std::unique_ptr<ProxyResolver::Request> req2; |
408 resolver->GetProxyForURL(GURL("http://foopy/req2"), &proxy_info, | 414 rv = resolver->GetProxyForURL(GURL("http://foopy/req2"), &proxy_info, |
409 callback2.callback(), NULL, request_log.bound()); | 415 callback2.callback(), &req2, |
| 416 request_log.bound()); |
410 | 417 |
411 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 418 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
412 EXPECT_THAT(callback2.WaitForResult(), IsOk()); | 419 EXPECT_THAT(callback2.WaitForResult(), IsOk()); |
413 | 420 |
414 EXPECT_EQ(4u, host_resolver.num_resolve()); | 421 EXPECT_EQ(4u, host_resolver.num_resolve()); |
415 | 422 |
416 // This time no restarts were required, so g_iteration incremented by 1. | 423 // This time no restarts were required, so g_iteration incremented by 1. |
417 EXPECT_EQ("166.155.144.11:4", proxy_info.proxy_server().ToURI()); | 424 EXPECT_EQ("166.155.144.11:4", proxy_info.proxy_server().ToURI()); |
418 | 425 |
419 // No errors. | 426 // No errors. |
(...skipping 16 matching lines...) Expand all Loading... |
436 host_resolver.rules()->AddRule("crazy4", "133.199.111.4"); | 443 host_resolver.rules()->AddRule("crazy4", "133.199.111.4"); |
437 host_resolver.rules()->AddRule("*", "122.133.144.155"); | 444 host_resolver.rules()->AddRule("*", "122.133.144.155"); |
438 | 445 |
439 std::unique_ptr<ProxyResolver> resolver = | 446 std::unique_ptr<ProxyResolver> resolver = |
440 CreateResolver(&log, &host_resolver, base::WrapUnique(error_observer), | 447 CreateResolver(&log, &host_resolver, base::WrapUnique(error_observer), |
441 "global_sideffects1.js"); | 448 "global_sideffects1.js"); |
442 | 449 |
443 TestCompletionCallback callback; | 450 TestCompletionCallback callback; |
444 ProxyInfo proxy_info; | 451 ProxyInfo proxy_info; |
445 | 452 |
| 453 std::unique_ptr<ProxyResolver::Request> req; |
446 int rv = | 454 int rv = |
447 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, | 455 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, |
448 callback.callback(), NULL, request_log.bound()); | 456 callback.callback(), &req, request_log.bound()); |
449 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 457 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
450 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 458 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
451 | 459 |
452 // The script itself only does 2 DNS resolves per execution, however it | 460 // The script itself only does 2 DNS resolves per execution, however it |
453 // constructs the hostname using a global counter which changes on each | 461 // constructs the hostname using a global counter which changes on each |
454 // invocation. | 462 // invocation. |
455 EXPECT_EQ(3u, host_resolver.num_resolve()); | 463 EXPECT_EQ(3u, host_resolver.num_resolve()); |
456 | 464 |
457 EXPECT_EQ("166.155.144.11-133.199.111.4:100", | 465 EXPECT_EQ("166.155.144.11-133.199.111.4:100", |
458 proxy_info.proxy_server().ToURI()); | 466 proxy_info.proxy_server().ToURI()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 host_resolver.rules()->AddRule("host4", "166.155.144.44"); | 499 host_resolver.rules()->AddRule("host4", "166.155.144.44"); |
492 host_resolver.rules()->AddRule("*", "122.133.144.155"); | 500 host_resolver.rules()->AddRule("*", "122.133.144.155"); |
493 | 501 |
494 std::unique_ptr<ProxyResolver> resolver = | 502 std::unique_ptr<ProxyResolver> resolver = |
495 CreateResolver(&log, &host_resolver, base::WrapUnique(error_observer), | 503 CreateResolver(&log, &host_resolver, base::WrapUnique(error_observer), |
496 "global_sideffects2.js"); | 504 "global_sideffects2.js"); |
497 | 505 |
498 TestCompletionCallback callback; | 506 TestCompletionCallback callback; |
499 ProxyInfo proxy_info; | 507 ProxyInfo proxy_info; |
500 | 508 |
| 509 std::unique_ptr<ProxyResolver::Request> req; |
501 int rv = | 510 int rv = |
502 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, | 511 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, |
503 callback.callback(), NULL, request_log.bound()); | 512 callback.callback(), &req, request_log.bound()); |
504 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 513 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
505 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 514 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
506 | 515 |
507 EXPECT_EQ(3u, host_resolver.num_resolve()); | 516 EXPECT_EQ(3u, host_resolver.num_resolve()); |
508 | 517 |
509 EXPECT_EQ("166.155.144.44:100", proxy_info.proxy_server().ToURI()); | 518 EXPECT_EQ("166.155.144.44:100", proxy_info.proxy_server().ToURI()); |
510 | 519 |
511 // No errors. | 520 // No errors. |
512 EXPECT_EQ("", error_observer->GetOutput()); | 521 EXPECT_EQ("", error_observer->GetOutput()); |
513 | 522 |
(...skipping 15 matching lines...) Expand all Loading... |
529 host_resolver.rules()->AddRule("host*", "166.155.144.11"); | 538 host_resolver.rules()->AddRule("host*", "166.155.144.11"); |
530 host_resolver.rules()->AddRule("*", "122.133.144.155"); | 539 host_resolver.rules()->AddRule("*", "122.133.144.155"); |
531 | 540 |
532 std::unique_ptr<ProxyResolver> resolver = | 541 std::unique_ptr<ProxyResolver> resolver = |
533 CreateResolver(&log, &host_resolver, base::WrapUnique(error_observer), | 542 CreateResolver(&log, &host_resolver, base::WrapUnique(error_observer), |
534 "global_sideffects3.js"); | 543 "global_sideffects3.js"); |
535 | 544 |
536 TestCompletionCallback callback; | 545 TestCompletionCallback callback; |
537 ProxyInfo proxy_info; | 546 ProxyInfo proxy_info; |
538 | 547 |
| 548 std::unique_ptr<ProxyResolver::Request> req; |
539 int rv = | 549 int rv = |
540 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, | 550 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, |
541 callback.callback(), NULL, request_log.bound()); | 551 |
| 552 callback.callback(), &req, request_log.bound()); |
542 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 553 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
543 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 554 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
544 | 555 |
545 EXPECT_EQ(20u, host_resolver.num_resolve()); | 556 EXPECT_EQ(20u, host_resolver.num_resolve()); |
546 | 557 |
547 EXPECT_EQ( | 558 EXPECT_EQ( |
548 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" | 559 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" |
549 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" | 560 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" |
550 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" | 561 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" |
551 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" | 562 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" |
(...skipping 22 matching lines...) Expand all Loading... |
574 host_resolver.rules()->AddRule("host*", "166.155.144.11"); | 585 host_resolver.rules()->AddRule("host*", "166.155.144.11"); |
575 host_resolver.rules()->AddRule("*", "122.133.144.155"); | 586 host_resolver.rules()->AddRule("*", "122.133.144.155"); |
576 | 587 |
577 std::unique_ptr<ProxyResolver> resolver = | 588 std::unique_ptr<ProxyResolver> resolver = |
578 CreateResolver(&log, &host_resolver, base::WrapUnique(error_observer), | 589 CreateResolver(&log, &host_resolver, base::WrapUnique(error_observer), |
579 "global_sideffects4.js"); | 590 "global_sideffects4.js"); |
580 | 591 |
581 TestCompletionCallback callback; | 592 TestCompletionCallback callback; |
582 ProxyInfo proxy_info; | 593 ProxyInfo proxy_info; |
583 | 594 |
| 595 std::unique_ptr<ProxyResolver::Request> req; |
584 int rv = | 596 int rv = |
585 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, | 597 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, |
586 callback.callback(), NULL, request_log.bound()); | 598 callback.callback(), &req, request_log.bound()); |
587 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 599 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
588 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 600 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
589 | 601 |
590 EXPECT_EQ(20u, host_resolver.num_resolve()); | 602 EXPECT_EQ(20u, host_resolver.num_resolve()); |
591 | 603 |
592 EXPECT_EQ("null21:34", proxy_info.proxy_server().ToURI()); | 604 EXPECT_EQ("null21:34", proxy_info.proxy_server().ToURI()); |
593 | 605 |
594 // No errors. | 606 // No errors. |
595 EXPECT_EQ("", error_observer->GetOutput()); | 607 EXPECT_EQ("", error_observer->GetOutput()); |
596 | 608 |
(...skipping 21 matching lines...) Expand all Loading... |
618 | 630 |
619 host_resolver.rules()->ClearRules(); | 631 host_resolver.rules()->ClearRules(); |
620 host_resolver.GetHostCache()->clear(); | 632 host_resolver.GetHostCache()->clear(); |
621 | 633 |
622 host_resolver.rules()->AddRule("host1", "145.88.13.3"); | 634 host_resolver.rules()->AddRule("host1", "145.88.13.3"); |
623 host_resolver.rules()->AddRule("host2", "137.89.8.45"); | 635 host_resolver.rules()->AddRule("host2", "137.89.8.45"); |
624 | 636 |
625 TestCompletionCallback callback; | 637 TestCompletionCallback callback; |
626 ProxyInfo proxy_info; | 638 ProxyInfo proxy_info; |
627 | 639 |
| 640 std::unique_ptr<ProxyResolver::Request> req; |
628 int rv = | 641 int rv = |
629 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, | 642 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, |
630 callback.callback(), NULL, request_log.bound()); | 643 callback.callback(), &req, request_log.bound()); |
631 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 644 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
632 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 645 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
633 | 646 |
634 // Fetched host1 and host2 again, since the ones done during initialization | 647 // Fetched host1 and host2 again, since the ones done during initialization |
635 // should not have been cached. | 648 // should not have been cached. |
636 EXPECT_EQ(4u, host_resolver.num_resolve()); | 649 EXPECT_EQ(4u, host_resolver.num_resolve()); |
637 | 650 |
638 EXPECT_EQ("91.13.12.1-91.13.12.2-145.88.13.3-137.89.8.45:99", | 651 EXPECT_EQ("91.13.12.1-91.13.12.2-145.88.13.3-137.89.8.45:99", |
639 proxy_info.proxy_server().ToURI()); | 652 proxy_info.proxy_server().ToURI()); |
640 | 653 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 MockCachingHostResolver host_resolver; | 689 MockCachingHostResolver host_resolver; |
677 MockErrorObserver* error_observer = new MockErrorObserver; | 690 MockErrorObserver* error_observer = new MockErrorObserver; |
678 | 691 |
679 host_resolver.rules()->AddSimulatedFailure("*"); | 692 host_resolver.rules()->AddSimulatedFailure("*"); |
680 | 693 |
681 std::unique_ptr<ProxyResolver> resolver = CreateResolver( | 694 std::unique_ptr<ProxyResolver> resolver = CreateResolver( |
682 nullptr, &host_resolver, base::WrapUnique(error_observer), "dns.js"); | 695 nullptr, &host_resolver, base::WrapUnique(error_observer), "dns.js"); |
683 | 696 |
684 const size_t kNumRequests = 5; | 697 const size_t kNumRequests = 5; |
685 ProxyInfo proxy_info[kNumRequests]; | 698 ProxyInfo proxy_info[kNumRequests]; |
686 ProxyResolver::RequestHandle request[kNumRequests]; | 699 std::unique_ptr<ProxyResolver::Request> request[kNumRequests]; |
687 | 700 |
688 for (size_t i = 0; i < kNumRequests; ++i) { | 701 for (size_t i = 0; i < kNumRequests; ++i) { |
689 int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info[i], | 702 int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info[i], |
690 base::Bind(&CrashCallback), &request[i], | 703 base::Bind(&CrashCallback), &request[i], |
691 NetLogWithSource()); | 704 NetLogWithSource()); |
692 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 705 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
693 } | 706 } |
694 | 707 |
695 for (size_t i = 0; i < kNumRequests; ++i) { | 708 for (size_t i = 0; i < kNumRequests; ++i) { |
696 resolver->CancelRequest(request[i]); | 709 request[i].reset(); |
697 } | 710 } |
698 } | 711 } |
699 | 712 |
700 // Note the execution order for this test can vary. Since multiple | 713 // Note the execution order for this test can vary. Since multiple |
701 // threads are involved, the cancellation may be received a different | 714 // threads are involved, the cancellation may be received a different |
702 // times. | 715 // times. |
703 TEST_F(ProxyResolverV8TracingWrapperTest, CancelSome) { | 716 TEST_F(ProxyResolverV8TracingWrapperTest, CancelSome) { |
704 MockCachingHostResolver host_resolver; | 717 MockCachingHostResolver host_resolver; |
705 MockErrorObserver* error_observer = new MockErrorObserver; | 718 MockErrorObserver* error_observer = new MockErrorObserver; |
706 | 719 |
707 host_resolver.rules()->AddSimulatedFailure("*"); | 720 host_resolver.rules()->AddSimulatedFailure("*"); |
708 | 721 |
709 std::unique_ptr<ProxyResolver> resolver = CreateResolver( | 722 std::unique_ptr<ProxyResolver> resolver = CreateResolver( |
710 nullptr, &host_resolver, base::WrapUnique(error_observer), "dns.js"); | 723 nullptr, &host_resolver, base::WrapUnique(error_observer), "dns.js"); |
711 | 724 |
712 ProxyInfo proxy_info1; | 725 ProxyInfo proxy_info1; |
713 ProxyInfo proxy_info2; | 726 ProxyInfo proxy_info2; |
714 ProxyResolver::RequestHandle request1; | 727 std::unique_ptr<ProxyResolver::Request> request1; |
715 ProxyResolver::RequestHandle request2; | 728 std::unique_ptr<ProxyResolver::Request> request2; |
716 TestCompletionCallback callback; | 729 TestCompletionCallback callback; |
717 | 730 |
718 int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info1, | 731 int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info1, |
719 base::Bind(&CrashCallback), &request1, | 732 base::Bind(&CrashCallback), &request1, |
720 NetLogWithSource()); | 733 NetLogWithSource()); |
721 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 734 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
722 | 735 |
723 rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info2, | 736 rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info2, |
724 callback.callback(), &request2, | 737 callback.callback(), &request2, |
725 NetLogWithSource()); | 738 NetLogWithSource()); |
726 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 739 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
727 | 740 |
728 resolver->CancelRequest(request1); | 741 request1.reset(); |
729 | 742 |
730 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 743 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
731 } | 744 } |
732 | 745 |
733 // Cancel a request after it has finished running on the worker thread, and has | 746 // Cancel a request after it has finished running on the worker thread, and has |
734 // posted a task the completion task back to origin thread. | 747 // posted a task the completion task back to origin thread. |
735 TEST_F(ProxyResolverV8TracingWrapperTest, CancelWhilePendingCompletionTask) { | 748 TEST_F(ProxyResolverV8TracingWrapperTest, CancelWhilePendingCompletionTask) { |
736 MockCachingHostResolver host_resolver; | 749 MockCachingHostResolver host_resolver; |
737 MockErrorObserver* error_observer = new MockErrorObserver; | 750 MockErrorObserver* error_observer = new MockErrorObserver; |
738 | 751 |
739 host_resolver.rules()->AddSimulatedFailure("*"); | 752 host_resolver.rules()->AddSimulatedFailure("*"); |
740 | 753 |
741 std::unique_ptr<ProxyResolver> resolver = CreateResolver( | 754 std::unique_ptr<ProxyResolver> resolver = CreateResolver( |
742 nullptr, &host_resolver, base::WrapUnique(error_observer), "error.js"); | 755 nullptr, &host_resolver, base::WrapUnique(error_observer), "error.js"); |
743 | 756 |
744 ProxyInfo proxy_info1; | 757 ProxyInfo proxy_info1; |
745 ProxyInfo proxy_info2; | 758 ProxyInfo proxy_info2; |
746 ProxyResolver::RequestHandle request1; | 759 std::unique_ptr<ProxyResolver::Request> request1; |
747 ProxyResolver::RequestHandle request2; | 760 std::unique_ptr<ProxyResolver::Request> request2; |
748 TestCompletionCallback callback; | 761 TestCompletionCallback callback; |
749 | 762 |
750 int rv = resolver->GetProxyForURL(GURL("http://throw-an-error/"), | 763 int rv = resolver->GetProxyForURL(GURL("http://throw-an-error/"), |
751 &proxy_info1, base::Bind(&CrashCallback), | 764 &proxy_info1, base::Bind(&CrashCallback), |
752 &request1, NetLogWithSource()); | 765 &request1, NetLogWithSource()); |
753 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 766 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
754 | 767 |
755 // Wait until the first request has finished running on the worker thread. | 768 // Wait until the first request has finished running on the worker thread. |
756 // Cancel the first request, while it has a pending completion task on | 769 // Cancel the first request, while it has a pending completion task on |
757 // the origin thread. | 770 // the origin thread. Reset deletes Request object which cancels the request. |
758 error_observer->RunOnError(base::Bind(&ProxyResolver::CancelRequest, | 771 error_observer->RunOnError( |
759 base::Unretained(resolver.get()), | 772 base::Bind(&std::unique_ptr<ProxyResolver::Request>::reset, |
760 request1)); | 773 base::Unretained(&request1), nullptr)); |
761 | 774 |
762 // Start another request, to make sure it is able to complete. | 775 // Start another request, to make sure it is able to complete. |
763 rv = resolver->GetProxyForURL(GURL("http://i-have-no-idea-what-im-doing/"), | 776 rv = resolver->GetProxyForURL(GURL("http://i-have-no-idea-what-im-doing/"), |
764 &proxy_info2, callback.callback(), &request2, | 777 &proxy_info2, callback.callback(), &request2, |
765 NetLogWithSource()); | 778 NetLogWithSource()); |
766 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 779 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
767 | 780 |
768 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 781 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
769 | 782 |
770 EXPECT_EQ("i-approve-this-message:42", proxy_info2.proxy_server().ToURI()); | 783 EXPECT_EQ("i-approve-this-message:42", proxy_info2.proxy_server().ToURI()); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 TEST_F(ProxyResolverV8TracingWrapperTest, | 865 TEST_F(ProxyResolverV8TracingWrapperTest, |
853 CancelWhileOutstandingNonBlockingDns) { | 866 CancelWhileOutstandingNonBlockingDns) { |
854 BlockableHostResolver host_resolver; | 867 BlockableHostResolver host_resolver; |
855 MockErrorObserver* error_observer = new MockErrorObserver; | 868 MockErrorObserver* error_observer = new MockErrorObserver; |
856 | 869 |
857 std::unique_ptr<ProxyResolver> resolver = CreateResolver( | 870 std::unique_ptr<ProxyResolver> resolver = CreateResolver( |
858 nullptr, &host_resolver, base::WrapUnique(error_observer), "dns.js"); | 871 nullptr, &host_resolver, base::WrapUnique(error_observer), "dns.js"); |
859 | 872 |
860 ProxyInfo proxy_info1; | 873 ProxyInfo proxy_info1; |
861 ProxyInfo proxy_info2; | 874 ProxyInfo proxy_info2; |
862 ProxyResolver::RequestHandle request1; | 875 std::unique_ptr<ProxyResolver::Request> request1; |
863 ProxyResolver::RequestHandle request2; | 876 std::unique_ptr<ProxyResolver::Request> request2; |
864 | 877 |
865 int rv = resolver->GetProxyForURL(GURL("http://foo/req1"), &proxy_info1, | 878 int rv = resolver->GetProxyForURL(GURL("http://foo/req1"), &proxy_info1, |
866 base::Bind(&CrashCallback), &request1, | 879 base::Bind(&CrashCallback), &request1, |
867 NetLogWithSource()); | 880 NetLogWithSource()); |
868 | 881 |
869 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 882 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
870 | 883 |
871 host_resolver.WaitUntilRequestIsReceived(); | 884 host_resolver.WaitUntilRequestIsReceived(); |
872 | 885 |
873 rv = resolver->GetProxyForURL(GURL("http://foo/req2"), &proxy_info2, | 886 rv = resolver->GetProxyForURL(GURL("http://foo/req2"), &proxy_info2, |
874 base::Bind(&CrashCallback), &request2, | 887 base::Bind(&CrashCallback), &request2, |
875 NetLogWithSource()); | 888 NetLogWithSource()); |
876 | 889 |
877 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 890 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
878 | 891 |
879 host_resolver.WaitUntilRequestIsReceived(); | 892 host_resolver.WaitUntilRequestIsReceived(); |
880 | 893 |
881 resolver->CancelRequest(request1); | 894 request1.reset(); |
882 resolver->CancelRequest(request2); | 895 request2.reset(); |
883 | 896 |
884 EXPECT_EQ(2, host_resolver.num_cancelled_requests()); | 897 EXPECT_EQ(2, host_resolver.num_cancelled_requests()); |
885 | 898 |
886 // After leaving this scope, the ProxyResolver is destroyed. | 899 // After leaving this scope, the ProxyResolver is destroyed. |
887 // This should not cause any problems, as the outstanding work | 900 // This should not cause any problems, as the outstanding work |
888 // should have been cancelled. | 901 // should have been cancelled. |
889 } | 902 } |
890 | 903 |
891 void CancelRequestAndPause(ProxyResolver* resolver, | 904 void CancelRequestAndPause(std::unique_ptr<ProxyResolver::Request>* request) { |
892 ProxyResolver::RequestHandle request) { | 905 request->reset(); |
893 resolver->CancelRequest(request); | |
894 | 906 |
895 // Sleep for a little bit. This makes it more likely for the worker | 907 // Sleep for a little bit. This makes it more likely for the worker |
896 // thread to have returned from its call, and serves as a regression | 908 // thread to have returned from its call, and serves as a regression |
897 // test for http://crbug.com/173373. | 909 // test for http://crbug.com/173373. |
898 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(30)); | 910 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(30)); |
899 } | 911 } |
900 | 912 |
901 // In non-blocking mode, the worker thread actually does block for | 913 // In non-blocking mode, the worker thread actually does block for |
902 // a short time to see if the result is in the DNS cache. Test | 914 // a short time to see if the result is in the DNS cache. Test |
903 // cancellation while the worker thread is waiting on this event. | 915 // cancellation while the worker thread is waiting on this event. |
904 TEST_F(ProxyResolverV8TracingWrapperTest, CancelWhileBlockedInNonBlockingDns) { | 916 TEST_F(ProxyResolverV8TracingWrapperTest, CancelWhileBlockedInNonBlockingDns) { |
905 BlockableHostResolver host_resolver; | 917 BlockableHostResolver host_resolver; |
906 MockErrorObserver* error_observer = new MockErrorObserver; | 918 MockErrorObserver* error_observer = new MockErrorObserver; |
907 | 919 |
908 std::unique_ptr<ProxyResolver> resolver = CreateResolver( | 920 std::unique_ptr<ProxyResolver> resolver = CreateResolver( |
909 nullptr, &host_resolver, base::WrapUnique(error_observer), "dns.js"); | 921 nullptr, &host_resolver, base::WrapUnique(error_observer), "dns.js"); |
910 | 922 |
911 ProxyInfo proxy_info; | 923 ProxyInfo proxy_info; |
912 ProxyResolver::RequestHandle request; | 924 std::unique_ptr<ProxyResolver::Request> request; |
913 | 925 |
914 int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, | 926 int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, |
915 base::Bind(&CrashCallback), &request, | 927 base::Bind(&CrashCallback), &request, |
916 NetLogWithSource()); | 928 NetLogWithSource()); |
917 | 929 |
918 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 930 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
919 | 931 |
920 host_resolver.SetAction( | 932 host_resolver.SetAction(base::Bind(CancelRequestAndPause, &request)); |
921 base::Bind(CancelRequestAndPause, resolver.get(), request)); | |
922 | 933 |
923 host_resolver.WaitUntilRequestIsReceived(); | 934 host_resolver.WaitUntilRequestIsReceived(); |
924 } | 935 } |
925 | 936 |
926 // Cancel the request while there is a pending DNS request, however before | 937 // Cancel the request while there is a pending DNS request, however before |
927 // the request is sent to the host resolver. | 938 // the request is sent to the host resolver. |
928 TEST_F(ProxyResolverV8TracingWrapperTest, CancelWhileBlockedInNonBlockingDns2) { | 939 TEST_F(ProxyResolverV8TracingWrapperTest, CancelWhileBlockedInNonBlockingDns2) { |
929 MockCachingHostResolver host_resolver; | 940 MockCachingHostResolver host_resolver; |
930 MockErrorObserver* error_observer = new MockErrorObserver; | 941 MockErrorObserver* error_observer = new MockErrorObserver; |
931 | 942 |
932 std::unique_ptr<ProxyResolver> resolver = CreateResolver( | 943 std::unique_ptr<ProxyResolver> resolver = CreateResolver( |
933 nullptr, &host_resolver, base::WrapUnique(error_observer), "dns.js"); | 944 nullptr, &host_resolver, base::WrapUnique(error_observer), "dns.js"); |
934 | 945 |
935 ProxyInfo proxy_info; | 946 ProxyInfo proxy_info; |
936 ProxyResolver::RequestHandle request; | 947 std::unique_ptr<ProxyResolver::Request> request; |
937 | 948 |
938 int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, | 949 int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info, |
939 base::Bind(&CrashCallback), &request, | 950 base::Bind(&CrashCallback), &request, |
940 NetLogWithSource()); | 951 NetLogWithSource()); |
941 | 952 |
942 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 953 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
943 | 954 |
944 // Wait a bit, so the DNS task has hopefully been posted. The test will | 955 // Wait a bit, so the DNS task has hopefully been posted. The test will |
945 // work whatever the delay is here, but it is most useful if the delay | 956 // work whatever the delay is here, but it is most useful if the delay |
946 // is large enough to allow a task to be posted back. | 957 // is large enough to allow a task to be posted back. |
947 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10)); | 958 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10)); |
948 resolver->CancelRequest(request); | 959 request.reset(); |
949 | 960 |
950 EXPECT_EQ(0u, host_resolver.num_resolve()); | 961 EXPECT_EQ(0u, host_resolver.num_resolve()); |
951 } | 962 } |
952 | 963 |
953 TEST_F(ProxyResolverV8TracingWrapperTest, | 964 TEST_F(ProxyResolverV8TracingWrapperTest, |
954 CancelCreateResolverWhileOutstandingBlockingDns) { | 965 CancelCreateResolverWhileOutstandingBlockingDns) { |
955 BlockableHostResolver host_resolver; | 966 BlockableHostResolver host_resolver; |
956 MockErrorObserver* error_observer = new MockErrorObserver; | 967 MockErrorObserver* error_observer = new MockErrorObserver; |
957 | 968 |
958 ProxyResolverFactoryV8TracingWrapper factory( | 969 ProxyResolverFactoryV8TracingWrapper factory( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 | 1036 |
1026 host_resolver.rules()->AddRule("host1", "182.111.0.222"); | 1037 host_resolver.rules()->AddRule("host1", "182.111.0.222"); |
1027 host_resolver.rules()->AddRule("host2", "111.33.44.55"); | 1038 host_resolver.rules()->AddRule("host2", "111.33.44.55"); |
1028 | 1039 |
1029 std::unique_ptr<ProxyResolver> resolver = CreateResolver( | 1040 std::unique_ptr<ProxyResolver> resolver = CreateResolver( |
1030 &log, &host_resolver, base::WrapUnique(error_observer), "terminate.js"); | 1041 &log, &host_resolver, base::WrapUnique(error_observer), "terminate.js"); |
1031 | 1042 |
1032 TestCompletionCallback callback; | 1043 TestCompletionCallback callback; |
1033 ProxyInfo proxy_info; | 1044 ProxyInfo proxy_info; |
1034 | 1045 |
| 1046 std::unique_ptr<ProxyResolver::Request> req; |
1035 int rv = | 1047 int rv = |
1036 resolver->GetProxyForURL(GURL("http://foopy/req1"), &proxy_info, | 1048 resolver->GetProxyForURL(GURL("http://foopy/req1"), &proxy_info, |
1037 callback.callback(), NULL, request_log.bound()); | 1049 callback.callback(), &req, request_log.bound()); |
1038 | 1050 |
1039 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 1051 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
1040 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 1052 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
1041 | 1053 |
1042 // The test does 2 DNS resolutions. | 1054 // The test does 2 DNS resolutions. |
1043 EXPECT_EQ(2u, host_resolver.num_resolve()); | 1055 EXPECT_EQ(2u, host_resolver.num_resolve()); |
1044 | 1056 |
1045 EXPECT_EQ("foopy:3", proxy_info.proxy_server().ToURI()); | 1057 EXPECT_EQ("foopy:3", proxy_info.proxy_server().ToURI()); |
1046 | 1058 |
1047 // No errors. | 1059 // No errors. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 | 1117 |
1106 ProxyResolver* resolver[] = { | 1118 ProxyResolver* resolver[] = { |
1107 resolver0.get(), resolver1.get(), resolver2.get(), resolver3.get(), | 1119 resolver0.get(), resolver1.get(), resolver2.get(), resolver3.get(), |
1108 }; | 1120 }; |
1109 | 1121 |
1110 const size_t kNumResolvers = arraysize(resolver); | 1122 const size_t kNumResolvers = arraysize(resolver); |
1111 const size_t kNumIterations = 20; | 1123 const size_t kNumIterations = 20; |
1112 const size_t kNumResults = kNumResolvers * kNumIterations; | 1124 const size_t kNumResults = kNumResolvers * kNumIterations; |
1113 TestCompletionCallback callback[kNumResults]; | 1125 TestCompletionCallback callback[kNumResults]; |
1114 ProxyInfo proxy_info[kNumResults]; | 1126 ProxyInfo proxy_info[kNumResults]; |
| 1127 std::unique_ptr<ProxyResolver::Request> request[kNumResults]; |
1115 | 1128 |
1116 for (size_t i = 0; i < kNumResults; ++i) { | 1129 for (size_t i = 0; i < kNumResults; ++i) { |
1117 size_t resolver_i = i % kNumResolvers; | 1130 size_t resolver_i = i % kNumResolvers; |
1118 int rv = resolver[resolver_i]->GetProxyForURL( | 1131 int rv = resolver[resolver_i]->GetProxyForURL( |
1119 GURL("http://foo/"), &proxy_info[i], callback[i].callback(), NULL, | 1132 GURL("http://foo/"), &proxy_info[i], callback[i].callback(), |
1120 NetLogWithSource()); | 1133 &request[i], NetLogWithSource()); |
1121 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 1134 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
1122 } | 1135 } |
1123 | 1136 |
1124 // ------------------------ | 1137 // ------------------------ |
1125 // Verify all of the results. | 1138 // Verify all of the results. |
1126 // ------------------------ | 1139 // ------------------------ |
1127 | 1140 |
1128 const char* kExpectedForDnsJs = | 1141 const char* kExpectedForDnsJs = |
1129 "122.133.144.155-" // myIpAddress() | 1142 "122.133.144.155-" // myIpAddress() |
1130 "null-" // dnsResolve('') | 1143 "null-" // dnsResolve('') |
(...skipping 25 matching lines...) Expand all Loading... |
1156 proxy_uri.substr(0, proxy_uri.find(':') + 1)); | 1169 proxy_uri.substr(0, proxy_uri.find(':') + 1)); |
1157 } else { | 1170 } else { |
1158 NOTREACHED(); | 1171 NOTREACHED(); |
1159 } | 1172 } |
1160 } | 1173 } |
1161 } | 1174 } |
1162 | 1175 |
1163 } // namespace | 1176 } // namespace |
1164 | 1177 |
1165 } // namespace net | 1178 } // namespace net |
OLD | NEW |