| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_dispatcher.h" | 5 #include "net/quic/quic_dispatcher.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 | 8 |
| 9 #include "base/debug/stack_trace.h" | 9 #include "base/debug/stack_trace.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 QuicDispatcher::QuicDispatcher(const QuicConfig& config, | 157 QuicDispatcher::QuicDispatcher(const QuicConfig& config, |
| 158 const QuicCryptoServerConfig& crypto_config, | 158 const QuicCryptoServerConfig& crypto_config, |
| 159 const QuicVersionVector& supported_versions, | 159 const QuicVersionVector& supported_versions, |
| 160 QuicConnectionHelperInterface* helper) | 160 QuicConnectionHelperInterface* helper) |
| 161 : config_(config), | 161 : config_(config), |
| 162 crypto_config_(crypto_config), | 162 crypto_config_(crypto_config), |
| 163 helper_(helper), | 163 helper_(helper), |
| 164 delete_sessions_alarm_( | 164 delete_sessions_alarm_( |
| 165 helper_->CreateAlarm(new DeleteSessionsAlarm(this))), | 165 helper_->CreateAlarm(new DeleteSessionsAlarm(this))), |
| 166 supported_versions_(supported_versions), | 166 supported_versions_(supported_versions), |
| 167 supported_versions_no_flow_control_(supported_versions), | |
| 168 supported_versions_no_connection_flow_control_(supported_versions), | 167 supported_versions_no_connection_flow_control_(supported_versions), |
| 169 current_packet_(NULL), | 168 current_packet_(NULL), |
| 170 framer_(supported_versions, /*unused*/ QuicTime::Zero(), true), | 169 framer_(supported_versions, /*unused*/ QuicTime::Zero(), true), |
| 171 framer_visitor_(new QuicFramerVisitor(this)) { | 170 framer_visitor_(new QuicFramerVisitor(this)) { |
| 172 framer_.set_visitor(framer_visitor_.get()); | 171 framer_.set_visitor(framer_visitor_.get()); |
| 173 } | 172 } |
| 174 | 173 |
| 175 QuicDispatcher::~QuicDispatcher() { | 174 QuicDispatcher::~QuicDispatcher() { |
| 176 STLDeleteValues(&session_map_); | 175 STLDeleteValues(&session_map_); |
| 177 STLDeleteElements(&closed_session_list_); | 176 STLDeleteElements(&closed_session_list_); |
| 178 } | 177 } |
| 179 | 178 |
| 180 void QuicDispatcher::Initialize(QuicPacketWriter* writer) { | 179 void QuicDispatcher::Initialize(QuicPacketWriter* writer) { |
| 181 DCHECK(writer_ == NULL); | 180 DCHECK(writer_ == NULL); |
| 182 writer_.reset(writer); | 181 writer_.reset(writer); |
| 183 time_wait_list_manager_.reset(CreateQuicTimeWaitListManager()); | 182 time_wait_list_manager_.reset(CreateQuicTimeWaitListManager()); |
| 184 | 183 |
| 185 // Remove all versions > QUIC_VERSION_16 from the | |
| 186 // supported_versions_no_flow_control_ vector. | |
| 187 QuicVersionVector::iterator it = | |
| 188 find(supported_versions_no_flow_control_.begin(), | |
| 189 supported_versions_no_flow_control_.end(), QUIC_VERSION_17); | |
| 190 if (it != supported_versions_no_flow_control_.end()) { | |
| 191 supported_versions_no_flow_control_.erase( | |
| 192 supported_versions_no_flow_control_.begin(), it + 1); | |
| 193 } | |
| 194 CHECK(!supported_versions_no_flow_control_.empty()); | |
| 195 | |
| 196 // Remove all versions > QUIC_VERSION_18 from the | 184 // Remove all versions > QUIC_VERSION_18 from the |
| 197 // supported_versions_no_connection_flow_control_ vector. | 185 // supported_versions_no_connection_flow_control_ vector. |
| 198 QuicVersionVector::iterator connection_it = | 186 QuicVersionVector::iterator connection_it = |
| 199 find(supported_versions_no_connection_flow_control_.begin(), | 187 find(supported_versions_no_connection_flow_control_.begin(), |
| 200 supported_versions_no_connection_flow_control_.end(), | 188 supported_versions_no_connection_flow_control_.end(), |
| 201 QUIC_VERSION_19); | 189 QUIC_VERSION_19); |
| 202 if (connection_it != supported_versions_no_connection_flow_control_.end()) { | 190 if (connection_it != supported_versions_no_connection_flow_control_.end()) { |
| 203 supported_versions_no_connection_flow_control_.erase( | 191 supported_versions_no_connection_flow_control_.erase( |
| 204 supported_versions_no_connection_flow_control_.begin(), | 192 supported_versions_no_connection_flow_control_.begin(), |
| 205 connection_it + 1); | 193 connection_it + 1); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 CreateQuicConnection(connection_id, server_address, client_address), | 359 CreateQuicConnection(connection_id, server_address, client_address), |
| 372 this); | 360 this); |
| 373 session->InitializeSession(crypto_config_); | 361 session->InitializeSession(crypto_config_); |
| 374 return session; | 362 return session; |
| 375 } | 363 } |
| 376 | 364 |
| 377 QuicConnection* QuicDispatcher::CreateQuicConnection( | 365 QuicConnection* QuicDispatcher::CreateQuicConnection( |
| 378 QuicConnectionId connection_id, | 366 QuicConnectionId connection_id, |
| 379 const IPEndPoint& server_address, | 367 const IPEndPoint& server_address, |
| 380 const IPEndPoint& client_address) { | 368 const IPEndPoint& client_address) { |
| 381 if (FLAGS_enable_quic_stream_flow_control_2 && | 369 if (FLAGS_enable_quic_connection_flow_control_2) { |
| 382 FLAGS_enable_quic_connection_flow_control_2) { | |
| 383 DVLOG(1) << "Creating QuicDispatcher with all versions."; | 370 DVLOG(1) << "Creating QuicDispatcher with all versions."; |
| 384 return new QuicConnection(connection_id, client_address, helper_, | 371 return new QuicConnection(connection_id, client_address, helper_, |
| 385 writer_.get(), true, supported_versions_); | 372 writer_.get(), true, supported_versions_); |
| 386 } | 373 } |
| 387 | 374 |
| 388 if (FLAGS_enable_quic_stream_flow_control_2 && | 375 DVLOG(1) << "Connection flow control disabled, creating QuicDispatcher " |
| 389 !FLAGS_enable_quic_connection_flow_control_2) { | |
| 390 DVLOG(1) << "Connection flow control disabled, creating QuicDispatcher " | |
| 391 << "WITHOUT version 19 or higher."; | 376 << "WITHOUT version 19 or higher."; |
| 392 return new QuicConnection(connection_id, client_address, helper_, | |
| 393 writer_.get(), true, | |
| 394 supported_versions_no_connection_flow_control_); | |
| 395 } | |
| 396 | |
| 397 DVLOG(1) << "Flow control disabled, creating QuicDispatcher WITHOUT " | |
| 398 << "version 17 or higher."; | |
| 399 return new QuicConnection(connection_id, client_address, helper_, | 377 return new QuicConnection(connection_id, client_address, helper_, |
| 400 writer_.get(), true, | 378 writer_.get(), true, |
| 401 supported_versions_no_flow_control_); | 379 supported_versions_no_connection_flow_control_); |
| 402 } | 380 } |
| 403 | 381 |
| 404 QuicTimeWaitListManager* QuicDispatcher::CreateQuicTimeWaitListManager() { | 382 QuicTimeWaitListManager* QuicDispatcher::CreateQuicTimeWaitListManager() { |
| 405 return new QuicTimeWaitListManager( | 383 return new QuicTimeWaitListManager( |
| 406 writer_.get(), this, helper_, supported_versions()); | 384 writer_.get(), this, helper_, supported_versions()); |
| 407 } | 385 } |
| 408 | 386 |
| 409 bool QuicDispatcher::HandlePacketForTimeWait( | 387 bool QuicDispatcher::HandlePacketForTimeWait( |
| 410 const QuicPacketPublicHeader& header) { | 388 const QuicPacketPublicHeader& header) { |
| 411 if (header.reset_flag) { | 389 if (header.reset_flag) { |
| 412 // Public reset packets do not have sequence numbers, so ignore the packet. | 390 // Public reset packets do not have sequence numbers, so ignore the packet. |
| 413 return false; | 391 return false; |
| 414 } | 392 } |
| 415 | 393 |
| 416 // Switch the framer to the correct version, so that the sequence number can | 394 // Switch the framer to the correct version, so that the sequence number can |
| 417 // be parsed correctly. | 395 // be parsed correctly. |
| 418 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( | 396 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( |
| 419 header.connection_id)); | 397 header.connection_id)); |
| 420 | 398 |
| 421 // Continue parsing the packet to extract the sequence number. Then | 399 // Continue parsing the packet to extract the sequence number. Then |
| 422 // send it to the time wait manager in OnUnathenticatedHeader. | 400 // send it to the time wait manager in OnUnathenticatedHeader. |
| 423 return true; | 401 return true; |
| 424 } | 402 } |
| 425 | 403 |
| 426 } // namespace net | 404 } // namespace net |
| OLD | NEW |