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

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

Issue 1006643002: Plumb connection attempts from (non-proxy) ConnectJobs to HttpNetworkTransaction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, resolve conflict Created 5 years, 8 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
« no previous file with comments | « net/http/http_network_transaction.h ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 OnIOComplete(ERR_SSL_CLIENT_AUTH_CERT_NEEDED); 564 OnIOComplete(ERR_SSL_CLIENT_AUTH_CERT_NEEDED);
565 } 565 }
566 566
567 void HttpNetworkTransaction::OnHttpsProxyTunnelResponse( 567 void HttpNetworkTransaction::OnHttpsProxyTunnelResponse(
568 const HttpResponseInfo& response_info, 568 const HttpResponseInfo& response_info,
569 const SSLConfig& used_ssl_config, 569 const SSLConfig& used_ssl_config,
570 const ProxyInfo& used_proxy_info, 570 const ProxyInfo& used_proxy_info,
571 HttpStream* stream) { 571 HttpStream* stream) {
572 DCHECK_EQ(STATE_CREATE_STREAM_COMPLETE, next_state_); 572 DCHECK_EQ(STATE_CREATE_STREAM_COMPLETE, next_state_);
573 573
574 CopyConnectionAttemptsFromStreamRequest();
575
574 headers_valid_ = true; 576 headers_valid_ = true;
575 response_ = response_info; 577 response_ = response_info;
576 server_ssl_config_ = used_ssl_config; 578 server_ssl_config_ = used_ssl_config;
577 proxy_info_ = used_proxy_info; 579 proxy_info_ = used_proxy_info;
578 if (stream_) 580 if (stream_)
579 total_received_bytes_ += stream_->GetTotalReceivedBytes(); 581 total_received_bytes_ += stream_->GetTotalReceivedBytes();
580 stream_.reset(stream); 582 stream_.reset(stream);
581 stream_request_.reset(); // we're done with the stream request 583 stream_request_.reset(); // we're done with the stream request
582 OnIOComplete(ERR_HTTPS_PROXY_TUNNEL_RESPONSE); 584 OnIOComplete(ERR_HTTPS_PROXY_TUNNEL_RESPONSE);
583 } 585 }
584 586
587 void HttpNetworkTransaction::GetConnectionAttempts(
588 ConnectionAttempts* out) const {
589 *out = connection_attempts_;
590 }
591
585 bool HttpNetworkTransaction::IsSecureRequest() const { 592 bool HttpNetworkTransaction::IsSecureRequest() const {
586 return request_->url.SchemeIsSecure(); 593 return request_->url.SchemeIsSecure();
587 } 594 }
588 595
589 bool HttpNetworkTransaction::UsingHttpProxyWithoutTunnel() const { 596 bool HttpNetworkTransaction::UsingHttpProxyWithoutTunnel() const {
590 return (proxy_info_.is_http() || proxy_info_.is_https() || 597 return (proxy_info_.is_http() || proxy_info_.is_https() ||
591 proxy_info_.is_quic()) && 598 proxy_info_.is_quic()) &&
592 !(request_->url.SchemeIs("https") || request_->url.SchemeIsWSOrWSS()); 599 !(request_->url.SchemeIs("https") || request_->url.SchemeIsWSOrWSS());
593 } 600 }
594 601
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 DCHECK(stream_request_.get()); 771 DCHECK(stream_request_.get());
765 return ERR_IO_PENDING; 772 return ERR_IO_PENDING;
766 } 773 }
767 774
768 int HttpNetworkTransaction::DoCreateStreamComplete(int result) { 775 int HttpNetworkTransaction::DoCreateStreamComplete(int result) {
769 // TODO(pkasting): Remove ScopedTracker below once crbug.com/424359 is fixed. 776 // TODO(pkasting): Remove ScopedTracker below once crbug.com/424359 is fixed.
770 tracked_objects::ScopedTracker tracking_profile( 777 tracked_objects::ScopedTracker tracking_profile(
771 FROM_HERE_WITH_EXPLICIT_FUNCTION( 778 FROM_HERE_WITH_EXPLICIT_FUNCTION(
772 "424359 HttpNetworkTransaction::DoCreateStreamComplete")); 779 "424359 HttpNetworkTransaction::DoCreateStreamComplete"));
773 780
781 // If |result| is ERR_HTTPS_PROXY_TUNNEL_RESPONSE, then
782 // DoCreateStreamComplete is being called from OnHttpsProxyTunnelResponse,
783 // which resets the stream request first. Therefore, we have to grab the
784 // connection attempts in *that* function instead of here in that case.
785 if (result != ERR_HTTPS_PROXY_TUNNEL_RESPONSE)
786 CopyConnectionAttemptsFromStreamRequest();
787
774 if (result == OK) { 788 if (result == OK) {
775 next_state_ = STATE_INIT_STREAM; 789 next_state_ = STATE_INIT_STREAM;
776 DCHECK(stream_.get()); 790 DCHECK(stream_.get());
777 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { 791 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
778 result = HandleCertificateRequest(result); 792 result = HandleCertificateRequest(result);
779 } else if (result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { 793 } else if (result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) {
780 // Return OK and let the caller read the proxy's error page 794 // Return OK and let the caller read the proxy's error page
781 next_state_ = STATE_NONE; 795 next_state_ = STATE_NONE;
782 return OK; 796 return OK;
783 } else if (result == ERR_HTTP_1_1_REQUIRED || 797 } else if (result == ERR_HTTP_1_1_REQUIRED ||
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 default: 1666 default:
1653 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, 1667 description = base::StringPrintf("Unknown state 0x%08X (%u)", state,
1654 state); 1668 state);
1655 break; 1669 break;
1656 } 1670 }
1657 return description; 1671 return description;
1658 } 1672 }
1659 1673
1660 #undef STATE_CASE 1674 #undef STATE_CASE
1661 1675
1676 void HttpNetworkTransaction::CopyConnectionAttemptsFromStreamRequest() {
1677 DCHECK(stream_request_);
1678
1679 // Since the transaction can restart with auth credentials, it may create a
1680 // stream more than once. Accumulate all of the connection attempts across
1681 // those streams by appending them to the vector:
1682 for (const auto& attempt : stream_request_->connection_attempts())
1683 connection_attempts_.push_back(attempt);
1684 }
1685
1662 } // namespace net 1686 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.h ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698