| OLD | NEW |
| 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/tools/quic/quic_dispatcher.h" | 5 #include "net/tools/quic/quic_dispatcher.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 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 26 matching lines...) Expand all Loading... |
| 37 QuicDispatcher* dispatcher_; | 37 QuicDispatcher* dispatcher_; |
| 38 | 38 |
| 39 DISALLOW_COPY_AND_ASSIGN(DeleteSessionsAlarm); | 39 DISALLOW_COPY_AND_ASSIGN(DeleteSessionsAlarm); |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 QuicDispatcher::QuicDispatcher(const QuicConfig& config, | 44 QuicDispatcher::QuicDispatcher(const QuicConfig& config, |
| 45 const QuicCryptoServerConfig* crypto_config, | 45 const QuicCryptoServerConfig* crypto_config, |
| 46 const QuicVersionVector& supported_versions, | 46 const QuicVersionVector& supported_versions, |
| 47 QuicConnectionHelperInterface* helper) | 47 QuicConnectionHelperInterface* helper, |
| 48 QuicAlarmFactory* alarm_factory) |
| 48 : config_(config), | 49 : config_(config), |
| 49 crypto_config_(crypto_config), | 50 crypto_config_(crypto_config), |
| 50 compressed_certs_cache_( | 51 compressed_certs_cache_( |
| 51 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize), | 52 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize), |
| 52 helper_(helper), | 53 helper_(helper), |
| 54 alarm_factory_(alarm_factory), |
| 53 delete_sessions_alarm_( | 55 delete_sessions_alarm_( |
| 54 helper_->CreateAlarm(new DeleteSessionsAlarm(this))), | 56 alarm_factory_->CreateAlarm(new DeleteSessionsAlarm(this))), |
| 55 supported_versions_(supported_versions), | 57 supported_versions_(supported_versions), |
| 56 current_packet_(nullptr), | 58 current_packet_(nullptr), |
| 57 framer_(supported_versions, | 59 framer_(supported_versions, |
| 58 /*unused*/ QuicTime::Zero(), | 60 /*unused*/ QuicTime::Zero(), |
| 59 Perspective::IS_SERVER), | 61 Perspective::IS_SERVER), |
| 60 last_error_(QUIC_NO_ERROR) { | 62 last_error_(QUIC_NO_ERROR) { |
| 61 framer_.set_visitor(this); | 63 framer_.set_visitor(this); |
| 62 } | 64 } |
| 63 | 65 |
| 64 QuicDispatcher::~QuicDispatcher() { | 66 QuicDispatcher::~QuicDispatcher() { |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 | 444 |
| 443 void QuicDispatcher::OnPacketComplete() { | 445 void QuicDispatcher::OnPacketComplete() { |
| 444 DCHECK(false); | 446 DCHECK(false); |
| 445 } | 447 } |
| 446 | 448 |
| 447 QuicServerSessionBase* QuicDispatcher::CreateQuicSession( | 449 QuicServerSessionBase* QuicDispatcher::CreateQuicSession( |
| 448 QuicConnectionId connection_id, | 450 QuicConnectionId connection_id, |
| 449 const IPEndPoint& client_address) { | 451 const IPEndPoint& client_address) { |
| 450 // The QuicServerSessionBase takes ownership of |connection| below. | 452 // The QuicServerSessionBase takes ownership of |connection| below. |
| 451 QuicConnection* connection = new QuicConnection( | 453 QuicConnection* connection = new QuicConnection( |
| 452 connection_id, client_address, helper_.get(), CreatePerConnectionWriter(), | 454 connection_id, client_address, helper_.get(), alarm_factory_.get(), |
| 455 CreatePerConnectionWriter(), |
| 453 /* owns_writer= */ true, Perspective::IS_SERVER, supported_versions_); | 456 /* owns_writer= */ true, Perspective::IS_SERVER, supported_versions_); |
| 454 | 457 |
| 455 QuicServerSessionBase* session = new QuicSimpleServerSession( | 458 QuicServerSessionBase* session = new QuicSimpleServerSession( |
| 456 config_, connection, this, crypto_config_, &compressed_certs_cache_); | 459 config_, connection, this, crypto_config_, &compressed_certs_cache_); |
| 457 session->Initialize(); | 460 session->Initialize(); |
| 458 return session; | 461 return session; |
| 459 } | 462 } |
| 460 | 463 |
| 461 QuicTimeWaitListManager* QuicDispatcher::CreateQuicTimeWaitListManager() { | 464 QuicTimeWaitListManager* QuicDispatcher::CreateQuicTimeWaitListManager() { |
| 462 return new QuicTimeWaitListManager(writer_.get(), this, helper_.get()); | 465 return new QuicTimeWaitListManager(writer_.get(), this, helper_.get(), |
| 466 alarm_factory_.get()); |
| 463 } | 467 } |
| 464 | 468 |
| 465 bool QuicDispatcher::HandlePacketForTimeWait( | 469 bool QuicDispatcher::HandlePacketForTimeWait( |
| 466 const QuicPacketPublicHeader& header) { | 470 const QuicPacketPublicHeader& header) { |
| 467 if (header.reset_flag) { | 471 if (header.reset_flag) { |
| 468 // Public reset packets do not have packet numbers, so ignore the packet. | 472 // Public reset packets do not have packet numbers, so ignore the packet. |
| 469 return false; | 473 return false; |
| 470 } | 474 } |
| 471 | 475 |
| 472 // Switch the framer to the correct version, so that the packet number can | 476 // Switch the framer to the correct version, so that the packet number can |
| 473 // be parsed correctly. | 477 // be parsed correctly. |
| 474 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( | 478 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( |
| 475 header.connection_id)); | 479 header.connection_id)); |
| 476 | 480 |
| 477 // Continue parsing the packet to extract the packet number. Then | 481 // Continue parsing the packet to extract the packet number. Then |
| 478 // send it to the time wait manager in OnUnathenticatedHeader. | 482 // send it to the time wait manager in OnUnathenticatedHeader. |
| 479 return true; | 483 return true; |
| 480 } | 484 } |
| 481 | 485 |
| 482 QuicPacketWriter* QuicDispatcher::CreatePerConnectionWriter() { | 486 QuicPacketWriter* QuicDispatcher::CreatePerConnectionWriter() { |
| 483 return new QuicPerConnectionPacketWriter(writer_.get()); | 487 return new QuicPerConnectionPacketWriter(writer_.get()); |
| 484 } | 488 } |
| 485 | 489 |
| 486 void QuicDispatcher::SetLastError(QuicErrorCode error) { | 490 void QuicDispatcher::SetLastError(QuicErrorCode error) { |
| 487 last_error_ = error; | 491 last_error_ = error; |
| 488 } | 492 } |
| 489 | 493 |
| 490 } // namespace net | 494 } // namespace net |
| OLD | NEW |