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

Side by Side Diff: net/quic/quic_client_session.cc

Issue 420313005: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0723
Patch Set: change QUIC packet size to 1350 Created 6 years, 4 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/quic/quic_client_session.h" 5 #include "net/quic/quic_client_session.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/sparse_histogram.h" 10 #include "base/metrics/sparse_histogram.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 require_confirmation_(false), 149 require_confirmation_(false),
150 stream_factory_(stream_factory), 150 stream_factory_(stream_factory),
151 socket_(socket.Pass()), 151 socket_(socket.Pass()),
152 writer_(writer.Pass()), 152 writer_(writer.Pass()),
153 read_buffer_(new IOBufferWithSize(kMaxPacketSize)), 153 read_buffer_(new IOBufferWithSize(kMaxPacketSize)),
154 server_info_(server_info.Pass()), 154 server_info_(server_info.Pass()),
155 read_pending_(false), 155 read_pending_(false),
156 num_total_streams_(0), 156 num_total_streams_(0),
157 task_runner_(task_runner), 157 task_runner_(task_runner),
158 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), 158 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)),
159 logger_(net_log_), 159 logger_(new QuicConnectionLogger(net_log_)),
160 num_packets_read_(0), 160 num_packets_read_(0),
161 going_away_(false), 161 going_away_(false),
162 weak_factory_(this) { 162 weak_factory_(this) {
163 crypto_stream_.reset( 163 crypto_stream_.reset(
164 crypto_client_stream_factory ? 164 crypto_client_stream_factory ?
165 crypto_client_stream_factory->CreateQuicCryptoClientStream( 165 crypto_client_stream_factory->CreateQuicCryptoClientStream(
166 server_id, this, crypto_config) : 166 server_id, this, crypto_config) :
167 new QuicCryptoClientStream(server_id, this, 167 new QuicCryptoClientStream(server_id, this,
168 new ProofVerifyContextChromium(net_log_), 168 new ProofVerifyContextChromium(net_log_),
169 crypto_config)); 169 crypto_config));
170 170
171 connection->set_debug_visitor(&logger_); 171 connection->set_debug_visitor(logger_);
172 // TODO(rch): pass in full host port proxy pair 172 // TODO(rch): pass in full host port proxy pair
173 net_log_.BeginEvent( 173 net_log_.BeginEvent(
174 NetLog::TYPE_QUIC_SESSION, 174 NetLog::TYPE_QUIC_SESSION,
175 NetLog::StringCallback("host", &server_id.host())); 175 NetLog::StringCallback("host", &server_id.host()));
176 } 176 }
177 177
178 QuicClientSession::~QuicClientSession() { 178 QuicClientSession::~QuicClientSession() {
179 if (!streams()->empty()) 179 if (!streams()->empty())
180 RecordUnexpectedOpenStreams(DESTRUCTOR); 180 RecordUnexpectedOpenStreams(DESTRUCTOR);
181 if (!observers_.empty()) 181 if (!observers_.empty())
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 514
515 QuicDataStream* QuicClientSession::CreateIncomingDataStream( 515 QuicDataStream* QuicClientSession::CreateIncomingDataStream(
516 QuicStreamId id) { 516 QuicStreamId id) {
517 DLOG(ERROR) << "Server push not supported"; 517 DLOG(ERROR) << "Server push not supported";
518 return NULL; 518 return NULL;
519 } 519 }
520 520
521 void QuicClientSession::CloseStream(QuicStreamId stream_id) { 521 void QuicClientSession::CloseStream(QuicStreamId stream_id) {
522 ReliableQuicStream* stream = GetStream(stream_id); 522 ReliableQuicStream* stream = GetStream(stream_id);
523 if (stream) { 523 if (stream) {
524 logger_.UpdateReceivedFrameCounts( 524 logger_->UpdateReceivedFrameCounts(
525 stream_id, stream->num_frames_received(), 525 stream_id, stream->num_frames_received(),
526 stream->num_duplicate_frames_received()); 526 stream->num_duplicate_frames_received());
527 } 527 }
528 QuicSession::CloseStream(stream_id); 528 QuicSession::CloseStream(stream_id);
529 OnClosedStream(); 529 OnClosedStream();
530 } 530 }
531 531
532 void QuicClientSession::SendRstStream(QuicStreamId id, 532 void QuicClientSession::SendRstStream(QuicStreamId id,
533 QuicRstStreamErrorCode error, 533 QuicRstStreamErrorCode error,
534 QuicStreamOffset bytes_written) { 534 QuicStreamOffset bytes_written) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 Observer* observer = *it; 570 Observer* observer = *it;
571 ++it; 571 ++it;
572 observer->OnCryptoHandshakeConfirmed(); 572 observer->OnCryptoHandshakeConfirmed();
573 } 573 }
574 } 574 }
575 QuicSession::OnCryptoHandshakeEvent(event); 575 QuicSession::OnCryptoHandshakeEvent(event);
576 } 576 }
577 577
578 void QuicClientSession::OnCryptoHandshakeMessageSent( 578 void QuicClientSession::OnCryptoHandshakeMessageSent(
579 const CryptoHandshakeMessage& message) { 579 const CryptoHandshakeMessage& message) {
580 logger_.OnCryptoHandshakeMessageSent(message); 580 logger_->OnCryptoHandshakeMessageSent(message);
581 } 581 }
582 582
583 void QuicClientSession::OnCryptoHandshakeMessageReceived( 583 void QuicClientSession::OnCryptoHandshakeMessageReceived(
584 const CryptoHandshakeMessage& message) { 584 const CryptoHandshakeMessage& message) {
585 logger_.OnCryptoHandshakeMessageReceived(message); 585 logger_->OnCryptoHandshakeMessageReceived(message);
586 } 586 }
587 587
588 void QuicClientSession::OnConnectionClosed(QuicErrorCode error, 588 void QuicClientSession::OnConnectionClosed(QuicErrorCode error,
589 bool from_peer) { 589 bool from_peer) {
590 DCHECK(!connection()->connected()); 590 DCHECK(!connection()->connected());
591 logger_.OnConnectionClosed(error, from_peer); 591 logger_->OnConnectionClosed(error, from_peer);
592 if (from_peer) { 592 if (from_peer) {
593 UMA_HISTOGRAM_SPARSE_SLOWLY( 593 UMA_HISTOGRAM_SPARSE_SLOWLY(
594 "Net.QuicSession.ConnectionCloseErrorCodeServer", error); 594 "Net.QuicSession.ConnectionCloseErrorCodeServer", error);
595 } else { 595 } else {
596 UMA_HISTOGRAM_SPARSE_SLOWLY( 596 UMA_HISTOGRAM_SPARSE_SLOWLY(
597 "Net.QuicSession.ConnectionCloseErrorCodeClient", error); 597 "Net.QuicSession.ConnectionCloseErrorCodeClient", error);
598 } 598 }
599 599
600 if (error == QUIC_CONNECTION_TIMED_OUT) { 600 if (error == QUIC_CONNECTION_TIMED_OUT) {
601 UMA_HISTOGRAM_COUNTS( 601 UMA_HISTOGRAM_COUNTS(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 socket_->Close(); 636 socket_->Close();
637 QuicSession::OnConnectionClosed(error, from_peer); 637 QuicSession::OnConnectionClosed(error, from_peer);
638 DCHECK(streams()->empty()); 638 DCHECK(streams()->empty());
639 CloseAllStreams(ERR_UNEXPECTED); 639 CloseAllStreams(ERR_UNEXPECTED);
640 CloseAllObservers(ERR_UNEXPECTED); 640 CloseAllObservers(ERR_UNEXPECTED);
641 NotifyFactoryOfSessionClosedLater(); 641 NotifyFactoryOfSessionClosedLater();
642 } 642 }
643 643
644 void QuicClientSession::OnSuccessfulVersionNegotiation( 644 void QuicClientSession::OnSuccessfulVersionNegotiation(
645 const QuicVersion& version) { 645 const QuicVersion& version) {
646 logger_.OnSuccessfulVersionNegotiation(version); 646 logger_->OnSuccessfulVersionNegotiation(version);
647 QuicSession::OnSuccessfulVersionNegotiation(version); 647 QuicSession::OnSuccessfulVersionNegotiation(version);
648 } 648 }
649 649
650 void QuicClientSession::OnProofValid( 650 void QuicClientSession::OnProofValid(
651 const QuicCryptoClientConfig::CachedState& cached) { 651 const QuicCryptoClientConfig::CachedState& cached) {
652 DCHECK(cached.proof_valid()); 652 DCHECK(cached.proof_valid());
653 653
654 if (!server_info_ || !server_info_->IsReadyToPersist()) { 654 if (!server_info_ || !server_info_->IsReadyToPersist()) {
655 return; 655 return;
656 } 656 }
657 657
658 QuicServerInfo::State* state = server_info_->mutable_state(); 658 QuicServerInfo::State* state = server_info_->mutable_state();
659 659
660 state->server_config = cached.server_config(); 660 state->server_config = cached.server_config();
661 state->source_address_token = cached.source_address_token(); 661 state->source_address_token = cached.source_address_token();
662 state->server_config_sig = cached.signature(); 662 state->server_config_sig = cached.signature();
663 state->certs = cached.certs(); 663 state->certs = cached.certs();
664 664
665 server_info_->Persist(); 665 server_info_->Persist();
666 } 666 }
667 667
668 void QuicClientSession::OnProofVerifyDetailsAvailable( 668 void QuicClientSession::OnProofVerifyDetailsAvailable(
669 const ProofVerifyDetails& verify_details) { 669 const ProofVerifyDetails& verify_details) {
670 const CertVerifyResult* cert_verify_result_other = 670 const CertVerifyResult* cert_verify_result_other =
671 &(reinterpret_cast<const ProofVerifyDetailsChromium*>( 671 &(reinterpret_cast<const ProofVerifyDetailsChromium*>(
672 &verify_details))->cert_verify_result; 672 &verify_details))->cert_verify_result;
673 CertVerifyResult* result_copy = new CertVerifyResult; 673 CertVerifyResult* result_copy = new CertVerifyResult;
674 result_copy->CopyFrom(*cert_verify_result_other); 674 result_copy->CopyFrom(*cert_verify_result_other);
675 cert_verify_result_.reset(result_copy); 675 cert_verify_result_.reset(result_copy);
676 logger_.OnCertificateVerified(*cert_verify_result_); 676 logger_->OnCertificateVerified(*cert_verify_result_);
677 } 677 }
678 678
679 void QuicClientSession::StartReading() { 679 void QuicClientSession::StartReading() {
680 if (read_pending_) { 680 if (read_pending_) {
681 return; 681 return;
682 } 682 }
683 read_pending_ = true; 683 read_pending_ = true;
684 int rv = socket_->Read(read_buffer_.get(), 684 int rv = socket_->Read(read_buffer_.get(),
685 read_buffer_->size(), 685 read_buffer_->size(),
686 base::Bind(&QuicClientSession::OnReadComplete, 686 base::Bind(&QuicClientSession::OnReadComplete,
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 return; 856 return;
857 857
858 // TODO(rch): re-enable this code once beta is cut. 858 // TODO(rch): re-enable this code once beta is cut.
859 // if (stream_factory_) 859 // if (stream_factory_)
860 // stream_factory_->OnSessionConnectTimeout(this); 860 // stream_factory_->OnSessionConnectTimeout(this);
861 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED); 861 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED);
862 // DCHECK_EQ(0u, GetNumOpenStreams()); 862 // DCHECK_EQ(0u, GetNumOpenStreams());
863 } 863 }
864 864
865 } // namespace net 865 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698