diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-04 21:00:36 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-04 21:00:36 +0000 |
commit | c976120a73d5b7e991bc37c705b9a1ee59bf4e4a (patch) | |
tree | 91c75ab7287fc4dbad2317743f7eb7f9580736c3 /net | |
parent | c706996bf7fa2c52cfda479d324102fee69ab3bf (diff) | |
download | chromium_src-c976120a73d5b7e991bc37c705b9a1ee59bf4e4a.zip chromium_src-c976120a73d5b7e991bc37c705b9a1ee59bf4e4a.tar.gz chromium_src-c976120a73d5b7e991bc37c705b9a1ee59bf4e4a.tar.bz2 |
Revert 54906 - Refactor HttpNetworkTransaction to eliminate the SPDY
specific states of the state machine. This required
adding two new states:
STATE_INIT_STREAM
STATE_INTI_STREAM_COMPLETE
The http_stream_ and spdy_http_stream_ member fields
have been removed, and replaced by a single stream_
member field which is initialized with either an
HttpBasicStream, or SpdyHttpStream depending on the
underlying connection.
In the process, the NetLog no longer receives TYPE_SPDY
events, only TYPE_HTTP, so spdy_network_transaction_unittest.cc
needed to be modified accordingly.
This seems to causing Valgrind leaks:
http://build.chromium.org/buildbot/memory/builders/Chromium%20Mac%20(valgrind)/builds/6887/steps/memory%20test:%20net/logs/stdio
E.g.:
Leak_DefinitelyLost
78,766 (888 direct, 77,878 indirect) bytes in 2 blocks are definitely lost in loss record 6,975 of 7,027
operator new(unsigned long) (mp/vg-bins/scripts/valgrind-memcheck/coregrind/m_replacemalloc/vg_replace_malloc.c:276)
net::SpdySessionPool::GetSpdySessionFromSocket(std::pair<net::HostPortPair, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&, net::HttpNetworkSession*, net::ClientSocketHandle*, net::BoundNetLog const&, int, scoped_refptr<net::SpdySession>*, bool)
net::HttpNetworkTransaction::DoInitStream()
net::HttpNetworkTransaction::DoLoop(int)
net::HttpNetworkTransaction::OnIOComplete(int)
net::ClientSocketHandle::OnIOComplete(int)
net::internal::ClientSocketPoolBaseHelper::InvokeUserCallback(net::ClientSocketHandle*)
RunnableMethod<net::internal::ClientSocketPoolBaseHelper, void (net::internal::ClientSocketPoolBaseHelper::*)(net::ClientSocketHandle*), Tuple1<net::ClientSocketHandle*> >::Run()
MessageLoop::RunTask(Task*)
MessageLoop::DeferOrRunPendingTask(MessageLoop::PendingTask const&)
MessageLoop::DoWork()
base::MessagePumpLibevent::Run(base::MessagePump::Delegate*)
MessageLoop::RunInternal()
MessageLoop::Run()
TestCompletionCallback::WaitForResult()
net::SpdyNetworkTransactionTest_SocketWriteReturnsZero_Test::TestBody()
testing::Test::Run()
testing::internal::TestInfoImpl::Run()
testing::TestCase::Run()
testing::internal::UnitTestImpl::RunAllTests()
TestSuite::Run()
main
Suppression (error hash=#-444E9002#):
{
<insert_a_suppression_name_here>
Memcheck:Leak
fun:_Znw*
fun:_ZN3net15SpdySessionPool24GetSpdySessionFromSocketERKSt4pairINS_12HostPortPairESsEPNS_18HttpNetworkSessionEPNS_18ClientSocketHandleERKNS_11BoundNetLogEiP13scoped_refptrINS_11SpdySessionEEb
fun:_ZN3net22HttpNetworkTransaction12DoInitStreamEv
fun:_ZN3net22HttpNetworkTransaction6DoLoopEi
fun:_ZN3net22HttpNetworkTransaction12OnIOCompleteEi
fun:_ZN3net18ClientSocketHandle12OnIOCompleteEi
fun:_ZN3net8internal26ClientSocketPoolBaseHelper18InvokeUserCallbackEPNS_18ClientSocketHandleE
fun:_ZN14RunnableMethodIN3net8internal26ClientSocketPoolBaseHelperEMS2_FvPNS0_18ClientSocketHandleEE6Tuple1IS4_EE3RunEv
fun:_ZN11MessageLoop7RunTaskEP4Task
fun:_ZN11MessageLoop21DeferOrRunPendingTaskERKNS_11PendingTaskE
fun:_ZN11MessageLoop6DoWorkEv
fun:_ZN4base19MessagePumpLibevent3RunEPNS_11MessagePump8DelegateE
fun:_ZN11MessageLoop11RunInternalEv
}
BUG=50267
TEST=none
Review URL: http://codereview.chromium.org/3064033
TBR=rch@chromium.org
Review URL: http://codereview.chromium.org/3038048
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54963 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_network_transaction.cc | 309 | ||||
-rw-r--r-- | net/http/http_network_transaction.h | 26 | ||||
-rw-r--r-- | net/spdy/spdy_network_transaction_unittest.cc | 13 |
3 files changed, 227 insertions, 121 deletions
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 53a64a6..93da711 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -298,7 +298,7 @@ int HttpNetworkTransaction::RestartIgnoringLastError( // update in DoSSLConnectComplete if |result| is OK? if (using_spdy_) { // TODO(cbentzel): Add auth support to spdy. See http://crbug.com/46620 - next_state_ = STATE_INIT_STREAM; + next_state_ = STATE_SPDY_GET_STREAM; } else { next_state_ = STATE_GENERATE_PROXY_AUTH_TOKEN; } @@ -370,10 +370,10 @@ void HttpNetworkTransaction::PrepareForAuthRestart(HttpAuth::Target target) { // Even if the server says the connection is keep-alive, we have to be // able to find the end of each response in order to reuse the connection. if (GetResponseHeaders()->IsKeepAlive() && - stream_->CanFindEndOfResponse()) { + http_stream_->CanFindEndOfResponse()) { // If the response body hasn't been completely read, we need to drain // it first. - if (!stream_->IsResponseBodyComplete()) { + if (!http_stream_->IsResponseBodyComplete()) { next_state_ = STATE_DRAIN_BODY_FOR_AUTH_RESTART; read_buf_ = new IOBuffer(kDrainBodyBufferSize); // A bit bucket. read_buf_len_ = kDrainBodyBufferSize; @@ -430,10 +430,16 @@ int HttpNetworkTransaction::Read(IOBuffer* buf, int buf_len, } // Are we using SPDY or HTTP? - next_state = STATE_READ_BODY; - DCHECK(stream_->GetResponseInfo()->headers); - if (!using_spdy_ && !connection_->is_initialized()) { - return 0; // |*connection_| has been reset. Treat like EOF. + if (using_spdy_) { + DCHECK(!http_stream_.get()); + DCHECK(spdy_http_stream_->GetResponseInfo()->headers); + next_state = STATE_SPDY_READ_BODY; + } else { + DCHECK(!spdy_http_stream_.get()); + next_state = STATE_READ_BODY; + + if (!connection_->is_initialized()) + return 0; // |*connection_| has been reset. Treat like EOF. } read_buf_ = buf; @@ -462,11 +468,14 @@ LoadState HttpNetworkTransaction::GetLoadState() const { case STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE: case STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE: case STATE_SEND_REQUEST_COMPLETE: - case STATE_INIT_STREAM_COMPLETE: + case STATE_SPDY_GET_STREAM: + case STATE_SPDY_SEND_REQUEST_COMPLETE: return LOAD_STATE_SENDING_REQUEST; case STATE_READ_HEADERS_COMPLETE: + case STATE_SPDY_READ_HEADERS_COMPLETE: return LOAD_STATE_WAITING_FOR_RESPONSE; case STATE_READ_BODY_COMPLETE: + case STATE_SPDY_READ_BODY_COMPLETE: return LOAD_STATE_READING_RESPONSE; default: return LOAD_STATE_IDLE; @@ -474,10 +483,10 @@ LoadState HttpNetworkTransaction::GetLoadState() const { } uint64 HttpNetworkTransaction::GetUploadProgress() const { - if (!stream_.get()) + if (!http_stream_.get()) return 0; - return stream_->GetUploadProgress(); + return http_stream_->GetUploadProgress(); } HttpNetworkTransaction::~HttpNetworkTransaction() { @@ -488,10 +497,9 @@ HttpNetworkTransaction::~HttpNetworkTransaction() { // The STATE_NONE check guarantees there are no pending socket IOs that // could try to call this object back after it is deleted. bool keep_alive = next_state_ == STATE_NONE && - !using_spdy_ && - stream_.get() && - stream_->IsResponseBodyComplete() && - stream_->CanFindEndOfResponse() && + http_stream_.get() && + http_stream_->IsResponseBodyComplete() && + http_stream_->CanFindEndOfResponse() && GetResponseHeaders()->IsKeepAlive(); if (!keep_alive) connection_->socket()->Disconnect(); @@ -500,8 +508,8 @@ HttpNetworkTransaction::~HttpNetworkTransaction() { if (pac_request_) session_->proxy_service()->CancelPacRequest(pac_request_); - if (using_spdy_ && stream_.get()) - static_cast<SpdyHttpStream*>(stream_.get())->Cancel(); + if (spdy_http_stream_.get()) + spdy_http_stream_->Cancel(); } void HttpNetworkTransaction::DoCallback(int rv) { @@ -542,13 +550,6 @@ int HttpNetworkTransaction::DoLoop(int result) { case STATE_INIT_CONNECTION_COMPLETE: rv = DoInitConnectionComplete(rv); break; - case STATE_INIT_STREAM: - DCHECK_EQ(OK, rv); - rv = DoInitStream(); - break; - case STATE_INIT_STREAM_COMPLETE: - rv = DoInitStreamComplete(rv); - break; case STATE_RESTART_TUNNEL_AUTH: DCHECK_EQ(OK, rv); rv = DoRestartTunnelAuth(); @@ -608,6 +609,40 @@ int HttpNetworkTransaction::DoLoop(int result) { net_log_.EndEvent( NetLog::TYPE_HTTP_TRANSACTION_DRAIN_BODY_FOR_AUTH_RESTART, NULL); break; + case STATE_SPDY_GET_STREAM: + DCHECK_EQ(OK, rv); + rv = DoSpdyGetStream(); + break; + case STATE_SPDY_GET_STREAM_COMPLETE: + rv = DoSpdyGetStreamComplete(rv); + break; + case STATE_SPDY_SEND_REQUEST: + DCHECK_EQ(OK, rv); + net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST, NULL); + rv = DoSpdySendRequest(); + break; + case STATE_SPDY_SEND_REQUEST_COMPLETE: + rv = DoSpdySendRequestComplete(rv); + net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST, NULL); + break; + case STATE_SPDY_READ_HEADERS: + DCHECK_EQ(OK, rv); + net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_HEADERS, NULL); + rv = DoSpdyReadHeaders(); + break; + case STATE_SPDY_READ_HEADERS_COMPLETE: + rv = DoSpdyReadHeadersComplete(rv); + net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_HEADERS, NULL); + break; + case STATE_SPDY_READ_BODY: + DCHECK_EQ(OK, rv); + net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_BODY, NULL); + rv = DoSpdyReadBody(); + break; + case STATE_SPDY_READ_BODY_COMPLETE: + rv = DoSpdyReadBodyComplete(rv); + net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_BODY, NULL); + break; default: NOTREACHED() << "bad state"; rv = ERR_FAILED; @@ -713,9 +748,7 @@ int HttpNetworkTransaction::DoInitConnection() { if (session_->spdy_session_pool()->HasSession(pair)) { using_spdy_ = true; reused_socket_ = true; - next_state_ = STATE_INIT_STREAM; - spdy_session_ = - session_->spdy_session_pool()->Get(pair, session_, net_log_); + next_state_ = STATE_SPDY_GET_STREAM; return OK; } @@ -923,7 +956,7 @@ int HttpNetworkTransaction::DoInitConnectionComplete(int result) { if (!using_ssl_) { DCHECK_EQ(OK, result); if (using_spdy_) - next_state_ = STATE_INIT_STREAM; + next_state_ = STATE_SPDY_GET_STREAM; else next_state_ = STATE_GENERATE_PROXY_AUTH_TOKEN; return result; @@ -960,56 +993,13 @@ int HttpNetworkTransaction::DoInitConnectionComplete(int result) { if (using_spdy_) { UpdateConnectionTypeHistograms(CONNECTION_SPDY); // TODO(cbentzel): Add auth support to spdy. See http://crbug.com/46620 - next_state_ = STATE_INIT_STREAM; + next_state_ = STATE_SPDY_GET_STREAM; } else { next_state_ = STATE_GENERATE_PROXY_AUTH_TOKEN; } return OK; } -int HttpNetworkTransaction::DoInitStream() { - next_state_ = STATE_INIT_STREAM_COMPLETE; - - if (!using_spdy_) { - stream_.reset(new HttpBasicStream(connection_.get())); - return stream_->InitializeStream(request_, net_log_, &io_callback_); - } - - CHECK(!stream_.get()); - - const scoped_refptr<SpdySessionPool> spdy_pool = - session_->spdy_session_pool(); - - HostPortProxyPair pair(endpoint_, proxy_info_.ToPacString()); - if (!spdy_session_.get()) { - // SPDY can be negotiated using the TLS next protocol negotiation (NPN) - // extension, or just directly using SSL. Either way, |connection_| must - // contain an SSLClientSocket. - CHECK(connection_->socket()); - int error = spdy_pool->GetSpdySessionFromSocket( - pair, session_, connection_.release(), net_log_, - spdy_certificate_error_, &spdy_session_, using_ssl_); - if (error != OK) - return error; - } - CHECK(spdy_session_.get()); - if (spdy_session_->IsClosed()) - return ERR_CONNECTION_CLOSED; - - headers_valid_ = false; - - stream_.reset(new SpdyHttpStream(spdy_session_.release())); - return stream_->InitializeStream(request_, net_log_, &io_callback_); -} - -int HttpNetworkTransaction::DoInitStreamComplete(int result) { - if (result < 0) - return result; - - next_state_ = STATE_SEND_REQUEST; - return OK; -} - int HttpNetworkTransaction::DoRestartTunnelAuth() { next_state_ = STATE_RESTART_TUNNEL_AUTH_COMPLETE; HttpProxyClientSocket* http_proxy_socket = @@ -1073,7 +1063,7 @@ int HttpNetworkTransaction::DoGenerateServerAuthToken() { int HttpNetworkTransaction::DoGenerateServerAuthTokenComplete(int rv) { DCHECK_NE(ERR_IO_PENDING, rv); if (rv == OK) - next_state_ = STATE_INIT_STREAM; + next_state_ = STATE_SEND_REQUEST; return rv; } @@ -1090,7 +1080,7 @@ int HttpNetworkTransaction::DoSendRequest() { // This is constructed lazily (instead of within our Start method), so that // we have proxy info available. - if (request_headers_.empty() && !using_spdy_) { + if (request_headers_.empty()) { // Figure out if we can/should add Proxy-Authentication & Authentication // headers. HttpRequestHeaders authorization_headers; @@ -1123,8 +1113,10 @@ int HttpNetworkTransaction::DoSendRequest() { } headers_valid_ = false; - return stream_->SendRequest(request_headers_, request_body, &response_, - &io_callback_); + http_stream_.reset(new HttpBasicStream(connection_.get())); + http_stream_->InitializeStream(request_, net_log_, NULL); + return http_stream_->SendRequest(request_headers_, request_body, &response_, + &io_callback_); } int HttpNetworkTransaction::DoSendRequestComplete(int result) { @@ -1136,7 +1128,7 @@ int HttpNetworkTransaction::DoSendRequestComplete(int result) { int HttpNetworkTransaction::DoReadHeaders() { next_state_ = STATE_READ_HEADERS_COMPLETE; - return stream_->ReadResponseHeaders(&io_callback_); + return http_stream_->ReadResponseHeaders(&io_callback_); } int HttpNetworkTransaction::HandleConnectionClosedBeforeEndOfHeaders() { @@ -1150,18 +1142,6 @@ int HttpNetworkTransaction::HandleConnectionClosedBeforeEndOfHeaders() { } int HttpNetworkTransaction::DoReadHeadersComplete(int result) { - if (using_spdy_) { - // TODO(willchan): Flesh out the support for HTTP authentication here. - if (result < 0) - return HandleIOError(result); - - if (result == OK) - headers_valid_ = true; - - LogTransactionConnectedMetrics(); - return result; - } - // We can get a certificate error or ERR_SSL_CLIENT_AUTH_CERT_NEEDED here // due to SSL renegotiation. if (using_ssl_) { @@ -1267,11 +1247,11 @@ int HttpNetworkTransaction::DoReadHeadersComplete(int result) { int HttpNetworkTransaction::DoReadBody() { DCHECK(read_buf_); DCHECK_GT(read_buf_len_, 0); - if (!using_spdy_) - DCHECK(connection_->is_initialized()); + DCHECK(connection_->is_initialized()); next_state_ = STATE_READ_BODY_COMPLETE; - return stream_->ReadResponseBody(read_buf_, read_buf_len_, &io_callback_); + return http_stream_->ReadResponseBody(read_buf_, read_buf_len_, + &io_callback_); } int HttpNetworkTransaction::DoReadBodyComplete(int result) { @@ -1280,21 +1260,19 @@ int HttpNetworkTransaction::DoReadBodyComplete(int result) { if (result <= 0) done = true; - if (stream_->IsResponseBodyComplete()) { + if (http_stream_->IsResponseBodyComplete()) { done = true; - if (stream_->CanFindEndOfResponse()) + if (http_stream_->CanFindEndOfResponse()) keep_alive = GetResponseHeaders()->IsKeepAlive(); } // Clean up connection_->if we are done. if (done) { LogTransactionMetrics(); - if (!using_spdy_) { - if (!keep_alive) - connection_->socket()->Disconnect(); - connection_->Reset(); - // The next Read call will return 0 (EOF). - } + if (!keep_alive) + connection_->socket()->Disconnect(); + connection_->Reset(); + // The next Read call will return 0 (EOF). } // Clear these to avoid leaving around old state. @@ -1324,7 +1302,7 @@ int HttpNetworkTransaction::DoDrainBodyForAuthRestartComplete(int result) { // Error or closed connection while reading the socket. done = true; keep_alive = false; - } else if (stream_->IsResponseBodyComplete()) { + } else if (http_stream_->IsResponseBodyComplete()) { done = true; } @@ -1338,6 +1316,118 @@ int HttpNetworkTransaction::DoDrainBodyForAuthRestartComplete(int result) { return OK; } +int HttpNetworkTransaction::DoSpdyGetStream() { + next_state_ = STATE_SPDY_GET_STREAM_COMPLETE; + CHECK(!spdy_http_stream_.get()); + + // First we get a SPDY session. Theoretically, we've just negotiated one, but + // if one already exists, then screw it, use the existing one! Otherwise, + // use the existing TCP socket. + + const scoped_refptr<SpdySessionPool> spdy_pool = + session_->spdy_session_pool(); + scoped_refptr<SpdySession> spdy_session; + + HostPortProxyPair pair(endpoint_, proxy_info_.ToPacString()); + if (spdy_pool->HasSession(pair)) { + spdy_session = spdy_pool->Get(pair, session_, net_log_); + } else { + if(using_ssl_) { + // SPDY can be negotiated using the TLS next protocol negotiation (NPN) + // extension, or just directly using SSL. Either way, |connection_| must + // contain an SSLClientSocket. + CHECK(connection_->socket()); + int error = spdy_pool->GetSpdySessionFromSocket( + pair, session_, connection_.release(), net_log_, + spdy_certificate_error_, &spdy_session, true); + if (error != OK) + return error; + } + else { + // We may want SPDY without SSL + int error = spdy_pool->GetSpdySessionFromSocket( + pair, session_, connection_.release(), net_log_, + spdy_certificate_error_, &spdy_session, false); + if (error != OK) + return error; + } + } + + CHECK(spdy_session.get()); + if (spdy_session->IsClosed()) + return ERR_CONNECTION_CLOSED; + + headers_valid_ = false; + + spdy_http_stream_.reset(new SpdyHttpStream(spdy_session)); + return spdy_http_stream_->InitializeStream(request_, net_log_, &io_callback_); +} + +int HttpNetworkTransaction::DoSpdyGetStreamComplete(int result) { + if (result < 0) + return result; + + next_state_ = STATE_SPDY_SEND_REQUEST; + return OK; +} + +int HttpNetworkTransaction::DoSpdySendRequest() { + next_state_ = STATE_SPDY_SEND_REQUEST_COMPLETE; + + UploadDataStream* upload_data_stream = NULL; + if (request_->upload_data) { + int error_code = OK; + upload_data_stream = UploadDataStream::Create(request_->upload_data, + &error_code); + if (!upload_data_stream) + return error_code; + } + return spdy_http_stream_->SendRequest(request_headers_, upload_data_stream, + &response_, &io_callback_); +} + +int HttpNetworkTransaction::DoSpdySendRequestComplete(int result) { + if (result < 0) + return HandleIOError(result); + + next_state_ = STATE_SPDY_READ_HEADERS; + return OK; +} + +int HttpNetworkTransaction::DoSpdyReadHeaders() { + next_state_ = STATE_SPDY_READ_HEADERS_COMPLETE; + return spdy_http_stream_->ReadResponseHeaders(&io_callback_); +} + +int HttpNetworkTransaction::DoSpdyReadHeadersComplete(int result) { + // TODO(willchan): Flesh out the support for HTTP authentication here. + if (result < 0) + return HandleIOError(result); + + if (result == OK) + headers_valid_ = true; + + LogTransactionConnectedMetrics(); + return result; +} + +int HttpNetworkTransaction::DoSpdyReadBody() { + next_state_ = STATE_SPDY_READ_BODY_COMPLETE; + + return spdy_http_stream_->ReadResponseBody( + read_buf_, read_buf_len_, &io_callback_); +} + +int HttpNetworkTransaction::DoSpdyReadBodyComplete(int result) { + read_buf_ = NULL; + read_buf_len_ = 0; + + if (result <= 0) + spdy_http_stream_.reset(); + + return result; +} + void HttpNetworkTransaction::LogHttpConnectedMetrics( const ClientSocketHandle& handle) { UMA_HISTOGRAM_ENUMERATION("Net.HttpSocketType", handle.reuse_type(), @@ -1616,7 +1706,7 @@ void HttpNetworkTransaction::ResetStateForRestart() { pending_auth_target_ = HttpAuth::AUTH_NONE; read_buf_ = NULL; read_buf_len_ = 0; - stream_.reset(); + http_stream_.reset(); headers_valid_ = false; request_headers_.clear(); response_ = HttpResponseInfo(); @@ -1627,9 +1717,8 @@ HttpResponseHeaders* HttpNetworkTransaction::GetResponseHeaders() const { } bool HttpNetworkTransaction::ShouldResendRequest(int error) const { - if (using_spdy_ && stream_ != NULL) - return static_cast<SpdyHttpStream *>(stream_.get())-> - ShouldResendFailedRequest(error); + if (using_spdy_ && spdy_http_stream_ != NULL) + return spdy_http_stream_->ShouldResendFailedRequest(error); // NOTE: we resend a request only if we reused a keep-alive connection. // This automatically prevents an infinite resend loop because we'll run @@ -1656,7 +1745,7 @@ void HttpNetworkTransaction::ResetConnectionAndRequestForResend() { // headers, but we may need to resend the CONNECT request first to recreate // the SSL tunnel. - stream_.reset(NULL); + spdy_http_stream_.reset(NULL); request_headers_.clear(); next_state_ = STATE_INIT_CONNECTION; // Resend the request. @@ -1805,8 +1894,6 @@ std::string HttpNetworkTransaction::DescribeState(State state) { STATE_CASE(STATE_RESOLVE_PROXY_COMPLETE); STATE_CASE(STATE_INIT_CONNECTION); STATE_CASE(STATE_INIT_CONNECTION_COMPLETE); - STATE_CASE(STATE_INIT_STREAM); - STATE_CASE(STATE_INIT_STREAM_COMPLETE); STATE_CASE(STATE_GENERATE_PROXY_AUTH_TOKEN); STATE_CASE(STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE); STATE_CASE(STATE_GENERATE_SERVER_AUTH_TOKEN); @@ -1819,6 +1906,14 @@ std::string HttpNetworkTransaction::DescribeState(State state) { STATE_CASE(STATE_READ_BODY_COMPLETE); STATE_CASE(STATE_DRAIN_BODY_FOR_AUTH_RESTART); STATE_CASE(STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE); + STATE_CASE(STATE_SPDY_GET_STREAM); + STATE_CASE(STATE_SPDY_GET_STREAM_COMPLETE); + STATE_CASE(STATE_SPDY_SEND_REQUEST); + STATE_CASE(STATE_SPDY_SEND_REQUEST_COMPLETE); + STATE_CASE(STATE_SPDY_READ_HEADERS); + STATE_CASE(STATE_SPDY_READ_HEADERS_COMPLETE); + STATE_CASE(STATE_SPDY_READ_BODY); + STATE_CASE(STATE_SPDY_READ_BODY_COMPLETE); STATE_CASE(STATE_NONE); default: description = StringPrintf("Unknown state 0x%08X (%u)", state, state); diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h index 46b9c8cec..b3a083c 100644 --- a/net/http/http_network_transaction.h +++ b/net/http/http_network_transaction.h @@ -36,7 +36,7 @@ class ClientSocketHandle; class HttpNetworkSession; class HttpRequestHeaders; class HttpStream; -class SpdySession; +class SpdyHttpStream; class HttpNetworkTransaction : public HttpTransaction { public: @@ -91,8 +91,6 @@ class HttpNetworkTransaction : public HttpTransaction { STATE_RESOLVE_PROXY_COMPLETE, STATE_INIT_CONNECTION, STATE_INIT_CONNECTION_COMPLETE, - STATE_INIT_STREAM, - STATE_INIT_STREAM_COMPLETE, STATE_RESTART_TUNNEL_AUTH, STATE_RESTART_TUNNEL_AUTH_COMPLETE, STATE_GENERATE_PROXY_AUTH_TOKEN, @@ -107,6 +105,14 @@ class HttpNetworkTransaction : public HttpTransaction { STATE_READ_BODY_COMPLETE, STATE_DRAIN_BODY_FOR_AUTH_RESTART, STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, + STATE_SPDY_GET_STREAM, + STATE_SPDY_GET_STREAM_COMPLETE, + STATE_SPDY_SEND_REQUEST, + STATE_SPDY_SEND_REQUEST_COMPLETE, + STATE_SPDY_READ_HEADERS, + STATE_SPDY_READ_HEADERS_COMPLETE, + STATE_SPDY_READ_BODY, + STATE_SPDY_READ_BODY_COMPLETE, STATE_NONE }; @@ -130,8 +136,6 @@ class HttpNetworkTransaction : public HttpTransaction { int DoResolveProxyComplete(int result); int DoInitConnection(); int DoInitConnectionComplete(int result); - int DoInitStream(); - int DoInitStreamComplete(int result); int DoRestartTunnelAuth(); int DoRestartTunnelAuthComplete(int result); int DoGenerateProxyAuthToken(); @@ -146,6 +150,14 @@ class HttpNetworkTransaction : public HttpTransaction { int DoReadBodyComplete(int result); int DoDrainBodyForAuthRestart(); int DoDrainBodyForAuthRestartComplete(int result); + int DoSpdyGetStream(); + int DoSpdyGetStreamComplete(int result); + int DoSpdySendRequest(); + int DoSpdySendRequestComplete(int result); + int DoSpdyReadHeaders(); + int DoSpdyReadHeadersComplete(int result); + int DoSpdyReadBody(); + int DoSpdyReadBodyComplete(int result); // Record histograms of latency until Connect() completes. static void LogHttpConnectedMetrics(const ClientSocketHandle& handle); @@ -265,8 +277,8 @@ class HttpNetworkTransaction : public HttpTransaction { ProxyInfo proxy_info_; scoped_ptr<ClientSocketHandle> connection_; - scoped_ptr<HttpStream> stream_; - scoped_refptr<SpdySession> spdy_session_; + scoped_ptr<HttpStream> http_stream_; + scoped_ptr<SpdyHttpStream> spdy_http_stream_; bool reused_socket_; // True if we've validated the headers that the stream parser has returned. diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc index 11d20cb..24ad8ad 100644 --- a/net/spdy/spdy_network_transaction_unittest.cc +++ b/net/spdy/spdy_network_transaction_unittest.cc @@ -1977,22 +1977,22 @@ TEST_P(SpdyNetworkTransactionTest, NetLog) { EXPECT_LT(0u, log.entries().size()); int pos = 0; pos = net::ExpectLogContainsSomewhere(log.entries(), 0, - net::NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST, + net::NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST, net::NetLog::PHASE_BEGIN); pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1, - net::NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST, + net::NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST, net::NetLog::PHASE_END); pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1, - net::NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS, + net::NetLog::TYPE_SPDY_TRANSACTION_READ_HEADERS, net::NetLog::PHASE_BEGIN); pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1, - net::NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS, + net::NetLog::TYPE_SPDY_TRANSACTION_READ_HEADERS, net::NetLog::PHASE_END); pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1, - net::NetLog::TYPE_HTTP_TRANSACTION_READ_BODY, + net::NetLog::TYPE_SPDY_TRANSACTION_READ_BODY, net::NetLog::PHASE_BEGIN); pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1, - net::NetLog::TYPE_HTTP_TRANSACTION_READ_BODY, + net::NetLog::TYPE_SPDY_TRANSACTION_READ_BODY, net::NetLog::PHASE_END); } @@ -3157,7 +3157,6 @@ TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) { EXPECT_EQ(OK, rv); const HttpResponseInfo* response = trans->GetResponseInfo(); - ASSERT_TRUE(response != NULL); EXPECT_TRUE(response->headers != NULL); EXPECT_TRUE(response->was_fetched_via_spdy); std::string response_data; |