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

Side by Side Diff: net/proxy/multi_threaded_proxy_resolver_unittest.cc

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: one more fix, content bound_net_log_ Created 4 years, 3 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 unified diff | Download patch
OLDNEW
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 "net/proxy/multi_threaded_proxy_resolver.h" 5 #include "net/proxy/multi_threaded_proxy_resolver.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 class MockProxyResolver : public ProxyResolver { 47 class MockProxyResolver : public ProxyResolver {
48 public: 48 public:
49 MockProxyResolver() 49 MockProxyResolver()
50 : worker_loop_(base::MessageLoop::current()), request_count_(0) {} 50 : worker_loop_(base::MessageLoop::current()), request_count_(0) {}
51 51
52 // ProxyResolver implementation. 52 // ProxyResolver implementation.
53 int GetProxyForURL(const GURL& query_url, 53 int GetProxyForURL(const GURL& query_url,
54 ProxyInfo* results, 54 ProxyInfo* results,
55 const CompletionCallback& callback, 55 const CompletionCallback& callback,
56 RequestHandle* request, 56 RequestHandle* request,
57 const BoundNetLog& net_log) override { 57 const NetLogWithSource& net_log) override {
58 if (!resolve_latency_.is_zero()) 58 if (!resolve_latency_.is_zero())
59 base::PlatformThread::Sleep(resolve_latency_); 59 base::PlatformThread::Sleep(resolve_latency_);
60 60
61 CheckIsOnWorkerThread(); 61 CheckIsOnWorkerThread();
62 62
63 EXPECT_TRUE(callback.is_null()); 63 EXPECT_TRUE(callback.is_null());
64 EXPECT_TRUE(request == NULL); 64 EXPECT_TRUE(request == NULL);
65 65
66 // Write something into |net_log| (doesn't really have any meaning.) 66 // Write something into |net_log| (doesn't really have any meaning.)
67 net_log.BeginEvent(NetLogEventType::PAC_JAVASCRIPT_ALERT); 67 net_log.BeginEvent(NetLogEventType::PAC_JAVASCRIPT_ALERT);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 122 }
123 123
124 void WaitUntilBlocked() { 124 void WaitUntilBlocked() {
125 blocked_.Wait(); 125 blocked_.Wait();
126 } 126 }
127 127
128 int GetProxyForURL(const GURL& query_url, 128 int GetProxyForURL(const GURL& query_url,
129 ProxyInfo* results, 129 ProxyInfo* results,
130 const CompletionCallback& callback, 130 const CompletionCallback& callback,
131 RequestHandle* request, 131 RequestHandle* request,
132 const BoundNetLog& net_log) override { 132 const NetLogWithSource& net_log) override {
133 if (should_block_) { 133 if (should_block_) {
134 blocked_.Signal(); 134 blocked_.Signal();
135 unblocked_.Wait(); 135 unblocked_.Wait();
136 } 136 }
137 137
138 return MockProxyResolver::GetProxyForURL( 138 return MockProxyResolver::GetProxyForURL(
139 query_url, results, callback, request, net_log); 139 query_url, results, callback, request, net_log);
140 } 140 }
141 141
142 private: 142 private:
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 TestNetLogEntry::List entries0; 264 TestNetLogEntry::List entries0;
265 log0.GetEntries(&entries0); 265 log0.GetEntries(&entries0);
266 266
267 ASSERT_EQ(2u, entries0.size()); 267 ASSERT_EQ(2u, entries0.size());
268 EXPECT_EQ(NetLogEventType::SUBMITTED_TO_RESOLVER_THREAD, entries0[0].type); 268 EXPECT_EQ(NetLogEventType::SUBMITTED_TO_RESOLVER_THREAD, entries0[0].type);
269 269
270 // Start 3 more requests (request1 to request3). 270 // Start 3 more requests (request1 to request3).
271 271
272 TestCompletionCallback callback1; 272 TestCompletionCallback callback1;
273 ProxyInfo results1; 273 ProxyInfo results1;
274 rv = resolver().GetProxyForURL(GURL("http://request1"), &results1, 274 rv =
275 callback1.callback(), NULL, BoundNetLog()); 275 resolver().GetProxyForURL(GURL("http://request1"), &results1,
276 callback1.callback(), NULL, NetLogWithSource());
276 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 277 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
277 278
278 TestCompletionCallback callback2; 279 TestCompletionCallback callback2;
279 ProxyInfo results2; 280 ProxyInfo results2;
280 rv = resolver().GetProxyForURL(GURL("http://request2"), &results2, 281 rv =
281 callback2.callback(), NULL, BoundNetLog()); 282 resolver().GetProxyForURL(GURL("http://request2"), &results2,
283 callback2.callback(), NULL, NetLogWithSource());
282 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 284 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
283 285
284 TestCompletionCallback callback3; 286 TestCompletionCallback callback3;
285 ProxyInfo results3; 287 ProxyInfo results3;
286 rv = resolver().GetProxyForURL(GURL("http://request3"), &results3, 288 rv =
287 callback3.callback(), NULL, BoundNetLog()); 289 resolver().GetProxyForURL(GURL("http://request3"), &results3,
290 callback3.callback(), NULL, NetLogWithSource());
288 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 291 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
289 292
290 // Wait for the requests to finish (they must finish in the order they were 293 // Wait for the requests to finish (they must finish in the order they were
291 // started, which is what we check for from their magic return value) 294 // started, which is what we check for from their magic return value)
292 295
293 rv = callback1.WaitForResult(); 296 rv = callback1.WaitForResult();
294 EXPECT_EQ(1, rv); 297 EXPECT_EQ(1, rv);
295 EXPECT_EQ("PROXY request1:80", results1.ToPacString()); 298 EXPECT_EQ("PROXY request1:80", results1.ToPacString());
296 299
297 rv = callback2.WaitForResult(); 300 rv = callback2.WaitForResult();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 395
393 int rv; 396 int rv;
394 397
395 // Block the proxy resolver, so no request can complete. 398 // Block the proxy resolver, so no request can complete.
396 factory().resolvers()[0]->Block(); 399 factory().resolvers()[0]->Block();
397 400
398 // Start request 0. 401 // Start request 0.
399 ProxyResolver::RequestHandle request0; 402 ProxyResolver::RequestHandle request0;
400 TestCompletionCallback callback0; 403 TestCompletionCallback callback0;
401 ProxyInfo results0; 404 ProxyInfo results0;
402 rv = 405 rv = resolver().GetProxyForURL(GURL("http://request0"), &results0,
403 resolver().GetProxyForURL(GURL("http://request0"), &results0, 406 callback0.callback(), &request0,
404 callback0.callback(), &request0, BoundNetLog()); 407 NetLogWithSource());
405 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 408 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
406 409
407 // Wait until requests 0 reaches the worker thread. 410 // Wait until requests 0 reaches the worker thread.
408 factory().resolvers()[0]->WaitUntilBlocked(); 411 factory().resolvers()[0]->WaitUntilBlocked();
409 412
410 // Start 3 more requests (request1 : request3). 413 // Start 3 more requests (request1 : request3).
411 414
412 TestCompletionCallback callback1; 415 TestCompletionCallback callback1;
413 ProxyInfo results1; 416 ProxyInfo results1;
414 rv = resolver().GetProxyForURL(GURL("http://request1"), &results1, 417 rv =
415 callback1.callback(), NULL, BoundNetLog()); 418 resolver().GetProxyForURL(GURL("http://request1"), &results1,
419 callback1.callback(), NULL, NetLogWithSource());
416 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 420 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
417 421
418 ProxyResolver::RequestHandle request2; 422 ProxyResolver::RequestHandle request2;
419 TestCompletionCallback callback2; 423 TestCompletionCallback callback2;
420 ProxyInfo results2; 424 ProxyInfo results2;
421 rv = 425 rv = resolver().GetProxyForURL(GURL("http://request2"), &results2,
422 resolver().GetProxyForURL(GURL("http://request2"), &results2, 426 callback2.callback(), &request2,
423 callback2.callback(), &request2, BoundNetLog()); 427 NetLogWithSource());
424 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 428 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
425 429
426 TestCompletionCallback callback3; 430 TestCompletionCallback callback3;
427 ProxyInfo results3; 431 ProxyInfo results3;
428 rv = resolver().GetProxyForURL(GURL("http://request3"), &results3, 432 rv =
429 callback3.callback(), NULL, BoundNetLog()); 433 resolver().GetProxyForURL(GURL("http://request3"), &results3,
434 callback3.callback(), NULL, NetLogWithSource());
430 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 435 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
431 436
432 // Cancel request0 (inprogress) and request2 (pending). 437 // Cancel request0 (inprogress) and request2 (pending).
433 resolver().CancelRequest(request0); 438 resolver().CancelRequest(request0);
434 resolver().CancelRequest(request2); 439 resolver().CancelRequest(request2);
435 440
436 // Unblock the worker thread so the requests can continue running. 441 // Unblock the worker thread so the requests can continue running.
437 factory().resolvers()[0]->Unblock(); 442 factory().resolvers()[0]->Unblock();
438 443
439 // Wait for requests 1 and 3 to finish. 444 // Wait for requests 1 and 3 to finish.
(...skipping 23 matching lines...) Expand all
463 ASSERT_EQ(1u, factory().resolvers().size()); 468 ASSERT_EQ(1u, factory().resolvers().size());
464 469
465 // Block the proxy resolver, so no request can complete. 470 // Block the proxy resolver, so no request can complete.
466 factory().resolvers()[0]->Block(); 471 factory().resolvers()[0]->Block();
467 472
468 int rv; 473 int rv;
469 // Start 3 requests. 474 // Start 3 requests.
470 475
471 TestCompletionCallback callback0; 476 TestCompletionCallback callback0;
472 ProxyInfo results0; 477 ProxyInfo results0;
473 rv = resolver().GetProxyForURL(GURL("http://request0"), &results0, 478 rv =
474 callback0.callback(), NULL, BoundNetLog()); 479 resolver().GetProxyForURL(GURL("http://request0"), &results0,
480 callback0.callback(), NULL, NetLogWithSource());
475 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 481 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
476 482
477 TestCompletionCallback callback1; 483 TestCompletionCallback callback1;
478 ProxyInfo results1; 484 ProxyInfo results1;
479 rv = resolver().GetProxyForURL(GURL("http://request1"), &results1, 485 rv =
480 callback1.callback(), NULL, BoundNetLog()); 486 resolver().GetProxyForURL(GURL("http://request1"), &results1,
487 callback1.callback(), NULL, NetLogWithSource());
481 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 488 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
482 489
483 TestCompletionCallback callback2; 490 TestCompletionCallback callback2;
484 ProxyInfo results2; 491 ProxyInfo results2;
485 rv = resolver().GetProxyForURL(GURL("http://request2"), &results2, 492 rv =
486 callback2.callback(), NULL, BoundNetLog()); 493 resolver().GetProxyForURL(GURL("http://request2"), &results2,
494 callback2.callback(), NULL, NetLogWithSource());
487 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 495 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
488 496
489 // Wait until request 0 reaches the worker thread. 497 // Wait until request 0 reaches the worker thread.
490 factory().resolvers()[0]->WaitUntilBlocked(); 498 factory().resolvers()[0]->WaitUntilBlocked();
491 499
492 // Add some latency, to improve the chance that when 500 // Add some latency, to improve the chance that when
493 // MultiThreadedProxyResolver is deleted below we are still running inside 501 // MultiThreadedProxyResolver is deleted below we are still running inside
494 // of the worker thread. The test will pass regardless, so this race doesn't 502 // of the worker thread. The test will pass regardless, so this race doesn't
495 // cause flakiness. However the destruction during execution is a more 503 // cause flakiness. However the destruction during execution is a more
496 // interesting case to test. 504 // interesting case to test.
(...skipping 27 matching lines...) Expand all
524 const int kNumRequests = 8; 532 const int kNumRequests = 8;
525 int rv; 533 int rv;
526 TestCompletionCallback callback[kNumRequests]; 534 TestCompletionCallback callback[kNumRequests];
527 ProxyInfo results[kNumRequests]; 535 ProxyInfo results[kNumRequests];
528 ProxyResolver::RequestHandle request[kNumRequests]; 536 ProxyResolver::RequestHandle request[kNumRequests];
529 537
530 // Start request 0 -- this should run on thread 0 as there is nothing else 538 // Start request 0 -- this should run on thread 0 as there is nothing else
531 // going on right now. 539 // going on right now.
532 rv = resolver().GetProxyForURL(GURL("http://request0"), &results[0], 540 rv = resolver().GetProxyForURL(GURL("http://request0"), &results[0],
533 callback[0].callback(), &request[0], 541 callback[0].callback(), &request[0],
534 BoundNetLog()); 542 NetLogWithSource());
535 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 543 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
536 544
537 // Wait for request 0 to finish. 545 // Wait for request 0 to finish.
538 rv = callback[0].WaitForResult(); 546 rv = callback[0].WaitForResult();
539 EXPECT_EQ(0, rv); 547 EXPECT_EQ(0, rv);
540 EXPECT_EQ("PROXY request0:80", results[0].ToPacString()); 548 EXPECT_EQ("PROXY request0:80", results[0].ToPacString());
541 ASSERT_EQ(1u, factory().resolvers().size()); 549 ASSERT_EQ(1u, factory().resolvers().size());
542 EXPECT_EQ(1, factory().resolvers()[0]->request_count()); 550 EXPECT_EQ(1, factory().resolvers()[0]->request_count());
543 551
544 base::RunLoop().RunUntilIdle(); 552 base::RunLoop().RunUntilIdle();
545 553
546 // We now block the first resolver to ensure a request is sent to the second 554 // We now block the first resolver to ensure a request is sent to the second
547 // thread. 555 // thread.
548 factory().resolvers()[0]->Block(); 556 factory().resolvers()[0]->Block();
549 rv = resolver().GetProxyForURL(GURL("http://request1"), &results[1], 557 rv = resolver().GetProxyForURL(GURL("http://request1"), &results[1],
550 callback[1].callback(), &request[1], 558 callback[1].callback(), &request[1],
551 BoundNetLog()); 559 NetLogWithSource());
552 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 560 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
553 factory().resolvers()[0]->WaitUntilBlocked(); 561 factory().resolvers()[0]->WaitUntilBlocked();
554 rv = resolver().GetProxyForURL(GURL("http://request2"), &results[2], 562 rv = resolver().GetProxyForURL(GURL("http://request2"), &results[2],
555 callback[2].callback(), &request[2], 563 callback[2].callback(), &request[2],
556 BoundNetLog()); 564 NetLogWithSource());
557 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 565 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
558 EXPECT_EQ(0, callback[2].WaitForResult()); 566 EXPECT_EQ(0, callback[2].WaitForResult());
559 ASSERT_EQ(2u, factory().resolvers().size()); 567 ASSERT_EQ(2u, factory().resolvers().size());
560 568
561 // We now block the second resolver as well to ensure a request is sent to the 569 // We now block the second resolver as well to ensure a request is sent to the
562 // third thread. 570 // third thread.
563 factory().resolvers()[1]->Block(); 571 factory().resolvers()[1]->Block();
564 rv = resolver().GetProxyForURL(GURL("http://request3"), &results[3], 572 rv = resolver().GetProxyForURL(GURL("http://request3"), &results[3],
565 callback[3].callback(), &request[3], 573 callback[3].callback(), &request[3],
566 BoundNetLog()); 574 NetLogWithSource());
567 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 575 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
568 factory().resolvers()[1]->WaitUntilBlocked(); 576 factory().resolvers()[1]->WaitUntilBlocked();
569 rv = resolver().GetProxyForURL(GURL("http://request4"), &results[4], 577 rv = resolver().GetProxyForURL(GURL("http://request4"), &results[4],
570 callback[4].callback(), &request[4], 578 callback[4].callback(), &request[4],
571 BoundNetLog()); 579 NetLogWithSource());
572 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 580 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
573 EXPECT_EQ(0, callback[4].WaitForResult()); 581 EXPECT_EQ(0, callback[4].WaitForResult());
574 582
575 // We should now have a total of 3 threads, each with its own ProxyResolver 583 // We should now have a total of 3 threads, each with its own ProxyResolver
576 // that will get initialized with the same data. 584 // that will get initialized with the same data.
577 ASSERT_EQ(3u, factory().resolvers().size()); 585 ASSERT_EQ(3u, factory().resolvers().size());
578 586
579 ASSERT_EQ(3u, factory().script_data().size()); 587 ASSERT_EQ(3u, factory().script_data().size());
580 for (int i = 0; i < 3; ++i) { 588 for (int i = 0; i < 3; ++i) {
581 EXPECT_EQ(ASCIIToUTF16("pac script bytes"), 589 EXPECT_EQ(ASCIIToUTF16("pac script bytes"),
582 factory().script_data()[i]->utf16()) 590 factory().script_data()[i]->utf16())
583 << "i=" << i; 591 << "i=" << i;
584 } 592 }
585 593
586 // Start and cancel two requests. Since the first two threads are still 594 // Start and cancel two requests. Since the first two threads are still
587 // blocked, they'll both be serviced by the third thread. The first request 595 // blocked, they'll both be serviced by the third thread. The first request
588 // will reach the resolver, but the second will still be queued when canceled. 596 // will reach the resolver, but the second will still be queued when canceled.
589 // Start a third request so we can be sure the resolver has completed running 597 // Start a third request so we can be sure the resolver has completed running
590 // the first request. 598 // the first request.
591 rv = resolver().GetProxyForURL(GURL("http://request5"), &results[5], 599 rv = resolver().GetProxyForURL(GURL("http://request5"), &results[5],
592 callback[5].callback(), &request[5], 600 callback[5].callback(), &request[5],
593 BoundNetLog()); 601 NetLogWithSource());
594 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 602 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
595 rv = resolver().GetProxyForURL(GURL("http://request6"), &results[6], 603 rv = resolver().GetProxyForURL(GURL("http://request6"), &results[6],
596 callback[6].callback(), &request[6], 604 callback[6].callback(), &request[6],
597 BoundNetLog()); 605 NetLogWithSource());
598 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 606 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
599 rv = resolver().GetProxyForURL(GURL("http://request7"), &results[7], 607 rv = resolver().GetProxyForURL(GURL("http://request7"), &results[7],
600 callback[7].callback(), &request[7], 608 callback[7].callback(), &request[7],
601 BoundNetLog()); 609 NetLogWithSource());
602 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 610 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
603 resolver().CancelRequest(request[5]); 611 resolver().CancelRequest(request[5]);
604 resolver().CancelRequest(request[6]); 612 resolver().CancelRequest(request[6]);
605 613
606 EXPECT_EQ(2, callback[7].WaitForResult()); 614 EXPECT_EQ(2, callback[7].WaitForResult());
607 615
608 // Check that the cancelled requests never invoked their callback. 616 // Check that the cancelled requests never invoked their callback.
609 EXPECT_FALSE(callback[5].have_result()); 617 EXPECT_FALSE(callback[5].have_result());
610 EXPECT_FALSE(callback[6].have_result()); 618 EXPECT_FALSE(callback[6].have_result());
611 619
(...skipping 26 matching lines...) Expand all
638 TestCompletionCallback callback[kNumRequests]; 646 TestCompletionCallback callback[kNumRequests];
639 ProxyInfo results[kNumRequests]; 647 ProxyInfo results[kNumRequests];
640 ProxyResolver::RequestHandle request[kNumRequests]; 648 ProxyResolver::RequestHandle request[kNumRequests];
641 649
642 // Start a request that will block the first thread. 650 // Start a request that will block the first thread.
643 651
644 factory().resolvers()[0]->Block(); 652 factory().resolvers()[0]->Block();
645 653
646 rv = resolver().GetProxyForURL(GURL("http://request0"), &results[0], 654 rv = resolver().GetProxyForURL(GURL("http://request0"), &results[0],
647 callback[0].callback(), &request[0], 655 callback[0].callback(), &request[0],
648 BoundNetLog()); 656 NetLogWithSource());
649 657
650 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 658 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
651 factory().resolvers()[0]->WaitUntilBlocked(); 659 factory().resolvers()[0]->WaitUntilBlocked();
652 660
653 // Start 3 more requests -- they should all be serviced by thread #2 661 // Start 3 more requests -- they should all be serviced by thread #2
654 // since thread #1 is blocked. 662 // since thread #1 is blocked.
655 663
656 for (int i = 1; i < kNumRequests; ++i) { 664 for (int i = 1; i < kNumRequests; ++i) {
657 rv = resolver().GetProxyForURL( 665 rv = resolver().GetProxyForURL(
658 GURL(base::StringPrintf("http://request%d", i)), &results[i], 666 GURL(base::StringPrintf("http://request%d", i)), &results[i],
659 callback[i].callback(), &request[i], BoundNetLog()); 667 callback[i].callback(), &request[i], NetLogWithSource());
660 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 668 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
661 } 669 }
662 670
663 // Wait for the three requests to complete (they should complete in FIFO 671 // Wait for the three requests to complete (they should complete in FIFO
664 // order). 672 // order).
665 for (int i = 1; i < kNumRequests; ++i) { 673 for (int i = 1; i < kNumRequests; ++i) {
666 EXPECT_EQ(i - 1, callback[i].WaitForResult()); 674 EXPECT_EQ(i - 1, callback[i].WaitForResult());
667 } 675 }
668 676
669 // Unblock the first thread. 677 // Unblock the first thread.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 } 783 }
776 // The factory destructor will block until the worker thread stops, but it may 784 // The factory destructor will block until the worker thread stops, but it may
777 // post tasks to the origin message loop which are still pending. Run them 785 // post tasks to the origin message loop which are still pending. Run them
778 // now to ensure it works as expected. 786 // now to ensure it works as expected.
779 base::RunLoop().RunUntilIdle(); 787 base::RunLoop().RunUntilIdle();
780 } 788 }
781 789
782 } // namespace 790 } // namespace
783 791
784 } // namespace net 792 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698