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

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: Add a few more tests 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
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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 OnIOComplete(ERR_SSL_CLIENT_AUTH_CERT_NEEDED); 563 OnIOComplete(ERR_SSL_CLIENT_AUTH_CERT_NEEDED);
564 } 564 }
565 565
566 void HttpNetworkTransaction::OnHttpsProxyTunnelResponse( 566 void HttpNetworkTransaction::OnHttpsProxyTunnelResponse(
567 const HttpResponseInfo& response_info, 567 const HttpResponseInfo& response_info,
568 const SSLConfig& used_ssl_config, 568 const SSLConfig& used_ssl_config,
569 const ProxyInfo& used_proxy_info, 569 const ProxyInfo& used_proxy_info,
570 HttpStream* stream) { 570 HttpStream* stream) {
571 DCHECK_EQ(STATE_CREATE_STREAM_COMPLETE, next_state_); 571 DCHECK_EQ(STATE_CREATE_STREAM_COMPLETE, next_state_);
572 572
573 CopyConnectionAttemptsFromStreamRequest();
574
573 headers_valid_ = true; 575 headers_valid_ = true;
574 response_ = response_info; 576 response_ = response_info;
575 server_ssl_config_ = used_ssl_config; 577 server_ssl_config_ = used_ssl_config;
576 proxy_info_ = used_proxy_info; 578 proxy_info_ = used_proxy_info;
577 if (stream_) 579 if (stream_)
578 total_received_bytes_ += stream_->GetTotalReceivedBytes(); 580 total_received_bytes_ += stream_->GetTotalReceivedBytes();
579 stream_.reset(stream); 581 stream_.reset(stream);
580 stream_request_.reset(); // we're done with the stream request 582 stream_request_.reset(); // we're done with the stream request
581 OnIOComplete(ERR_HTTPS_PROXY_TUNNEL_RESPONSE); 583 OnIOComplete(ERR_HTTPS_PROXY_TUNNEL_RESPONSE);
582 } 584 }
583 585
586 void HttpNetworkTransaction::GetConnectionAttempts(
587 ConnectionAttempts* out) const {
588 *out = connection_attempts_;
589 }
590
584 bool HttpNetworkTransaction::IsSecureRequest() const { 591 bool HttpNetworkTransaction::IsSecureRequest() const {
585 return request_->url.SchemeIsSecure(); 592 return request_->url.SchemeIsSecure();
586 } 593 }
587 594
588 bool HttpNetworkTransaction::UsingHttpProxyWithoutTunnel() const { 595 bool HttpNetworkTransaction::UsingHttpProxyWithoutTunnel() const {
589 return (proxy_info_.is_http() || proxy_info_.is_https() || 596 return (proxy_info_.is_http() || proxy_info_.is_https() ||
590 proxy_info_.is_quic()) && 597 proxy_info_.is_quic()) &&
591 !(request_->url.SchemeIs("https") || request_->url.SchemeIsWSOrWSS()); 598 !(request_->url.SchemeIs("https") || request_->url.SchemeIsWSOrWSS());
592 } 599 }
593 600
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 DCHECK(stream_request_.get()); 770 DCHECK(stream_request_.get());
764 return ERR_IO_PENDING; 771 return ERR_IO_PENDING;
765 } 772 }
766 773
767 int HttpNetworkTransaction::DoCreateStreamComplete(int result) { 774 int HttpNetworkTransaction::DoCreateStreamComplete(int result) {
768 // TODO(pkasting): Remove ScopedTracker below once crbug.com/424359 is fixed. 775 // TODO(pkasting): Remove ScopedTracker below once crbug.com/424359 is fixed.
769 tracked_objects::ScopedTracker tracking_profile( 776 tracked_objects::ScopedTracker tracking_profile(
770 FROM_HERE_WITH_EXPLICIT_FUNCTION( 777 FROM_HERE_WITH_EXPLICIT_FUNCTION(
771 "424359 HttpNetworkTransaction::DoCreateStreamComplete")); 778 "424359 HttpNetworkTransaction::DoCreateStreamComplete"));
772 779
780 // If |result| is ERR_HTTPS_PROXY_TUNNEL_RESPONSE, then
781 // DoCreateStreamComplete is being called from OnHttpsProxyTunnelResponse,
782 // which will have already copied connection attempts and reset the stream
783 // request, so don't try to do it again here.
Randy Smith (Not in Mondays) 2015/04/23 19:04:09 Also mention (here or in OnHttpsProxyTunnelRespons
Deprecated (see juliatuttle) 2015/04/23 21:04:16 Done.
784 if (result != ERR_HTTPS_PROXY_TUNNEL_RESPONSE)
785 CopyConnectionAttemptsFromStreamRequest();
786
773 if (result == OK) { 787 if (result == OK) {
774 next_state_ = STATE_INIT_STREAM; 788 next_state_ = STATE_INIT_STREAM;
775 DCHECK(stream_.get()); 789 DCHECK(stream_.get());
776 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { 790 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
777 result = HandleCertificateRequest(result); 791 result = HandleCertificateRequest(result);
778 } else if (result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { 792 } else if (result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) {
779 // Return OK and let the caller read the proxy's error page 793 // Return OK and let the caller read the proxy's error page
780 next_state_ = STATE_NONE; 794 next_state_ = STATE_NONE;
781 return OK; 795 return OK;
782 } else if (result == ERR_HTTP_1_1_REQUIRED || 796 } else if (result == ERR_HTTP_1_1_REQUIRED ||
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 default: 1665 default:
1652 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, 1666 description = base::StringPrintf("Unknown state 0x%08X (%u)", state,
1653 state); 1667 state);
1654 break; 1668 break;
1655 } 1669 }
1656 return description; 1670 return description;
1657 } 1671 }
1658 1672
1659 #undef STATE_CASE 1673 #undef STATE_CASE
1660 1674
1675 void HttpNetworkTransaction::CopyConnectionAttemptsFromStreamRequest() {
1676 DCHECK(stream_request_);
1677
1678 // Since the transaction can restart with auth credentials, it may create a
1679 // stream more than once. Accumulate all of the connection attempts across
1680 // those streams by appending them to the vector:
1681 for (const auto& attempt : stream_request_->connection_attempts())
1682 connection_attempts_.push_back(attempt);
1683 }
1684
1661 } // namespace net 1685 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698