Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: net/quic/core/quic_buffered_packet_store.cc

Issue 2464683002: adds std:: to stl types (#049) (Closed)
Patch Set: remove dead using std::foo declarations. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/quic/core/quic_buffered_packet_store_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
13
14 namespace net { 12 namespace net {
15 13
16 typedef QuicBufferedPacketStore::BufferedPacket BufferedPacket; 14 typedef QuicBufferedPacketStore::BufferedPacket BufferedPacket;
17 typedef QuicBufferedPacketStore::EnqueuePacketResult EnqueuePacketResult; 15 typedef QuicBufferedPacketStore::EnqueuePacketResult EnqueuePacketResult;
18 typedef QuicBufferedPacketStore::BufferedPacketList BufferedPacketList; 16 typedef QuicBufferedPacketStore::BufferedPacketList BufferedPacketList;
19 17
20 // Max number of connections this store can keep track. 18 // Max number of connections this store can keep track.
21 static const size_t kDefaultMaxConnectionsInStore = 100; 19 static const size_t kDefaultMaxConnectionsInStore = 100;
22 // Up to half of the capacity can be used for storing non-CHLO packets. 20 // Up to half of the capacity can be used for storing non-CHLO packets.
23 static const size_t kMaxConnectionsWithoutCHLO = 21 static const size_t kMaxConnectionsWithoutCHLO =
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 136
139 bool QuicBufferedPacketStore::HasBufferedPackets( 137 bool QuicBufferedPacketStore::HasBufferedPackets(
140 QuicConnectionId connection_id) const { 138 QuicConnectionId connection_id) const {
141 return base::ContainsKey(undecryptable_packets_, connection_id); 139 return base::ContainsKey(undecryptable_packets_, connection_id);
142 } 140 }
143 141
144 bool QuicBufferedPacketStore::HasChlosBuffered() const { 142 bool QuicBufferedPacketStore::HasChlosBuffered() const {
145 return !connections_with_chlo_.empty(); 143 return !connections_with_chlo_.empty();
146 } 144 }
147 145
148 list<BufferedPacket> QuicBufferedPacketStore::DeliverPackets( 146 std::list<BufferedPacket> QuicBufferedPacketStore::DeliverPackets(
149 QuicConnectionId connection_id) { 147 QuicConnectionId connection_id) {
150 list<BufferedPacket> packets_to_deliver; 148 std::list<BufferedPacket> packets_to_deliver;
151 auto it = undecryptable_packets_.find(connection_id); 149 auto it = undecryptable_packets_.find(connection_id);
152 if (it != undecryptable_packets_.end()) { 150 if (it != undecryptable_packets_.end()) {
153 packets_to_deliver = std::move(it->second.buffered_packets); 151 packets_to_deliver = std::move(it->second.buffered_packets);
154 undecryptable_packets_.erase(connection_id); 152 undecryptable_packets_.erase(connection_id);
155 } 153 }
156 return packets_to_deliver; 154 return packets_to_deliver;
157 } 155 }
158 156
159 void QuicBufferedPacketStore::DiscardPackets(QuicConnectionId connection_id) { 157 void QuicBufferedPacketStore::DiscardPackets(QuicConnectionId connection_id) {
160 undecryptable_packets_.erase(connection_id); 158 undecryptable_packets_.erase(connection_id);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 192
195 size_t num_connections_without_chlo = 193 size_t num_connections_without_chlo =
196 undecryptable_packets_.size() - connections_with_chlo_.size(); 194 undecryptable_packets_.size() - connections_with_chlo_.size();
197 bool reach_non_chlo_limit = 195 bool reach_non_chlo_limit =
198 FLAGS_quic_limit_num_new_sessions_per_epoll_loop && 196 FLAGS_quic_limit_num_new_sessions_per_epoll_loop &&
199 num_connections_without_chlo >= kMaxConnectionsWithoutCHLO; 197 num_connections_without_chlo >= kMaxConnectionsWithoutCHLO;
200 198
201 return is_store_full || reach_non_chlo_limit; 199 return is_store_full || reach_non_chlo_limit;
202 } 200 }
203 201
204 list<BufferedPacket> QuicBufferedPacketStore::DeliverPacketsForNextConnection( 202 std::list<BufferedPacket>
203 QuicBufferedPacketStore::DeliverPacketsForNextConnection(
205 QuicConnectionId* connection_id) { 204 QuicConnectionId* connection_id) {
206 if (connections_with_chlo_.empty()) { 205 if (connections_with_chlo_.empty()) {
207 // Returns empty list if no CHLO has been buffered. 206 // Returns empty list if no CHLO has been buffered.
208 return list<BufferedPacket>(); 207 return std::list<BufferedPacket>();
209 } 208 }
210 *connection_id = connections_with_chlo_.front().first; 209 *connection_id = connections_with_chlo_.front().first;
211 connections_with_chlo_.erase(connections_with_chlo_.begin()); 210 connections_with_chlo_.erase(connections_with_chlo_.begin());
212 211
213 list<BufferedPacket> packets = DeliverPackets(*connection_id); 212 std::list<BufferedPacket> packets = DeliverPackets(*connection_id);
214 DCHECK(!packets.empty()) << "Try to deliver connectons without CHLO"; 213 DCHECK(!packets.empty()) << "Try to deliver connectons without CHLO";
215 return packets; 214 return packets;
216 } 215 }
217 216
218 bool QuicBufferedPacketStore::HasChloForConnection( 217 bool QuicBufferedPacketStore::HasChloForConnection(
219 QuicConnectionId connection_id) { 218 QuicConnectionId connection_id) {
220 return base::ContainsKey(connections_with_chlo_, connection_id); 219 return base::ContainsKey(connections_with_chlo_, connection_id);
221 } 220 }
222 221
223 } // namespace net 222 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/core/quic_buffered_packet_store_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698