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

Side by Side Diff: net/quic/chromium/quic_http_stream.cc

Issue 2461683002: Slice enum HttpResponseInfo::ConnectionInfo by QUIC version. (Closed)
Patch Set: Update recently introduced CONNECTION_INFO_QUIC occurrences. Created 4 years, 1 month 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/quic/chromium/quic_http_stream.h" 5 #include "net/quic/chromium/quic_http_stream.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 28 matching lines...) Expand all
39 dict->SetString("url", url->spec()); 39 dict->SetString("url", url->spec());
40 return std::move(dict); 40 return std::move(dict);
41 } 41 }
42 42
43 } // namespace 43 } // namespace
44 44
45 QuicHttpStream::QuicHttpStream( 45 QuicHttpStream::QuicHttpStream(
46 const base::WeakPtr<QuicChromiumClientSession>& session) 46 const base::WeakPtr<QuicChromiumClientSession>& session)
47 : next_state_(STATE_NONE), 47 : next_state_(STATE_NONE),
48 session_(session), 48 session_(session),
49 quic_version_(session->GetQuicVersion()),
49 session_error_(OK), 50 session_error_(OK),
50 was_handshake_confirmed_(session->IsCryptoHandshakeConfirmed()), 51 was_handshake_confirmed_(session->IsCryptoHandshakeConfirmed()),
51 stream_(nullptr), 52 stream_(nullptr),
52 request_info_(nullptr), 53 request_info_(nullptr),
53 request_body_stream_(nullptr), 54 request_body_stream_(nullptr),
54 priority_(MINIMUM_PRIORITY), 55 priority_(MINIMUM_PRIORITY),
55 response_info_(nullptr), 56 response_info_(nullptr),
56 response_status_(OK), 57 response_status_(OK),
57 response_headers_received_(false), 58 response_headers_received_(false),
58 headers_bytes_received_(0), 59 headers_bytes_received_(0),
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 121
121 DCHECK_EQ(STATE_HANDLE_PROMISE_COMPLETE, next_state_); 122 DCHECK_EQ(STATE_HANDLE_PROMISE_COMPLETE, next_state_);
122 if (!stream) { 123 if (!stream) {
123 // rendezvous has failed so proceed as with a non-push request. 124 // rendezvous has failed so proceed as with a non-push request.
124 next_state_ = STATE_REQUEST_STREAM; 125 next_state_ = STATE_REQUEST_STREAM;
125 } 126 }
126 127
127 OnIOComplete(OK); 128 OnIOComplete(OK);
128 } 129 }
129 130
131 HttpResponseInfo::ConnectionInfo QuicHttpStream::ConnectionInfoFromQuicVersion(
132 QuicVersion quic_version) {
133 switch (quic_version) {
134 case QUIC_VERSION_UNSUPPORTED:
135 return HttpResponseInfo::CONNECTION_INFO_QUIC_UNKNOWN_VERSION;
136 case QUIC_VERSION_32:
137 return HttpResponseInfo::CONNECTION_INFO_QUIC_32;
138 case QUIC_VERSION_33:
139 return HttpResponseInfo::CONNECTION_INFO_QUIC_33;
140 case QUIC_VERSION_34:
141 return HttpResponseInfo::CONNECTION_INFO_QUIC_34;
142 case QUIC_VERSION_35:
143 return HttpResponseInfo::CONNECTION_INFO_QUIC_35;
144 case QUIC_VERSION_36:
145 return HttpResponseInfo::CONNECTION_INFO_QUIC_36;
146 }
147 NOTREACHED();
148 return HttpResponseInfo::CONNECTION_INFO_QUIC_UNKNOWN_VERSION;
149 }
150
130 int QuicHttpStream::InitializeStream(const HttpRequestInfo* request_info, 151 int QuicHttpStream::InitializeStream(const HttpRequestInfo* request_info,
131 RequestPriority priority, 152 RequestPriority priority,
132 const NetLogWithSource& stream_net_log, 153 const NetLogWithSource& stream_net_log,
133 const CompletionCallback& callback) { 154 const CompletionCallback& callback) {
134 CHECK(callback_.is_null()); 155 CHECK(callback_.is_null());
135 DCHECK(!stream_); 156 DCHECK(!stream_);
136 if (!session_) 157 if (!session_)
137 return was_handshake_confirmed_ ? ERR_CONNECTION_CLOSED 158 return was_handshake_confirmed_ ? ERR_CONNECTION_CLOSED
138 : ERR_QUIC_HANDSHAKE_FAILED; 159 : ERR_QUIC_HANDSHAKE_FAILED;
139 160
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 return session_->GetTokenBindingSignature(key, tb_type, out); 444 return session_->GetTokenBindingSignature(key, tb_type, out);
424 } 445 }
425 446
426 void QuicHttpStream::Drain(HttpNetworkSession* session) { 447 void QuicHttpStream::Drain(HttpNetworkSession* session) {
427 NOTREACHED(); 448 NOTREACHED();
428 Close(false); 449 Close(false);
429 delete this; 450 delete this;
430 } 451 }
431 452
432 void QuicHttpStream::PopulateNetErrorDetails(NetErrorDetails* details) { 453 void QuicHttpStream::PopulateNetErrorDetails(NetErrorDetails* details) {
433 details->connection_info = HttpResponseInfo::CONNECTION_INFO_QUIC; 454 details->connection_info = ConnectionInfoFromQuicVersion(quic_version_);
434 if (was_handshake_confirmed_) 455 if (was_handshake_confirmed_)
435 details->quic_connection_error = quic_connection_error_; 456 details->quic_connection_error = quic_connection_error_;
436 if (session_) { 457 if (session_) {
437 session_->PopulateNetErrorDetails(details); 458 session_->PopulateNetErrorDetails(details);
438 } else { 459 } else {
439 details->quic_port_migration_detected = port_migration_detected_; 460 details->quic_port_migration_detected = port_migration_detected_;
440 } 461 }
441 } 462 }
442 463
443 void QuicHttpStream::SetPriority(RequestPriority priority) { 464 void QuicHttpStream::SetPriority(RequestPriority priority) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 was_handshake_confirmed_ = true; 545 was_handshake_confirmed_ = true;
525 if (next_state_ == STATE_WAIT_FOR_CONFIRMATION_COMPLETE) { 546 if (next_state_ == STATE_WAIT_FOR_CONFIRMATION_COMPLETE) {
526 int rv = DoLoop(OK); 547 int rv = DoLoop(OK);
527 548
528 if (rv != ERR_IO_PENDING && !callback_.is_null()) { 549 if (rv != ERR_IO_PENDING && !callback_.is_null()) {
529 DoCallback(rv); 550 DoCallback(rv);
530 } 551 }
531 } 552 }
532 } 553 }
533 554
555 void QuicHttpStream::OnSuccessfulVersionNegotiation(
556 const QuicVersion& version) {
557 quic_version_ = version;
558 }
559
534 void QuicHttpStream::OnSessionClosed(int error, bool port_migration_detected) { 560 void QuicHttpStream::OnSessionClosed(int error, bool port_migration_detected) {
535 Close(false); 561 Close(false);
536 session_error_ = error; 562 session_error_ = error;
537 port_migration_detected_ = port_migration_detected; 563 port_migration_detected_ = port_migration_detected;
538 session_.reset(); 564 session_.reset();
539 } 565 }
540 566
541 void QuicHttpStream::OnIOComplete(int rv) { 567 void QuicHttpStream::OnIOComplete(int rv) {
542 rv = DoLoop(rv); 568 rv = DoLoop(rv);
543 569
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 } 807 }
782 808
783 int QuicHttpStream::ProcessResponseHeaders(const SpdyHeaderBlock& headers) { 809 int QuicHttpStream::ProcessResponseHeaders(const SpdyHeaderBlock& headers) {
784 if (!SpdyHeadersToHttpResponse(headers, response_info_)) { 810 if (!SpdyHeadersToHttpResponse(headers, response_info_)) {
785 DLOG(WARNING) << "Invalid headers"; 811 DLOG(WARNING) << "Invalid headers";
786 return ERR_QUIC_PROTOCOL_ERROR; 812 return ERR_QUIC_PROTOCOL_ERROR;
787 } 813 }
788 // Put the peer's IP address and port into the response. 814 // Put the peer's IP address and port into the response.
789 IPEndPoint address = session_->peer_address(); 815 IPEndPoint address = session_->peer_address();
790 response_info_->socket_address = HostPortPair::FromIPEndPoint(address); 816 response_info_->socket_address = HostPortPair::FromIPEndPoint(address);
791 response_info_->connection_info = HttpResponseInfo::CONNECTION_INFO_QUIC; 817 response_info_->connection_info =
818 ConnectionInfoFromQuicVersion(quic_version_);
792 response_info_->vary_data.Init(*request_info_, 819 response_info_->vary_data.Init(*request_info_,
793 *response_info_->headers.get()); 820 *response_info_->headers.get());
794 response_info_->was_alpn_negotiated = true; 821 response_info_->was_alpn_negotiated = true;
795 response_info_->alpn_negotiated_protocol = "quic/1+spdy/3"; 822 response_info_->alpn_negotiated_protocol =
823 HttpResponseInfo::ConnectionInfoToString(response_info_->connection_info);
796 response_info_->response_time = base::Time::Now(); 824 response_info_->response_time = base::Time::Now();
797 response_info_->request_time = request_time_; 825 response_info_->request_time = request_time_;
798 response_headers_received_ = true; 826 response_headers_received_ = true;
799 827
800 // Populate |connect_timing_| when response headers are received. This should 828 // Populate |connect_timing_| when response headers are received. This should
801 // take care of 0-RTT where request is sent before handshake is confirmed. 829 // take care of 0-RTT where request is sent before handshake is confirmed.
802 connect_timing_ = session_->GetConnectTiming(); 830 connect_timing_ = session_->GetConnectTiming();
803 return OK; 831 return OK;
804 } 832 }
805 833
(...skipping 26 matching lines...) Expand all
832 closed_is_first_stream_ = stream_->IsFirstStream(); 860 closed_is_first_stream_ = stream_->IsFirstStream();
833 stream_ = nullptr; 861 stream_ = nullptr;
834 862
835 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress 863 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress
836 // read. 864 // read.
837 if (request_body_stream_) 865 if (request_body_stream_)
838 request_body_stream_->Reset(); 866 request_body_stream_->Reset();
839 } 867 }
840 868
841 } // namespace net 869 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_http_stream.h ('k') | net/quic/chromium/quic_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698