diff options
author | tonyg@chromium.org <tonyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-03 18:40:42 +0000 |
---|---|---|
committer | tonyg@chromium.org <tonyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-03 18:40:42 +0000 |
commit | cbfe7495fbc78a3b72a5429ac13926ed008460f7 (patch) | |
tree | db9d863bee5456ff172ea2da0bd2fe85ca98752c /content | |
parent | 52b3384d8f0048b2885cedbd98b61b50a47cfc6e (diff) | |
download | chromium_src-cbfe7495fbc78a3b72a5429ac13926ed008460f7.zip chromium_src-cbfe7495fbc78a3b72a5429ac13926ed008460f7.tar.gz chromium_src-cbfe7495fbc78a3b72a5429ac13926ed008460f7.tar.bz2 |
Make content shell support some testing flags.
This copies support for --testing-fixed-http-port, --testing-fixed-https-port
and --host-resolver-rules from chrome to content_shell. These flags are useful
for benchmarking against recorded web pages with web page replay.
TEST=Manual
BUG=None
Review URL: https://chromiumcodereview.appspot.com/11053007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159930 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/public/common/content_switches.cc | 7 | ||||
-rw-r--r-- | content/public/common/content_switches.h | 3 | ||||
-rw-r--r-- | content/shell/shell_url_request_context_getter.cc | 24 | ||||
-rw-r--r-- | content/shell/shell_url_request_context_getter.h | 2 |
4 files changed, 36 insertions, 0 deletions
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index 9e3e3a8..8655676 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -435,6 +435,9 @@ const char kGpuVendorID[] = "gpu-vendor-id"; // to run as a guest renderer instead of a regular renderer. const char kGuestRenderer[] = "guest-renderer"; +// These mappings only apply to the host resolver. +const char kHostResolverRules[] = "host-resolver-rules"; + // Ignores GPU blacklist. const char kIgnoreGpuBlacklist[] = "ignore-gpu-blacklist"; @@ -587,6 +590,10 @@ const char kTapDownDeferralTimeMs[] = "tap-down-deferral-time"; // Runs the security test for the renderer sandbox. const char kTestSandbox[] = "test-sandbox"; +// Allows for forcing socket connections to http/https to use fixed ports. +const char kTestingFixedHttpPort[] = "testing-fixed-http-port"; +const char kTestingFixedHttpsPort[] = "testing-fixed-https-port"; + // Causes TRACE_EVENT flags to be recorded from startup. Optionally, can // specify the specific trace categories to include (e.g. // --trace-startup=base,net) otherwise, all events are recorded. Setting this diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index e1b1aae..2605146 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -138,6 +138,7 @@ CONTENT_EXPORT extern const char kGpuProcess[]; extern const char kGpuStartupDialog[]; extern const char kGpuVendorID[]; CONTENT_EXPORT extern const char kGuestRenderer[]; +CONTENT_EXPORT extern const char kHostResolverRules[]; CONTENT_EXPORT extern const char kIgnoreGpuBlacklist[]; extern const char kInProcessGPU[]; extern const char kInProcessPlugins[]; @@ -182,6 +183,8 @@ CONTENT_EXPORT extern const char kSingleProcess[]; CONTENT_EXPORT extern const char kSkipGpuDataLoading[]; extern const char kTapDownDeferralTimeMs[]; CONTENT_EXPORT extern const char kTestSandbox[]; +CONTENT_EXPORT extern const char kTestingFixedHttpPort[]; +CONTENT_EXPORT extern const char kTestingFixedHttpsPort[]; extern const char kTraceStartup[]; extern const char kTraceStartupFile[]; extern const char kTraceStartupDuration[]; diff --git a/content/shell/shell_url_request_context_getter.cc b/content/shell/shell_url_request_context_getter.cc index b8a6f03..f612fa5 100644 --- a/content/shell/shell_url_request_context_getter.cc +++ b/content/shell/shell_url_request_context_getter.cc @@ -6,13 +6,16 @@ #include "base/command_line.h" #include "base/logging.h" +#include "base/string_number_conversions.h" #include "base/string_split.h" #include "base/threading/worker_pool.h" #include "content/public/browser/browser_thread.h" +#include "content/public/common/content_switches.h" #include "content/shell/shell_network_delegate.h" #include "net/base/cert_verifier.h" #include "net/base/default_server_bound_cert_store.h" #include "net/base/host_resolver.h" +#include "net/base/mapped_host_resolver.h" #include "net/base/server_bound_cert_service.h" #include "net/base/ssl_config_service_defaults.h" #include "net/cookies/cookie_monster.h" @@ -54,6 +57,8 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (!url_request_context_.get()) { + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + url_request_context_.reset(new net::URLRequestContext()); network_delegate_.reset(new ShellNetworkDelegate); url_request_context_->set_network_delegate(network_delegate_.get()); @@ -111,6 +116,25 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { url_request_context_->http_server_properties(); network_session_params.ignore_certificate_errors = ignore_certificate_errors_; + if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { + int value; + base::StringToInt(command_line.GetSwitchValueASCII( + switches::kTestingFixedHttpPort), &value); + network_session_params.testing_fixed_http_port = value; + } + if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { + int value; + base::StringToInt(command_line.GetSwitchValueASCII( + switches::kTestingFixedHttpsPort), &value); + network_session_params.testing_fixed_https_port = value; + } + if (command_line.HasSwitch(switches::kHostResolverRules)) { + mapped_host_resolver_.reset( + new net::MappedHostResolver(network_session_params.host_resolver)); + mapped_host_resolver_->SetRulesFromString( + command_line.GetSwitchValueASCII(switches::kHostResolverRules)); + network_session_params.host_resolver = mapped_host_resolver_.get(); + } net::HttpCache* main_cache = new net::HttpCache( network_session_params, main_backend); diff --git a/content/shell/shell_url_request_context_getter.h b/content/shell/shell_url_request_context_getter.h index 98fa03c..8f61d8b 100644 --- a/content/shell/shell_url_request_context_getter.h +++ b/content/shell/shell_url_request_context_getter.h @@ -15,6 +15,7 @@ class MessageLoop; namespace net { class HostResolver; +class MappedHostResolver; class NetworkDelegate; class ProxyConfigService; class URLRequestContextStorage; @@ -50,6 +51,7 @@ class ShellURLRequestContextGetter : public net::URLRequestContextGetter { scoped_ptr<net::NetworkDelegate> network_delegate_; scoped_ptr<net::URLRequestContextStorage> storage_; scoped_ptr<net::URLRequestContext> url_request_context_; + scoped_ptr<net::MappedHostResolver> mapped_host_resolver_; DISALLOW_COPY_AND_ASSIGN(ShellURLRequestContextGetter); }; |