summaryrefslogtreecommitdiffstats
path: root/net/http/http_network_transaction.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/http/http_network_transaction.cc')
-rw-r--r--net/http/http_network_transaction.cc114
1 files changed, 20 insertions, 94 deletions
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 7ef80f7..7f0ac4f 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -1,5 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -55,7 +54,6 @@
#include "net/spdy/spdy_http_stream.h"
#include "net/spdy/spdy_session.h"
#include "net/spdy/spdy_session_pool.h"
-#include <cutils/log.h>
using base::Time;
@@ -247,17 +245,8 @@ int HttpNetworkTransaction::RestartWithAuth(
void HttpNetworkTransaction::PrepareForAuthRestart(HttpAuth::Target target) {
DCHECK(HaveAuth(target));
- PrepareForRetry(true);
-}
-
-void HttpNetworkTransaction::PrepareForGetZipRetry()
-{
- PrepareForRetry(false);
-}
-
-void HttpNetworkTransaction::PrepareForRetry(bool isForAuthentication)
-{
DCHECK(!stream_request_.get());
+
bool keep_alive = false;
// 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.
@@ -265,10 +254,8 @@ void HttpNetworkTransaction::PrepareForRetry(bool isForAuthentication)
stream_->CanFindEndOfResponse()) {
// If the response body hasn't been completely read, we need to drain
// it first.
- // goes to drain body first!!!
if (!stream_->IsResponseBodyComplete()) {
- next_state_ = isForAuthentication ? STATE_DRAIN_BODY_FOR_AUTH_RESTART:
- STATE_DRAIN_BODY_FOR_GETZIP_RETRY;
+ next_state_ = STATE_DRAIN_BODY_FOR_AUTH_RESTART;
read_buf_ = new IOBuffer(kDrainBodyBufferSize); // A bit bucket.
read_buf_len_ = kDrainBodyBufferSize;
return;
@@ -278,58 +265,35 @@ void HttpNetworkTransaction::PrepareForRetry(bool isForAuthentication)
// We don't need to drain the response body, so we act as if we had drained
// the response body.
- isForAuthentication ?
- DidDrainBodyForAuthRestart(keep_alive):
- DidDrainBodyForGetZipRetry(keep_alive);
+ DidDrainBodyForAuthRestart(keep_alive);
}
-void HttpNetworkTransaction::DidDrainBodyForAuthRestart( bool keep_alive )
- {
-
- DidDrainBodyForRetry( keep_alive );
- // Reset the other member variables.
- ResetStateForAuthRestart();
- }
-
-void HttpNetworkTransaction::DidDrainBodyForGetZipRetry( bool keep_alive )
-{
- DidDrainBodyForRetry( keep_alive );
- read_buf_ = NULL;
- read_buf_len_ = 0;
- headers_valid_ = false;
- request_headers_.Clear();
- response_ = HttpResponseInfo();
-}
-
-void HttpNetworkTransaction::DidDrainBodyForRetry( bool keep_alive )
-{
- DCHECK( !stream_request_.get() );
+void HttpNetworkTransaction::DidDrainBodyForAuthRestart(bool keep_alive) {
+ DCHECK(!stream_request_.get());
- if ( stream_.get() )
- {
+ if (stream_.get()) {
HttpStream* new_stream = NULL;
- if ( keep_alive && stream_->IsConnectionReusable() )
- {
+ if (keep_alive && stream_->IsConnectionReusable()) {
// We should call connection_->set_idle_time(), but this doesn't occur
// often enough to be worth the trouble.
stream_->SetConnectionReused();
new_stream = stream_->RenewStreamForAuth();
}
- if ( !new_stream )
- {
+ if (!new_stream) {
// Close the stream and mark it as not_reusable. Even in the
// keep_alive case, we've determined that the stream_ is not
// reusable if new_stream is NULL.
- stream_->Close( true );
+ stream_->Close(true);
next_state_ = STATE_CREATE_STREAM;
- }
- else
- {
+ } else {
next_state_ = STATE_INIT_STREAM;
}
- stream_.reset( new_stream );
+ stream_.reset(new_stream);
}
+
+ // Reset the other member variables.
+ ResetStateForAuthRestart();
}
bool HttpNetworkTransaction::IsReadyToRestartForAuth() {
@@ -595,13 +559,6 @@ int HttpNetworkTransaction::DoLoop(int result) {
net_log_.EndEventWithNetErrorCode(
NetLog::TYPE_HTTP_TRANSACTION_READ_BODY, rv);
break;
- case STATE_DRAIN_BODY_FOR_GETZIP_RETRY:
- DCHECK_EQ(OK, rv);
- rv = DoDrainBodyForGetZipRetry();
- break;
- case STATE_DRAIN_BODY_FOR_GETZIP_RETRY_COMPLETE:
- rv = DoDrainBodyForGetZipRetryComplete(rv);
- break;
case STATE_DRAIN_BODY_FOR_AUTH_RESTART:
DCHECK_EQ(OK, rv);
net_log_.BeginEvent(
@@ -1006,28 +963,9 @@ int HttpNetworkTransaction::DoDrainBodyForAuthRestart() {
return rv;
}
-int HttpNetworkTransaction::DoDrainBodyForGetZipRetry() {
- int rv = DoReadBody();
- DCHECK(next_state_ == STATE_READ_BODY_COMPLETE);
- next_state_ = STATE_DRAIN_BODY_FOR_GETZIP_RETRY_COMPLETE;
- return rv;
-}
-
-int HttpNetworkTransaction::DoDrainBodyForGetZipRetryComplete(int result) {
- DoDrainBodyForRetryComplete( result, false );
- return OK;
-}
-
// TODO(wtc): This method and the DoReadBodyComplete method are almost
// the same. Figure out a good way for these two methods to share code.
int HttpNetworkTransaction::DoDrainBodyForAuthRestartComplete(int result) {
- DoDrainBodyForRetryComplete( result, true );
- return OK;
-}
-
-void HttpNetworkTransaction::DoDrainBodyForRetryComplete( int result,
- bool isForAuthentication )
-{
// keep_alive defaults to true because the very reason we're draining the
// response body is to reuse the connection for auth restart.
bool done = false, keep_alive = true;
@@ -1040,15 +978,13 @@ void HttpNetworkTransaction::DoDrainBodyForRetryComplete( int result,
}
if (done) {
- isForAuthentication ?
- DidDrainBodyForAuthRestart(keep_alive):
- DidDrainBodyForGetZipRetry(keep_alive);
+ DidDrainBodyForAuthRestart(keep_alive);
} else {
// Keep draining.
- next_state_ = isForAuthentication ?
- STATE_DRAIN_BODY_FOR_AUTH_RESTART :
- STATE_DRAIN_BODY_FOR_GETZIP_RETRY ;
+ next_state_ = STATE_DRAIN_BODY_FOR_AUTH_RESTART;
}
+
+ return OK;
}
void HttpNetworkTransaction::LogTransactionConnectedMetrics() {
@@ -1254,12 +1190,8 @@ int HttpNetworkTransaction::HandleIOError(int error) {
// cause SSL handshake errors to be delayed until the first or second Write
// (Snap Start) or the first Read (False & Snap Start) on the underlying
// connection.
- if(error != ERR_GETZIP)
- error = HandleSSLHandshakeError(error);
- else
- {
- SLOGD("%s:%s:: SHUTR protocol failure", __FILE__, __FUNCTION__);
- }
+ error = HandleSSLHandshakeError(error);
+
switch (error) {
// If we try to reuse a connection that the server is in the process of
// closing, we may end up successfully writing out our request (or a
@@ -1277,10 +1209,6 @@ int HttpNetworkTransaction::HandleIOError(int error) {
ResetConnectionAndRequestForResend();
error = OK;
break;
- case ERR_GETZIP:
- PrepareForGetZipRetry();
- error = OK;
- break;
}
return error;
}
@@ -1410,8 +1338,6 @@ std::string HttpNetworkTransaction::DescribeState(State state) {
STATE_CASE(STATE_READ_HEADERS_COMPLETE);
STATE_CASE(STATE_READ_BODY);
STATE_CASE(STATE_READ_BODY_COMPLETE);
- STATE_CASE(STATE_DRAIN_BODY_FOR_GETZIP_RETRY);
- STATE_CASE(STATE_DRAIN_BODY_FOR_GETZIP_RETRY_COMPLETE);
STATE_CASE(STATE_DRAIN_BODY_FOR_AUTH_RESTART);
STATE_CASE(STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE);
STATE_CASE(STATE_NONE);