From 4a5e1780401366315132683fa5079c6690e50156 Mon Sep 17 00:00:00 2001 From: "mbelshe@chromium.org" Date: Fri, 5 Mar 2010 20:49:02 +0000 Subject: 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 --- net/spdy/spdy_session_pool.cc | 6 ++++-- net/spdy/spdy_session_pool.h | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'net') 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 SpdySessionPool::Get( scoped_refptr spdy_session; SpdySessionList* list = GetSessionList(host_port_pair); if (list) { - if (list->size() >= kMaxSessionsPerDomain) { + if (list->size() >= static_cast(g_max_sessions_per_domain)) { spdy_session = list->front(); list->pop_front(); } @@ -36,7 +38,7 @@ scoped_refptr SpdySessionPool::Get( DCHECK(spdy_session); list->push_back(spdy_session); - DCHECK(list->size() <= kMaxSessionsPerDomain); + DCHECK_LE(list->size(), static_cast(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 { scoped_refptr 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 { // This is our weak session pool - one session per domain. SpdySessionsMap sessions_; + static int g_max_sessions_per_domain; + DISALLOW_COPY_AND_ASSIGN(SpdySessionPool); }; -- cgit v1.1