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

Unified 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: Respond to comments by wtc and rch 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/public/common/content_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/io_thread.cc
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index ee97bb952a9ecb0ffe8e207b3acd5038d995391a..4a436833976195386bab890e3700fe77af4ee39b 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -48,6 +48,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/cookie_store_factory.h"
#include "net/base/host_mapping_rules.h"
+#include "net/base/ip_mapping_rules.h"
#include "net/base/net_util.h"
#include "net/base/network_time_notifier.h"
#include "net/base/sdch_manager.h"
@@ -58,6 +59,7 @@
#include "net/dns/host_cache.h"
#include "net/dns/host_resolver.h"
#include "net/dns/mapped_host_resolver.h"
+#include "net/dns/mapped_ip_resolver.h"
#include "net/ftp/ftp_network_layer.h"
#include "net/http/http_auth_filter.h"
#include "net/http/http_auth_handler_factory.h"
@@ -190,17 +192,28 @@ scoped_ptr<net::HostResolver> CreateGlobalHostResolver(net::NetLog* net_log) {
global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4);
}
- // If hostname remappings were specified on the command-line, layer these
- // rules on top of the real host resolver. This allows forwarding all requests
- // through a designated test server.
- if (!command_line.HasSwitch(switches::kHostResolverRules))
- return global_host_resolver.PassAs<net::HostResolver>();
-
- scoped_ptr<net::MappedHostResolver> remapped_resolver(
- new net::MappedHostResolver(global_host_resolver.Pass()));
- remapped_resolver->SetRulesFromString(
- command_line.GetSwitchValueASCII(switches::kHostResolverRules));
- return remapped_resolver.PassAs<net::HostResolver>();
+ // If hostname or IP remappings were specified on the command-line, layer
+ // these rules on top of the real host resolver. Hostname remapping allows
+ // forwarding of all requests to hosts (matching a pattern) through a
+ // designated test server. IP remapping allows for all IP resolutions that
+ // match a given pattern, such as those destined for a specific CDN, to be
+ // instead directed to a specific/alternate IP address.
+ if (command_line.HasSwitch(switches::kHostResolverRules)) {
+ scoped_ptr<net::MappedHostResolver> remapped_resolver(
+ new net::MappedHostResolver(global_host_resolver.Pass()));
+ remapped_resolver->SetRulesFromString(
+ command_line.GetSwitchValueASCII(switches::kHostResolverRules));
+ global_host_resolver = remapped_resolver.Pass();
+ }
+
+ if (command_line.HasSwitch(switches::kIpResolverRules)) {
+ scoped_ptr<net::MappedIPResolver> remapped_resolver(
+ new net::MappedIPResolver(global_host_resolver.Pass()));
+ remapped_resolver->SetRulesFromString(
+ command_line.GetSwitchValueASCII(switches::kIpResolverRules));
+ global_host_resolver = remapped_resolver.Pass();
+ }
+ return global_host_resolver.Pass();
}
// TODO(willchan): Remove proxy script fetcher context since it's not necessary
« no previous file with comments | « no previous file | content/public/common/content_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698