diff options
Diffstat (limited to 'net/spdy')
-rw-r--r-- | net/spdy/spdy_session.cc | 20 | ||||
-rw-r--r-- | net/spdy/spdy_session.h | 6 | ||||
-rw-r--r-- | net/spdy/spdy_session_pool.cc | 14 | ||||
-rw-r--r-- | net/spdy/spdy_session_pool.h | 8 |
4 files changed, 31 insertions, 17 deletions
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index 9e474b4..2e771e7 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -300,7 +300,8 @@ SpdySession::~SpdySession() { net_log_.EndEvent(NetLog::TYPE_SPDY_SESSION, NULL); } -void SpdySession::InitializeWithSSLSocket(ClientSocketHandle* connection) { +net::Error SpdySession::InitializeWithSSLSocket( + ClientSocketHandle* connection) { static StatsCounter spdy_sessions("spdy.sessions"); spdy_sessions.Increment(); @@ -313,7 +314,10 @@ void SpdySession::InitializeWithSSLSocket(ClientSocketHandle* connection) { // This is a newly initialized session that no client should have a handle to // yet, so there's no need to start writing data as in OnTCPConnect(), but we // should start reading data. - ReadSocket(); + net::Error error = ReadSocket(); + if (error == ERR_IO_PENDING) + return OK; + return error; } net::Error SpdySession::Connect(const std::string& group_name, @@ -347,6 +351,7 @@ scoped_refptr<SpdyHttpStream> SpdySession::GetOrCreateStream( const HttpRequestInfo& request, const UploadDataStream* upload_data, const BoundNetLog& stream_net_log) { + CHECK_NE(state_, CLOSED); const GURL& url = request.url; const std::string& path = url.PathForRequest(); @@ -666,13 +671,13 @@ void SpdySession::OnWriteComplete(int result) { } } -void SpdySession::ReadSocket() { +net::Error SpdySession::ReadSocket() { if (read_pending_) - return; + return OK; if (state_ == CLOSED) { NOTREACHED(); - return; + return ERR_UNEXPECTED; } CHECK(connection_.get()); @@ -684,11 +689,11 @@ void SpdySession::ReadSocket() { case 0: // Socket is closed! CloseSessionOnError(ERR_CONNECTION_CLOSED); - return; + return ERR_CONNECTION_CLOSED; case net::ERR_IO_PENDING: // Waiting for data. Nothing to do now. read_pending_ = true; - return; + return ERR_IO_PENDING; default: // Data was read, process it. // Schedule the work through the message loop to avoid recursive @@ -698,6 +703,7 @@ void SpdySession::ReadSocket() { this, &SpdySession::OnReadComplete, bytes_read)); break; } + return OK; } void SpdySession::WriteSocketLater() { diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h index 4d70d22..588b7fb 100644 --- a/net/spdy/spdy_session.h +++ b/net/spdy/spdy_session.h @@ -71,7 +71,8 @@ class SpdySession : public base::RefCounted<SpdySession>, const BoundNetLog& stream_net_log); // Used by SpdySessionPool to initialize with a pre-existing SSL socket. - void InitializeWithSSLSocket(ClientSocketHandle* connection); + // Returns OK on success, or an error on failure. + net::Error InitializeWithSSLSocket(ClientSocketHandle* connection); // Write a data frame to the stream. // Used to create and queue a data frame for the given stream. @@ -141,7 +142,8 @@ class SpdySession : public base::RefCounted<SpdySession>, void SendSettings(); // Start reading from the socket. - void ReadSocket(); + // Returns OK on success, or an error on failure. + net::Error ReadSocket(); // Write current data to the socket. void WriteSocketLater(); diff --git a/net/spdy/spdy_session_pool.cc b/net/spdy/spdy_session_pool.cc index 40557f2..c7e2e79 100644 --- a/net/spdy/spdy_session_pool.cc +++ b/net/spdy/spdy_session_pool.cc @@ -51,20 +51,22 @@ scoped_refptr<SpdySession> SpdySessionPool::Get( return spdy_session; } -scoped_refptr<SpdySession> SpdySessionPool::GetSpdySessionFromSSLSocket( +net::Error SpdySessionPool::GetSpdySessionFromSSLSocket( const HostPortPair& host_port_pair, HttpNetworkSession* session, ClientSocketHandle* connection, - const BoundNetLog& net_log) { + const BoundNetLog& net_log, + scoped_refptr<SpdySession>& spdy_session) { + // Create the SPDY session and add it to the pool. + spdy_session = (new SpdySession(host_port_pair, session, net_log.net_log())); SpdySessionList* list = GetSessionList(host_port_pair); if (!list) list = AddSessionList(host_port_pair); DCHECK(list->empty()); - scoped_refptr<SpdySession> spdy_session( - new SpdySession(host_port_pair, session, net_log.net_log())); - spdy_session->InitializeWithSSLSocket(connection); list->push_back(spdy_session); - return spdy_session; + + // Now we can initialize the session with the SSL socket. + return spdy_session->InitializeWithSSLSocket(connection); } bool SpdySessionPool::HasSession(const HostPortPair& host_port_pair) const { diff --git a/net/spdy/spdy_session_pool.h b/net/spdy/spdy_session_pool.h index fa02121e..08d01e0 100644 --- a/net/spdy/spdy_session_pool.h +++ b/net/spdy/spdy_session_pool.h @@ -13,6 +13,7 @@ #include "base/ref_counted.h" #include "base/scoped_ptr.h" #include "net/base/host_port_pair.h" +#include "net/base/net_errors.h" #include "net/base/network_change_notifier.h" namespace net { @@ -47,11 +48,14 @@ class SpdySessionPool // calling Get() first to use an existing SpdySession so we don't get // multiple SpdySessions per domain. Note that ownership of |connection| is // transferred from the caller to the SpdySession. - scoped_refptr<SpdySession> GetSpdySessionFromSSLSocket( + // Returns OK on success, and the |spdy_session| will be provided. + // Returns an error on failure, and |spdy_session| will be NULL. + net::Error GetSpdySessionFromSSLSocket( const HostPortPair& host_port_pair, HttpNetworkSession* session, ClientSocketHandle* connection, - const BoundNetLog& net_log); + const BoundNetLog& net_log, + scoped_refptr<SpdySession>& spdy_session); // TODO(willchan): Consider renaming to HasReusableSession, since perhaps we // should be creating a new session. |