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

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

Issue 11450023: Partial changes to enable net-internals in iOS. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years 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 18 matching lines...) Expand all
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 int rv; 89 int rv;
90 90
91 // Create a custom HostResolver for this experiment. 91 // Create a custom HostResolver for this experiment.
92 scoped_ptr<net::HostResolver> host_resolver_tmp; 92 scoped_ptr<net::HostResolver> host_resolver_tmp;
93 rv = CreateHostResolver(experiment.host_resolver_experiment, 93 rv = CreateHostResolver(experiment.host_resolver_experiment,
94 &host_resolver_tmp); 94 &host_resolver_tmp);
95 if (rv != net::OK) 95 if (rv != net::OK)
96 return rv; // Failure. 96 return rv; // Failure.
97 storage_.set_host_resolver(host_resolver_tmp.Pass()); 97 storage_.set_host_resolver(host_resolver_tmp.Pass());
98 98
99 #if !defined(OS_IOS)
stuartmorgan 2012/12/10 12:56:03 Is this necessary? We're already doing ifdef's in
ramant (doing other things) 2012/12/11 05:34:16 Done.
99 // Create a custom ProxyService for this this experiment. 100 // Create a custom ProxyService for this this experiment.
100 scoped_ptr<net::ProxyService> experiment_proxy_service; 101 scoped_ptr<net::ProxyService> experiment_proxy_service;
101 rv = CreateProxyService(experiment.proxy_settings_experiment, 102 rv = CreateProxyService(experiment.proxy_settings_experiment,
102 proxy_config_service, &experiment_proxy_service); 103 proxy_config_service, &experiment_proxy_service);
103 if (rv != net::OK) 104 if (rv != net::OK)
104 return rv; // Failure. 105 return rv; // Failure.
stuartmorgan 2012/12/10 12:56:03 Is this right? If not being able to create the ser
ramant (doing other things) 2012/12/11 05:34:16 Removed the ifdef'ing out of net::CreateProxyServi
ramant (doing other things) 2012/12/11 19:41:40 CreateProxyServiceUsingV8ProxyResolver is not buil
105 storage_.set_proxy_service(experiment_proxy_service.release()); 106 storage_.set_proxy_service(experiment_proxy_service.release());
107 #endif
106 108
107 // The rest of the dependencies are standard, and don't depend on the 109 // The rest of the dependencies are standard, and don't depend on the
108 // experiment being run. 110 // experiment being run.
109 storage_.set_cert_verifier(net::CertVerifier::CreateDefault()); 111 storage_.set_cert_verifier(net::CertVerifier::CreateDefault());
112 #if !defined(OS_IOS)
droger 2012/12/10 10:23:06 Use DISABLE_FTP_SUPPORT instead of OS_IOS. I think
ramant (doing other things) 2012/12/11 05:34:16 Done.
110 storage_.set_ftp_transaction_factory( 113 storage_.set_ftp_transaction_factory(
111 new net::FtpNetworkLayer(host_resolver())); 114 new net::FtpNetworkLayer(host_resolver()));
115 #endif
112 storage_.set_ssl_config_service(new net::SSLConfigServiceDefaults); 116 storage_.set_ssl_config_service(new net::SSLConfigServiceDefaults);
113 storage_.set_http_auth_handler_factory( 117 storage_.set_http_auth_handler_factory(
114 net::HttpAuthHandlerFactory::CreateDefault(host_resolver())); 118 net::HttpAuthHandlerFactory::CreateDefault(host_resolver()));
115 storage_.set_http_server_properties(new net::HttpServerPropertiesImpl); 119 storage_.set_http_server_properties(new net::HttpServerPropertiesImpl);
116 120
117 net::HttpNetworkSession::Params session_params; 121 net::HttpNetworkSession::Params session_params;
118 session_params.host_resolver = host_resolver(); 122 session_params.host_resolver = host_resolver();
119 session_params.cert_verifier = cert_verifier(); 123 session_params.cert_verifier = cert_verifier();
120 session_params.proxy_service = proxy_service(); 124 session_params.proxy_service = proxy_service();
121 session_params.ssl_config_service = ssl_config_service(); 125 session_params.ssl_config_service = ssl_config_service();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // Rather than falling-back to some other implementation, fail. 191 // Rather than falling-back to some other implementation, fail.
188 return net::ERR_NOT_IMPLEMENTED; 192 return net::ERR_NOT_IMPLEMENTED;
189 } 193 }
190 194
191 net::DhcpProxyScriptFetcherFactory dhcp_factory; 195 net::DhcpProxyScriptFetcherFactory dhcp_factory;
192 if (CommandLine::ForCurrentProcess()->HasSwitch( 196 if (CommandLine::ForCurrentProcess()->HasSwitch(
193 switches::kDisableDhcpWpad)) { 197 switches::kDisableDhcpWpad)) {
194 dhcp_factory.set_enabled(false); 198 dhcp_factory.set_enabled(false);
195 } 199 }
196 200
201 #if !defined(OS_IOS)
197 experiment_proxy_service->reset( 202 experiment_proxy_service->reset(
198 net::CreateProxyServiceUsingV8ProxyResolver( 203 net::CreateProxyServiceUsingV8ProxyResolver(
199 proxy_config_service->release(), 204 proxy_config_service->release(),
200 0u, 205 0u,
201 new net::ProxyScriptFetcherImpl(proxy_request_context_), 206 new net::ProxyScriptFetcherImpl(proxy_request_context_),
202 dhcp_factory.Create(proxy_request_context_), 207 dhcp_factory.Create(proxy_request_context_),
203 host_resolver(), 208 host_resolver(),
204 NULL, 209 NULL,
205 NULL)); 210 NULL));
211 #endif
206 212
207 return net::OK; 213 return net::OK;
208 } 214 }
209 215
210 // Creates a proxy config service that pulls from the system proxy settings. 216 // 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. 217 // On success returns net::OK and fills |config_service| with a new pointer.
212 // Otherwise returns a network error code. 218 // Otherwise returns a network error code.
213 int CreateSystemProxyConfigService( 219 int CreateSystemProxyConfigService(
214 scoped_ptr<net::ProxyConfigService>* config_service) { 220 scoped_ptr<net::ProxyConfigService>* config_service) {
215 #if defined(OS_LINUX) || defined(OS_OPENBSD) 221 #if defined(OS_LINUX) || defined(OS_OPENBSD)
216 // TODO(eroman): This is not supported on Linux yet, because of how 222 // TODO(eroman): This is not supported on Linux yet, because of how
217 // construction needs ot happen on the UI thread. 223 // construction needs ot happen on the UI thread.
218 return net::ERR_NOT_IMPLEMENTED; 224 return net::ERR_NOT_IMPLEMENTED;
219 #else 225 #else
220 config_service->reset( 226 config_service->reset(
221 net::ProxyService::CreateSystemProxyConfigService( 227 net::ProxyService::CreateSystemProxyConfigService(
222 base::ThreadTaskRunnerHandle::Get(), NULL)); 228 base::ThreadTaskRunnerHandle::Get(), NULL));
223 return net::OK; 229 return net::OK;
224 #endif 230 #endif
225 } 231 }
226 232
227 #if !defined(OS_ANDROID) 233 #if !defined(OS_ANDROID) && !defined(OS_IOS)
228 static int FirefoxProxySettingsTask( 234 static int FirefoxProxySettingsTask(
229 FirefoxProxySettings* firefox_settings) { 235 FirefoxProxySettings* firefox_settings) {
230 if (!FirefoxProxySettings::GetSettings(firefox_settings)) 236 if (!FirefoxProxySettings::GetSettings(firefox_settings))
231 return net::ERR_FILE_NOT_FOUND; 237 return net::ERR_FILE_NOT_FOUND;
232 return net::OK; 238 return net::OK;
233 } 239 }
234 240
235 void FirefoxProxySettingsReply( 241 void FirefoxProxySettingsReply(
236 scoped_ptr<net::ProxyConfigService>* config_service, 242 scoped_ptr<net::ProxyConfigService>* config_service,
237 FirefoxProxySettings* firefox_settings, 243 FirefoxProxySettings* firefox_settings,
(...skipping 14 matching lines...) Expand all
252 } 258 }
253 #endif 259 #endif
254 260
255 // Creates a fixed proxy config service that is initialized using Firefox's 261 // Creates a fixed proxy config service that is initialized using Firefox's
256 // current proxy settings. On success returns net::OK and fills 262 // current proxy settings. On success returns net::OK and fills
257 // |config_service| with a new pointer. Otherwise returns a network error 263 // |config_service| with a new pointer. Otherwise returns a network error
258 // code. 264 // code.
259 int CreateFirefoxProxyConfigService( 265 int CreateFirefoxProxyConfigService(
260 scoped_ptr<net::ProxyConfigService>* config_service, 266 scoped_ptr<net::ProxyConfigService>* config_service,
261 base::Callback<void(int)> callback) { 267 base::Callback<void(int)> callback) {
262 #if defined(OS_ANDROID) 268 #if defined(OS_ANDROID) || defined(OS_IOS)
263 // Chrome on Android does not support Firefox settings. 269 // Chrome on Android does not support Firefox settings.
stuartmorgan 2012/12/10 12:56:03 Update comment.
ramant (doing other things) 2012/12/11 05:34:16 Done.
264 return net::ERR_NOT_IMPLEMENTED; 270 return net::ERR_NOT_IMPLEMENTED;
265 #else 271 #else
266 // Fetch Firefox's proxy settings (can fail if Firefox is not installed). 272 // Fetch Firefox's proxy settings (can fail if Firefox is not installed).
267 FirefoxProxySettings* ff_settings = new FirefoxProxySettings(); 273 FirefoxProxySettings* ff_settings = new FirefoxProxySettings();
268 base::Callback<int(void)> task = base::Bind( 274 base::Callback<int(void)> task = base::Bind(
269 &FirefoxProxySettingsTask, ff_settings); 275 &FirefoxProxySettingsTask, ff_settings);
270 base::Callback<void(int)> reply = base::Bind( 276 base::Callback<void(int)> reply = base::Bind(
271 &ExperimentURLRequestContext::FirefoxProxySettingsReply, 277 &ExperimentURLRequestContext::FirefoxProxySettingsReply,
272 weak_factory_.GetWeakPtr(), config_service, 278 weak_factory_.GetWeakPtr(), config_service,
273 base::Owned(ff_settings), callback); 279 base::Owned(ff_settings), callback);
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 532
527 // Notify the delegate of completion. 533 // Notify the delegate of completion.
528 delegate_->OnCompletedConnectionTestExperiment(current, result); 534 delegate_->OnCompletedConnectionTestExperiment(current, result);
529 535
530 if (remaining_experiments_.empty()) { 536 if (remaining_experiments_.empty()) {
531 delegate_->OnCompletedConnectionTestSuite(); 537 delegate_->OnCompletedConnectionTestSuite();
532 } else { 538 } else {
533 StartNextExperiment(); 539 StartNextExperiment();
534 } 540 }
535 } 541 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698