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

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

Issue 3390026: net: Append base:: in the StringPrintf calls. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: fix include order Created 10 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
« no previous file with comments | « net/proxy/multi_threaded_proxy_resolver.cc ('k') | net/proxy/proxy_bypass_rules_unittest.cc » ('j') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/stringprintf.h"
9 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
10 #include "base/waitable_event.h" 11 #include "base/waitable_event.h"
11 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
13 #include "net/base/net_errors.h"
12 #include "net/base/net_log.h" 14 #include "net/base/net_log.h"
13 #include "net/base/net_log_unittest.h" 15 #include "net/base/net_log_unittest.h"
14 #include "net/base/net_errors.h"
15 #include "net/base/test_completion_callback.h" 16 #include "net/base/test_completion_callback.h"
16 #include "net/proxy/proxy_info.h" 17 #include "net/proxy/proxy_info.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 namespace net { 20 namespace net {
20 21
21 namespace { 22 namespace {
22 23
23 // A synchronous mock ProxyResolver implementation, which can be used in 24 // A synchronous mock ProxyResolver implementation, which can be used in
24 // conjunction with MultiThreadedProxyResolver. 25 // conjunction with MultiThreadedProxyResolver.
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 EXPECT_EQ(1, factory->resolvers()[0]->request_count()); 613 EXPECT_EQ(1, factory->resolvers()[0]->request_count());
613 614
614 MessageLoop::current()->RunAllPending(); 615 MessageLoop::current()->RunAllPending();
615 616
616 // We now start 8 requests in parallel -- this will cause the maximum of 617 // We now start 8 requests in parallel -- this will cause the maximum of
617 // three threads to be provisioned (an additional two from what we already 618 // three threads to be provisioned (an additional two from what we already
618 // have). 619 // have).
619 620
620 for (int i = 1; i < kNumRequests; ++i) { 621 for (int i = 1; i < kNumRequests; ++i) {
621 rv = resolver.GetProxyForURL( 622 rv = resolver.GetProxyForURL(
622 GURL(StringPrintf("http://request%d", i)), &results[i], &callback[i], 623 GURL(base::StringPrintf("http://request%d", i)), &results[i],
623 &request[i], BoundNetLog()); 624 &callback[i], &request[i], BoundNetLog());
624 EXPECT_EQ(ERR_IO_PENDING, rv); 625 EXPECT_EQ(ERR_IO_PENDING, rv);
625 } 626 }
626 627
627 // We should now have a total of 3 threads, each with its own ProxyResolver 628 // We should now have a total of 3 threads, each with its own ProxyResolver
628 // that will get initialized with the same data. (We check this later since 629 // that will get initialized with the same data. (We check this later since
629 // the assignment happens on the worker threads and may not have occurred 630 // the assignment happens on the worker threads and may not have occurred
630 // yet.) 631 // yet.)
631 ASSERT_EQ(3u, factory->resolvers().size()); 632 ASSERT_EQ(3u, factory->resolvers().size());
632 633
633 // Cancel 3 of the 8 oustanding requests. 634 // Cancel 3 of the 8 oustanding requests.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 BoundNetLog()); 719 BoundNetLog());
719 720
720 EXPECT_EQ(ERR_IO_PENDING, rv); 721 EXPECT_EQ(ERR_IO_PENDING, rv);
721 factory->resolvers()[0]->WaitUntilBlocked(); 722 factory->resolvers()[0]->WaitUntilBlocked();
722 723
723 // Start 3 more requests -- they should all be serviced by thread #2 724 // Start 3 more requests -- they should all be serviced by thread #2
724 // since thread #1 is blocked. 725 // since thread #1 is blocked.
725 726
726 for (int i = 1; i < kNumRequests; ++i) { 727 for (int i = 1; i < kNumRequests; ++i) {
727 rv = resolver.GetProxyForURL( 728 rv = resolver.GetProxyForURL(
728 GURL(StringPrintf("http://request%d", i)), 729 GURL(base::StringPrintf("http://request%d", i)),
729 &results[i], &callback[i], &request[i], BoundNetLog()); 730 &results[i], &callback[i], &request[i], BoundNetLog());
730 EXPECT_EQ(ERR_IO_PENDING, rv); 731 EXPECT_EQ(ERR_IO_PENDING, rv);
731 } 732 }
732 733
733 // Wait for the three requests to complete (they should complete in FIFO 734 // Wait for the three requests to complete (they should complete in FIFO
734 // order). 735 // order).
735 for (int i = 1; i < kNumRequests; ++i) { 736 for (int i = 1; i < kNumRequests; ++i) {
736 EXPECT_EQ(i - 1, callback[i].WaitForResult()); 737 EXPECT_EQ(i - 1, callback[i].WaitForResult());
737 } 738 }
738 739
739 // Unblock the first thread. 740 // Unblock the first thread.
740 factory->resolvers()[0]->Unblock(); 741 factory->resolvers()[0]->Unblock();
741 EXPECT_EQ(0, callback[0].WaitForResult()); 742 EXPECT_EQ(0, callback[0].WaitForResult());
742 743
743 // All in all, the first thread should have seen just 1 request. And the 744 // All in all, the first thread should have seen just 1 request. And the
744 // second thread 3 requests. 745 // second thread 3 requests.
745 ASSERT_EQ(2u, factory->resolvers().size()); 746 ASSERT_EQ(2u, factory->resolvers().size());
746 EXPECT_EQ(1, factory->resolvers()[0]->request_count()); 747 EXPECT_EQ(1, factory->resolvers()[0]->request_count());
747 EXPECT_EQ(3, factory->resolvers()[1]->request_count()); 748 EXPECT_EQ(3, factory->resolvers()[1]->request_count());
748 } 749 }
749 750
750 } // namespace 751 } // namespace
751 752
752 } // namespace net 753 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/multi_threaded_proxy_resolver.cc ('k') | net/proxy/proxy_bypass_rules_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698