| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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/core/quic_buffered_packet_store.h" | 5 #include "net/quic/core/quic_buffered_packet_store.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "net/quic/core/quic_bug_tracker.h" | 10 #include "net/quic/core/quic_bug_tracker.h" |
| 11 #include "net/quic/core/quic_flags.h" |
| 11 | 12 |
| 12 namespace net { | 13 namespace net { |
| 13 | 14 |
| 14 typedef QuicBufferedPacketStore::BufferedPacket BufferedPacket; | 15 typedef QuicBufferedPacketStore::BufferedPacket BufferedPacket; |
| 15 typedef QuicBufferedPacketStore::EnqueuePacketResult EnqueuePacketResult; | 16 typedef QuicBufferedPacketStore::EnqueuePacketResult EnqueuePacketResult; |
| 16 typedef QuicBufferedPacketStore::BufferedPacketList BufferedPacketList; | 17 typedef QuicBufferedPacketStore::BufferedPacketList BufferedPacketList; |
| 17 | 18 |
| 18 // Max number of connections this store can keep track. | 19 // Max number of connections this store can keep track. |
| 19 static const size_t kDefaultMaxConnectionsInStore = 100; | 20 static const size_t kDefaultMaxConnectionsInStore = 100; |
| 20 // Up to half of the capacity can be used for storing non-CHLO packets. | 21 // Up to half of the capacity can be used for storing non-CHLO packets. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 alarm_factory->CreateAlarm(new ConnectionExpireAlarm(this))) {} | 76 alarm_factory->CreateAlarm(new ConnectionExpireAlarm(this))) {} |
| 76 | 77 |
| 77 QuicBufferedPacketStore::~QuicBufferedPacketStore() {} | 78 QuicBufferedPacketStore::~QuicBufferedPacketStore() {} |
| 78 | 79 |
| 79 EnqueuePacketResult QuicBufferedPacketStore::EnqueuePacket( | 80 EnqueuePacketResult QuicBufferedPacketStore::EnqueuePacket( |
| 80 QuicConnectionId connection_id, | 81 QuicConnectionId connection_id, |
| 81 const QuicReceivedPacket& packet, | 82 const QuicReceivedPacket& packet, |
| 82 IPEndPoint server_address, | 83 IPEndPoint server_address, |
| 83 IPEndPoint client_address, | 84 IPEndPoint client_address, |
| 84 bool is_chlo) { | 85 bool is_chlo) { |
| 86 QUIC_BUG_IF(!FLAGS_quic_allow_chlo_buffering) |
| 87 << "Shouldn't buffer packets if disabled via flag."; |
| 85 QUIC_BUG_IF(is_chlo && | 88 QUIC_BUG_IF(is_chlo && |
| 86 base::ContainsKey(connections_with_chlo_, connection_id)) | 89 base::ContainsKey(connections_with_chlo_, connection_id)) |
| 87 << "Shouldn't buffer duplicated CHLO on connection " << connection_id; | 90 << "Shouldn't buffer duplicated CHLO on connection " << connection_id; |
| 88 | 91 |
| 89 if (!base::ContainsKey(undecryptable_packets_, connection_id) && | 92 if (!base::ContainsKey(undecryptable_packets_, connection_id) && |
| 90 ShouldBufferPacket(is_chlo)) { | 93 ShouldBufferPacket(is_chlo)) { |
| 91 // Drop the packet if the upper limit of undecryptable packets has been | 94 // Drop the packet if the upper limit of undecryptable packets has been |
| 92 // reached or the whole capacity of the store has been reached. | 95 // reached or the whole capacity of the store has been reached. |
| 93 return TOO_MANY_CONNECTIONS; | 96 return TOO_MANY_CONNECTIONS; |
| 94 } else if (!base::ContainsKey(undecryptable_packets_, connection_id)) { | 97 } else if (!base::ContainsKey(undecryptable_packets_, connection_id)) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 DCHECK(!packets.empty()) << "Try to deliver connectons without CHLO"; | 216 DCHECK(!packets.empty()) << "Try to deliver connectons without CHLO"; |
| 214 return packets; | 217 return packets; |
| 215 } | 218 } |
| 216 | 219 |
| 217 bool QuicBufferedPacketStore::HasChloForConnection( | 220 bool QuicBufferedPacketStore::HasChloForConnection( |
| 218 QuicConnectionId connection_id) { | 221 QuicConnectionId connection_id) { |
| 219 return base::ContainsKey(connections_with_chlo_, connection_id); | 222 return base::ContainsKey(connections_with_chlo_, connection_id); |
| 220 } | 223 } |
| 221 | 224 |
| 222 } // namespace net | 225 } // namespace net |
| OLD | NEW |