Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: net/http/http_network_transaction.cc

Issue 137493008: Retry HttpNetworkTransactions upon receipt of ERR_NETWORK_CHANGED during host resolution and … Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Flush task queue before restart Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 request_(NULL), 131 request_(NULL),
132 priority_(priority), 132 priority_(priority),
133 headers_valid_(false), 133 headers_valid_(false),
134 logged_response_time_(false), 134 logged_response_time_(false),
135 fallback_error_code_(ERR_SSL_INAPPROPRIATE_FALLBACK), 135 fallback_error_code_(ERR_SSL_INAPPROPRIATE_FALLBACK),
136 request_headers_(), 136 request_headers_(),
137 read_buf_len_(0), 137 read_buf_len_(0),
138 total_received_bytes_(0), 138 total_received_bytes_(0),
139 next_state_(STATE_NONE), 139 next_state_(STATE_NONE),
140 establishing_tunnel_(false), 140 establishing_tunnel_(false),
141 websocket_handshake_stream_base_create_helper_(NULL) { 141 websocket_handshake_stream_base_create_helper_(NULL),
142 num_automatic_retries_on_network_changes_(0),
143 weak_factory_(this) {
142 session->ssl_config_service()->GetSSLConfig(&server_ssl_config_); 144 session->ssl_config_service()->GetSSLConfig(&server_ssl_config_);
143 if (session->http_stream_factory()->has_next_protos()) { 145 if (session->http_stream_factory()->has_next_protos()) {
144 server_ssl_config_.next_protos = 146 server_ssl_config_.next_protos =
145 session->http_stream_factory()->next_protos(); 147 session->http_stream_factory()->next_protos();
146 } 148 }
147 proxy_ssl_config_ = server_ssl_config_; 149 proxy_ssl_config_ = server_ssl_config_;
148 } 150 }
149 151
150 HttpNetworkTransaction::~HttpNetworkTransaction() { 152 HttpNetworkTransaction::~HttpNetworkTransaction() {
151 if (stream_.get()) { 153 if (stream_.get()) {
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 int HttpNetworkTransaction::DoCreateStreamComplete(int result) { 740 int HttpNetworkTransaction::DoCreateStreamComplete(int result) {
739 if (result == OK) { 741 if (result == OK) {
740 next_state_ = STATE_INIT_STREAM; 742 next_state_ = STATE_INIT_STREAM;
741 DCHECK(stream_.get()); 743 DCHECK(stream_.get());
742 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { 744 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
743 result = HandleCertificateRequest(result); 745 result = HandleCertificateRequest(result);
744 } else if (result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { 746 } else if (result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) {
745 // Return OK and let the caller read the proxy's error page 747 // Return OK and let the caller read the proxy's error page
746 next_state_ = STATE_NONE; 748 next_state_ = STATE_NONE;
747 return OK; 749 return OK;
750 } else if (result == ERR_NETWORK_CHANGED &&
751 num_automatic_retries_on_network_changes_ <
752 request_->max_automatic_retries_on_network_changes_) {
753 // Try again to create the stream.
754 ++num_automatic_retries_on_network_changes_;
755 next_state_ = STATE_CREATE_STREAM;
756 // Retry after flushing all the current tasks which may include further
757 // network change observers that could trigger another ERR_NETWORK_CHANGED
758 // failure.
759 base::MessageLoop::current()->PostTask(
760 FROM_HERE,
761 base::Bind(&HttpNetworkTransaction::OnIOComplete,
762 weak_factory_.GetWeakPtr(), OK));
763 return ERR_IO_PENDING;
748 } 764 }
749 765
750 // Handle possible handshake errors that may have occurred if the stream 766 // Handle possible handshake errors that may have occurred if the stream
751 // used SSL for one or more of the layers. 767 // used SSL for one or more of the layers.
752 result = HandleSSLHandshakeError(result); 768 result = HandleSSLHandshakeError(result);
753 769
754 // At this point we are done with the stream_request_. 770 // At this point we are done with the stream_request_.
755 stream_request_.reset(); 771 stream_request_.reset();
756 return result; 772 return result;
757 } 773 }
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, 1629 description = base::StringPrintf("Unknown state 0x%08X (%u)", state,
1614 state); 1630 state);
1615 break; 1631 break;
1616 } 1632 }
1617 return description; 1633 return description;
1618 } 1634 }
1619 1635
1620 #undef STATE_CASE 1636 #undef STATE_CASE
1621 1637
1622 } // namespace net 1638 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698