Chromium Code Reviews| 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 | 11 |
| 12 using std::list; | 12 using std::list; |
|
Ryan Hamilton
2016/10/30 20:22:05
If it's not too much work, can you remove using st
Buck
2016/10/30 23:53:16
Done.
| |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 typedef QuicBufferedPacketStore::BufferedPacket BufferedPacket; | 16 typedef QuicBufferedPacketStore::BufferedPacket BufferedPacket; |
| 17 typedef QuicBufferedPacketStore::EnqueuePacketResult EnqueuePacketResult; | 17 typedef QuicBufferedPacketStore::EnqueuePacketResult EnqueuePacketResult; |
| 18 typedef QuicBufferedPacketStore::BufferedPacketList BufferedPacketList; | 18 typedef QuicBufferedPacketStore::BufferedPacketList BufferedPacketList; |
| 19 | 19 |
| 20 // Max number of connections this store can keep track. | 20 // Max number of connections this store can keep track. |
| 21 static const size_t kDefaultMaxConnectionsInStore = 100; | 21 static const size_t kDefaultMaxConnectionsInStore = 100; |
| 22 // Up to half of the capacity can be used for storing non-CHLO packets. | 22 // Up to half of the capacity can be used for storing non-CHLO packets. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 | 138 |
| 139 bool QuicBufferedPacketStore::HasBufferedPackets( | 139 bool QuicBufferedPacketStore::HasBufferedPackets( |
| 140 QuicConnectionId connection_id) const { | 140 QuicConnectionId connection_id) const { |
| 141 return base::ContainsKey(undecryptable_packets_, connection_id); | 141 return base::ContainsKey(undecryptable_packets_, connection_id); |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool QuicBufferedPacketStore::HasChlosBuffered() const { | 144 bool QuicBufferedPacketStore::HasChlosBuffered() const { |
| 145 return !connections_with_chlo_.empty(); | 145 return !connections_with_chlo_.empty(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 list<BufferedPacket> QuicBufferedPacketStore::DeliverPackets( | 148 std::list<BufferedPacket> QuicBufferedPacketStore::DeliverPackets( |
| 149 QuicConnectionId connection_id) { | 149 QuicConnectionId connection_id) { |
| 150 list<BufferedPacket> packets_to_deliver; | 150 std::list<BufferedPacket> packets_to_deliver; |
| 151 auto it = undecryptable_packets_.find(connection_id); | 151 auto it = undecryptable_packets_.find(connection_id); |
| 152 if (it != undecryptable_packets_.end()) { | 152 if (it != undecryptable_packets_.end()) { |
| 153 packets_to_deliver = std::move(it->second.buffered_packets); | 153 packets_to_deliver = std::move(it->second.buffered_packets); |
| 154 undecryptable_packets_.erase(connection_id); | 154 undecryptable_packets_.erase(connection_id); |
| 155 } | 155 } |
| 156 return packets_to_deliver; | 156 return packets_to_deliver; |
| 157 } | 157 } |
| 158 | 158 |
| 159 void QuicBufferedPacketStore::DiscardPackets(QuicConnectionId connection_id) { | 159 void QuicBufferedPacketStore::DiscardPackets(QuicConnectionId connection_id) { |
| 160 undecryptable_packets_.erase(connection_id); | 160 undecryptable_packets_.erase(connection_id); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 | 194 |
| 195 size_t num_connections_without_chlo = | 195 size_t num_connections_without_chlo = |
| 196 undecryptable_packets_.size() - connections_with_chlo_.size(); | 196 undecryptable_packets_.size() - connections_with_chlo_.size(); |
| 197 bool reach_non_chlo_limit = | 197 bool reach_non_chlo_limit = |
| 198 FLAGS_quic_limit_num_new_sessions_per_epoll_loop && | 198 FLAGS_quic_limit_num_new_sessions_per_epoll_loop && |
| 199 num_connections_without_chlo >= kMaxConnectionsWithoutCHLO; | 199 num_connections_without_chlo >= kMaxConnectionsWithoutCHLO; |
| 200 | 200 |
| 201 return is_store_full || reach_non_chlo_limit; | 201 return is_store_full || reach_non_chlo_limit; |
| 202 } | 202 } |
| 203 | 203 |
| 204 list<BufferedPacket> QuicBufferedPacketStore::DeliverPacketsForNextConnection( | 204 std::list<BufferedPacket> |
| 205 QuicBufferedPacketStore::DeliverPacketsForNextConnection( | |
| 205 QuicConnectionId* connection_id) { | 206 QuicConnectionId* connection_id) { |
| 206 if (connections_with_chlo_.empty()) { | 207 if (connections_with_chlo_.empty()) { |
| 207 // Returns empty list if no CHLO has been buffered. | 208 // Returns empty list if no CHLO has been buffered. |
| 208 return list<BufferedPacket>(); | 209 return std::list<BufferedPacket>(); |
| 209 } | 210 } |
| 210 *connection_id = connections_with_chlo_.front().first; | 211 *connection_id = connections_with_chlo_.front().first; |
| 211 connections_with_chlo_.erase(connections_with_chlo_.begin()); | 212 connections_with_chlo_.erase(connections_with_chlo_.begin()); |
| 212 | 213 |
| 213 list<BufferedPacket> packets = DeliverPackets(*connection_id); | 214 std::list<BufferedPacket> packets = DeliverPackets(*connection_id); |
| 214 DCHECK(!packets.empty()) << "Try to deliver connectons without CHLO"; | 215 DCHECK(!packets.empty()) << "Try to deliver connectons without CHLO"; |
| 215 return packets; | 216 return packets; |
| 216 } | 217 } |
| 217 | 218 |
| 218 bool QuicBufferedPacketStore::HasChloForConnection( | 219 bool QuicBufferedPacketStore::HasChloForConnection( |
| 219 QuicConnectionId connection_id) { | 220 QuicConnectionId connection_id) { |
| 220 return base::ContainsKey(connections_with_chlo_, connection_id); | 221 return base::ContainsKey(connections_with_chlo_, connection_id); |
| 221 } | 222 } |
| 222 | 223 |
| 223 } // namespace net | 224 } // namespace net |
| OLD | NEW |