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

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

Issue 330333006: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/quic/quic_session.h" 5 #include "net/quic/quic_session.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "net/quic/crypto/proof_verifier.h" 8 #include "net/quic/crypto/proof_verifier.h"
9 #include "net/quic/quic_connection.h" 9 #include "net/quic/quic_connection.h"
10 #include "net/quic/quic_flags.h" 10 #include "net/quic/quic_flags.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 virtual bool HasOpenDataStreams() const OVERRIDE { 90 virtual bool HasOpenDataStreams() const OVERRIDE {
91 return session_->HasOpenDataStreams(); 91 return session_->HasOpenDataStreams();
92 } 92 }
93 93
94 private: 94 private:
95 QuicSession* session_; 95 QuicSession* session_;
96 }; 96 };
97 97
98 QuicSession::QuicSession(QuicConnection* connection, 98 QuicSession::QuicSession(QuicConnection* connection,
99 uint32 max_flow_control_receive_window_bytes,
100 const QuicConfig& config) 99 const QuicConfig& config)
101 : connection_(connection), 100 : connection_(connection),
102 visitor_shim_(new VisitorShim(this)), 101 visitor_shim_(new VisitorShim(this)),
103 config_(config), 102 config_(config),
104 max_open_streams_(config_.max_streams_per_connection()), 103 max_open_streams_(config_.max_streams_per_connection()),
105 next_stream_id_(is_server() ? 2 : 3), 104 next_stream_id_(is_server() ? 2 : 3),
106 largest_peer_created_stream_id_(0), 105 largest_peer_created_stream_id_(0),
107 error_(QUIC_NO_ERROR), 106 error_(QUIC_NO_ERROR),
108 goaway_received_(false), 107 goaway_received_(false),
109 goaway_sent_(false), 108 goaway_sent_(false),
110 has_pending_handshake_(false), 109 has_pending_handshake_(false) {
111 max_flow_control_receive_window_bytes_(
112 max_flow_control_receive_window_bytes) {
113 if (max_flow_control_receive_window_bytes_ < kDefaultFlowControlSendWindow) {
114 LOG(ERROR) << "Initial receive window ("
115 << max_flow_control_receive_window_bytes_
116 << ") cannot be set lower than default ("
117 << kDefaultFlowControlSendWindow << ").";
118 max_flow_control_receive_window_bytes_ = kDefaultFlowControlSendWindow;
119 }
120 flow_controller_.reset(new QuicFlowController( 110 flow_controller_.reset(new QuicFlowController(
121 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, 111 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow,
122 max_flow_control_receive_window_bytes_, 112 config_.GetInitialFlowControlWindowToSend(),
123 max_flow_control_receive_window_bytes_)); 113 config_.GetInitialFlowControlWindowToSend()));
124 114
125 connection_->set_visitor(visitor_shim_.get()); 115 connection_->set_visitor(visitor_shim_.get());
126 connection_->SetFromConfig(config_); 116 connection_->SetFromConfig(config_);
127 if (connection_->connected()) { 117 if (connection_->connected()) {
128 connection_->SetOverallConnectionTimeout( 118 connection_->SetOverallConnectionTimeout(
129 config_.max_time_before_crypto_handshake()); 119 config_.max_time_before_crypto_handshake());
130 } 120 }
131 headers_stream_.reset(new QuicHeadersStream(this)); 121 headers_stream_.reset(new QuicHeadersStream(this));
132 if (!is_server()) { 122 if (!is_server()) {
133 // For version above QUIC v12, the headers stream is stream 3, so the 123 // For version above QUIC v12, the headers stream is stream 3, so the
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 return GetCryptoStream()->handshake_confirmed(); 460 return GetCryptoStream()->handshake_confirmed();
471 } 461 }
472 462
473 void QuicSession::OnConfigNegotiated() { 463 void QuicSession::OnConfigNegotiated() {
474 connection_->SetFromConfig(config_); 464 connection_->SetFromConfig(config_);
475 // Tell all streams about the newly received peer receive window. 465 // Tell all streams about the newly received peer receive window.
476 if (connection()->version() >= QUIC_VERSION_17 && 466 if (connection()->version() >= QUIC_VERSION_17 &&
477 config_.HasReceivedInitialFlowControlWindowBytes()) { 467 config_.HasReceivedInitialFlowControlWindowBytes()) {
478 // Streams which were created before the SHLO was received (0RTT requests) 468 // Streams which were created before the SHLO was received (0RTT requests)
479 // are now informed of the peer's initial flow control window. 469 // are now informed of the peer's initial flow control window.
480 uint32 new_flow_control_send_window = 470 uint32 new_window = config_.ReceivedInitialFlowControlWindowBytes();
481 config_.ReceivedInitialFlowControlWindowBytes(); 471 OnNewStreamFlowControlWindow(new_window);
482 if (new_flow_control_send_window < kDefaultFlowControlSendWindow) { 472 OnNewSessionFlowControlWindow(new_window);
483 LOG(ERROR)
484 << "Peer sent us an invalid flow control send window: "
485 << new_flow_control_send_window
486 << ", below default: " << kDefaultFlowControlSendWindow;
487 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW);
488 return;
489 }
490 DataStreamMap::iterator it = stream_map_.begin();
491 while (it != stream_map_.end()) {
492 it->second->flow_controller()->UpdateSendWindowOffset(
493 new_flow_control_send_window);
494 it++;
495 }
496
497 // Update connection level window.
498 flow_controller_->UpdateSendWindowOffset(new_flow_control_send_window);
499 } 473 }
500 } 474 }
501 475
476 void QuicSession::OnNewStreamFlowControlWindow(uint32 new_window) {
477 if (new_window < kDefaultFlowControlSendWindow) {
478 LOG(ERROR)
479 << "Peer sent us an invalid stream flow control send window: "
480 << new_window << ", below default: " << kDefaultFlowControlSendWindow;
481 if (connection_->connected()) {
482 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW);
483 }
484 return;
485 }
486
487 DataStreamMap::iterator it = stream_map_.begin();
488 while (it != stream_map_.end()) {
489 it->second->flow_controller()->UpdateSendWindowOffset(new_window);
490 it++;
wtc 2014/06/16 19:35:56 Nit: ++it is more efficient. You can also write t
ramant (doing other things) 2014/06/16 21:13:53 Done.
491 }
492 }
493
494 void QuicSession::OnNewSessionFlowControlWindow(uint32 new_window) {
495 if (new_window < kDefaultFlowControlSendWindow) {
496 LOG(ERROR)
497 << "Peer sent us an invalid session flow control send window: "
498 << new_window << ", below default: " << kDefaultFlowControlSendWindow;
499 if (connection_->connected()) {
500 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW);
501 }
502 return;
503 }
504
505 flow_controller_->UpdateSendWindowOffset(new_window);
506 }
507
502 void QuicSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { 508 void QuicSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) {
503 switch (event) { 509 switch (event) {
504 // TODO(satyamshekhar): Move the logic of setting the encrypter/decrypter 510 // TODO(satyamshekhar): Move the logic of setting the encrypter/decrypter
505 // to QuicSession since it is the glue. 511 // to QuicSession since it is the glue.
506 case ENCRYPTION_FIRST_ESTABLISHED: 512 case ENCRYPTION_FIRST_ESTABLISHED:
507 break; 513 break;
508 514
509 case ENCRYPTION_REESTABLISHED: 515 case ENCRYPTION_REESTABLISHED:
510 // Retransmit originally packets that were sent, since they can't be 516 // Retransmit originally packets that were sent, since they can't be
511 // decrypted by the peer. 517 // decrypted by the peer.
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 // with a different version. 716 // with a different version.
711 for (DataStreamMap::iterator it = stream_map_.begin(); 717 for (DataStreamMap::iterator it = stream_map_.begin();
712 it != stream_map_.end(); ++it) { 718 it != stream_map_.end(); ++it) {
713 if (version < QUIC_VERSION_17) { 719 if (version < QUIC_VERSION_17) {
714 it->second->flow_controller()->Disable(); 720 it->second->flow_controller()->Disable();
715 } 721 }
716 } 722 }
717 } 723 }
718 724
719 } // namespace net 725 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698