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

Side by Side Diff: chrome/browser/net/connection_tester.cc

Issue 10831277: [net] Change factory methods for HostResolver and HostCache to return a scoped_ptr (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add ChromeBrowserFieldTrials::AsyncDnsFieldTrial Created 8 years, 4 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 | Annotate | Revision Log
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 "chrome/browser/net/connection_tester.h" 5 #include "chrome/browser/net/connection_tester.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 private: 135 private:
136 // Creates a host resolver for |experiment|. On success returns net::OK and 136 // Creates a host resolver for |experiment|. On success returns net::OK and
137 // fills |host_resolver| with a new pointer. Otherwise returns a network 137 // fills |host_resolver| with a new pointer. Otherwise returns a network
138 // error code. 138 // error code.
139 int CreateHostResolver( 139 int CreateHostResolver(
140 ConnectionTester::HostResolverExperiment experiment, 140 ConnectionTester::HostResolverExperiment experiment,
141 scoped_ptr<net::HostResolver>* host_resolver) { 141 scoped_ptr<net::HostResolver>* host_resolver) {
142 // Create a vanilla HostResolver that disables caching. 142 // Create a vanilla HostResolver that disables caching.
143 const size_t kMaxJobs = 50u; 143 const size_t kMaxJobs = 50u;
144 const size_t kMaxRetryAttempts = 4u; 144 const size_t kMaxRetryAttempts = 4u;
145 net::HostResolver* impl = net::CreateNonCachingSystemHostResolver( 145 *host_resolver = net::HostResolver::CreateSystemResolver(
146 kMaxJobs, 146 kMaxJobs,
147 kMaxRetryAttempts, 147 kMaxRetryAttempts,
148 false /* use_cache */,
149 false /* use_async */,
148 NULL /* NetLog */); 150 NULL /* NetLog */);
149 151
150 host_resolver->reset(impl);
151
152 // Modify it slightly based on the experiment being run. 152 // Modify it slightly based on the experiment being run.
153 switch (experiment) { 153 switch (experiment) {
154 case ConnectionTester::HOST_RESOLVER_EXPERIMENT_PLAIN: 154 case ConnectionTester::HOST_RESOLVER_EXPERIMENT_PLAIN:
155 return net::OK; 155 return net::OK;
156 case ConnectionTester::HOST_RESOLVER_EXPERIMENT_DISABLE_IPV6: 156 case ConnectionTester::HOST_RESOLVER_EXPERIMENT_DISABLE_IPV6:
157 impl->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); 157 (*host_resolver)->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4);
158 return net::OK; 158 return net::OK;
159 case ConnectionTester::HOST_RESOLVER_EXPERIMENT_IPV6_PROBE: { 159 case ConnectionTester::HOST_RESOLVER_EXPERIMENT_IPV6_PROBE: {
160 // Note that we don't use impl->ProbeIPv6Support() since that finishes 160 // Note that we don't use impl->ProbeIPv6Support() since that finishes
161 // asynchronously and may not take effect in time for the test. 161 // asynchronously and may not take effect in time for the test.
162 // So instead we will probe synchronously (might take 100-200 ms). 162 // So instead we will probe synchronously (might take 100-200 ms).
163 net::AddressFamily family = net::TestIPv6Support().ipv6_supported ? 163 net::AddressFamily family = net::TestIPv6Support().ipv6_supported ?
164 net::ADDRESS_FAMILY_UNSPECIFIED : net::ADDRESS_FAMILY_IPV4; 164 net::ADDRESS_FAMILY_UNSPECIFIED : net::ADDRESS_FAMILY_IPV4;
165 impl->SetDefaultAddressFamily(family); 165 (*host_resolver)->SetDefaultAddressFamily(family);
166 return net::OK; 166 return net::OK;
167 } 167 }
168 default: 168 default:
169 NOTREACHED(); 169 NOTREACHED();
170 return net::ERR_UNEXPECTED; 170 return net::ERR_UNEXPECTED;
171 } 171 }
172 } 172 }
173 173
174 // Creates a proxy service for |experiment|. On success returns net::OK 174 // Creates a proxy service for |experiment|. On success returns net::OK
175 // and fills |experiment_proxy_service| with a new pointer. Otherwise returns 175 // and fills |experiment_proxy_service| with a new pointer. Otherwise returns
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 525
526 // Notify the delegate of completion. 526 // Notify the delegate of completion.
527 delegate_->OnCompletedConnectionTestExperiment(current, result); 527 delegate_->OnCompletedConnectionTestExperiment(current, result);
528 528
529 if (remaining_experiments_.empty()) { 529 if (remaining_experiments_.empty()) {
530 delegate_->OnCompletedConnectionTestSuite(); 530 delegate_->OnCompletedConnectionTestSuite();
531 } else { 531 } else {
532 StartNextExperiment(); 532 StartNextExperiment();
533 } 533 }
534 } 534 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698