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

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

Issue 1138313003: Fix a race in MultiThreadedProxyResolverTest.ThreeThreads_Basic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@multi-threaded-proxy-resolver-flake
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 7 #include <vector>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 548
549 base::MessageLoop::current()->RunUntilIdle(); 549 base::MessageLoop::current()->RunUntilIdle();
550 550
551 // We now block the first resolver to ensure a request is sent to the second 551 // We now block the first resolver to ensure a request is sent to the second
552 // thread. 552 // thread.
553 factory().resolvers()[0]->Block(); 553 factory().resolvers()[0]->Block();
554 rv = resolver().GetProxyForURL(GURL("http://request1"), &results[1], 554 rv = resolver().GetProxyForURL(GURL("http://request1"), &results[1],
555 callback[1].callback(), &request[1], 555 callback[1].callback(), &request[1],
556 BoundNetLog()); 556 BoundNetLog());
557 EXPECT_EQ(ERR_IO_PENDING, rv); 557 EXPECT_EQ(ERR_IO_PENDING, rv);
558 factory().resolvers()[0]->WaitUntilBlocked();
558 rv = resolver().GetProxyForURL(GURL("http://request2"), &results[2], 559 rv = resolver().GetProxyForURL(GURL("http://request2"), &results[2],
559 callback[2].callback(), &request[2], 560 callback[2].callback(), &request[2],
560 BoundNetLog()); 561 BoundNetLog());
561 EXPECT_EQ(ERR_IO_PENDING, rv); 562 EXPECT_EQ(ERR_IO_PENDING, rv);
562 EXPECT_EQ(0, callback[2].WaitForResult()); 563 EXPECT_EQ(0, callback[2].WaitForResult());
563 ASSERT_EQ(2u, factory().resolvers().size()); 564 ASSERT_EQ(2u, factory().resolvers().size());
564 565
565 // We now block the second resolver as well to ensure a request is sent to the 566 // We now block the second resolver as well to ensure a request is sent to the
566 // third thread. 567 // third thread.
567 factory().resolvers()[1]->Block(); 568 factory().resolvers()[1]->Block();
568 rv = resolver().GetProxyForURL(GURL("http://request3"), &results[3], 569 rv = resolver().GetProxyForURL(GURL("http://request3"), &results[3],
569 callback[3].callback(), &request[3], 570 callback[3].callback(), &request[3],
570 BoundNetLog()); 571 BoundNetLog());
571 EXPECT_EQ(ERR_IO_PENDING, rv); 572 EXPECT_EQ(ERR_IO_PENDING, rv);
573 factory().resolvers()[1]->WaitUntilBlocked();
572 rv = resolver().GetProxyForURL(GURL("http://request4"), &results[4], 574 rv = resolver().GetProxyForURL(GURL("http://request4"), &results[4],
573 callback[4].callback(), &request[4], 575 callback[4].callback(), &request[4],
574 BoundNetLog()); 576 BoundNetLog());
575 EXPECT_EQ(ERR_IO_PENDING, rv); 577 EXPECT_EQ(ERR_IO_PENDING, rv);
576 EXPECT_EQ(0, callback[4].WaitForResult()); 578 EXPECT_EQ(0, callback[4].WaitForResult());
577 579
578 // We should now have a total of 3 threads, each with its own ProxyResolver 580 // We should now have a total of 3 threads, each with its own ProxyResolver
579 // that will get initialized with the same data. 581 // that will get initialized with the same data.
580 ASSERT_EQ(3u, factory().resolvers().size()); 582 ASSERT_EQ(3u, factory().resolvers().size());
581 583
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 } 780 }
779 // The factory destructor will block until the worker thread stops, but it may 781 // The factory destructor will block until the worker thread stops, but it may
780 // post tasks to the origin message loop which are still pending. Run them 782 // post tasks to the origin message loop which are still pending. Run them
781 // now to ensure it works as expected. 783 // now to ensure it works as expected.
782 base::RunLoop().RunUntilIdle(); 784 base::RunLoop().RunUntilIdle();
783 } 785 }
784 786
785 } // namespace 787 } // namespace
786 788
787 } // namespace net 789 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698