OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 rv = CreateProxyService(experiment.proxy_settings_experiment, | 46 rv = CreateProxyService(experiment.proxy_settings_experiment, |
47 &proxy_service_); | 47 &proxy_service_); |
48 if (rv != net::OK) | 48 if (rv != net::OK) |
49 return rv; // Failure. | 49 return rv; // Failure. |
50 | 50 |
51 // The rest of the dependencies are standard, and don't depend on the | 51 // The rest of the dependencies are standard, and don't depend on the |
52 // experiment being run. | 52 // experiment being run. |
53 ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_); | 53 ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_); |
54 ssl_config_service_ = new net::SSLConfigServiceDefaults; | 54 ssl_config_service_ = new net::SSLConfigServiceDefaults; |
55 http_auth_handler_factory_ = net::HttpAuthHandlerFactory::CreateDefault(); | 55 http_auth_handler_factory_ = net::HttpAuthHandlerFactory::CreateDefault(); |
56 http_transaction_factory_ = | 56 http_transaction_factory_ = new net::HttpCache( |
57 new net::HttpCache( | 57 net::HttpNetworkLayer::CreateFactory(host_resolver_, proxy_service_, |
58 net::HttpNetworkLayer::CreateFactory(NULL, host_resolver_, | 58 ssl_config_service_, http_auth_handler_factory_, NULL, NULL), |
59 proxy_service_, | 59 net::HttpCache::DefaultBackend::InMemory(0)); |
60 ssl_config_service_, | |
61 http_auth_handler_factory_, | |
62 NULL, | |
63 NULL), | |
64 net::HttpCache::DefaultBackend::InMemory(0)); | |
65 // In-memory cookie store. | 60 // In-memory cookie store. |
66 cookie_store_ = new net::CookieMonster(NULL, NULL); | 61 cookie_store_ = new net::CookieMonster(NULL, NULL); |
67 | 62 |
68 return net::OK; | 63 return net::OK; |
69 } | 64 } |
70 | 65 |
71 protected: | 66 protected: |
72 virtual ~ExperimentURLRequestContext() { | 67 virtual ~ExperimentURLRequestContext() { |
73 delete ftp_transaction_factory_; | 68 delete ftp_transaction_factory_; |
74 delete http_transaction_factory_; | 69 delete http_transaction_factory_; |
75 delete http_auth_handler_factory_; | 70 delete http_auth_handler_factory_; |
76 } | 71 } |
77 | 72 |
78 private: | 73 private: |
79 // Creates a host resolver for |experiment|. On success returns net::OK and | 74 // Creates a host resolver for |experiment|. On success returns net::OK and |
80 // fills |host_resolver| with a new pointer. Otherwise returns a network | 75 // fills |host_resolver| with a new pointer. Otherwise returns a network |
81 // error code. | 76 // error code. |
82 int CreateHostResolver( | 77 int CreateHostResolver( |
83 ConnectionTester::HostResolverExperiment experiment, | 78 ConnectionTester::HostResolverExperiment experiment, |
84 scoped_refptr<net::HostResolver>* host_resolver) { | 79 scoped_refptr<net::HostResolver>* host_resolver) { |
85 // Create a vanilla HostResolver that disables caching. | 80 // Create a vanilla HostResolver that disables caching. |
86 const size_t kMaxJobs = 50u; | 81 const size_t kMaxJobs = 50u; |
87 scoped_refptr<net::HostResolverImpl> impl = new net::HostResolverImpl( | 82 scoped_refptr<net::HostResolverImpl> impl = |
88 NULL, NULL, NULL, kMaxJobs); | 83 new net::HostResolverImpl(NULL, NULL, kMaxJobs); |
89 | 84 |
90 *host_resolver = impl; | 85 *host_resolver = impl; |
91 | 86 |
92 // Modify it slightly based on the experiment being run. | 87 // Modify it slightly based on the experiment being run. |
93 switch (experiment) { | 88 switch (experiment) { |
94 case ConnectionTester::HOST_RESOLVER_EXPERIMENT_PLAIN: | 89 case ConnectionTester::HOST_RESOLVER_EXPERIMENT_PLAIN: |
95 return net::OK; | 90 return net::OK; |
96 case ConnectionTester::HOST_RESOLVER_EXPERIMENT_DISABLE_IPV6: | 91 case ConnectionTester::HOST_RESOLVER_EXPERIMENT_DISABLE_IPV6: |
97 impl->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); | 92 impl->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); |
98 return net::OK; | 93 return net::OK; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 if (rv != net::OK) | 143 if (rv != net::OK) |
149 return rv; // Failure. | 144 return rv; // Failure. |
150 | 145 |
151 if (CommandLine::ForCurrentProcess()->HasSwitch( | 146 if (CommandLine::ForCurrentProcess()->HasSwitch( |
152 switches::kSingleProcess)) { | 147 switches::kSingleProcess)) { |
153 // We can't create a standard proxy resolver in single-process mode. | 148 // We can't create a standard proxy resolver in single-process mode. |
154 // Rather than falling-back to some other implementation, fail. | 149 // Rather than falling-back to some other implementation, fail. |
155 return net::ERR_NOT_IMPLEMENTED; | 150 return net::ERR_NOT_IMPLEMENTED; |
156 } | 151 } |
157 | 152 |
158 *proxy_service = net::ProxyService::Create( | 153 *proxy_service = net::ProxyService::Create(config_service.release(), true, |
159 config_service.release(), | 154 this, NULL, MessageLoop::current()); |
160 true, this, NULL, NULL, MessageLoop::current()); | |
161 | 155 |
162 return net::OK; | 156 return net::OK; |
163 } | 157 } |
164 | 158 |
165 // Creates a proxy config service that pulls from the system proxy settings. | 159 // Creates a proxy config service that pulls from the system proxy settings. |
166 // On success returns net::OK and fills |config_service| with a new pointer. | 160 // On success returns net::OK and fills |config_service| with a new pointer. |
167 // Otherwise returns a network error code. | 161 // Otherwise returns a network error code. |
168 int CreateSystemProxyConfigService( | 162 int CreateSystemProxyConfigService( |
169 scoped_ptr<net::ProxyConfigService>* config_service) { | 163 scoped_ptr<net::ProxyConfigService>* config_service) { |
170 #if defined(OS_LINUX) | 164 #if defined(OS_LINUX) |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 389 |
396 // Notify the delegate of completion. | 390 // Notify the delegate of completion. |
397 delegate_->OnCompletedConnectionTestExperiment(current, result); | 391 delegate_->OnCompletedConnectionTestExperiment(current, result); |
398 | 392 |
399 if (remaining_experiments_.empty()) { | 393 if (remaining_experiments_.empty()) { |
400 delegate_->OnCompletedConnectionTestSuite(); | 394 delegate_->OnCompletedConnectionTestSuite(); |
401 } else { | 395 } else { |
402 StartNextExperiment(); | 396 StartNextExperiment(); |
403 } | 397 } |
404 } | 398 } |
OLD | NEW |