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_time_wait_list_manager.h" | 5 #include "net/tools/quic/quic_time_wait_list_manager.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 | 8 |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "net/base/ip_endpoint.h" | 12 #include "net/base/ip_endpoint.h" |
13 #include "net/quic/crypto/crypto_protocol.h" | 13 #include "net/quic/crypto/crypto_protocol.h" |
14 #include "net/quic/crypto/quic_decrypter.h" | 14 #include "net/quic/crypto/quic_decrypter.h" |
15 #include "net/quic/crypto/quic_encrypter.h" | 15 #include "net/quic/crypto/quic_encrypter.h" |
16 #include "net/quic/quic_clock.h" | 16 #include "net/quic/quic_clock.h" |
17 #include "net/quic/quic_flags.h" | 17 #include "net/quic/quic_flags.h" |
18 #include "net/quic/quic_framer.h" | 18 #include "net/quic/quic_framer.h" |
19 #include "net/quic/quic_protocol.h" | 19 #include "net/quic/quic_protocol.h" |
20 #include "net/quic/quic_utils.h" | 20 #include "net/quic/quic_utils.h" |
21 #include "net/tools/epoll_server/epoll_server.h" | 21 #include "net/tools/epoll_server/epoll_server.h" |
22 #include "net/tools/quic/quic_server_session.h" | 22 #include "net/tools/quic/quic_server_session.h" |
23 | 23 |
24 using base::StringPiece; | 24 using base::StringPiece; |
25 using std::make_pair; | |
26 | 25 |
27 namespace net { | 26 namespace net { |
28 namespace tools { | 27 namespace tools { |
29 | 28 |
30 // TODO(rtenneti): Remove the duplicated code in this file. Share code with | 29 // TODO(rtenneti): Remove the duplicated code in this file. Share code with |
31 // "net/quic/quic_time_wait_list_manager.cc" | 30 // "net/quic/quic_time_wait_list_manager.cc" |
32 | 31 |
33 // A very simple alarm that just informs the QuicTimeWaitListManager to clean | 32 // A very simple alarm that just informs the QuicTimeWaitListManager to clean |
34 // up old connection_ids. This alarm should be unregistered and deleted before | 33 // up old connection_ids. This alarm should be unregistered and deleted before |
35 // the QuicTimeWaitListManager is deleted. | 34 // the QuicTimeWaitListManager is deleted. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 119 } |
121 TrimTimeWaitListIfNeeded(); | 120 TrimTimeWaitListIfNeeded(); |
122 if (FLAGS_quic_limit_time_wait_list_size) { | 121 if (FLAGS_quic_limit_time_wait_list_size) { |
123 DCHECK_LT(num_connections(), | 122 DCHECK_LT(num_connections(), |
124 static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections)); | 123 static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections)); |
125 } | 124 } |
126 ConnectionIdData data(num_packets, | 125 ConnectionIdData data(num_packets, |
127 version, | 126 version, |
128 clock_.ApproximateNow(), | 127 clock_.ApproximateNow(), |
129 close_packet); | 128 close_packet); |
130 connection_id_map_.insert(make_pair(connection_id, data)); | 129 connection_id_map_.insert(std::make_pair(connection_id, data)); |
131 if (new_connection_id) { | 130 if (new_connection_id) { |
132 visitor_->OnConnectionAddedToTimeWaitList(connection_id); | 131 visitor_->OnConnectionAddedToTimeWaitList(connection_id); |
133 } | 132 } |
134 } | 133 } |
135 | 134 |
136 bool QuicTimeWaitListManager::IsConnectionIdInTimeWait( | 135 bool QuicTimeWaitListManager::IsConnectionIdInTimeWait( |
137 QuicConnectionId connection_id) const { | 136 QuicConnectionId connection_id) const { |
138 return ContainsKey(connection_id_map_, connection_id); | 137 return ContainsKey(connection_id_map_, connection_id); |
139 } | 138 } |
140 | 139 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 } | 328 } |
330 while (num_connections() >= | 329 while (num_connections() >= |
331 static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections)) { | 330 static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections)) { |
332 MaybeExpireOldestConnection(QuicTime::Infinite()); | 331 MaybeExpireOldestConnection(QuicTime::Infinite()); |
333 } | 332 } |
334 } | 333 } |
335 } | 334 } |
336 | 335 |
337 } // namespace tools | 336 } // namespace tools |
338 } // namespace net | 337 } // namespace net |
OLD | NEW |