| 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" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/importer/firefox_proxy_settings.h" | |
| 16 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 17 #include "net/base/cert_verifier.h" | 16 #include "net/base/cert_verifier.h" |
| 18 #include "net/base/cookie_monster.h" | 17 #include "net/base/cookie_monster.h" |
| 19 #include "net/base/host_resolver.h" | 18 #include "net/base/host_resolver.h" |
| 20 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
| 21 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 22 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
| 23 #include "net/base/ssl_config_service_defaults.h" | 22 #include "net/base/ssl_config_service_defaults.h" |
| 24 #include "net/ftp/ftp_network_layer.h" | 23 #include "net/ftp/ftp_network_layer.h" |
| 25 #include "net/http/http_auth_handler_factory.h" | 24 #include "net/http/http_auth_handler_factory.h" |
| 26 #include "net/http/http_cache.h" | 25 #include "net/http/http_cache.h" |
| 27 #include "net/http/http_network_session.h" | 26 #include "net/http/http_network_session.h" |
| 28 #include "net/http/http_server_properties_impl.h" | 27 #include "net/http/http_server_properties_impl.h" |
| 29 #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" | 28 #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" |
| 30 #include "net/proxy/proxy_config_service_fixed.h" | 29 #include "net/proxy/proxy_config_service_fixed.h" |
| 31 #include "net/proxy/proxy_script_fetcher_impl.h" | 30 #include "net/proxy/proxy_script_fetcher_impl.h" |
| 32 #include "net/proxy/proxy_service.h" | 31 #include "net/proxy/proxy_service.h" |
| 33 #include "net/url_request/url_request.h" | 32 #include "net/url_request/url_request.h" |
| 34 #include "net/url_request/url_request_context.h" | 33 #include "net/url_request/url_request_context.h" |
| 35 #include "net/url_request/url_request_context_storage.h" | 34 #include "net/url_request/url_request_context_storage.h" |
| 36 | 35 |
| 36 #if !defined(OS_ANDROID) |
| 37 #include "chrome/browser/importer/firefox_proxy_settings.h" |
| 38 #endif |
| 39 |
| 37 namespace { | 40 namespace { |
| 38 | 41 |
| 39 // ExperimentURLRequestContext ------------------------------------------------ | 42 // ExperimentURLRequestContext ------------------------------------------------ |
| 40 | 43 |
| 41 // An instance of ExperimentURLRequestContext is created for each experiment | 44 // An instance of ExperimentURLRequestContext is created for each experiment |
| 42 // run by ConnectionTester. The class initializes network dependencies according | 45 // run by ConnectionTester. The class initializes network dependencies according |
| 43 // to the specified "experiment". | 46 // to the specified "experiment". |
| 44 class ExperimentURLRequestContext : public net::URLRequestContext { | 47 class ExperimentURLRequestContext : public net::URLRequestContext { |
| 45 public: | 48 public: |
| 46 explicit ExperimentURLRequestContext( | 49 explicit ExperimentURLRequestContext( |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 return net::OK; | 223 return net::OK; |
| 221 #endif | 224 #endif |
| 222 } | 225 } |
| 223 | 226 |
| 224 // Creates a fixed proxy config service that is initialized using Firefox's | 227 // Creates a fixed proxy config service that is initialized using Firefox's |
| 225 // current proxy settings. On success returns net::OK and fills | 228 // current proxy settings. On success returns net::OK and fills |
| 226 // |config_service| with a new pointer. Otherwise returns a network error | 229 // |config_service| with a new pointer. Otherwise returns a network error |
| 227 // code. | 230 // code. |
| 228 int CreateFirefoxProxyConfigService( | 231 int CreateFirefoxProxyConfigService( |
| 229 scoped_ptr<net::ProxyConfigService>* config_service) { | 232 scoped_ptr<net::ProxyConfigService>* config_service) { |
| 233 #if defined(OS_ANDROID) |
| 234 // Chrome on Android does not support Firefox settings. |
| 235 return net::ERR_NOT_IMPLEMENTED; |
| 236 #else |
| 230 // Fetch Firefox's proxy settings (can fail if Firefox is not installed). | 237 // Fetch Firefox's proxy settings (can fail if Firefox is not installed). |
| 231 FirefoxProxySettings firefox_settings; | 238 FirefoxProxySettings firefox_settings; |
| 232 if (!FirefoxProxySettings::GetSettings(&firefox_settings)) | 239 if (!FirefoxProxySettings::GetSettings(&firefox_settings)) |
| 233 return net::ERR_FILE_NOT_FOUND; | 240 return net::ERR_FILE_NOT_FOUND; |
| 234 | 241 |
| 235 if (FirefoxProxySettings::SYSTEM == firefox_settings.config_type()) | 242 if (FirefoxProxySettings::SYSTEM == firefox_settings.config_type()) |
| 236 return CreateSystemProxyConfigService(config_service); | 243 return CreateSystemProxyConfigService(config_service); |
| 237 | 244 |
| 238 net::ProxyConfig config; | 245 net::ProxyConfig config; |
| 239 if (firefox_settings.ToProxyConfig(&config)) { | 246 if (firefox_settings.ToProxyConfig(&config)) { |
| 240 config_service->reset(new net::ProxyConfigServiceFixed(config)); | 247 config_service->reset(new net::ProxyConfigServiceFixed(config)); |
| 241 return net::OK; | 248 return net::OK; |
| 242 } | 249 } |
| 243 | 250 |
| 244 return net::ERR_FAILED; | 251 return net::ERR_FAILED; |
| 252 #endif |
| 245 } | 253 } |
| 246 | 254 |
| 247 const scoped_refptr<net::URLRequestContext> proxy_request_context_; | 255 const scoped_refptr<net::URLRequestContext> proxy_request_context_; |
| 248 net::URLRequestContextStorage storage_; | 256 net::URLRequestContextStorage storage_; |
| 249 }; | 257 }; |
| 250 | 258 |
| 251 } // namespace | 259 } // namespace |
| 252 | 260 |
| 253 // ConnectionTester::TestRunner ---------------------------------------------- | 261 // ConnectionTester::TestRunner ---------------------------------------------- |
| 254 | 262 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 469 |
| 462 // Notify the delegate of completion. | 470 // Notify the delegate of completion. |
| 463 delegate_->OnCompletedConnectionTestExperiment(current, result); | 471 delegate_->OnCompletedConnectionTestExperiment(current, result); |
| 464 | 472 |
| 465 if (remaining_experiments_.empty()) { | 473 if (remaining_experiments_.empty()) { |
| 466 delegate_->OnCompletedConnectionTestSuite(); | 474 delegate_->OnCompletedConnectionTestSuite(); |
| 467 } else { | 475 } else { |
| 468 StartNextExperiment(); | 476 StartNextExperiment(); |
| 469 } | 477 } |
| 470 } | 478 } |
| OLD | NEW |