diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_basic_stream.cc | 4 | ||||
-rw-r--r-- | net/http/http_basic_stream.h | 2 | ||||
-rw-r--r-- | net/http/http_network_transaction.cc | 3 | ||||
-rw-r--r-- | net/http/http_network_transaction.h | 6 | ||||
-rw-r--r-- | net/http/http_proxy_client_socket.cc | 29 | ||||
-rw-r--r-- | net/http/http_proxy_client_socket.h | 5 | ||||
-rw-r--r-- | net/http/http_stream.h | 5 | ||||
-rw-r--r-- | net/http/http_stream_handle.cc | 82 | ||||
-rw-r--r-- | net/http/http_stream_handle.h | 78 | ||||
-rw-r--r-- | net/http/http_stream_request.cc | 24 | ||||
-rw-r--r-- | net/http/http_stream_request.h | 4 | ||||
-rw-r--r-- | net/http/stream_factory.h | 4 | ||||
-rw-r--r-- | net/net.gyp | 2 | ||||
-rw-r--r-- | net/spdy/spdy_network_transaction_unittest.cc | 9 |
14 files changed, 50 insertions, 207 deletions
diff --git a/net/http/http_basic_stream.cc b/net/http/http_basic_stream.cc index 0543112..d90cb73 100644 --- a/net/http/http_basic_stream.cc +++ b/net/http/http_basic_stream.cc @@ -7,6 +7,7 @@ #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "net/http/http_stream_parser.h" +#include "net/socket/client_socket_handle.h" namespace net { @@ -18,9 +19,8 @@ HttpBasicStream::HttpBasicStream(ClientSocketHandle* connection) int HttpBasicStream::InitializeStream(const HttpRequestInfo* request_info, const BoundNetLog& net_log, CompletionCallback* callback) { - parser_.reset(new HttpStreamParser(connection_, request_info, + parser_.reset(new HttpStreamParser(connection_.get(), request_info, read_buf_, net_log)); - connection_ = NULL; return OK; } diff --git a/net/http/http_basic_stream.h b/net/http/http_basic_stream.h index f6192e4..a572bfc 100644 --- a/net/http/http_basic_stream.h +++ b/net/http/http_basic_stream.h @@ -72,7 +72,7 @@ class HttpBasicStream : public HttpStream { scoped_ptr<HttpStreamParser> parser_; - ClientSocketHandle* connection_; + scoped_ptr<ClientSocketHandle> connection_; DISALLOW_COPY_AND_ASSIGN(HttpBasicStream); }; diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index e6084bc..6dd62fd 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -39,7 +39,6 @@ #include "net/http/http_request_info.h" #include "net/http/http_response_headers.h" #include "net/http/http_response_info.h" -#include "net/http/http_stream_handle.h" #include "net/http/http_stream_request.h" #include "net/http/http_util.h" #include "net/http/url_security_manager.h" @@ -408,7 +407,7 @@ uint64 HttpNetworkTransaction::GetUploadProgress() const { return stream_->GetUploadProgress(); } -void HttpNetworkTransaction::OnStreamReady(HttpStreamHandle* stream) { +void HttpNetworkTransaction::OnStreamReady(HttpStream* stream) { DCHECK_EQ(STATE_CREATE_STREAM_COMPLETE, next_state_); DCHECK(stream_request_.get()); diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h index 037bd77..4473d57 100644 --- a/net/http/http_network_transaction.h +++ b/net/http/http_network_transaction.h @@ -27,7 +27,7 @@ namespace net { class HttpAuthController; class HttpNetworkSession; class HttpStream; -class HttpStreamHandle; +class HttpStreamRequest; class IOBuffer; struct HttpRequestInfo; @@ -57,7 +57,7 @@ class HttpNetworkTransaction : public HttpTransaction, virtual uint64 GetUploadProgress() const; // StreamRequestDelegate methods: - virtual void OnStreamReady(HttpStreamHandle* stream); + virtual void OnStreamReady(HttpStream* stream); virtual void OnStreamFailed(int status); virtual void OnCertificateError(int status, const SSLInfo& ssl_info); virtual void OnNeedsProxyAuth( @@ -206,7 +206,7 @@ class HttpNetworkTransaction : public HttpTransaction, ProxyInfo proxy_info_; scoped_refptr<StreamFactory::StreamRequestJob> stream_request_; - scoped_ptr<HttpStreamHandle> stream_; + scoped_ptr<HttpStream> stream_; // True if we've validated the headers that the stream parser has returned. bool headers_valid_; diff --git a/net/http/http_proxy_client_socket.cc b/net/http/http_proxy_client_socket.cc index 700f8b1..76befab 100644 --- a/net/http/http_proxy_client_socket.cc +++ b/net/http/http_proxy_client_socket.cc @@ -11,10 +11,10 @@ #include "net/base/io_buffer.h" #include "net/base/net_log.h" #include "net/base/net_util.h" -#include "net/http/http_basic_stream.h" #include "net/http/http_net_log_params.h" #include "net/http/http_network_session.h" #include "net/http/http_request_info.h" +#include "net/http/http_stream_parser.h" #include "net/socket/client_socket_handle.h" namespace net { @@ -130,8 +130,8 @@ int HttpProxyClientSocket::PrepareForAuthRestart() { bool keep_alive = false; if (response_.headers->IsKeepAlive() && - http_stream_->CanFindEndOfResponse()) { - if (!http_stream_->IsResponseBodyComplete()) { + http_stream_parser_->CanFindEndOfResponse()) { + if (!http_stream_parser_->IsResponseBodyComplete()) { next_state_ = STATE_DRAIN_BODY; drain_buf_ = new IOBuffer(kDrainBodyBufferSize); return OK; @@ -157,7 +157,8 @@ int HttpProxyClientSocket::DidDrainBodyForAuthRestart(bool keep_alive) { // Reset the other member variables. drain_buf_ = NULL; - http_stream_.reset(); + parser_buf_ = NULL; + http_stream_parser_.reset(); request_headers_.clear(); response_ = HttpResponseInfo(); return OK; @@ -367,10 +368,12 @@ int HttpProxyClientSocket::DoSendRequest() { request_headers_ = request_line + request_headers.ToString(); } - http_stream_.reset(new HttpBasicStream(transport_.get())); - http_stream_->InitializeStream(&request_, net_log_, NULL); - return http_stream_->SendRequest(request_headers_, NULL, - &response_, &io_callback_); + + parser_buf_ = new GrowableIOBuffer(); + http_stream_parser_.reset( + new HttpStreamParser(transport_.get(), &request_, parser_buf_, net_log_)); + return http_stream_parser_->SendRequest(request_headers_, NULL, + &response_, &io_callback_); } int HttpProxyClientSocket::DoSendRequestComplete(int result) { @@ -383,7 +386,7 @@ int HttpProxyClientSocket::DoSendRequestComplete(int result) { int HttpProxyClientSocket::DoReadHeaders() { next_state_ = STATE_READ_HEADERS_COMPLETE; - return http_stream_->ReadResponseHeaders(&io_callback_); + return http_stream_parser_->ReadResponseHeaders(&io_callback_); } int HttpProxyClientSocket::DoReadHeadersComplete(int result) { @@ -402,7 +405,7 @@ int HttpProxyClientSocket::DoReadHeadersComplete(int result) { switch (response_.headers->response_code()) { case 200: // OK - if (http_stream_->IsMoreDataBuffered()) + if (http_stream_parser_->IsMoreDataBuffered()) // The proxy sent extraneous data after the headers. return ERR_TUNNEL_CONNECTION_FAILED; @@ -438,15 +441,15 @@ int HttpProxyClientSocket::DoDrainBody() { DCHECK(drain_buf_); DCHECK(transport_->is_initialized()); next_state_ = STATE_DRAIN_BODY_COMPLETE; - return http_stream_->ReadResponseBody(drain_buf_, kDrainBodyBufferSize, - &io_callback_); + return http_stream_parser_->ReadResponseBody(drain_buf_, kDrainBodyBufferSize, + &io_callback_); } int HttpProxyClientSocket::DoDrainBodyComplete(int result) { if (result < 0) return result; - if (http_stream_->IsResponseBodyComplete()) + if (http_stream_parser_->IsResponseBodyComplete()) return DidDrainBodyForAuthRestart(true); // Keep draining. diff --git a/net/http/http_proxy_client_socket.h b/net/http/http_proxy_client_socket.h index e80f697..11e0dc5 100644 --- a/net/http/http_proxy_client_socket.h +++ b/net/http/http_proxy_client_socket.h @@ -25,9 +25,11 @@ namespace net { class AddressList; class ClientSocketHandle; +class GrowableIOBuffer; class HttpAuthCache; class HttpAuthHandleFactory; class HttpStream; +class HttpStreamParser; class IOBuffer; class HttpProxyClientSocket : public ClientSocket { @@ -138,7 +140,8 @@ class HttpProxyClientSocket : public ClientSocket { HttpRequestInfo request_; HttpResponseInfo response_; - scoped_ptr<HttpStream> http_stream_; + scoped_refptr<GrowableIOBuffer> parser_buf_; + scoped_ptr<HttpStreamParser> http_stream_parser_; scoped_refptr<IOBuffer> drain_buf_; // Stores the underlying socket. diff --git a/net/http/http_stream.h b/net/http/http_stream.h index 9981e09..211267d 100644 --- a/net/http/http_stream.h +++ b/net/http/http_stream.h @@ -5,7 +5,10 @@ // HttpStream is an interface for reading and writing data to an HttpStream that // keeps the client agnostic of the actual underlying transport layer. This // provides an abstraction for both a basic http stream as well as http -// pipelining implementations. +// pipelining implementations. The HttpStream subtype is expected to manage the +// underlying transport appropriately. For example, a non-pipelined HttpStream +// would return the transport socket to the pool for reuse. SPDY streams on the +// other hand leave the transport socket management to the SpdySession. #ifndef NET_HTTP_HTTP_STREAM_H_ #define NET_HTTP_HTTP_STREAM_H_ diff --git a/net/http/http_stream_handle.cc b/net/http/http_stream_handle.cc deleted file mode 100644 index d2ad0f0..0000000 --- a/net/http/http_stream_handle.cc +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "net/http/http_stream_handle.h" - -namespace net { - -HttpStreamHandle::HttpStreamHandle(ClientSocketHandle* connection, - HttpStream* stream) - : connection_(connection), stream_(stream) { - DCHECK(stream_.get()); -} - -HttpStreamHandle::~HttpStreamHandle() { -} - -int HttpStreamHandle::InitializeStream(const HttpRequestInfo* request_info, - const BoundNetLog& net_log, - CompletionCallback* callback) { - return stream_->InitializeStream(request_info, net_log, callback); -} - -int HttpStreamHandle::SendRequest(const std::string& request_headers, - UploadDataStream* request_body, - HttpResponseInfo* response, - CompletionCallback* callback) { - return stream_->SendRequest(request_headers, request_body, response, - callback); -} - -uint64 HttpStreamHandle::GetUploadProgress() const { - return stream_->GetUploadProgress(); -} - -int HttpStreamHandle::ReadResponseHeaders(CompletionCallback* callback) { - return stream_->ReadResponseHeaders(callback); -} - -const HttpResponseInfo* HttpStreamHandle::GetResponseInfo() const { - return stream_->GetResponseInfo(); -} - -int HttpStreamHandle::ReadResponseBody(IOBuffer* buf, int buf_len, - CompletionCallback* callback) { - return stream_->ReadResponseBody(buf, buf_len, callback); -} - -void HttpStreamHandle::Close(bool not_reusable) { - stream_->Close(not_reusable); -} - -bool HttpStreamHandle::IsResponseBodyComplete() const { - return stream_->IsResponseBodyComplete(); -} - -bool HttpStreamHandle::CanFindEndOfResponse() const { - return stream_->CanFindEndOfResponse(); -} - -bool HttpStreamHandle::IsMoreDataBuffered() const { - return stream_->IsMoreDataBuffered(); -} - -bool HttpStreamHandle::IsConnectionReused() const { - return stream_->IsConnectionReused(); -} - -void HttpStreamHandle::SetConnectionReused() { - stream_->SetConnectionReused(); -} - -void HttpStreamHandle::GetSSLInfo(SSLInfo* ssl_info) { - stream_->GetSSLInfo(ssl_info); -} - -void HttpStreamHandle::GetSSLCertRequestInfo( - SSLCertRequestInfo* cert_request_info) { - stream_->GetSSLCertRequestInfo(cert_request_info); -} - -} // namespace net diff --git a/net/http/http_stream_handle.h b/net/http/http_stream_handle.h deleted file mode 100644 index a328ff2..0000000 --- a/net/http/http_stream_handle.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef NET_HTTP_HTTP_STREAM_HANDLE_H_ -#define NET_HTTP_HTTP_STREAM_HANDLE_H_ -#pragma once - -#include <string> - -#include "base/gtest_prod_util.h" -#include "net/http/http_stream.h" -#include "net/socket/client_socket_handle.h" - -namespace net { - -struct HttpRequestInfo; - -// The HttpStreamHandle provides a container for a ClientSocketHandle and -// a stream. The HttpStream does not own the ClientSocketHandle which it uses. -// The HttpStreamHandle container can be used in cases where you just want a -// handle to the stream but you don't want to manage the lifecycle of the -// underlying ClientSocketHandle manually. -class HttpStreamHandle : public HttpStream { - public: - HttpStreamHandle(ClientSocketHandle* connection, HttpStream* stream); - virtual ~HttpStreamHandle(); - - HttpStream* stream() { return stream_.get(); } - - // HttpStream interface - int InitializeStream(const HttpRequestInfo* request_info, - const BoundNetLog& net_log, - CompletionCallback* callback); - - int SendRequest(const std::string& request_headers, - UploadDataStream* request_body, - HttpResponseInfo* response, - CompletionCallback* callback); - - uint64 GetUploadProgress() const; - - int ReadResponseHeaders(CompletionCallback* callback); - - const HttpResponseInfo* GetResponseInfo() const; - - int ReadResponseBody(IOBuffer* buf, int buf_len, - CompletionCallback* callback); - - void Close(bool not_reusable); - - bool IsResponseBodyComplete() const; - - bool CanFindEndOfResponse() const; - - bool IsMoreDataBuffered() const; - - bool IsConnectionReused() const; - - void SetConnectionReused(); - - void GetSSLInfo(SSLInfo* ssl_info); - - void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info); - - private: - FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, WindowUpdateSent); - - scoped_ptr<ClientSocketHandle> connection_; - scoped_ptr<HttpStream> stream_; - - DISALLOW_COPY_AND_ASSIGN(HttpStreamHandle); -}; - -} // namespace net - -#endif // NET_HTTP_HTTP_STREAM_HANDLE_H_ - diff --git a/net/http/http_stream_request.cc b/net/http/http_stream_request.cc index cbc2188..0486ac2 100644 --- a/net/http/http_stream_request.cc +++ b/net/http/http_stream_request.cc @@ -15,7 +15,6 @@ #include "net/http/http_network_session.h" #include "net/http/http_proxy_client_socket.h" #include "net/http/http_request_info.h" -#include "net/http/http_stream_handle.h" #include "net/spdy/spdy_http_stream.h" #include "net/spdy/spdy_session.h" #include "net/spdy/spdy_session_pool.h" @@ -178,7 +177,7 @@ SSLConfig* HttpStreamRequest::ssl_config() const { return ssl_config_; } -void HttpStreamRequest::OnStreamReadyCallback(HttpStreamHandle* stream) { +void HttpStreamRequest::OnStreamReadyCallback(HttpStream* stream) { if (cancelled_) { // The delegate is gone. We need to cleanup the stream. delete stream; @@ -232,7 +231,8 @@ int HttpStreamRequest::RunLoop(int result) { GetSSLInfo(); next_state_ = STATE_WAITING_USER_ACTION; - MessageLoop::current()->PostTask(FROM_HERE, + MessageLoop::current()->PostTask( + FROM_HERE, NewRunnableMethod(this, &HttpStreamRequest::OnCertificateErrorCallback, result, ssl_info_)); @@ -252,7 +252,8 @@ int HttpStreamRequest::RunLoop(int result) { http_proxy_socket->GetResponseInfo(); next_state_ = STATE_WAITING_USER_ACTION; - MessageLoop::current()->PostTask(FROM_HERE, + MessageLoop::current()->PostTask( + FROM_HERE, NewRunnableMethod(this, &HttpStreamRequest::OnNeedsProxyAuthCallback, *tunnel_auth_response, @@ -261,7 +262,8 @@ int HttpStreamRequest::RunLoop(int result) { return ERR_IO_PENDING; case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: - MessageLoop::current()->PostTask(FROM_HERE, + MessageLoop::current()->PostTask( + FROM_HERE, NewRunnableMethod(this, &HttpStreamRequest::OnNeedsClientAuthCallback, connection_->ssl_error_response_info().cert_request_info)); @@ -271,14 +273,16 @@ int HttpStreamRequest::RunLoop(int result) { break; case OK: - MessageLoop::current()->PostTask(FROM_HERE, + MessageLoop::current()->PostTask( + FROM_HERE, NewRunnableMethod(this, &HttpStreamRequest::OnStreamReadyCallback, stream_.release())); return ERR_IO_PENDING; default: - MessageLoop::current()->PostTask(FROM_HERE, + MessageLoop::current()->PostTask( + FROM_HERE, NewRunnableMethod(this, &HttpStreamRequest::OnStreamFailedCallback, result)); @@ -676,8 +680,7 @@ int HttpStreamRequest::DoCreateStream() { SetSocketMotivation(); if (!using_spdy_) { - HttpBasicStream* stream = new HttpBasicStream(connection_.get()); - stream_.reset(new HttpStreamHandle(connection_.release(), stream)); + stream_.reset(new HttpBasicStream(connection_.release())); return OK; } @@ -720,8 +723,7 @@ int HttpStreamRequest::DoCreateStream() { if (spdy_session->IsClosed()) return ERR_CONNECTION_CLOSED; - SpdyHttpStream* stream = new SpdyHttpStream(spdy_session, direct); - stream_.reset(new HttpStreamHandle(NULL, stream)); + stream_.reset(new SpdyHttpStream(spdy_session, direct)); return OK; } diff --git a/net/http/http_stream_request.h b/net/http/http_stream_request.h index 8b45530..a60c96d 100644 --- a/net/http/http_stream_request.h +++ b/net/http/http_stream_request.h @@ -83,7 +83,7 @@ class HttpStreamRequest : public StreamFactory::StreamRequestJob { SSLConfig* ssl_config() const; // Callbacks to the delegate. - void OnStreamReadyCallback(HttpStreamHandle* stream); + void OnStreamReadyCallback(HttpStream* stream); void OnStreamFailedCallback(int result); void OnCertificateErrorCallback(int result, const SSLInfo& ssl_info); void OnNeedsProxyAuthCallback(const HttpResponseInfo& response_info, @@ -196,7 +196,7 @@ class HttpStreamRequest : public StreamFactory::StreamRequestJob { // read from the socket until the tunnel is done. bool establishing_tunnel_; - scoped_ptr<HttpStreamHandle> stream_; + scoped_ptr<HttpStream> stream_; // True if finding the connection for this request found an alternate // protocol was available. diff --git a/net/http/stream_factory.h b/net/http/stream_factory.h index 773e0ff..9ec85f1 100644 --- a/net/http/stream_factory.h +++ b/net/http/stream_factory.h @@ -19,7 +19,6 @@ class HttpAuthController; class HttpNetworkSession; class HttpResponseInfo; class HttpStream; -class HttpStreamHandle; class ProxyInfo; class SSLCertRequestInfo; class SSLInfo; @@ -39,7 +38,7 @@ class StreamFactory { // This is the success case. // |stream| is now owned by the delegate. - virtual void OnStreamReady(HttpStreamHandle* stream) = 0; + virtual void OnStreamReady(HttpStream* stream) = 0; // This is the failure to create a stream case. virtual void OnStreamFailed(int status) = 0; @@ -148,4 +147,3 @@ class StreamFactory { } // namespace net #endif // NET_HTTP_STREAM_FACTORY_H_ - diff --git a/net/net.gyp b/net/net.gyp index 080b5b0..2358473 100644 --- a/net/net.gyp +++ b/net/net.gyp @@ -438,8 +438,6 @@ 'http/http_stream.h', 'http/http_stream_factory.cc', 'http/http_stream_factory.h', - 'http/http_stream_handle.cc', - 'http/http_stream_handle.h', 'http/http_stream_parser.cc', 'http/http_stream_parser.h', 'http/http_stream_request.cc', diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc index 927d2aa..bed0b08 100644 --- a/net/spdy/spdy_network_transaction_unittest.cc +++ b/net/spdy/spdy_network_transaction_unittest.cc @@ -6,7 +6,6 @@ #include <vector> #include "net/base/net_log_unittest.h" -#include "net/http/http_stream_handle.h" #include "net/http/http_transaction_unittest.h" #include "net/spdy/spdy_http_stream.h" #include "net/spdy/spdy_session.h" @@ -1622,8 +1621,7 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) { rv = callback.WaitForResult(); EXPECT_EQ(OK, rv); - SpdyHttpStream* stream = - static_cast<SpdyHttpStream*>(trans->stream_->stream()); + SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); ASSERT_TRUE(stream != NULL); ASSERT_TRUE(stream->stream() != NULL); EXPECT_EQ(spdy::kInitialWindowSize + @@ -1681,7 +1679,7 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) { EXPECT_EQ(OK, rv); SpdyHttpStream* stream = - static_cast<SpdyHttpStream*>(trans->stream_.get()->stream_.get()); + static_cast<SpdyHttpStream*>(trans->stream_.get()); ASSERT_TRUE(stream != NULL); ASSERT_TRUE(stream->stream() != NULL); @@ -1890,8 +1888,7 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) { MessageLoop::current()->RunAllPending(); // Write as much as we can. - SpdyHttpStream* stream = - static_cast<SpdyHttpStream*>(trans->stream_->stream()); + SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); ASSERT_TRUE(stream != NULL); ASSERT_TRUE(stream->stream() != NULL); EXPECT_EQ(0, stream->stream()->send_window_size()); |