summaryrefslogtreecommitdiffstats
path: root/net/spdy/spdy_session_pool.h
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-07 18:13:10 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-07 18:13:10 +0000
commitb846acde84543772099763542d9411eacbe684f9 (patch)
treefd0884ad9b0fd2628fb735a1371e56ccd8cdcda3 /net/spdy/spdy_session_pool.h
parente953ef72bcda93f8e89b7145cbaaa8b7ef23e8da (diff)
downloadchromium_src-b846acde84543772099763542d9411eacbe684f9.zip
chromium_src-b846acde84543772099763542d9411eacbe684f9.tar.gz
chromium_src-b846acde84543772099763542d9411eacbe684f9.tar.bz2
Make SpdySessionPool observe network changes.
BUG=40457 Review URL: http://codereview.chromium.org/2627003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49075 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy/spdy_session_pool.h')
-rw-r--r--net/spdy/spdy_session_pool.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/net/spdy/spdy_session_pool.h b/net/spdy/spdy_session_pool.h
index 2a1cb7b..fa02121e 100644
--- a/net/spdy/spdy_session_pool.h
+++ b/net/spdy/spdy_session_pool.h
@@ -13,19 +13,23 @@
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "net/base/host_port_pair.h"
+#include "net/base/network_change_notifier.h"
namespace net {
+class BoundNetLog;
class ClientSocketHandle;
class HttpNetworkSession;
-class BoundNetLog;
+class NetworkChangeNotifier;
class SpdySession;
// This is a very simple pool for open SpdySessions.
// TODO(mbelshe): Make this production ready.
-class SpdySessionPool : public base::RefCounted<SpdySessionPool> {
+class SpdySessionPool
+ : public base::RefCounted<SpdySessionPool>,
+ public NetworkChangeNotifier::Observer {
public:
- SpdySessionPool();
+ explicit SpdySessionPool(NetworkChangeNotifier* notifier);
// Either returns an existing SpdySession or creates a new SpdySession for
// use.
@@ -59,6 +63,13 @@ class SpdySessionPool : public base::RefCounted<SpdySessionPool> {
// Removes a SpdySession from the SpdySessionPool.
void Remove(const scoped_refptr<SpdySession>& session);
+ // NetworkChangeNotifier::Observer methods:
+
+ // We flush all idle sessions and release references to the active ones so
+ // they won't get re-used. The active ones will either complete successfully
+ // or error out due to the IP address change.
+ virtual void OnIPAddressChanged() { ClearSessions(); }
+
private:
friend class base::RefCounted<SpdySessionPool>;
friend class SpdySessionPoolPeer; // For testing.
@@ -75,12 +86,18 @@ class SpdySessionPool : public base::RefCounted<SpdySessionPool> {
const SpdySessionList* GetSessionList(
const HostPortPair& host_port_pair) const;
void RemoveSessionList(const HostPortPair& host_port_pair);
+ // Releases the SpdySessionPool reference to all sessions. Will result in all
+ // idle sessions being deleted, and the active sessions from being reused, so
+ // they will be deleted once all active streams belonging to that session go
+ // away.
void ClearSessions() { RemoveAllSessions(false); }
void RemoveAllSessions(bool close);
// This is our weak session pool - one session per domain.
SpdySessionsMap sessions_;
+ NetworkChangeNotifier* const network_change_notifier_;
+
static int g_max_sessions_per_domain;
DISALLOW_COPY_AND_ASSIGN(SpdySessionPool);