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

Unified Diff: chrome/browser/net/dns_global.cc

Issue 345034: Add a command line flag to force all network traffic through a particular ser... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | « chrome/browser/net/chrome_url_request_context.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/dns_global.cc
===================================================================
--- chrome/browser/net/dns_global.cc (revision 30486)
+++ chrome/browser/net/dns_global.cc (working copy)
@@ -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"
@@ -23,6 +24,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"
@@ -478,12 +480,21 @@
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;
}
« no previous file with comments | « chrome/browser/net/chrome_url_request_context.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698