Chromium Code Reviews| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 framer_(supported_versions, /*unused*/ QuicTime::Zero(), true), | 170 framer_(supported_versions, /*unused*/ QuicTime::Zero(), true), |
| 171 framer_visitor_(new QuicFramerVisitor(this)) { | 171 framer_visitor_(new QuicFramerVisitor(this)) { |
| 172 framer_.set_visitor(framer_visitor_.get()); | 172 framer_.set_visitor(framer_visitor_.get()); |
| 173 } | 173 } |
| 174 | 174 |
| 175 QuicDispatcher::~QuicDispatcher() { | 175 QuicDispatcher::~QuicDispatcher() { |
| 176 STLDeleteValues(&session_map_); | 176 STLDeleteValues(&session_map_); |
| 177 STLDeleteElements(&closed_session_list_); | 177 STLDeleteElements(&closed_session_list_); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void QuicDispatcher::Initialize(QuicPacketWriter* writer) { | 180 void QuicDispatcher::Initialize(QuicServerPacketWriter* writer) { |
| 181 DCHECK(writer_ == NULL); | 181 DCHECK(writer_ == NULL); |
| 182 writer_.reset(writer); | 182 writer_.reset(writer); |
| 183 time_wait_list_manager_.reset(CreateQuicTimeWaitListManager()); | 183 time_wait_list_manager_.reset(CreateQuicTimeWaitListManager()); |
| 184 | 184 |
| 185 // Remove all versions > QUIC_VERSION_16 from the | 185 // Remove all versions > QUIC_VERSION_16 from the |
| 186 // supported_versions_no_flow_control_ vector. | 186 // supported_versions_no_flow_control_ vector. |
| 187 QuicVersionVector::iterator it = | 187 QuicVersionVector::iterator it = |
| 188 find(supported_versions_no_flow_control_.begin(), | 188 find(supported_versions_no_flow_control_.begin(), |
| 189 supported_versions_no_flow_control_.end(), QUIC_VERSION_17); | 189 supported_versions_no_flow_control_.end(), QUIC_VERSION_17); |
| 190 if (it != supported_versions_no_flow_control_.end()) { | 190 if (it != supported_versions_no_flow_control_.end()) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 | 359 |
| 360 void QuicDispatcher::OnWriteBlocked(QuicBlockedWriterInterface* writer) { | 360 void QuicDispatcher::OnWriteBlocked(QuicBlockedWriterInterface* writer) { |
| 361 DCHECK(writer_->IsWriteBlocked()); | 361 DCHECK(writer_->IsWriteBlocked()); |
| 362 write_blocked_list_.insert(make_pair(writer, true)); | 362 write_blocked_list_.insert(make_pair(writer, true)); |
| 363 } | 363 } |
| 364 | 364 |
| 365 QuicSession* QuicDispatcher::CreateQuicSession( | 365 QuicSession* QuicDispatcher::CreateQuicSession( |
| 366 QuicConnectionId connection_id, | 366 QuicConnectionId connection_id, |
| 367 const IPEndPoint& server_address, | 367 const IPEndPoint& server_address, |
| 368 const IPEndPoint& client_address) { | 368 const IPEndPoint& client_address) { |
| 369 QuicPerConnectionPacketWriter* connection_packet_writer = | |
|
wtc
2014/06/23 23:12:15
Nit: rename this variable "per_connection_packet_w
dmziegler
2014/06/24 00:08:52
Done.
| |
| 370 new QuicPerConnectionPacketWriter(writer_.get()); | |
| 371 QuicConnection* connection = | |
| 372 CreateQuicConnection(connection_id, | |
| 373 server_address, | |
| 374 client_address, | |
| 375 connection_packet_writer); | |
| 376 connection_packet_writer->set_connection(connection); | |
|
wtc
2014/06/23 23:12:15
1. Nit: the two-way links between |connection| and
dmziegler
2014/06/24 00:08:52
The connection needs to write on the writer, and t
| |
| 369 QuicServerSession* session = new QuicServerSession( | 377 QuicServerSession* session = new QuicServerSession( |
| 370 config_, | 378 config_, |
| 371 CreateQuicConnection(connection_id, server_address, client_address), | 379 connection, |
| 380 connection_packet_writer, | |
| 372 this); | 381 this); |
| 373 session->InitializeSession(crypto_config_); | 382 session->InitializeSession(crypto_config_); |
| 374 return session; | 383 return session; |
| 375 } | 384 } |
| 376 | 385 |
| 377 QuicConnection* QuicDispatcher::CreateQuicConnection( | 386 QuicConnection* QuicDispatcher::CreateQuicConnection( |
| 378 QuicConnectionId connection_id, | 387 QuicConnectionId connection_id, |
| 379 const IPEndPoint& server_address, | 388 const IPEndPoint& server_address, |
| 380 const IPEndPoint& client_address) { | 389 const IPEndPoint& client_address, |
| 390 QuicPerConnectionPacketWriter* writer) { | |
| 381 if (FLAGS_enable_quic_stream_flow_control_2 && | 391 if (FLAGS_enable_quic_stream_flow_control_2 && |
| 382 FLAGS_enable_quic_connection_flow_control_2) { | 392 FLAGS_enable_quic_connection_flow_control_2) { |
| 383 DVLOG(1) << "Creating QuicDispatcher with all versions."; | 393 DVLOG(1) << "Creating QuicDispatcher with all versions."; |
| 384 return new QuicConnection(connection_id, client_address, helper_, | 394 return new QuicConnection(connection_id, client_address, helper_, |
| 385 writer_.get(), true, supported_versions_); | 395 writer, true, supported_versions_); |
| 386 } | 396 } |
| 387 | 397 |
| 388 if (FLAGS_enable_quic_stream_flow_control_2 && | 398 if (FLAGS_enable_quic_stream_flow_control_2 && |
| 389 !FLAGS_enable_quic_connection_flow_control_2) { | 399 !FLAGS_enable_quic_connection_flow_control_2) { |
| 390 DVLOG(1) << "Connection flow control disabled, creating QuicDispatcher " | 400 DVLOG(1) << "Connection flow control disabled, creating QuicDispatcher " |
| 391 << "WITHOUT version 19 or higher."; | 401 << "WITHOUT version 19 or higher."; |
| 392 return new QuicConnection(connection_id, client_address, helper_, | 402 return new QuicConnection(connection_id, client_address, helper_, |
| 393 writer_.get(), true, | 403 writer, true, |
| 394 supported_versions_no_connection_flow_control_); | 404 supported_versions_no_connection_flow_control_); |
| 395 } | 405 } |
| 396 | 406 |
| 397 DVLOG(1) << "Flow control disabled, creating QuicDispatcher WITHOUT " | 407 DVLOG(1) << "Flow control disabled, creating QuicDispatcher WITHOUT " |
| 398 << "version 17 or higher."; | 408 << "version 17 or higher."; |
| 399 return new QuicConnection(connection_id, client_address, helper_, | 409 return new QuicConnection(connection_id, client_address, helper_, |
| 400 writer_.get(), true, | 410 writer, true, |
| 401 supported_versions_no_flow_control_); | 411 supported_versions_no_flow_control_); |
| 402 } | 412 } |
| 403 | 413 |
| 404 QuicTimeWaitListManager* QuicDispatcher::CreateQuicTimeWaitListManager() { | 414 QuicTimeWaitListManager* QuicDispatcher::CreateQuicTimeWaitListManager() { |
| 405 return new QuicTimeWaitListManager( | 415 return new QuicTimeWaitListManager( |
| 406 writer_.get(), this, helper_, supported_versions()); | 416 writer_.get(), this, helper_, supported_versions()); |
| 407 } | 417 } |
| 408 | 418 |
| 409 bool QuicDispatcher::HandlePacketForTimeWait( | 419 bool QuicDispatcher::HandlePacketForTimeWait( |
| 410 const QuicPacketPublicHeader& header) { | 420 const QuicPacketPublicHeader& header) { |
| 411 if (header.reset_flag) { | 421 if (header.reset_flag) { |
| 412 // Public reset packets do not have sequence numbers, so ignore the packet. | 422 // Public reset packets do not have sequence numbers, so ignore the packet. |
| 413 return false; | 423 return false; |
| 414 } | 424 } |
| 415 | 425 |
| 416 // Switch the framer to the correct version, so that the sequence number can | 426 // Switch the framer to the correct version, so that the sequence number can |
| 417 // be parsed correctly. | 427 // be parsed correctly. |
| 418 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( | 428 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( |
| 419 header.connection_id)); | 429 header.connection_id)); |
| 420 | 430 |
| 421 // Continue parsing the packet to extract the sequence number. Then | 431 // Continue parsing the packet to extract the sequence number. Then |
| 422 // send it to the time wait manager in OnUnathenticatedHeader. | 432 // send it to the time wait manager in OnUnathenticatedHeader. |
| 423 return true; | 433 return true; |
| 424 } | 434 } |
| 425 | 435 |
| 426 } // namespace net | 436 } // namespace net |
| OLD | NEW |