diff options
author | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 20:49:02 +0000 |
---|---|---|
committer | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 20:49:02 +0000 |
commit | 4a5e1780401366315132683fa5079c6690e50156 (patch) | |
tree | 10d6a63b7b52345bcc58dba71a7c8bcf697de003 | |
parent | 2539acbc3e92658bd4a6178896de85650e18860b (diff) | |
download | chromium_src-4a5e1780401366315132683fa5079c6690e50156.zip chromium_src-4a5e1780401366315132683fa5079c6690e50156.tar.gz chromium_src-4a5e1780401366315132683fa5079c6690e50156.tar.bz2 |
Add command line option for changing the max number of SPDY sessions per
domain. The default remains at 1.
Command line usage to set it to 13:
chrome.exe --use-spdy --max-spdy-sessions-per-domain=13
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/669169
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40775 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser_main.cc | 9 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | net/spdy/spdy_session_pool.cc | 6 | ||||
-rw-r--r-- | net/spdy/spdy_session_pool.h | 8 |
5 files changed, 25 insertions, 2 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 4d9803c..0d76b8e 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -67,6 +67,7 @@ #include "net/http/http_network_session.h" #include "net/http/http_network_transaction.h" #include "net/socket/client_socket_pool_base.h" +#include "net/spdy/spdy_session_pool.h" #if defined(OS_POSIX) // TODO(port): get rid of this include. It's used just to provide declarations @@ -674,6 +675,14 @@ int BrowserMain(const MainFunctionParams& parameters) { if (parsed_command_line.HasSwitch(switches::kIgnoreCertificateErrors)) net::HttpNetworkTransaction::IgnoreCertificateErrors(true); + if (parsed_command_line.HasSwitch(switches::kMaxSpdySessionsPerDomain)) { + int value = StringToInt( + parsed_command_line.GetSwitchValueASCII( + switches::kMaxSpdySessionsPerDomain)); + net::SpdySessionPool::set_max_sessions_per_domain(value); + } + + // Initialize histogram statistics gathering system. StatisticsRecorder statistics; diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index ac8ee7b..31e3ae3 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -699,6 +699,9 @@ const char kFixedHttpsPort[] = "testing-fixed-https-port"; // Ignore certificate related errors. const char kIgnoreCertificateErrors[] = "ignore-certificate-errors"; +// Set the maximum SPDY sessions per domain. +const char kMaxSpdySessionsPerDomain[] = "max-spdy-sessions-per-domain"; + // Use the low fragmentation heap for the CRT. const char kUseLowFragHeapCrt[] = "use-lf-heap"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 5ceb5fb..0e463a6 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -198,6 +198,7 @@ extern const char kUseSpdy[]; extern const char kFixedHttpPort[]; extern const char kFixedHttpsPort[]; extern const char kIgnoreCertificateErrors[]; +extern const char kMaxSpdySessionsPerDomain[]; extern const char kUseLowFragHeapCrt[]; extern const char kUserAgent[]; extern const char kUserDataDir[]; diff --git a/net/spdy/spdy_session_pool.cc b/net/spdy/spdy_session_pool.cc index 0f012fb..5cfd62c 100644 --- a/net/spdy/spdy_session_pool.cc +++ b/net/spdy/spdy_session_pool.cc @@ -12,6 +12,8 @@ namespace net { // The maximum number of sessions to open to a single domain. static const size_t kMaxSessionsPerDomain = 1; +int SpdySessionPool::g_max_sessions_per_domain = kMaxSessionsPerDomain; + SpdySessionPool::SpdySessionPool() {} SpdySessionPool::~SpdySessionPool() { CloseAllSessions(); @@ -22,7 +24,7 @@ scoped_refptr<SpdySession> SpdySessionPool::Get( scoped_refptr<SpdySession> spdy_session; SpdySessionList* list = GetSessionList(host_port_pair); if (list) { - if (list->size() >= kMaxSessionsPerDomain) { + if (list->size() >= static_cast<unsigned int>(g_max_sessions_per_domain)) { spdy_session = list->front(); list->pop_front(); } @@ -36,7 +38,7 @@ scoped_refptr<SpdySession> SpdySessionPool::Get( DCHECK(spdy_session); list->push_back(spdy_session); - DCHECK(list->size() <= kMaxSessionsPerDomain); + DCHECK_LE(list->size(), static_cast<unsigned int>(g_max_sessions_per_domain)); return spdy_session; } diff --git a/net/spdy/spdy_session_pool.h b/net/spdy/spdy_session_pool.h index 8cf8c60..8c50577 100644 --- a/net/spdy/spdy_session_pool.h +++ b/net/spdy/spdy_session_pool.h @@ -47,6 +47,12 @@ class SpdySessionPool : public base::RefCounted<SpdySessionPool> { scoped_refptr<SpdySession> Get( const HostPortPair& host_port_pair, HttpNetworkSession* session); + // Set the maximum concurrent sessions per domain. + static void set_max_sessions_per_domain(int max) { + if (max >= 1) + g_max_sessions_per_domain = max; + } + // Builds a SpdySession from an existing SSL socket. Users should try // calling Get() first to use an existing SpdySession so we don't get // multiple SpdySessions per domain. Note that ownership of |connection| is @@ -86,6 +92,8 @@ class SpdySessionPool : public base::RefCounted<SpdySessionPool> { // This is our weak session pool - one session per domain. SpdySessionsMap sessions_; + static int g_max_sessions_per_domain; + DISALLOW_COPY_AND_ASSIGN(SpdySessionPool); }; |