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

Side by Side Diff: chrome/browser/io_thread.cc

Issue 156963003: Support replacement of IP address resolutions via command line flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove use of back() and front() string methods Created 6 years, 10 months 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
« no previous file with comments | « no previous file | content/public/common/content_switches.h » ('j') | net/base/ip_mapping_rules.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/io_thread.h" 5 #include "chrome/browser/io_thread.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 30 matching lines...) Expand all
41 #include "chrome/browser/net/sdch_dictionary_fetcher.h" 41 #include "chrome/browser/net/sdch_dictionary_fetcher.h"
42 #include "chrome/browser/net/spdyproxy/http_auth_handler_spdyproxy.h" 42 #include "chrome/browser/net/spdyproxy/http_auth_handler_spdyproxy.h"
43 #include "chrome/common/chrome_switches.h" 43 #include "chrome/common/chrome_switches.h"
44 #include "chrome/common/chrome_version_info.h" 44 #include "chrome/common/chrome_version_info.h"
45 #include "chrome/common/pref_names.h" 45 #include "chrome/common/pref_names.h"
46 #include "chrome/common/url_constants.h" 46 #include "chrome/common/url_constants.h"
47 #include "components/policy/core/common/policy_service.h" 47 #include "components/policy/core/common/policy_service.h"
48 #include "content/public/browser/browser_thread.h" 48 #include "content/public/browser/browser_thread.h"
49 #include "content/public/browser/cookie_store_factory.h" 49 #include "content/public/browser/cookie_store_factory.h"
50 #include "net/base/host_mapping_rules.h" 50 #include "net/base/host_mapping_rules.h"
51 #include "net/base/ip_mapping_rules.h"
51 #include "net/base/net_util.h" 52 #include "net/base/net_util.h"
52 #include "net/base/network_time_notifier.h" 53 #include "net/base/network_time_notifier.h"
53 #include "net/base/sdch_manager.h" 54 #include "net/base/sdch_manager.h"
54 #include "net/cert/cert_verifier.h" 55 #include "net/cert/cert_verifier.h"
55 #include "net/cert/ct_known_logs.h" 56 #include "net/cert/ct_known_logs.h"
56 #include "net/cert/ct_verifier.h" 57 #include "net/cert/ct_verifier.h"
57 #include "net/cookies/cookie_store.h" 58 #include "net/cookies/cookie_store.h"
58 #include "net/dns/host_cache.h" 59 #include "net/dns/host_cache.h"
59 #include "net/dns/host_resolver.h" 60 #include "net/dns/host_resolver.h"
60 #include "net/dns/mapped_host_resolver.h" 61 #include "net/dns/mapped_host_resolver.h"
62 #include "net/dns/mapped_ip_resolver.h"
61 #include "net/ftp/ftp_network_layer.h" 63 #include "net/ftp/ftp_network_layer.h"
62 #include "net/http/http_auth_filter.h" 64 #include "net/http/http_auth_filter.h"
63 #include "net/http/http_auth_handler_factory.h" 65 #include "net/http/http_auth_handler_factory.h"
64 #include "net/http/http_network_layer.h" 66 #include "net/http/http_network_layer.h"
65 #include "net/http/http_server_properties_impl.h" 67 #include "net/http/http_server_properties_impl.h"
66 #include "net/proxy/proxy_config_service.h" 68 #include "net/proxy/proxy_config_service.h"
67 #include "net/proxy/proxy_script_fetcher_impl.h" 69 #include "net/proxy/proxy_script_fetcher_impl.h"
68 #include "net/proxy/proxy_service.h" 70 #include "net/proxy/proxy_service.h"
69 #include "net/quic/quic_protocol.h" 71 #include "net/quic/quic_protocol.h"
70 #include "net/socket/tcp_client_socket.h" 72 #include "net/socket/tcp_client_socket.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 185
184 // Determine if we should disable IPv6 support. 186 // Determine if we should disable IPv6 support.
185 if (command_line.HasSwitch(switches::kEnableIPv6)) { 187 if (command_line.HasSwitch(switches::kEnableIPv6)) {
186 // Disable IPv6 probing. 188 // Disable IPv6 probing.
187 global_host_resolver->SetDefaultAddressFamily( 189 global_host_resolver->SetDefaultAddressFamily(
188 net::ADDRESS_FAMILY_UNSPECIFIED); 190 net::ADDRESS_FAMILY_UNSPECIFIED);
189 } else if (command_line.HasSwitch(switches::kDisableIPv6)) { 191 } else if (command_line.HasSwitch(switches::kDisableIPv6)) {
190 global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); 192 global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4);
191 } 193 }
192 194
193 // If hostname remappings were specified on the command-line, layer these 195 // If hostname or IP remappings were specified on the command-line, layer
194 // rules on top of the real host resolver. This allows forwarding all requests 196 // these rules on top of the real host resolver. Hostname remapping allows
195 // through a designated test server. 197 // forwarding of all requests to hosts (matching a pattern) through a
196 if (!command_line.HasSwitch(switches::kHostResolverRules)) 198 // designated test server. IP remapping allows for all IP resolutions that
197 return global_host_resolver.PassAs<net::HostResolver>(); 199 // match a given pattern, such as those destined for a specific CDN, to be
200 // instead directed to a specific/alternate IP address.
201 if (command_line.HasSwitch(switches::kHostResolverRules)) {
202 scoped_ptr<net::MappedHostResolver> remapped_resolver(
203 new net::MappedHostResolver(global_host_resolver.Pass()));
204 remapped_resolver->SetRulesFromString(
205 command_line.GetSwitchValueASCII(switches::kHostResolverRules));
206 global_host_resolver = remapped_resolver.Pass();
207 }
198 208
199 scoped_ptr<net::MappedHostResolver> remapped_resolver( 209 if (command_line.HasSwitch(switches::kIpResolverRules)) {
200 new net::MappedHostResolver(global_host_resolver.Pass())); 210 scoped_ptr<net::MappedIPResolver> remapped_resolver(
201 remapped_resolver->SetRulesFromString( 211 new net::MappedIPResolver(global_host_resolver.Pass()));
202 command_line.GetSwitchValueASCII(switches::kHostResolverRules)); 212 remapped_resolver->SetRulesFromString(
203 return remapped_resolver.PassAs<net::HostResolver>(); 213 command_line.GetSwitchValueASCII(switches::kIpResolverRules));
214 global_host_resolver = remapped_resolver.Pass();
215 }
216 return global_host_resolver.Pass();
204 } 217 }
205 218
206 // TODO(willchan): Remove proxy script fetcher context since it's not necessary 219 // TODO(willchan): Remove proxy script fetcher context since it's not necessary
207 // now that I got rid of refcounting URLRequestContexts. 220 // now that I got rid of refcounting URLRequestContexts.
208 // See IOThread::Globals for details. 221 // See IOThread::Globals for details.
209 net::URLRequestContext* 222 net::URLRequestContext*
210 ConstructProxyScriptFetcherContext(IOThread::Globals* globals, 223 ConstructProxyScriptFetcherContext(IOThread::Globals* globals,
211 net::NetLog* net_log) { 224 net::NetLog* net_log) {
212 net::URLRequestContext* context = new net::URLRequestContext; 225 net::URLRequestContext* context = new net::URLRequestContext;
213 context->set_net_log(net_log); 226 context->set_net_log(net_log);
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 std::string version_flag = 1204 std::string version_flag =
1192 command_line.GetSwitchValueASCII(switches::kQuicVersion); 1205 command_line.GetSwitchValueASCII(switches::kQuicVersion);
1193 for (size_t i = 0; i < supported_versions.size(); ++i) { 1206 for (size_t i = 0; i < supported_versions.size(); ++i) {
1194 net::QuicVersion version = supported_versions[i]; 1207 net::QuicVersion version = supported_versions[i];
1195 if (net::QuicVersionToString(version) == version_flag) { 1208 if (net::QuicVersionToString(version) == version_flag) {
1196 return version; 1209 return version;
1197 } 1210 }
1198 } 1211 }
1199 return net::QUIC_VERSION_UNSUPPORTED; 1212 return net::QUIC_VERSION_UNSUPPORTED;
1200 } 1213 }
OLDNEW
« no previous file with comments | « no previous file | content/public/common/content_switches.h » ('j') | net/base/ip_mapping_rules.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698