summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-01 11:48:13 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-01 11:48:13 +0000
commit9a96389e66421f3c76b5349acaf78ab94eb322f1 (patch)
treeaea208c6f5f48ddff94125662838d1d385a242ec /net
parent4ab7f1754de68fc87217a99a55f46d5d180f0b9a (diff)
downloadchromium_src-9a96389e66421f3c76b5349acaf78ab94eb322f1.zip
chromium_src-9a96389e66421f3c76b5349acaf78ab94eb322f1.tar.gz
chromium_src-9a96389e66421f3c76b5349acaf78ab94eb322f1.tar.bz2
net: Stop passing ownership of UploadDataStream from HttpNetworkTransaction to HttpStream
This change is a preparation step before moving ownership of UploadDataStream to URLRequest. HttpStream::SendRequest takes UploadDataStream* instead of scoped_ptr<UploadDataStream>. HttpNetworkTransaction does not release the ownership of UploadDataStream. Some include cleanups. BUG=155242 TEST=net_unittests Review URL: https://chromiumcodereview.appspot.com/11269066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165337 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/http/http_basic_stream.cc5
-rw-r--r--net/http/http_basic_stream.h2
-rw-r--r--net/http/http_network_transaction.cc2
-rw-r--r--net/http/http_pipelined_connection_impl.cc7
-rw-r--r--net/http/http_pipelined_connection_impl.h4
-rw-r--r--net/http/http_pipelined_connection_impl_unittest.cc308
-rw-r--r--net/http/http_pipelined_stream.cc5
-rw-r--r--net/http/http_pipelined_stream.h2
-rw-r--r--net/http/http_proxy_client_socket.cc4
-rw-r--r--net/http/http_response_body_drainer_unittest.cc3
-rw-r--r--net/http/http_stream.h5
-rw-r--r--net/http/http_stream_parser.cc14
-rw-r--r--net/http/http_stream_parser.h7
-rw-r--r--net/http/http_stream_parser_unittest.cc20
-rw-r--r--net/spdy/spdy_http_stream.cc25
-rw-r--r--net/spdy/spdy_http_stream.h9
-rw-r--r--net/spdy/spdy_http_stream_spdy2_unittest.cc34
-rw-r--r--net/spdy/spdy_http_stream_spdy3_unittest.cc57
18 files changed, 215 insertions, 298 deletions
diff --git a/net/http/http_basic_stream.cc b/net/http/http_basic_stream.cc
index a8e973f..7077ee2 100644
--- a/net/http/http_basic_stream.cc
+++ b/net/http/http_basic_stream.cc
@@ -9,7 +9,6 @@
#include "base/stringprintf.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
-#include "net/base/upload_data_stream.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_request_info.h"
#include "net/http/http_response_body_drainer.h"
@@ -47,7 +46,7 @@ int HttpBasicStream::InitializeStream(
int HttpBasicStream::SendRequest(const HttpRequestHeaders& headers,
- scoped_ptr<UploadDataStream> request_body,
+ UploadDataStream* request_body,
HttpResponseInfo* response,
const CompletionCallback& callback) {
DCHECK(parser_.get());
@@ -59,7 +58,7 @@ int HttpBasicStream::SendRequest(const HttpRequestHeaders& headers,
request_info_->method.c_str(),
path.c_str());
response_ = response;
- return parser_->SendRequest(request_line_, headers, request_body.Pass(),
+ return parser_->SendRequest(request_line_, headers, request_body,
response, callback);
}
diff --git a/net/http/http_basic_stream.h b/net/http/http_basic_stream.h
index 50bb380..9a85770 100644
--- a/net/http/http_basic_stream.h
+++ b/net/http/http_basic_stream.h
@@ -43,7 +43,7 @@ class HttpBasicStream : public HttpStream {
const CompletionCallback& callback) OVERRIDE;
virtual int SendRequest(const HttpRequestHeaders& headers,
- scoped_ptr<UploadDataStream> request_body,
+ UploadDataStream* request_body,
HttpResponseInfo* response,
const CompletionCallback& callback) OVERRIDE;
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 4c32166..0ab553e 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -793,7 +793,7 @@ int HttpNetworkTransaction::DoSendRequest() {
next_state_ = STATE_SEND_REQUEST_COMPLETE;
return stream_->SendRequest(
- request_headers_, request_body_.Pass(), &response_, io_callback_);
+ request_headers_, request_body_.get(), &response_, io_callback_);
}
int HttpNetworkTransaction::DoSendRequestComplete(int result) {
diff --git a/net/http/http_pipelined_connection_impl.cc b/net/http/http_pipelined_connection_impl.cc
index 9fc6dd6..7b5b0d2 100644
--- a/net/http/http_pipelined_connection_impl.cc
+++ b/net/http/http_pipelined_connection_impl.cc
@@ -10,7 +10,6 @@
#include "base/stl_util.h"
#include "base/values.h"
#include "net/base/io_buffer.h"
-#include "net/base/upload_data_stream.h"
#include "net/http/http_pipelined_stream.h"
#include "net/http/http_request_info.h"
#include "net/http/http_response_body_drainer.h"
@@ -175,7 +174,7 @@ int HttpPipelinedConnectionImpl::SendRequest(
int pipeline_id,
const std::string& request_line,
const HttpRequestHeaders& headers,
- scoped_ptr<UploadDataStream> request_body,
+ UploadDataStream* request_body,
HttpResponseInfo* response,
const CompletionCallback& callback) {
CHECK(ContainsKey(stream_info_map_, pipeline_id));
@@ -188,7 +187,7 @@ int HttpPipelinedConnectionImpl::SendRequest(
send_request->pipeline_id = pipeline_id;
send_request->request_line = request_line;
send_request->headers = headers;
- send_request->request_body.reset(request_body.release());
+ send_request->request_body = request_body;
send_request->response = response;
send_request->callback = callback;
pending_send_request_queue_.push(send_request);
@@ -278,7 +277,7 @@ int HttpPipelinedConnectionImpl::DoSendActiveRequest(int result) {
int rv = stream_info_map_[active_send_request_->pipeline_id].parser->
SendRequest(active_send_request_->request_line,
active_send_request_->headers,
- active_send_request_->request_body.Pass(),
+ active_send_request_->request_body,
active_send_request_->response,
base::Bind(&HttpPipelinedConnectionImpl::OnSendIOCallback,
base::Unretained(this)));
diff --git a/net/http/http_pipelined_connection_impl.h b/net/http/http_pipelined_connection_impl.h
index 8134d75..787f672 100644
--- a/net/http/http_pipelined_connection_impl.h
+++ b/net/http/http_pipelined_connection_impl.h
@@ -100,7 +100,7 @@ class NET_EXPORT_PRIVATE HttpPipelinedConnectionImpl
int SendRequest(int pipeline_id,
const std::string& request_line,
const HttpRequestHeaders& headers,
- scoped_ptr<UploadDataStream> request_body,
+ UploadDataStream* request_body,
HttpResponseInfo* response,
const CompletionCallback& callback);
@@ -176,7 +176,7 @@ class NET_EXPORT_PRIVATE HttpPipelinedConnectionImpl
int pipeline_id;
std::string request_line;
HttpRequestHeaders headers;
- scoped_ptr<UploadDataStream> request_body;
+ UploadDataStream* request_body;
HttpResponseInfo* response;
CompletionCallback callback;
};
diff --git a/net/http/http_pipelined_connection_impl_unittest.cc b/net/http/http_pipelined_connection_impl_unittest.cc
index 36384ad..0256efa 100644
--- a/net/http/http_pipelined_connection_impl_unittest.cc
+++ b/net/http/http_pipelined_connection_impl_unittest.cc
@@ -12,7 +12,6 @@
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/base/request_priority.h"
-#include "net/base/upload_data_stream.h"
#include "net/http/http_pipelined_stream.h"
#include "net/socket/client_socket_handle.h"
#include "net/socket/client_socket_pool_histograms.h"
@@ -138,9 +137,8 @@ class HttpPipelinedConnectionImplTest : public testing::Test {
const std::string& filename) {
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK, stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- callback_.callback()));
+ EXPECT_EQ(OK, stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
EXPECT_EQ(OK, stream->ReadResponseHeaders(callback_.callback()));
ExpectResponse(filename, stream, false);
@@ -211,9 +209,8 @@ TEST_F(HttpPipelinedConnectionImplTest, AsyncSingleRequest) {
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(ERR_IO_PENDING,
- stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
data_->RunFor(1);
EXPECT_LE(OK, callback_.WaitForResult());
@@ -246,15 +243,13 @@ TEST_F(HttpPipelinedConnectionImplTest, LockStepAsyncRequests) {
HttpRequestHeaders headers1;
HttpResponseInfo response1;
- EXPECT_EQ(ERR_IO_PENDING,
- stream1->SendRequest(headers1, scoped_ptr<UploadDataStream>(),
- &response1, callback_.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, stream1->SendRequest(headers1, NULL, &response1,
+ callback_.callback()));
HttpRequestHeaders headers2;
HttpResponseInfo response2;
- EXPECT_EQ(ERR_IO_PENDING,
- stream2->SendRequest(headers2, scoped_ptr<UploadDataStream>(),
- &response2, callback_.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, stream2->SendRequest(headers2, NULL, &response2,
+ callback_.callback()));
data_->RunFor(1);
EXPECT_LE(OK, callback_.WaitForResult());
@@ -300,14 +295,12 @@ TEST_F(HttpPipelinedConnectionImplTest, TwoResponsesInOnePacket) {
HttpRequestHeaders headers1;
HttpResponseInfo response1;
- EXPECT_EQ(OK,
- stream1->SendRequest(headers1, scoped_ptr<UploadDataStream>(),
- &response1, callback_.callback()));
+ EXPECT_EQ(OK, stream1->SendRequest(headers1, NULL,
+ &response1, callback_.callback()));
HttpRequestHeaders headers2;
HttpResponseInfo response2;
- EXPECT_EQ(OK,
- stream2->SendRequest(headers2, scoped_ptr<UploadDataStream>(),
- &response2, callback_.callback()));
+ EXPECT_EQ(OK, stream2->SendRequest(headers2, NULL,
+ &response2, callback_.callback()));
EXPECT_EQ(OK, stream1->ReadResponseHeaders(callback_.callback()));
ExpectResponse("ok.html", stream1, false);
@@ -360,12 +353,12 @@ TEST_F(HttpPipelinedConnectionImplTest, ReadOrderSwapped) {
HttpRequestHeaders headers1;
HttpResponseInfo response1;
- EXPECT_EQ(OK, stream1->SendRequest(headers1, scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, stream1->SendRequest(headers1, NULL,
&response1, callback_.callback()));
HttpRequestHeaders headers2;
HttpResponseInfo response2;
- EXPECT_EQ(OK, stream2->SendRequest(headers2, scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, stream2->SendRequest(headers2, NULL,
&response2, callback_.callback()));
EXPECT_EQ(ERR_IO_PENDING, stream2->ReadResponseHeaders(callback_.callback()));
@@ -401,13 +394,13 @@ TEST_F(HttpPipelinedConnectionImplTest, SendWhileReading) {
HttpRequestHeaders headers1;
HttpResponseInfo response1;
- EXPECT_EQ(OK, stream1->SendRequest(headers1, scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, stream1->SendRequest(headers1, NULL,
&response1, callback_.callback()));
EXPECT_EQ(OK, stream1->ReadResponseHeaders(callback_.callback()));
HttpRequestHeaders headers2;
HttpResponseInfo response2;
- EXPECT_EQ(OK, stream2->SendRequest(headers2, scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, stream2->SendRequest(headers2, NULL,
&response2, callback_.callback()));
ExpectResponse("ok.html", stream1, false);
@@ -438,7 +431,7 @@ TEST_F(HttpPipelinedConnectionImplTest, AsyncSendWhileAsyncReadBlocked) {
HttpRequestHeaders headers1;
HttpResponseInfo response1;
- EXPECT_EQ(OK, stream1->SendRequest(headers1, scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, stream1->SendRequest(headers1, NULL,
&response1, callback_.callback()));
EXPECT_EQ(OK, stream1->ReadResponseHeaders(callback_.callback()));
TestCompletionCallback callback1;
@@ -451,9 +444,8 @@ TEST_F(HttpPipelinedConnectionImplTest, AsyncSendWhileAsyncReadBlocked) {
HttpRequestHeaders headers2;
HttpResponseInfo response2;
TestCompletionCallback callback2;
- EXPECT_EQ(ERR_IO_PENDING,
- stream2->SendRequest(headers2, scoped_ptr<UploadDataStream>(),
- &response2, callback2.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, stream2->SendRequest(headers2, NULL, &response2,
+ callback2.callback()));
data_->RunFor(1);
EXPECT_LE(OK, callback2.WaitForResult());
@@ -508,16 +500,15 @@ TEST_F(HttpPipelinedConnectionImplTest, UnsentStreamAllowsLaterUse) {
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(ERR_IO_PENDING,
- stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
scoped_ptr<HttpStream> unsent_stream(NewTestStream("unsent.html"));
HttpRequestHeaders unsent_headers;
HttpResponseInfo unsent_response;
EXPECT_EQ(ERR_IO_PENDING,
unsent_stream->SendRequest(unsent_headers,
- scoped_ptr<UploadDataStream>(),
+ NULL,
&unsent_response,
callback_.callback()));
unsent_stream->Close(false);
@@ -553,27 +544,24 @@ TEST_F(HttpPipelinedConnectionImplTest, FailedSend) {
HttpResponseInfo response;
TestCompletionCallback failed_callback;
EXPECT_EQ(ERR_IO_PENDING,
- failed_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
+ failed_stream->SendRequest(headers, NULL,
&response, failed_callback.callback()));
TestCompletionCallback evicted_callback;
EXPECT_EQ(ERR_IO_PENDING,
evicted_stream->SendRequest(headers,
- scoped_ptr<UploadDataStream>(),
+ NULL,
&response,
evicted_callback.callback()));
- EXPECT_EQ(ERR_IO_PENDING,
- closed_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response,
- callback_.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, closed_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
closed_stream->Close(false);
data_->RunFor(1);
EXPECT_EQ(ERR_FAILED, failed_callback.WaitForResult());
EXPECT_EQ(ERR_PIPELINE_EVICTION, evicted_callback.WaitForResult());
EXPECT_EQ(ERR_PIPELINE_EVICTION,
- rejected_stream->SendRequest(headers,
- scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
+ rejected_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
failed_stream->Close(true);
evicted_stream->Close(true);
@@ -607,27 +595,20 @@ TEST_F(HttpPipelinedConnectionImplTest, ConnectionSuddenlyClosedAfterResponse) {
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK,
- closed_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
- EXPECT_EQ(OK,
- read_evicted_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- callback_.callback()));
- EXPECT_EQ(OK,
- read_rejected_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- callback_.callback()));
+ EXPECT_EQ(OK, closed_stream->SendRequest(headers, NULL,
+ &response, callback_.callback()));
+ EXPECT_EQ(OK, read_evicted_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
+ EXPECT_EQ(OK, read_rejected_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
TestCompletionCallback send_closed_callback;
EXPECT_EQ(ERR_IO_PENDING,
- send_closed_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- send_closed_callback.callback()));
+ send_closed_stream->SendRequest(headers, NULL, &response,
+ send_closed_callback.callback()));
TestCompletionCallback send_evicted_callback;
EXPECT_EQ(ERR_IO_PENDING,
- send_evicted_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- send_evicted_callback.callback()));
+ send_evicted_stream->SendRequest(headers, NULL, &response,
+ send_evicted_callback.callback()));
TestCompletionCallback read_evicted_callback;
EXPECT_EQ(ERR_IO_PENDING,
@@ -653,9 +634,8 @@ TEST_F(HttpPipelinedConnectionImplTest, ConnectionSuddenlyClosedAfterResponse) {
send_evicted_stream->Close(true);
EXPECT_EQ(ERR_PIPELINE_EVICTION,
- send_rejected_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- callback_.callback()));
+ send_rejected_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
send_rejected_stream->Close(true);
}
@@ -672,14 +652,12 @@ TEST_F(HttpPipelinedConnectionImplTest, AbortWhileSending) {
HttpResponseInfo response;
TestCompletionCallback aborted_callback;
EXPECT_EQ(ERR_IO_PENDING,
- aborted_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- aborted_callback.callback()));
+ aborted_stream->SendRequest(headers, NULL, &response,
+ aborted_callback.callback()));
TestCompletionCallback evicted_callback;
EXPECT_EQ(ERR_IO_PENDING,
- evicted_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- evicted_callback.callback()));
+ evicted_stream->SendRequest(headers, NULL, &response,
+ evicted_callback.callback()));
aborted_stream->Close(true);
EXPECT_EQ(ERR_PIPELINE_EVICTION, evicted_callback.WaitForResult());
@@ -701,19 +679,16 @@ TEST_F(HttpPipelinedConnectionImplTest, AbortWhileSendingSecondRequest) {
HttpRequestHeaders headers;
HttpResponseInfo response;
TestCompletionCallback ok_callback;
- EXPECT_EQ(ERR_IO_PENDING,
- ok_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, ok_callback.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, ok_stream->SendRequest(headers, NULL, &response,
+ ok_callback.callback()));
TestCompletionCallback aborted_callback;
EXPECT_EQ(ERR_IO_PENDING,
- aborted_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- aborted_callback.callback()));
+ aborted_stream->SendRequest(headers, NULL, &response,
+ aborted_callback.callback()));
TestCompletionCallback evicted_callback;
EXPECT_EQ(ERR_IO_PENDING,
- evicted_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- evicted_callback.callback()));
+ evicted_stream->SendRequest(headers, NULL, &response,
+ evicted_callback.callback()));
data_->RunFor(1);
EXPECT_LE(OK, ok_callback.WaitForResult());
@@ -742,13 +717,11 @@ TEST_F(HttpPipelinedConnectionImplTest, AbortWhileReadingHeaders) {
HttpRequestHeaders headers;
HttpResponseInfo response;
EXPECT_EQ(OK,
- aborted_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- callback_.callback()));
+ aborted_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
EXPECT_EQ(OK,
- evicted_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- callback_.callback()));
+ evicted_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
EXPECT_EQ(ERR_IO_PENDING,
aborted_stream->ReadResponseHeaders(callback_.callback()));
@@ -761,9 +734,8 @@ TEST_F(HttpPipelinedConnectionImplTest, AbortWhileReadingHeaders) {
evicted_stream->Close(true);
EXPECT_EQ(ERR_PIPELINE_EVICTION,
- rejected_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- callback_.callback()));
+ rejected_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
rejected_stream->Close(true);
}
@@ -786,17 +758,12 @@ TEST_F(HttpPipelinedConnectionImplTest, PendingResponseAbandoned) {
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK,
- ok_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
- EXPECT_EQ(OK,
- abandoned_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- callback_.callback()));
- EXPECT_EQ(OK,
- evicted_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- callback_.callback()));
+ EXPECT_EQ(OK, ok_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
+ EXPECT_EQ(OK, abandoned_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
+ EXPECT_EQ(OK, evicted_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
EXPECT_EQ(OK, ok_stream->ReadResponseHeaders(callback_.callback()));
TestCompletionCallback abandoned_callback;
@@ -838,13 +805,10 @@ TEST_F(HttpPipelinedConnectionImplTest, DisconnectedAfterOneRequestRecovery) {
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK,
- ok_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
- EXPECT_EQ(OK,
- rejected_read_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- callback_.callback()));
+ EXPECT_EQ(OK, ok_stream->SendRequest(headers, NULL,
+ &response, callback_.callback()));
+ EXPECT_EQ(OK, rejected_read_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
EXPECT_EQ(OK, ok_stream->ReadResponseHeaders(callback_.callback()));
ExpectResponse("ok.html", ok_stream, false);
@@ -852,18 +816,16 @@ TEST_F(HttpPipelinedConnectionImplTest, DisconnectedAfterOneRequestRecovery) {
TestCompletionCallback read_callback;
EXPECT_EQ(ERR_IO_PENDING,
- evicted_send_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- read_callback.callback()));
+ evicted_send_stream->SendRequest(headers, NULL, &response,
+ read_callback.callback()));
data_->RunFor(1);
EXPECT_EQ(ERR_PIPELINE_EVICTION, read_callback.WaitForResult());
EXPECT_EQ(ERR_PIPELINE_EVICTION,
rejected_read_stream->ReadResponseHeaders(callback_.callback()));
EXPECT_EQ(ERR_PIPELINE_EVICTION,
- rejected_send_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- callback_.callback()));
+ rejected_send_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
rejected_read_stream->Close(true);
rejected_send_stream->Close(true);
@@ -887,13 +849,10 @@ TEST_F(HttpPipelinedConnectionImplTest, DisconnectedPendingReadRecovery) {
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK,
- ok_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
- EXPECT_EQ(OK,
- evicted_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- callback_.callback()));
+ EXPECT_EQ(OK, ok_stream->SendRequest(headers, NULL,
+ &response, callback_.callback()));
+ EXPECT_EQ(OK, evicted_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
EXPECT_EQ(OK, ok_stream->ReadResponseHeaders(callback_.callback()));
ExpectResponse("ok.html", ok_stream, false);
@@ -926,13 +885,10 @@ TEST_F(HttpPipelinedConnectionImplTest, CloseCalledBeforeNextReadLoop) {
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK,
- ok_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
- EXPECT_EQ(OK,
- evicted_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- callback_.callback()));
+ EXPECT_EQ(OK, ok_stream->SendRequest(headers, NULL,
+ &response, callback_.callback()));
+ EXPECT_EQ(OK, evicted_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
EXPECT_EQ(OK, ok_stream->ReadResponseHeaders(callback_.callback()));
ExpectResponse("ok.html", ok_stream, false);
@@ -963,13 +919,10 @@ TEST_F(HttpPipelinedConnectionImplTest, CloseCalledBeforeReadCallback) {
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK,
- ok_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
- EXPECT_EQ(OK,
- evicted_stream->SendRequest(
- headers, scoped_ptr<UploadDataStream>(), &response,
- callback_.callback()));
+ EXPECT_EQ(OK, ok_stream->SendRequest(headers, NULL,
+ &response, callback_.callback()));
+ EXPECT_EQ(OK, evicted_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
EXPECT_EQ(OK, ok_stream->ReadResponseHeaders(callback_.callback()));
ExpectResponse("ok.html", ok_stream, false);
@@ -1019,9 +972,8 @@ TEST_F(HttpPipelinedConnectionImplTest, CloseCalledDuringSendCallback) {
StreamDeleter deleter(stream);
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(ERR_IO_PENDING,
- stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, deleter.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(headers, NULL, &response,
+ deleter.callback()));
data_->RunFor(1);
}
@@ -1039,7 +991,7 @@ TEST_F(HttpPipelinedConnectionImplTest, CloseCalledDuringReadCallback) {
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK, stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, stream->SendRequest(headers, NULL,
&response, callback_.callback()));
StreamDeleter deleter(stream);
@@ -1064,13 +1016,10 @@ TEST_F(HttpPipelinedConnectionImplTest,
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK,
- failed_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
- EXPECT_EQ(OK,
- evicted_stream->SendRequest(headers,
- scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
+ EXPECT_EQ(OK, failed_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
+ EXPECT_EQ(OK, evicted_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
StreamDeleter failed_deleter(failed_stream);
EXPECT_EQ(ERR_IO_PENDING,
@@ -1097,13 +1046,10 @@ TEST_F(HttpPipelinedConnectionImplTest, CloseOtherDuringReadCallback) {
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK, deleter_stream->SendRequest(headers,
- scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, deleter_stream->SendRequest(headers, NULL,
+ &response, callback_.callback()));
+ EXPECT_EQ(OK, deleted_stream->SendRequest(headers, NULL,
&response, callback_.callback()));
- EXPECT_EQ(OK,
- deleted_stream->SendRequest(headers,
- scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
StreamDeleter deleter(deleted_stream);
EXPECT_EQ(ERR_IO_PENDING,
@@ -1128,7 +1074,7 @@ TEST_F(HttpPipelinedConnectionImplTest, CloseBeforeSendCallbackRuns) {
HttpRequestHeaders headers;
HttpResponseInfo response;
EXPECT_EQ(ERR_IO_PENDING,
- close_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
+ close_stream->SendRequest(headers, NULL,
&response, close_callback->callback()));
data_->RunFor(1);
@@ -1157,9 +1103,8 @@ TEST_F(HttpPipelinedConnectionImplTest, CloseBeforeReadCallbackRuns) {
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK,
- close_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
+ EXPECT_EQ(OK, close_stream->SendRequest(headers, NULL,
+ &response, callback_.callback()));
scoped_ptr<TestCompletionCallback> close_callback(
new TestCompletionCallback);
@@ -1189,16 +1134,14 @@ TEST_F(HttpPipelinedConnectionImplTest, AbortWhileSendQueued) {
HttpRequestHeaders headers1;
HttpResponseInfo response1;
TestCompletionCallback callback1;
- EXPECT_EQ(ERR_IO_PENDING,
- stream1->SendRequest(headers1, scoped_ptr<UploadDataStream>(),
- &response1, callback1.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, stream1->SendRequest(headers1, NULL, &response1,
+ callback1.callback()));
HttpRequestHeaders headers2;
HttpResponseInfo response2;
TestCompletionCallback callback2;
- EXPECT_EQ(ERR_IO_PENDING,
- stream2->SendRequest(headers2, scoped_ptr<UploadDataStream>(),
- &response2, callback2.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, stream2->SendRequest(headers2, NULL, &response2,
+ callback2.callback()));
stream2.reset();
stream1->Close(true);
@@ -1222,17 +1165,15 @@ TEST_F(HttpPipelinedConnectionImplTest, NoGapBetweenCloseAndEviction) {
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK,
- close_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
+ EXPECT_EQ(OK, close_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
TestCompletionCallback close_callback;
EXPECT_EQ(ERR_IO_PENDING,
close_stream->ReadResponseHeaders(close_callback.callback()));
- EXPECT_EQ(OK,
- dummy_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
+ EXPECT_EQ(OK, dummy_stream->SendRequest(headers, NULL, &response,
+ callback_.callback()));
TestCompletionCallback dummy_callback;
EXPECT_EQ(ERR_IO_PENDING,
@@ -1270,11 +1211,11 @@ TEST_F(HttpPipelinedConnectionImplTest, RecoverFromDrainOnRedirect) {
HttpRequestHeaders headers1;
HttpResponseInfo response1;
- EXPECT_EQ(OK, stream1->SendRequest(headers1, scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, stream1->SendRequest(headers1, NULL,
&response1, callback_.callback()));
HttpRequestHeaders headers2;
HttpResponseInfo response2;
- EXPECT_EQ(OK, stream2->SendRequest(headers2, scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, stream2->SendRequest(headers2, NULL,
&response2, callback_.callback()));
EXPECT_EQ(OK, stream1->ReadResponseHeaders(callback_.callback()));
@@ -1302,11 +1243,11 @@ TEST_F(HttpPipelinedConnectionImplTest, EvictAfterDrainOfUnknownSize) {
HttpRequestHeaders headers1;
HttpResponseInfo response1;
- EXPECT_EQ(OK, stream1->SendRequest(headers1, scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, stream1->SendRequest(headers1, NULL,
&response1, callback_.callback()));
HttpRequestHeaders headers2;
HttpResponseInfo response2;
- EXPECT_EQ(OK, stream2->SendRequest(headers2, scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, stream2->SendRequest(headers2, NULL,
&response2, callback_.callback()));
EXPECT_EQ(OK, stream1->ReadResponseHeaders(callback_.callback()));
@@ -1335,11 +1276,11 @@ TEST_F(HttpPipelinedConnectionImplTest, EvictAfterFailedDrain) {
HttpRequestHeaders headers1;
HttpResponseInfo response1;
- EXPECT_EQ(OK, stream1->SendRequest(headers1, scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, stream1->SendRequest(headers1, NULL,
&response1, callback_.callback()));
HttpRequestHeaders headers2;
HttpResponseInfo response2;
- EXPECT_EQ(OK, stream2->SendRequest(headers2, scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, stream2->SendRequest(headers2, NULL,
&response2, callback_.callback()));
@@ -1370,11 +1311,11 @@ TEST_F(HttpPipelinedConnectionImplTest, EvictIfDrainingChunkedEncoding) {
HttpRequestHeaders headers1;
HttpResponseInfo response1;
- EXPECT_EQ(OK, stream1->SendRequest(headers1, scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, stream1->SendRequest(headers1, NULL,
&response1, callback_.callback()));
HttpRequestHeaders headers2;
HttpResponseInfo response2;
- EXPECT_EQ(OK, stream2->SendRequest(headers2, scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, stream2->SendRequest(headers2, NULL,
&response2, callback_.callback()));
@@ -1405,17 +1346,12 @@ TEST_F(HttpPipelinedConnectionImplTest, EvictionDueToMissingContentLength) {
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK,
- ok_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
- EXPECT_EQ(OK,
- evicted_stream->SendRequest(headers,
- scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
- EXPECT_EQ(OK,
- rejected_stream->SendRequest(headers,
- scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
+ EXPECT_EQ(OK, ok_stream->SendRequest(headers, NULL,
+ &response, callback_.callback()));
+ EXPECT_EQ(OK, evicted_stream->SendRequest(headers, NULL,
+ &response, callback_.callback()));
+ EXPECT_EQ(OK, rejected_stream->SendRequest(headers, NULL,
+ &response, callback_.callback()));
TestCompletionCallback ok_callback;
EXPECT_EQ(ERR_IO_PENDING,
@@ -1457,7 +1393,7 @@ TEST_F(HttpPipelinedConnectionImplTest, FeedbackOnSocketError) {
scoped_ptr<HttpStream> stream(NewTestStream("ok.html"));
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK, stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
+ EXPECT_EQ(OK, stream->SendRequest(headers, NULL,
&response, callback_.callback()));
EXPECT_EQ(ERR_FAILED, stream->ReadResponseHeaders(callback_.callback()));
}
@@ -1477,8 +1413,8 @@ TEST_F(HttpPipelinedConnectionImplTest, FeedbackOnNoInternetConnection) {
scoped_ptr<HttpStream> stream(NewTestStream("ok.html"));
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK, stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
+ EXPECT_EQ(OK, stream->SendRequest(headers, NULL,
+ &response, callback_.callback()));
EXPECT_EQ(ERR_INTERNET_DISCONNECTED,
stream->ReadResponseHeaders(callback_.callback()));
}
@@ -1580,8 +1516,8 @@ TEST_F(HttpPipelinedConnectionImplTest, OnPipelineHasCapacity) {
EXPECT_CALL(delegate_, OnPipelineHasCapacity(pipeline_.get())).Times(1);
HttpRequestHeaders headers;
HttpResponseInfo response;
- EXPECT_EQ(OK, stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback_.callback()));
+ EXPECT_EQ(OK, stream->SendRequest(headers, NULL,
+ &response, callback_.callback()));
EXPECT_CALL(delegate_, OnPipelineHasCapacity(pipeline_.get())).Times(0);
MessageLoop::current()->RunAllPending();
diff --git a/net/http/http_pipelined_stream.cc b/net/http/http_pipelined_stream.cc
index 3b25e94..9dc85df 100644
--- a/net/http/http_pipelined_stream.cc
+++ b/net/http/http_pipelined_stream.cc
@@ -7,7 +7,6 @@
#include "base/logging.h"
#include "base/stringprintf.h"
#include "net/base/net_errors.h"
-#include "net/base/upload_data_stream.h"
#include "net/http/http_pipelined_connection_impl.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_request_info.h"
@@ -38,7 +37,7 @@ int HttpPipelinedStream::InitializeStream(
int HttpPipelinedStream::SendRequest(
const HttpRequestHeaders& headers,
- scoped_ptr<UploadDataStream> request_body,
+ UploadDataStream* request_body,
HttpResponseInfo* response,
const CompletionCallback& callback) {
CHECK(pipeline_id_);
@@ -49,7 +48,7 @@ int HttpPipelinedStream::SendRequest(
request_info_->method.c_str(),
path.c_str());
return pipeline_->SendRequest(pipeline_id_, request_line_, headers,
- request_body.Pass(), response, callback);
+ request_body, response, callback);
}
UploadProgress HttpPipelinedStream::GetUploadProgress() const {
diff --git a/net/http/http_pipelined_stream.h b/net/http/http_pipelined_stream.h
index 876346f..92f2130 100644
--- a/net/http/http_pipelined_stream.h
+++ b/net/http/http_pipelined_stream.h
@@ -43,7 +43,7 @@ class HttpPipelinedStream : public HttpStream {
const CompletionCallback& callback) OVERRIDE;
virtual int SendRequest(const HttpRequestHeaders& headers,
- scoped_ptr<UploadDataStream> request_body,
+ UploadDataStream* request_body,
HttpResponseInfo* response,
const CompletionCallback& callback) OVERRIDE;
diff --git a/net/http/http_proxy_client_socket.cc b/net/http/http_proxy_client_socket.cc
index 9b57770..4042a17 100644
--- a/net/http/http_proxy_client_socket.cc
+++ b/net/http/http_proxy_client_socket.cc
@@ -14,7 +14,6 @@
#include "net/base/io_buffer.h"
#include "net/base/net_log.h"
#include "net/base/net_util.h"
-#include "net/base/upload_data_stream.h"
#include "net/http/http_basic_stream.h"
#include "net/http/http_network_session.h"
#include "net/http/http_request_info.h"
@@ -435,8 +434,7 @@ int HttpProxyClientSocket::DoSendRequest() {
http_stream_parser_.reset(
new HttpStreamParser(transport_.get(), &request_, parser_buf_, net_log_));
return http_stream_parser_->SendRequest(
- request_line_, request_headers_, scoped_ptr<UploadDataStream>(),
- &response_, io_callback_);
+ request_line_, request_headers_, NULL, &response_, io_callback_);
}
int HttpProxyClientSocket::DoSendRequestComplete(int result) {
diff --git a/net/http/http_response_body_drainer_unittest.cc b/net/http/http_response_body_drainer_unittest.cc
index d9b6492..02b89c3 100644
--- a/net/http/http_response_body_drainer_unittest.cc
+++ b/net/http/http_response_body_drainer_unittest.cc
@@ -14,7 +14,6 @@
#include "net/base/net_errors.h"
#include "net/base/ssl_config_service_defaults.h"
#include "net/base/test_completion_callback.h"
-#include "net/base/upload_data_stream.h"
#include "net/http/http_network_session.h"
#include "net/http/http_server_properties_impl.h"
#include "net/http/http_stream.h"
@@ -80,7 +79,7 @@ class MockHttpStream : public HttpStream {
return ERR_UNEXPECTED;
}
virtual int SendRequest(const HttpRequestHeaders& request_headers,
- scoped_ptr<UploadDataStream> request_body,
+ UploadDataStream* request_body,
HttpResponseInfo* response,
const CompletionCallback& callback) OVERRIDE {
return ERR_UNEXPECTED;
diff --git a/net/http/http_stream.h b/net/http/http_stream.h
index 6016018..d1c4c6e 100644
--- a/net/http/http_stream.h
+++ b/net/http/http_stream.h
@@ -13,10 +13,7 @@
#ifndef NET_HTTP_HTTP_STREAM_H_
#define NET_HTTP_HTTP_STREAM_H_
-#include <string>
-
#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
#include "net/base/completion_callback.h"
#include "net/base/net_export.h"
#include "net/base/upload_progress.h"
@@ -49,7 +46,7 @@ class NET_EXPORT_PRIVATE HttpStream {
// synchronously, in which case the result will be passed to the callback
// when available. Returns OK on success.
virtual int SendRequest(const HttpRequestHeaders& request_headers,
- scoped_ptr<UploadDataStream> request_body,
+ UploadDataStream* request_body,
HttpResponseInfo* response,
const CompletionCallback& callback) = 0;
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index f5d1191..7bb7199 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -6,14 +6,12 @@
#include "base/bind.h"
#include "base/compiler_specific.h"
-#include "base/metrics/histogram.h"
#include "base/string_util.h"
#include "base/values.h"
-#include "net/base/address_list.h"
-#include "net/base/auth.h"
#include "net/base/io_buffer.h"
-#include "net/base/ssl_cert_request_info.h"
+#include "net/base/ip_endpoint.h"
#include "net/base/upload_data_stream.h"
+#include "net/http/http_chunked_decoder.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_request_info.h"
#include "net/http/http_response_headers.h"
@@ -199,7 +197,7 @@ HttpStreamParser::~HttpStreamParser() {
int HttpStreamParser::SendRequest(const std::string& request_line,
const HttpRequestHeaders& headers,
- scoped_ptr<UploadDataStream> request_body,
+ UploadDataStream* request_body,
HttpResponseInfo* response,
const CompletionCallback& callback) {
DCHECK_EQ(STATE_NONE, io_state_);
@@ -227,7 +225,7 @@ int HttpStreamParser::SendRequest(const std::string& request_line,
std::string request = request_line + headers.ToString();
- request_body_.reset(request_body.release());
+ request_body_ = request_body;
if (request_body_ != NULL) {
request_body_send_buf_ = new SeekableIOBuffer(kRequestBodyBufferSize);
if (request_body_->is_chunked()) {
@@ -246,7 +244,7 @@ int HttpStreamParser::SendRequest(const std::string& request_line,
// If we have a small request body, then we'll merge with the headers into a
// single write.
bool did_merge = false;
- if (ShouldMergeRequestHeadersAndBody(request, request_body_.get())) {
+ if (ShouldMergeRequestHeadersAndBody(request, request_body_)) {
size_t merged_size = request.size() + request_body_->size();
scoped_refptr<IOBuffer> merged_request_headers_and_body(
new IOBuffer(merged_size));
@@ -852,7 +850,7 @@ void HttpStreamParser::CalculateResponseBodySize() {
}
UploadProgress HttpStreamParser::GetUploadProgress() const {
- if (!request_body_.get())
+ if (!request_body_)
return UploadProgress();
return UploadProgress(request_body_->position(), request_body_->size());
diff --git a/net/http/http_stream_parser.h b/net/http/http_stream_parser.h
index 7f1dcce..259badf 100644
--- a/net/http/http_stream_parser.h
+++ b/net/http/http_stream_parser.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/string_piece.h"
@@ -15,13 +16,13 @@
#include "net/base/net_export.h"
#include "net/base/net_log.h"
#include "net/base/upload_progress.h"
-#include "net/http/http_chunked_decoder.h"
namespace net {
class ClientSocketHandle;
class DrainableIOBuffer;
class GrowableIOBuffer;
+class HttpChunkedDecoder;
struct HttpRequestInfo;
class HttpRequestHeaders;
class HttpResponseInfo;
@@ -48,7 +49,7 @@ class NET_EXPORT_PRIVATE HttpStreamParser {
// some additional functionality
int SendRequest(const std::string& request_line,
const HttpRequestHeaders& headers,
- scoped_ptr<UploadDataStream> request_body,
+ UploadDataStream* request_body,
HttpResponseInfo* response,
const CompletionCallback& callback);
@@ -175,7 +176,7 @@ class NET_EXPORT_PRIVATE HttpStreamParser {
scoped_refptr<DrainableIOBuffer> request_headers_;
// The request body data.
- scoped_ptr<UploadDataStream> request_body_;
+ UploadDataStream* request_body_;
// Temporary buffer for reading.
scoped_refptr<GrowableIOBuffer> read_buf_;
diff --git a/net/http/http_stream_parser_unittest.cc b/net/http/http_stream_parser_unittest.cc
index 9ef3cc7..2fb8730 100644
--- a/net/http/http_stream_parser_unittest.cc
+++ b/net/http/http_stream_parser_unittest.cc
@@ -194,6 +194,15 @@ TEST(HttpStreamParser, AsyncChunkAndAsyncSocket) {
MockRead(SYNCHRONOUS, 0, 8), // EOF
};
+ scoped_refptr<UploadData> upload_data(new UploadData);
+ upload_data->set_is_chunked(true);
+
+ upload_data->AppendChunk(kChunk1, arraysize(kChunk1) - 1, false);
+
+ scoped_ptr<UploadDataStream> upload_stream(
+ new UploadDataStream(upload_data));
+ ASSERT_EQ(OK, upload_stream->InitSync());
+
DeterministicSocketData data(reads, arraysize(reads),
writes, arraysize(writes));
data.set_connect_data(MockConnect(SYNCHRONOUS, OK));
@@ -219,15 +228,6 @@ TEST(HttpStreamParser, AsyncChunkAndAsyncSocket) {
HttpStreamParser parser(socket_handle.get(), &request_info, read_buffer,
BoundNetLog());
- scoped_refptr<UploadData> upload_data(new UploadData);
- upload_data->set_is_chunked(true);
-
- upload_data->AppendChunk(kChunk1, arraysize(kChunk1) - 1, false);
-
- scoped_ptr<UploadDataStream> upload_stream(
- new UploadDataStream(upload_data));
- ASSERT_EQ(OK, upload_stream->InitSync());
-
HttpRequestHeaders request_headers;
request_headers.SetHeader("Host", "localhost");
request_headers.SetHeader("Transfer-Encoding", "chunked");
@@ -237,7 +237,7 @@ TEST(HttpStreamParser, AsyncChunkAndAsyncSocket) {
// This will attempt to Write() the initial request and headers, which will
// complete asynchronously.
rv = parser.SendRequest("GET /one.html HTTP/1.1\r\n", request_headers,
- upload_stream.Pass(), &response_info,
+ upload_stream.get(), &response_info,
callback.callback());
ASSERT_EQ(ERR_IO_PENDING, rv);
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc
index cfbadd1..274fe47 100644
--- a/net/spdy/spdy_http_stream.cc
+++ b/net/spdy/spdy_http_stream.cc
@@ -6,24 +6,19 @@
#include <algorithm>
#include <list>
-#include <string>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/stringprintf.h"
-#include "base/values.h"
-#include "net/base/address_list.h"
#include "net/base/host_port_pair.h"
-#include "net/base/load_flags.h"
#include "net/base/net_log.h"
#include "net/base/net_util.h"
#include "net/base/upload_data_stream.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_request_info.h"
#include "net/http/http_response_info.h"
-#include "net/http/http_util.h"
#include "net/spdy/spdy_header_block.h"
#include "net/spdy/spdy_http_utils.h"
#include "net/spdy/spdy_session.h"
@@ -35,6 +30,8 @@ SpdyHttpStream::SpdyHttpStream(SpdySession* spdy_session,
: ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
stream_(NULL),
spdy_session_(spdy_session),
+ request_info_(NULL),
+ request_body_stream_(NULL),
response_info_(NULL),
download_finished_(false),
response_headers_received_(false),
@@ -82,7 +79,7 @@ const HttpResponseInfo* SpdyHttpStream::GetResponseInfo() const {
}
UploadProgress SpdyHttpStream::GetUploadProgress() const {
- if (!request_body_stream_.get())
+ if (!request_body_stream_)
return UploadProgress();
return UploadProgress(request_body_stream_->position(),
@@ -189,7 +186,7 @@ bool SpdyHttpStream::IsConnectionReusable() const {
}
int SpdyHttpStream::SendRequest(const HttpRequestHeaders& request_headers,
- scoped_ptr<UploadDataStream> request_body,
+ UploadDataStream* request_body,
HttpResponseInfo* response,
const CompletionCallback& callback) {
base::Time request_time = base::Time::Now();
@@ -213,10 +210,10 @@ int SpdyHttpStream::SendRequest(const HttpRequestHeaders& request_headers,
if (response_info_)
response_info_->request_time = request_time;
- CHECK(!request_body_stream_.get());
+ CHECK(!request_body_stream_);
if (request_body != NULL) {
if (request_body->size() || request_body->is_chunked()) {
- request_body_stream_.reset(request_body.release());
+ request_body_stream_ = request_body;
// Use kMaxSpdyFrameChunkSize as the buffer size, since the request
// body data is written with this size at a time.
raw_request_body_buf_ = new IOBufferWithSize(kMaxSpdyFrameChunkSize);
@@ -258,7 +255,7 @@ int SpdyHttpStream::SendRequest(const HttpRequestHeaders& request_headers,
return result;
response_info_->socket_address = HostPortPair::FromIPEndPoint(address);
- bool has_upload_data = request_body_stream_.get() != NULL;
+ bool has_upload_data = request_body_stream_ != NULL;
result = stream_->SendRequest(has_upload_data);
if (result == ERR_IO_PENDING) {
CHECK(callback_.is_null());
@@ -276,7 +273,7 @@ void SpdyHttpStream::Cancel() {
}
int SpdyHttpStream::SendData() {
- CHECK(request_body_stream_.get());
+ CHECK(request_body_stream_);
CHECK_EQ(0, request_body_buf_->BytesRemaining());
// Read the data from the request body stream.
@@ -296,11 +293,11 @@ int SpdyHttpStream::SendData() {
bool SpdyHttpStream::OnSendHeadersComplete(int status) {
if (!callback_.is_null())
DoCallback(status);
- return request_body_stream_.get() == NULL;
+ return request_body_stream_ == NULL;
}
int SpdyHttpStream::OnSendBody() {
- CHECK(request_body_stream_.get());
+ CHECK(request_body_stream_);
const bool eof = request_body_stream_->IsEOF();
if (request_body_buf_->BytesRemaining() > 0) {
return stream_->WriteStreamData(
@@ -318,7 +315,7 @@ int SpdyHttpStream::OnSendBody() {
int SpdyHttpStream::OnSendBodyComplete(int status, bool* eof) {
// |status| is the number of bytes written to the SPDY stream.
- CHECK(request_body_stream_.get());
+ CHECK(request_body_stream_);
*eof = false;
if (status > 0) {
diff --git a/net/spdy/spdy_http_stream.h b/net/spdy/spdy_http_stream.h
index e9b1f77..7c461ad 100644
--- a/net/spdy/spdy_http_stream.h
+++ b/net/spdy/spdy_http_stream.h
@@ -6,22 +6,19 @@
#define NET_SPDY_SPDY_HTTP_STREAM_H_
#include <list>
-#include <string>
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "net/base/completion_callback.h"
#include "net/base/net_log.h"
-#include "net/http/http_request_info.h"
#include "net/http/http_stream.h"
-#include "net/spdy/spdy_protocol.h"
-#include "net/spdy/spdy_session.h"
#include "net/spdy/spdy_stream.h"
namespace net {
class DrainableIOBuffer;
+struct HttpRequestInfo;
class HttpResponseInfo;
class IOBuffer;
class SpdySession;
@@ -47,7 +44,7 @@ class NET_EXPORT_PRIVATE SpdyHttpStream : public SpdyStream::Delegate,
const BoundNetLog& net_log,
const CompletionCallback& callback) OVERRIDE;
virtual int SendRequest(const HttpRequestHeaders& headers,
- scoped_ptr<UploadDataStream> request_body,
+ UploadDataStream* request_body,
HttpResponseInfo* response,
const CompletionCallback& callback) OVERRIDE;
virtual UploadProgress GetUploadProgress() const OVERRIDE;
@@ -115,7 +112,7 @@ class NET_EXPORT_PRIVATE SpdyHttpStream : public SpdyStream::Delegate,
// The request to send.
const HttpRequestInfo* request_info_;
- scoped_ptr<UploadDataStream> request_body_stream_;
+ UploadDataStream* request_body_stream_;
// |response_info_| is the HTTP response data object which is filled in
// when a SYN_REPLY comes in for the stream.
diff --git a/net/spdy/spdy_http_stream_spdy2_unittest.cc b/net/spdy/spdy_http_stream_spdy2_unittest.cc
index 83094f2..7e0a113 100644
--- a/net/spdy/spdy_http_stream_spdy2_unittest.cc
+++ b/net/spdy/spdy_http_stream_spdy2_unittest.cc
@@ -10,6 +10,7 @@
#include "net/base/asn1_util.h"
#include "net/base/default_server_bound_cert_store.h"
#include "net/base/upload_data_stream.h"
+#include "net/http/http_request_info.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_response_info.h"
#include "net/spdy/spdy_session.h"
@@ -105,9 +106,8 @@ TEST_F(SpdyHttpStreamSpdy2Test, SendRequest) {
OK,
http_stream->InitializeStream(&request, net_log, CompletionCallback()));
- EXPECT_EQ(ERR_IO_PENDING,
- http_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, http_stream->SendRequest(headers, NULL, &response,
+ callback.callback()));
EXPECT_TRUE(http_session_->spdy_session_pool()->HasSession(pair));
// This triggers the MockWrite and read 2
@@ -154,6 +154,11 @@ TEST_F(SpdyHttpStreamSpdy2Test, SendChunkedPost) {
request.upload_data->set_is_chunked(true);
request.upload_data->AppendChunk(kUploadData, kUploadDataSize, false);
request.upload_data->AppendChunk(kUploadData, kUploadDataSize, true);
+
+ scoped_ptr<UploadDataStream> upload_stream(
+ new UploadDataStream(request.upload_data));
+ ASSERT_EQ(OK, upload_stream->InitSync());
+
TestCompletionCallback callback;
HttpResponseInfo response;
HttpRequestHeaders headers;
@@ -163,11 +168,8 @@ TEST_F(SpdyHttpStreamSpdy2Test, SendChunkedPost) {
OK,
http_stream.InitializeStream(&request, net_log, CompletionCallback()));
- scoped_ptr<UploadDataStream> upload_stream(
- new UploadDataStream(request.upload_data));
- ASSERT_EQ(OK, upload_stream->InitSync());
EXPECT_EQ(ERR_IO_PENDING, http_stream.SendRequest(
- headers, upload_stream.Pass(), &response, callback.callback()));
+ headers, upload_stream.get(), &response, callback.callback()));
EXPECT_TRUE(http_session_->spdy_session_pool()->HasSession(pair));
// This triggers the MockWrite and read 2
@@ -250,6 +252,11 @@ TEST_F(SpdyHttpStreamSpdy2Test, DelayedSendChunkedPost) {
request.upload_data = new UploadData();
request.upload_data->set_is_chunked(true);
+ scoped_ptr<UploadDataStream> upload_stream(
+ new UploadDataStream(request.upload_data));
+ ASSERT_EQ(OK, upload_stream->InitSync());
+ request.upload_data->AppendChunk(kUploadData, kUploadDataSize, false);
+
BoundNetLog net_log;
scoped_ptr<SpdyHttpStream> http_stream(
new SpdyHttpStream(session_.get(), true));
@@ -258,19 +265,13 @@ TEST_F(SpdyHttpStreamSpdy2Test, DelayedSendChunkedPost) {
net_log,
CompletionCallback()));
- scoped_ptr<UploadDataStream> upload_stream(
- new UploadDataStream(request.upload_data));
- ASSERT_EQ(OK, upload_stream->InitSync());
-
- request.upload_data->AppendChunk(kUploadData, kUploadDataSize, false);
-
HttpRequestHeaders headers;
HttpResponseInfo response;
// This will attempt to Write() the initial request and headers, which will
// complete asynchronously.
EXPECT_EQ(ERR_IO_PENDING,
http_stream->SendRequest(headers,
- upload_stream.Pass(),
+ upload_stream.get(),
&response,
callback.callback()));
EXPECT_TRUE(http_session_->spdy_session_pool()->HasSession(pair));
@@ -357,9 +358,8 @@ TEST_F(SpdyHttpStreamSpdy2Test, SpdyURLTest) {
OK,
http_stream->InitializeStream(&request, net_log, CompletionCallback()));
- EXPECT_EQ(ERR_IO_PENDING,
- http_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, http_stream->SendRequest(headers, NULL, &response,
+ callback.callback()));
const SpdyHeaderBlock& spdy_header =
http_stream->stream()->spdy_headers();
diff --git a/net/spdy/spdy_http_stream_spdy3_unittest.cc b/net/spdy/spdy_http_stream_spdy3_unittest.cc
index 7aac5df..1c3b034e 100644
--- a/net/spdy/spdy_http_stream_spdy3_unittest.cc
+++ b/net/spdy/spdy_http_stream_spdy3_unittest.cc
@@ -12,6 +12,7 @@
#include "net/base/asn1_util.h"
#include "net/base/default_server_bound_cert_store.h"
#include "net/base/upload_data_stream.h"
+#include "net/http/http_request_info.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_response_info.h"
#include "net/spdy/spdy_credential_builder.h"
@@ -114,9 +115,8 @@ TEST_F(SpdyHttpStreamSpdy3Test, SendRequest) {
OK,
http_stream->InitializeStream(&request, net_log, CompletionCallback()));
- EXPECT_EQ(ERR_IO_PENDING,
- http_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, http_stream->SendRequest(headers, NULL, &response,
+ callback.callback()));
EXPECT_TRUE(http_session_->spdy_session_pool()->HasSession(pair));
// This triggers the MockWrite and read 2
@@ -163,6 +163,11 @@ TEST_F(SpdyHttpStreamSpdy3Test, SendChunkedPost) {
request.upload_data->set_is_chunked(true);
request.upload_data->AppendChunk(kUploadData, kUploadDataSize, false);
request.upload_data->AppendChunk(kUploadData, kUploadDataSize, true);
+
+ scoped_ptr<UploadDataStream> upload_stream(
+ new UploadDataStream(request.upload_data));
+ ASSERT_EQ(OK, upload_stream->InitSync());
+
TestCompletionCallback callback;
HttpResponseInfo response;
HttpRequestHeaders headers;
@@ -172,11 +177,8 @@ TEST_F(SpdyHttpStreamSpdy3Test, SendChunkedPost) {
OK,
http_stream.InitializeStream(&request, net_log, CompletionCallback()));
- scoped_ptr<UploadDataStream> upload_stream(
- new UploadDataStream(request.upload_data));
- ASSERT_EQ(OK, upload_stream->InitSync());
EXPECT_EQ(ERR_IO_PENDING, http_stream.SendRequest(
- headers, upload_stream.Pass(), &response, callback.callback()));
+ headers, upload_stream.get(), &response, callback.callback()));
EXPECT_TRUE(http_session_->spdy_session_pool()->HasSession(pair));
// This triggers the MockWrite and read 2
@@ -259,6 +261,11 @@ TEST_F(SpdyHttpStreamSpdy3Test, DelayedSendChunkedPost) {
request.upload_data = new UploadData();
request.upload_data->set_is_chunked(true);
+ scoped_ptr<UploadDataStream> upload_stream(
+ new UploadDataStream(request.upload_data));
+ ASSERT_EQ(OK, upload_stream->InitSync());
+ request.upload_data->AppendChunk(kUploadData, kUploadDataSize, false);
+
BoundNetLog net_log;
scoped_ptr<SpdyHttpStream> http_stream(
new SpdyHttpStream(session_.get(), true));
@@ -267,19 +274,13 @@ TEST_F(SpdyHttpStreamSpdy3Test, DelayedSendChunkedPost) {
net_log,
CompletionCallback()));
- scoped_ptr<UploadDataStream> upload_stream(
- new UploadDataStream(request.upload_data));
- ASSERT_EQ(OK, upload_stream->InitSync());
-
- request.upload_data->AppendChunk(kUploadData, kUploadDataSize, false);
-
HttpRequestHeaders headers;
HttpResponseInfo response;
// This will attempt to Write() the initial request and headers, which will
// complete asynchronously.
EXPECT_EQ(ERR_IO_PENDING,
http_stream->SendRequest(headers,
- upload_stream.Pass(),
+ upload_stream.get(),
&response,
callback.callback()));
EXPECT_TRUE(http_session_->spdy_session_pool()->HasSession(pair));
@@ -395,6 +396,11 @@ TEST_F(SpdyHttpStreamSpdy3Test, DelayedSendChunkedPostWithWindowUpdate) {
request.upload_data = new UploadData();
request.upload_data->set_is_chunked(true);
+ scoped_ptr<UploadDataStream> upload_stream(
+ new UploadDataStream(request.upload_data));
+ ASSERT_EQ(OK, upload_stream->InitSync());
+ request.upload_data->AppendChunk(kUploadData, kUploadDataSize, true);
+
BoundNetLog net_log;
scoped_ptr<SpdyHttpStream> http_stream(
new SpdyHttpStream(session_.get(), true));
@@ -403,19 +409,13 @@ TEST_F(SpdyHttpStreamSpdy3Test, DelayedSendChunkedPostWithWindowUpdate) {
net_log,
CompletionCallback()));
- scoped_ptr<UploadDataStream> upload_stream(
- new UploadDataStream(request.upload_data));
- ASSERT_EQ(OK, upload_stream->InitSync());
-
- request.upload_data->AppendChunk(kUploadData, kUploadDataSize, true);
-
HttpRequestHeaders headers;
HttpResponseInfo response;
// This will attempt to Write() the initial request and headers, which will
// complete asynchronously.
EXPECT_EQ(ERR_IO_PENDING,
http_stream->SendRequest(headers,
- upload_stream.Pass(),
+ upload_stream.get(),
&response,
callback.callback()));
EXPECT_TRUE(http_session_->spdy_session_pool()->HasSession(pair));
@@ -490,9 +490,8 @@ TEST_F(SpdyHttpStreamSpdy3Test, SpdyURLTest) {
OK,
http_stream->InitializeStream(&request, net_log, CompletionCallback()));
- EXPECT_EQ(ERR_IO_PENDING,
- http_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, http_stream->SendRequest(headers, NULL, &response,
+ callback.callback()));
const SpdyHeaderBlock& spdy_header =
http_stream->stream()->spdy_headers();
@@ -695,9 +694,8 @@ void SpdyHttpStreamSpdy3Test::TestSendCredentials(
// GURL new_origin(kUrl2);
// EXPECT_TRUE(session_->NeedsCredentials(new_origin));
- EXPECT_EQ(ERR_IO_PENDING,
- http_stream->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, http_stream->SendRequest(headers, NULL, &response,
+ callback.callback()));
EXPECT_TRUE(http_session_->spdy_session_pool()->HasSession(pair));
data.RunFor(2);
@@ -710,9 +708,8 @@ void SpdyHttpStreamSpdy3Test::TestSendCredentials(
ASSERT_EQ(
OK,
http_stream2->InitializeStream(&request, net_log, CompletionCallback()));
- EXPECT_EQ(ERR_IO_PENDING,
- http_stream2->SendRequest(headers, scoped_ptr<UploadDataStream>(),
- &response, callback.callback()));
+ EXPECT_EQ(ERR_IO_PENDING, http_stream2->SendRequest(headers, NULL, &response,
+ callback.callback()));
data.RunFor(2);
callback.WaitForResult();