diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-21 16:57:45 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-21 16:57:45 +0000 |
commit | 807c01ae2f590bc809312e9be809baa6ac38d5c7 (patch) | |
tree | 6fb7678efd51e4fe3db8a6df45b3c300188a3cb0 /net | |
parent | fd4d226549034acc7b249e0eff537089bd0cd6db (diff) | |
download | chromium_src-807c01ae2f590bc809312e9be809baa6ac38d5c7.zip chromium_src-807c01ae2f590bc809312e9be809baa6ac38d5c7.tar.gz chromium_src-807c01ae2f590bc809312e9be809baa6ac38d5c7.tar.bz2 |
SPDY: Fix unittest-only leak.
We leaked the SpdySessionPool and SpdySession in the test since they have a circular reference.
This is usually broken by a GOAWAY frame in real code, but we have to manually break the circular reference here.
BUG=42084
Review URL: http://codereview.chromium.org/1695001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45198 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/spdy/spdy_session.h | 32 | ||||
-rw-r--r-- | net/spdy/spdy_session_pool.h | 7 | ||||
-rw-r--r-- | net/spdy/spdy_session_unittest.cc | 5 |
3 files changed, 21 insertions, 23 deletions
diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h index 0564354..32d1d0c 100644 --- a/net/spdy/spdy_session.h +++ b/net/spdy/spdy_session.h @@ -38,6 +38,11 @@ class SSLInfo; class SpdySession : public base::RefCounted<SpdySession>, public spdy::SpdyFramerVisitorInterface { public: + // Create a new SpdySession. + // |host_port_pair| is the host/port that this session connects to. + // |session| is the HttpNetworkSession + SpdySession(const HostPortPair& host_port_pair, HttpNetworkSession* session); + const HostPortPair& host_port_pair() const { return host_port_pair_; } // Connect the Spdy Socket. @@ -58,6 +63,9 @@ class SpdySession : public base::RefCounted<SpdySession>, scoped_refptr<SpdyStream> GetOrCreateStream(const HttpRequestInfo& request, const UploadDataStream* upload_data, const BoundNetLog& log); + // Used by SpdySessionPool to initialize with a pre-existing SSL socket. + void InitializeWithSSLSocket(ClientSocketHandle* connection); + // Write a data frame to the stream. // Used to create and queue a data frame for the given stream. int WriteStreamData(spdy::SpdyStreamId stream_id, net::IOBuffer* data, @@ -73,12 +81,15 @@ class SpdySession : public base::RefCounted<SpdySession>, // status, such as "resolving host", "connecting", etc. LoadState GetLoadState() const; + // Closes all open streams. Used as part of shutdown. + void CloseAllStreams(net::Error code); + // Enable or disable SSL. static void SetSSLMode(bool enable) { use_ssl_ = enable; } static bool SSLMode() { return use_ssl_; } - protected: - friend class SpdySessionPool; + private: + friend class base::RefCounted<SpdySession>; enum State { IDLE, @@ -87,20 +98,6 @@ class SpdySession : public base::RefCounted<SpdySession>, CLOSED }; - // Provide access to the framer for testing. - spdy::SpdyFramer* GetFramer() { return &spdy_framer_; } - - // Create a new SpdySession. - // |host_port_pair| is the host/port that this session connects to. - // |session| is the HttpNetworkSession - SpdySession(const HostPortPair& host_port_pair, HttpNetworkSession* session); - - // Closes all open streams. Used as part of shutdown. - void CloseAllStreams(net::Error code); - - private: - friend class base::RefCounted<SpdySession>; - typedef std::map<int, scoped_refptr<SpdyStream> > ActiveStreamMap; typedef std::list<scoped_refptr<SpdyStream> > ActiveStreamList; typedef std::map<std::string, scoped_refptr<SpdyStream> > PendingStreamMap; @@ -108,9 +105,6 @@ class SpdySession : public base::RefCounted<SpdySession>, virtual ~SpdySession(); - // Used by SpdySessionPool to initialize with a pre-existing SSL socket. - void InitializeWithSSLSocket(ClientSocketHandle* connection); - // SpdyFramerVisitorInterface virtual void OnError(spdy::SpdyFramer*); virtual void OnStreamFrameData(spdy::SpdyStreamId stream_id, diff --git a/net/spdy/spdy_session_pool.h b/net/spdy/spdy_session_pool.h index db4ec42..3a77bc0 100644 --- a/net/spdy/spdy_session_pool.h +++ b/net/spdy/spdy_session_pool.h @@ -53,9 +53,11 @@ class SpdySessionPool : public base::RefCounted<SpdySessionPool> { // Close all Spdy Sessions; used for debugging. void CloseAllSessions(); + // Removes a SpdySession from the SpdySessionPool. + void Remove(const scoped_refptr<SpdySession>& session); + private: friend class base::RefCounted<SpdySessionPool>; - friend class SpdySession; // Needed for Remove(). friend class SpdySessionPoolPeer; // For testing. typedef std::list<scoped_refptr<SpdySession> > SpdySessionList; @@ -63,9 +65,6 @@ class SpdySessionPool : public base::RefCounted<SpdySessionPool> { virtual ~SpdySessionPool(); - // Removes a SpdySession from the SpdySessionPool. - void Remove(const scoped_refptr<SpdySession>& session); - // Helper functions for manipulating the lists. SpdySessionList* AddSessionList(const HostPortPair& host_port_pair); SpdySessionList* GetSessionList(const HostPortPair& host_port_pair); diff --git a/net/spdy/spdy_session_unittest.cc b/net/spdy/spdy_session_unittest.cc index 2dd0820..4e95263 100644 --- a/net/spdy/spdy_session_unittest.cc +++ b/net/spdy/spdy_session_unittest.cc @@ -138,7 +138,12 @@ TEST_F(SpdySessionTest, GoAway) { scoped_refptr<SpdySession> session2 = spdy_session_pool->Get(test_host_port_pair, http_session.get()); + // Delete the first session. session = NULL; + + // Delete the second session. + spdy_session_pool->Remove(session2); + session2 = NULL; } } // namespace |