summaryrefslogtreecommitdiffstats
path: root/net/flip
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-16 23:18:14 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-16 23:18:14 +0000
commita7e4131b3f56e3396a7d2b51ac022e2df220f28f (patch)
tree27f9cb64b2df2f31c13fd242338e30c504980de9 /net/flip
parent18d6a8f3322db4c50ae4a1ebd9e95796f43ea013 (diff)
downloadchromium_src-a7e4131b3f56e3396a7d2b51ac022e2df220f28f.zip
chromium_src-a7e4131b3f56e3396a7d2b51ac022e2df220f28f.tar.gz
chromium_src-a7e4131b3f56e3396a7d2b51ac022e2df220f28f.tar.bz2
Make the transactions own the HttpResponseInfo.
Necessary since we need the SSLInfo to handle certificate errors, but it lives within the HttpResponseInfo. SSL is before we choose http or spdy, so we don't have an http stream or a spdy stream yet, so they cannot own the HttpResponseInfo. Review URL: http://codereview.chromium.org/500039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34773 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/flip')
-rw-r--r--net/flip/flip_network_transaction.cc5
-rw-r--r--net/flip/flip_network_transaction.h2
-rwxr-xr-xnet/flip/flip_stream.cc16
-rwxr-xr-xnet/flip/flip_stream.h6
-rw-r--r--net/flip/flip_stream_unittest.cc4
5 files changed, 21 insertions, 12 deletions
diff --git a/net/flip/flip_network_transaction.cc b/net/flip/flip_network_transaction.cc
index 4b94b1f..4e0c3d2d 100644
--- a/net/flip/flip_network_transaction.cc
+++ b/net/flip/flip_network_transaction.cc
@@ -99,8 +99,7 @@ int FlipNetworkTransaction::Read(IOBuffer* buf, int buf_len,
}
const HttpResponseInfo* FlipNetworkTransaction::GetResponseInfo() const {
- const HttpResponseInfo* response = stream_->GetResponseInfo();
- return (response->headers || response->ssl_info.cert) ? response : NULL;
+ return (response_.headers || response_.ssl_info.cert) ? &response_ : NULL;
}
LoadState FlipNetworkTransaction::GetLoadState() const {
@@ -253,7 +252,7 @@ int FlipNetworkTransaction::DoSendRequest() {
UploadDataStream* upload_data = request_->upload_data ?
new UploadDataStream(request_->upload_data) : NULL;
stream_ = flip_->GetOrCreateStream(*request_, upload_data);
- return stream_->SendRequest(upload_data, &io_callback_);
+ return stream_->SendRequest(upload_data, &response_, &io_callback_);
}
int FlipNetworkTransaction::DoSendRequestComplete(int result) {
diff --git a/net/flip/flip_network_transaction.h b/net/flip/flip_network_transaction.h
index eab2f45..a48455a 100644
--- a/net/flip/flip_network_transaction.h
+++ b/net/flip/flip_network_transaction.h
@@ -15,6 +15,7 @@
#include "net/base/completion_callback.h"
#include "net/base/load_states.h"
#include "net/flip/flip_session.h"
+#include "net/http/http_response_info.h"
#include "net/http/http_transaction.h"
namespace net {
@@ -103,6 +104,7 @@ class FlipNetworkTransaction : public HttpTransaction {
scoped_refptr<HttpNetworkSession> session_;
const HttpRequestInfo* request_;
+ HttpResponseInfo response_;
// The time the Start method was called.
base::TimeTicks start_time_;
diff --git a/net/flip/flip_stream.cc b/net/flip/flip_stream.cc
index b0c7236..7288480 100755
--- a/net/flip/flip_stream.cc
+++ b/net/flip/flip_stream.cc
@@ -50,7 +50,7 @@ uint64 FlipStream::GetUploadProgress() const {
}
const HttpResponseInfo* FlipStream::GetResponseInfo() const {
- return response_.get();
+ return response_;
}
int FlipStream::ReadResponseHeaders(CompletionCallback* callback) {
@@ -61,7 +61,7 @@ int FlipStream::ReadResponseHeaders(CompletionCallback* callback) {
CHECK(!cancelled_);
// The SYN_REPLY has already been received.
- if (response_.get())
+ if (response_->headers)
return OK;
io_state_ = STATE_READ_HEADERS;
@@ -114,9 +114,13 @@ int FlipStream::ReadResponseBody(
}
int FlipStream::SendRequest(UploadDataStream* upload_data,
+ HttpResponseInfo* response,
CompletionCallback* callback) {
CHECK(callback);
CHECK(!cancelled_);
+ CHECK(response);
+
+ response_ = response;
if (upload_data) {
if (upload_data->size())
@@ -157,10 +161,10 @@ void FlipStream::Cancel() {
void FlipStream::OnResponseReceived(const HttpResponseInfo& response) {
metrics_.StartStream();
- CHECK(!response_.get());
+ CHECK(!response_->headers);
- response_.reset(new HttpResponseInfo);
*response_ = response; // TODO(mbelshe): avoid copy.
+ DCHECK(response_->headers);
if (io_state_ == STATE_NONE) {
CHECK(pushed_);
@@ -184,7 +188,7 @@ bool FlipStream::OnDataReceived(const char* data, int length) {
// If we don't have a response, then the SYN_REPLY did not come through.
// We cannot pass data up to the caller unless the reply headers have been
// received.
- if (!response_.get()) {
+ if (!response_->headers) {
OnClose(ERR_SYN_REPLY_NOT_RECEIVED);
return false;
}
@@ -359,7 +363,7 @@ int FlipStream::DoSendBodyComplete(int result) {
int FlipStream::DoReadHeaders() {
io_state_ = STATE_READ_HEADERS_COMPLETE;
- return response_.get() ? OK : ERR_IO_PENDING;
+ return response_->headers ? OK : ERR_IO_PENDING;
}
int FlipStream::DoReadHeadersComplete(int result) {
diff --git a/net/flip/flip_stream.h b/net/flip/flip_stream.h
index 54c5cd4..3ebdc2e 100755
--- a/net/flip/flip_stream.h
+++ b/net/flip/flip_stream.h
@@ -51,7 +51,9 @@ class FlipStream : public base::RefCounted<FlipStream> {
// body. |callback| is used when this completes asynchronously. Note that
// the actual SYN_STREAM packet will have already been sent by this point.
// Also note that FlipStream takes ownership of |upload_data|.
- int SendRequest(UploadDataStream* upload_data, CompletionCallback* callback);
+ int SendRequest(UploadDataStream* upload_data,
+ HttpResponseInfo* response,
+ CompletionCallback* callback);
// Reads the response headers. Returns a net error code.
int ReadResponseHeaders(CompletionCallback* callback);
@@ -164,7 +166,7 @@ class FlipStream : public base::RefCounted<FlipStream> {
scoped_refptr<FlipSession> session_;
- scoped_ptr<HttpResponseInfo> response_;
+ HttpResponseInfo* response_;
scoped_ptr<UploadDataStream> request_body_stream_;
bool response_complete_; // TODO(mbelshe): fold this into the io_state.
diff --git a/net/flip/flip_stream_unittest.cc b/net/flip/flip_stream_unittest.cc
index 311b51c..bb64d63 100644
--- a/net/flip/flip_stream_unittest.cc
+++ b/net/flip/flip_stream_unittest.cc
@@ -13,6 +13,7 @@
#include "net/flip/flip_session_pool.h"
#include "net/http/http_network_session.h"
#include "net/http/http_request_info.h"
+#include "net/http/http_response_info.h"
#include "net/proxy/proxy_service.h"
#include "net/socket/socket_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -103,9 +104,10 @@ TEST_F(FlipStreamTest, SendRequest) {
request.method = "GET";
request.url = GURL("http://www.google.com/");
TestCompletionCallback callback;
+ HttpResponseInfo response;
scoped_refptr<FlipStream> stream(new FlipStream(session, 1, false));
- EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(NULL, &callback));
+ EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(NULL, &response, &callback));
// Need to manually remove the flip session since normally it gets removed on
// socket close/error, but we aren't communicating over a socket here.