| 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/macros.h" | 9 #include "base/macros.h" |
| 10 #include "net/quic/core/crypto/quic_random.h" | 10 #include "net/quic/core/crypto/quic_random.h" |
| 11 #include "net/quic/core/quic_flags.h" | 11 #include "net/quic/core/quic_flags.h" |
| 12 #include "net/quic/core/quic_utils.h" | 12 #include "net/quic/core/quic_utils.h" |
| 13 #include "net/quic/platform/api/quic_bug_tracker.h" | 13 #include "net/quic/platform/api/quic_bug_tracker.h" |
| 14 #include "net/quic/platform/api/quic_flag_utils.h" |
| 14 #include "net/quic/platform/api/quic_logging.h" | 15 #include "net/quic/platform/api/quic_logging.h" |
| 15 #include "net/quic/platform/api/quic_ptr_util.h" | 16 #include "net/quic/platform/api/quic_ptr_util.h" |
| 16 #include "net/quic/platform/api/quic_stack_trace.h" | 17 #include "net/quic/platform/api/quic_stack_trace.h" |
| 17 #include "net/quic/platform/api/quic_string_piece.h" | 18 #include "net/quic/platform/api/quic_string_piece.h" |
| 18 #include "net/tools/quic/chlo_extractor.h" | 19 #include "net/tools/quic/chlo_extractor.h" |
| 19 #include "net/tools/quic/quic_per_connection_packet_writer.h" | 20 #include "net/tools/quic/quic_per_connection_packet_writer.h" |
| 20 #include "net/tools/quic/quic_simple_server_session.h" | 21 #include "net/tools/quic/quic_simple_server_session.h" |
| 21 #include "net/tools/quic/quic_time_wait_list_manager.h" | 22 #include "net/tools/quic/quic_time_wait_list_manager.h" |
| 22 #include "net/tools/quic/stateless_rejector.h" | 23 #include "net/tools/quic/stateless_rejector.h" |
| 23 | 24 |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 QuicTimeWaitListManager* QuicDispatcher::CreateQuicTimeWaitListManager() { | 688 QuicTimeWaitListManager* QuicDispatcher::CreateQuicTimeWaitListManager() { |
| 688 return new QuicTimeWaitListManager(writer_.get(), this, helper_.get(), | 689 return new QuicTimeWaitListManager(writer_.get(), this, helper_.get(), |
| 689 alarm_factory_.get()); | 690 alarm_factory_.get()); |
| 690 } | 691 } |
| 691 | 692 |
| 692 void QuicDispatcher::BufferEarlyPacket(QuicConnectionId connection_id) { | 693 void QuicDispatcher::BufferEarlyPacket(QuicConnectionId connection_id) { |
| 693 bool is_new_connection = !buffered_packets_.HasBufferedPackets(connection_id); | 694 bool is_new_connection = !buffered_packets_.HasBufferedPackets(connection_id); |
| 694 if (FLAGS_quic_reloadable_flag_quic_create_session_after_insertion && | 695 if (FLAGS_quic_reloadable_flag_quic_create_session_after_insertion && |
| 695 is_new_connection && | 696 is_new_connection && |
| 696 !ShouldCreateOrBufferPacketForConnection(connection_id)) { | 697 !ShouldCreateOrBufferPacketForConnection(connection_id)) { |
| 698 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_create_session_after_insertion, |
| 699 1, 5); |
| 697 return; | 700 return; |
| 698 } | 701 } |
| 699 EnqueuePacketResult rs = buffered_packets_.EnqueuePacket( | 702 EnqueuePacketResult rs = buffered_packets_.EnqueuePacket( |
| 700 connection_id, *current_packet_, current_server_address_, | 703 connection_id, *current_packet_, current_server_address_, |
| 701 current_client_address_, /*is_chlo=*/false); | 704 current_client_address_, /*is_chlo=*/false); |
| 702 if (rs != EnqueuePacketResult::SUCCESS) { | 705 if (rs != EnqueuePacketResult::SUCCESS) { |
| 703 OnBufferPacketFailure(rs, connection_id); | 706 OnBufferPacketFailure(rs, connection_id); |
| 704 } else if (!FLAGS_quic_reloadable_flag_quic_create_session_after_insertion && | 707 } else if (!FLAGS_quic_reloadable_flag_quic_create_session_after_insertion && |
| 705 is_new_connection) { | 708 is_new_connection) { |
| 706 ShouldCreateOrBufferPacketForConnection(connection_id); | 709 ShouldCreateOrBufferPacketForConnection(connection_id); |
| 707 } | 710 } |
| 708 } | 711 } |
| 709 | 712 |
| 710 void QuicDispatcher::ProcessChlo() { | 713 void QuicDispatcher::ProcessChlo() { |
| 711 if (FLAGS_quic_reloadable_flag_quic_create_session_after_insertion && | 714 if (FLAGS_quic_reloadable_flag_quic_create_session_after_insertion && |
| 712 !buffered_packets_.HasBufferedPackets(current_connection_id_) && | 715 !buffered_packets_.HasBufferedPackets(current_connection_id_) && |
| 713 !ShouldCreateOrBufferPacketForConnection(current_connection_id_)) { | 716 !ShouldCreateOrBufferPacketForConnection(current_connection_id_)) { |
| 717 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_create_session_after_insertion, |
| 718 2, 5); |
| 714 return; | 719 return; |
| 715 } | 720 } |
| 716 if (FLAGS_quic_allow_chlo_buffering && | 721 if (FLAGS_quic_allow_chlo_buffering && |
| 717 FLAGS_quic_reloadable_flag_quic_limit_num_new_sessions_per_epoll_loop && | 722 FLAGS_quic_reloadable_flag_quic_limit_num_new_sessions_per_epoll_loop && |
| 718 new_sessions_allowed_per_event_loop_ <= 0) { | 723 new_sessions_allowed_per_event_loop_ <= 0) { |
| 719 // Can't create new session any more. Wait till next event loop. | 724 // Can't create new session any more. Wait till next event loop. |
| 720 QUIC_BUG_IF(buffered_packets_.HasChloForConnection(current_connection_id_)); | 725 QUIC_BUG_IF(buffered_packets_.HasChloForConnection(current_connection_id_)); |
| 721 bool is_new_connection = | 726 bool is_new_connection = |
| 722 !buffered_packets_.HasBufferedPackets(current_connection_id_); | 727 !buffered_packets_.HasBufferedPackets(current_connection_id_); |
| 723 EnqueuePacketResult rs = buffered_packets_.EnqueuePacket( | 728 EnqueuePacketResult rs = buffered_packets_.EnqueuePacket( |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 void QuicDispatcher::DeliverPacketsToSession( | 979 void QuicDispatcher::DeliverPacketsToSession( |
| 975 const std::list<BufferedPacket>& packets, | 980 const std::list<BufferedPacket>& packets, |
| 976 QuicSession* session) { | 981 QuicSession* session) { |
| 977 for (const BufferedPacket& packet : packets) { | 982 for (const BufferedPacket& packet : packets) { |
| 978 session->ProcessUdpPacket(packet.server_address, packet.client_address, | 983 session->ProcessUdpPacket(packet.server_address, packet.client_address, |
| 979 *(packet.packet)); | 984 *(packet.packet)); |
| 980 } | 985 } |
| 981 } | 986 } |
| 982 | 987 |
| 983 } // namespace net | 988 } // namespace net |
| OLD | NEW |