summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/dns_global.cc
diff options
context:
space:
mode:
authormbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-03 06:03:31 +0000
committermbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-03 06:03:31 +0000
commit9697c5abfad683112288d367f07bf68d7eb9a05a (patch)
tree9f3568bad2be33a164e6f8f30f49b26e37f28347 /chrome/browser/net/dns_global.cc
parent7ea093ba47c5a1a1652f7249faf56399dd66876f (diff)
downloadchromium_src-9697c5abfad683112288d367f07bf68d7eb9a05a.zip
chromium_src-9697c5abfad683112288d367f07bf68d7eb9a05a.tar.gz
chromium_src-9697c5abfad683112288d367f07bf68d7eb9a05a.tar.bz2
Add a command line flag to force all network traffic through a particular server.
The command line is: --fixed-server=host:port When set, all traffic will be diverted through this server. This is useful for testing purposes with fixed servers. BUG=none TEST=none Review URL: http://codereview.chromium.org/345034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30798 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/dns_global.cc')
-rw-r--r--chrome/browser/net/dns_global.cc19
1 files changed, 15 insertions, 4 deletions
diff --git a/chrome/browser/net/dns_global.cc b/chrome/browser/net/dns_global.cc
index d70a3a0..7caef17 100644
--- a/chrome/browser/net/dns_global.cc
+++ b/chrome/browser/net/dns_global.cc
@@ -7,6 +7,7 @@
#include <map>
#include <string>
+#include "base/command_line.h"
#include "base/singleton.h"
#include "base/stats_counters.h"
#include "base/string_util.h"
@@ -22,6 +23,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/common/chrome_switches.h"
+#include "net/base/fixed_host_resolver.h"
#include "net/base/host_resolver.h"
#include "net/base/host_resolver_impl.h"
@@ -476,12 +478,21 @@ static void DiscardAllPrefetchState() {
net::HostResolver* GetGlobalHostResolver() {
// Called from UI thread.
if (!global_host_resolver) {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+
+ // The FixedHostResolver allows us to send all network requests through
+ // a designated test server.
+ if (command_line.HasSwitch(switches::kFixedServer)) {
+ std::string host_and_port =
+ WideToASCII(command_line.GetSwitchValue(switches::kFixedServer));
+ global_host_resolver = new net::FixedHostResolver(host_and_port);
+ return global_host_resolver;
+ }
+
global_host_resolver = net::CreateSystemHostResolver();
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableIPv6)) {
- global_host_resolver->SetDefaultAddressFamily(
- net::ADDRESS_FAMILY_IPV4);
- }
+ if (command_line.HasSwitch(switches::kDisableIPv6))
+ global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4);
}
return global_host_resolver;
}