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