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" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/importer/firefox_proxy_settings.h" | 12 #include "chrome/browser/importer/firefox_proxy_settings.h" |
13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
14 #include "net/base/cookie_monster.h" | 14 #include "net/base/cookie_monster.h" |
15 #include "net/base/dnsrr_resolver.h" | |
15 #include "net/base/host_resolver.h" | 16 #include "net/base/host_resolver.h" |
16 #include "net/base/host_resolver_impl.h" | 17 #include "net/base/host_resolver_impl.h" |
17 #include "net/base/io_buffer.h" | 18 #include "net/base/io_buffer.h" |
18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
19 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
20 #include "net/base/ssl_config_service_defaults.h" | 21 #include "net/base/ssl_config_service_defaults.h" |
21 #include "net/disk_cache/disk_cache.h" | 22 #include "net/disk_cache/disk_cache.h" |
22 #include "net/ftp/ftp_network_layer.h" | 23 #include "net/ftp/ftp_network_layer.h" |
23 #include "net/http/http_auth_handler_factory.h" | 24 #include "net/http/http_auth_handler_factory.h" |
24 #include "net/http/http_cache.h" | 25 #include "net/http/http_cache.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
46 return rv; // Failure. | 47 return rv; // Failure. |
47 | 48 |
48 // Create a custom ProxyService for this this experiment. | 49 // Create a custom ProxyService for this this experiment. |
49 rv = CreateProxyService(experiment.proxy_settings_experiment, | 50 rv = CreateProxyService(experiment.proxy_settings_experiment, |
50 &proxy_service_); | 51 &proxy_service_); |
51 if (rv != net::OK) | 52 if (rv != net::OK) |
52 return rv; // Failure. | 53 return rv; // Failure. |
53 | 54 |
54 // The rest of the dependencies are standard, and don't depend on the | 55 // The rest of the dependencies are standard, and don't depend on the |
55 // experiment being run. | 56 // experiment being run. |
57 dnsrr_resolver_ = new net::DnsRRResolver; | |
56 ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_); | 58 ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_); |
57 ssl_config_service_ = new net::SSLConfigServiceDefaults; | 59 ssl_config_service_ = new net::SSLConfigServiceDefaults; |
58 http_auth_handler_factory_ = net::HttpAuthHandlerFactory::CreateDefault( | 60 http_auth_handler_factory_ = net::HttpAuthHandlerFactory::CreateDefault( |
59 host_resolver_); | 61 host_resolver_); |
60 http_transaction_factory_ = new net::HttpCache( | 62 http_transaction_factory_ = new net::HttpCache( |
61 net::HttpNetworkLayer::CreateFactory(host_resolver_, proxy_service_, | 63 net::HttpNetworkLayer::CreateFactory(host_resolver_, dnsrr_resolver_, |
62 ssl_config_service_, http_auth_handler_factory_, NULL, NULL), | 64 proxy_service_, ssl_config_service_, http_auth_handler_factory_, |
65 NULL, NULL), | |
63 net::HttpCache::DefaultBackend::InMemory(0)); | 66 net::HttpCache::DefaultBackend::InMemory(0)); |
64 // In-memory cookie store. | 67 // In-memory cookie store. |
65 cookie_store_ = new net::CookieMonster(NULL, NULL); | 68 cookie_store_ = new net::CookieMonster(NULL, NULL); |
66 | 69 |
67 return net::OK; | 70 return net::OK; |
68 } | 71 } |
69 | 72 |
70 protected: | 73 protected: |
71 virtual ~ExperimentURLRequestContext() { | 74 virtual ~ExperimentURLRequestContext() { |
75 delete dnsrr_resolver_; | |
willchan no longer on Chromium
2010/10/05 04:33:08
You should delete in the reverse order of construc
| |
72 delete ftp_transaction_factory_; | 76 delete ftp_transaction_factory_; |
73 delete http_transaction_factory_; | 77 delete http_transaction_factory_; |
74 delete http_auth_handler_factory_; | 78 delete http_auth_handler_factory_; |
75 delete host_resolver_; | 79 delete host_resolver_; |
76 } | 80 } |
77 | 81 |
78 private: | 82 private: |
79 // Creates a host resolver for |experiment|. On success returns net::OK and | 83 // Creates a host resolver for |experiment|. On success returns net::OK and |
80 // fills |host_resolver| with a new pointer. Otherwise returns a network | 84 // fills |host_resolver| with a new pointer. Otherwise returns a network |
81 // error code. | 85 // error code. |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 | 399 |
396 // Notify the delegate of completion. | 400 // Notify the delegate of completion. |
397 delegate_->OnCompletedConnectionTestExperiment(current, result); | 401 delegate_->OnCompletedConnectionTestExperiment(current, result); |
398 | 402 |
399 if (remaining_experiments_.empty()) { | 403 if (remaining_experiments_.empty()) { |
400 delegate_->OnCompletedConnectionTestSuite(); | 404 delegate_->OnCompletedConnectionTestSuite(); |
401 } else { | 405 } else { |
402 StartNextExperiment(); | 406 StartNextExperiment(); |
403 } | 407 } |
404 } | 408 } |
OLD | NEW |