OLD | NEW |
---|---|
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 18 matching lines...) Expand all Loading... | |
29 #include "net/http/http_server_properties_impl.h" | 29 #include "net/http/http_server_properties_impl.h" |
30 #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" | 30 #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" |
31 #include "net/proxy/proxy_config_service_fixed.h" | 31 #include "net/proxy/proxy_config_service_fixed.h" |
32 #include "net/proxy/proxy_script_fetcher_impl.h" | 32 #include "net/proxy/proxy_script_fetcher_impl.h" |
33 #include "net/proxy/proxy_service.h" | 33 #include "net/proxy/proxy_service.h" |
34 #include "net/proxy/proxy_service_v8.h" | 34 #include "net/proxy/proxy_service_v8.h" |
35 #include "net/url_request/url_request.h" | 35 #include "net/url_request/url_request.h" |
36 #include "net/url_request/url_request_context.h" | 36 #include "net/url_request/url_request_context.h" |
37 #include "net/url_request/url_request_context_storage.h" | 37 #include "net/url_request/url_request_context_storage.h" |
38 | 38 |
39 #if !defined(OS_ANDROID) | 39 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
40 #include "chrome/browser/importer/firefox_proxy_settings.h" | 40 #include "chrome/browser/importer/firefox_proxy_settings.h" |
41 #endif | 41 #endif |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 // ExperimentURLRequestContext ------------------------------------------------ | 45 // ExperimentURLRequestContext ------------------------------------------------ |
46 | 46 |
47 // An instance of ExperimentURLRequestContext is created for each experiment | 47 // An instance of ExperimentURLRequestContext is created for each experiment |
48 // run by ConnectionTester. The class initializes network dependencies according | 48 // run by ConnectionTester. The class initializes network dependencies according |
49 // to the specified "experiment". | 49 // to the specified "experiment". |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 scoped_ptr<net::ProxyService> experiment_proxy_service; | 100 scoped_ptr<net::ProxyService> experiment_proxy_service; |
101 rv = CreateProxyService(experiment.proxy_settings_experiment, | 101 rv = CreateProxyService(experiment.proxy_settings_experiment, |
102 proxy_config_service, &experiment_proxy_service); | 102 proxy_config_service, &experiment_proxy_service); |
103 if (rv != net::OK) | 103 if (rv != net::OK) |
104 return rv; // Failure. | 104 return rv; // Failure. |
105 storage_.set_proxy_service(experiment_proxy_service.release()); | 105 storage_.set_proxy_service(experiment_proxy_service.release()); |
106 | 106 |
107 // The rest of the dependencies are standard, and don't depend on the | 107 // The rest of the dependencies are standard, and don't depend on the |
108 // experiment being run. | 108 // experiment being run. |
109 storage_.set_cert_verifier(net::CertVerifier::CreateDefault()); | 109 storage_.set_cert_verifier(net::CertVerifier::CreateDefault()); |
110 #if !defined(DISABLE_FTP_SUPPORT) | |
110 storage_.set_ftp_transaction_factory( | 111 storage_.set_ftp_transaction_factory( |
111 new net::FtpNetworkLayer(host_resolver())); | 112 new net::FtpNetworkLayer(host_resolver())); |
113 #endif | |
112 storage_.set_ssl_config_service(new net::SSLConfigServiceDefaults); | 114 storage_.set_ssl_config_service(new net::SSLConfigServiceDefaults); |
113 storage_.set_http_auth_handler_factory( | 115 storage_.set_http_auth_handler_factory( |
114 net::HttpAuthHandlerFactory::CreateDefault(host_resolver())); | 116 net::HttpAuthHandlerFactory::CreateDefault(host_resolver())); |
115 storage_.set_http_server_properties(new net::HttpServerPropertiesImpl); | 117 storage_.set_http_server_properties(new net::HttpServerPropertiesImpl); |
116 | 118 |
117 net::HttpNetworkSession::Params session_params; | 119 net::HttpNetworkSession::Params session_params; |
118 session_params.host_resolver = host_resolver(); | 120 session_params.host_resolver = host_resolver(); |
119 session_params.cert_verifier = cert_verifier(); | 121 session_params.cert_verifier = cert_verifier(); |
120 session_params.proxy_service = proxy_service(); | 122 session_params.proxy_service = proxy_service(); |
121 session_params.ssl_config_service = ssl_config_service(); | 123 session_params.ssl_config_service = ssl_config_service(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 // Rather than falling-back to some other implementation, fail. | 189 // Rather than falling-back to some other implementation, fail. |
188 return net::ERR_NOT_IMPLEMENTED; | 190 return net::ERR_NOT_IMPLEMENTED; |
189 } | 191 } |
190 | 192 |
191 net::DhcpProxyScriptFetcherFactory dhcp_factory; | 193 net::DhcpProxyScriptFetcherFactory dhcp_factory; |
192 if (CommandLine::ForCurrentProcess()->HasSwitch( | 194 if (CommandLine::ForCurrentProcess()->HasSwitch( |
193 switches::kDisableDhcpWpad)) { | 195 switches::kDisableDhcpWpad)) { |
194 dhcp_factory.set_enabled(false); | 196 dhcp_factory.set_enabled(false); |
195 } | 197 } |
196 | 198 |
199 #if defined(OS_IOS) | |
200 experiment_proxy_service->reset( | |
201 net::ProxyService::CreateUsingSystemProxyResolver( | |
202 proxy_config_service->release(), 0u, NULL)); | |
203 #else | |
197 experiment_proxy_service->reset( | 204 experiment_proxy_service->reset( |
198 net::CreateProxyServiceUsingV8ProxyResolver( | 205 net::CreateProxyServiceUsingV8ProxyResolver( |
199 proxy_config_service->release(), | 206 proxy_config_service->release(), |
200 0u, | 207 0u, |
201 new net::ProxyScriptFetcherImpl(proxy_request_context_), | 208 new net::ProxyScriptFetcherImpl(proxy_request_context_), |
202 dhcp_factory.Create(proxy_request_context_), | 209 dhcp_factory.Create(proxy_request_context_), |
203 host_resolver(), | 210 host_resolver(), |
204 NULL, | 211 NULL, |
205 NULL)); | 212 NULL)); |
213 #endif | |
206 | 214 |
207 return net::OK; | 215 return net::OK; |
208 } | 216 } |
209 | 217 |
210 // Creates a proxy config service that pulls from the system proxy settings. | 218 // Creates a proxy config service that pulls from the system proxy settings. |
211 // On success returns net::OK and fills |config_service| with a new pointer. | 219 // On success returns net::OK and fills |config_service| with a new pointer. |
212 // Otherwise returns a network error code. | 220 // Otherwise returns a network error code. |
213 int CreateSystemProxyConfigService( | 221 int CreateSystemProxyConfigService( |
214 scoped_ptr<net::ProxyConfigService>* config_service) { | 222 scoped_ptr<net::ProxyConfigService>* config_service) { |
215 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 223 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
216 // TODO(eroman): This is not supported on Linux yet, because of how | 224 // TODO(eroman): This is not supported on Linux yet, because of how |
217 // construction needs ot happen on the UI thread. | 225 // construction needs ot happen on the UI thread. |
218 return net::ERR_NOT_IMPLEMENTED; | 226 return net::ERR_NOT_IMPLEMENTED; |
219 #else | 227 #else |
220 config_service->reset( | 228 config_service->reset( |
221 net::ProxyService::CreateSystemProxyConfigService( | 229 net::ProxyService::CreateSystemProxyConfigService( |
222 base::ThreadTaskRunnerHandle::Get(), NULL)); | 230 base::ThreadTaskRunnerHandle::Get(), NULL)); |
223 return net::OK; | 231 return net::OK; |
224 #endif | 232 #endif |
225 } | 233 } |
226 | 234 |
227 #if !defined(OS_ANDROID) | 235 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
228 static int FirefoxProxySettingsTask( | 236 static int FirefoxProxySettingsTask( |
229 FirefoxProxySettings* firefox_settings) { | 237 FirefoxProxySettings* firefox_settings) { |
230 if (!FirefoxProxySettings::GetSettings(firefox_settings)) | 238 if (!FirefoxProxySettings::GetSettings(firefox_settings)) |
231 return net::ERR_FILE_NOT_FOUND; | 239 return net::ERR_FILE_NOT_FOUND; |
232 return net::OK; | 240 return net::OK; |
233 } | 241 } |
234 | 242 |
235 void FirefoxProxySettingsReply( | 243 void FirefoxProxySettingsReply( |
236 scoped_ptr<net::ProxyConfigService>* config_service, | 244 scoped_ptr<net::ProxyConfigService>* config_service, |
237 FirefoxProxySettings* firefox_settings, | 245 FirefoxProxySettings* firefox_settings, |
(...skipping 14 matching lines...) Expand all Loading... | |
252 } | 260 } |
253 #endif | 261 #endif |
254 | 262 |
255 // Creates a fixed proxy config service that is initialized using Firefox's | 263 // Creates a fixed proxy config service that is initialized using Firefox's |
256 // current proxy settings. On success returns net::OK and fills | 264 // current proxy settings. On success returns net::OK and fills |
257 // |config_service| with a new pointer. Otherwise returns a network error | 265 // |config_service| with a new pointer. Otherwise returns a network error |
258 // code. | 266 // code. |
259 int CreateFirefoxProxyConfigService( | 267 int CreateFirefoxProxyConfigService( |
260 scoped_ptr<net::ProxyConfigService>* config_service, | 268 scoped_ptr<net::ProxyConfigService>* config_service, |
261 base::Callback<void(int)> callback) { | 269 base::Callback<void(int)> callback) { |
262 #if defined(OS_ANDROID) | 270 #if defined(OS_ANDROID) || defined(OS_IOS) |
263 // Chrome on Android does not support Firefox settings. | 271 // Chrome on Android and IOS do not support Firefox settings. |
stuartmorgan
2012/12/12 10:36:21
iOS (IOS is to the iOS platform as ANDROID is to t
ramant (doing other things)
2012/12/12 18:25:50
Done.
| |
264 return net::ERR_NOT_IMPLEMENTED; | 272 return net::ERR_NOT_IMPLEMENTED; |
265 #else | 273 #else |
266 // Fetch Firefox's proxy settings (can fail if Firefox is not installed). | 274 // Fetch Firefox's proxy settings (can fail if Firefox is not installed). |
267 FirefoxProxySettings* ff_settings = new FirefoxProxySettings(); | 275 FirefoxProxySettings* ff_settings = new FirefoxProxySettings(); |
268 base::Callback<int(void)> task = base::Bind( | 276 base::Callback<int(void)> task = base::Bind( |
269 &FirefoxProxySettingsTask, ff_settings); | 277 &FirefoxProxySettingsTask, ff_settings); |
270 base::Callback<void(int)> reply = base::Bind( | 278 base::Callback<void(int)> reply = base::Bind( |
271 &ExperimentURLRequestContext::FirefoxProxySettingsReply, | 279 &ExperimentURLRequestContext::FirefoxProxySettingsReply, |
272 weak_factory_.GetWeakPtr(), config_service, | 280 weak_factory_.GetWeakPtr(), config_service, |
273 base::Owned(ff_settings), callback); | 281 base::Owned(ff_settings), callback); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 | 534 |
527 // Notify the delegate of completion. | 535 // Notify the delegate of completion. |
528 delegate_->OnCompletedConnectionTestExperiment(current, result); | 536 delegate_->OnCompletedConnectionTestExperiment(current, result); |
529 | 537 |
530 if (remaining_experiments_.empty()) { | 538 if (remaining_experiments_.empty()) { |
531 delegate_->OnCompletedConnectionTestSuite(); | 539 delegate_->OnCompletedConnectionTestSuite(); |
532 } else { | 540 } else { |
533 StartNextExperiment(); | 541 StartNextExperiment(); |
534 } | 542 } |
535 } | 543 } |
OLD | NEW |