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 // Handles packets for connection_ids in time wait state by discarding the | 5 // Handles packets for connection_ids in time wait state by discarding the |
6 // packet and sending the clients a public reset packet with exponential | 6 // packet and sending the clients a public reset packet with exponential |
7 // backoff. | 7 // backoff. |
8 | 8 |
9 #ifndef NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ | 9 #ifndef NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ |
10 #define NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ | 10 #define NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 // If necessary, trims the oldest connections from the time-wait list until | 95 // If necessary, trims the oldest connections from the time-wait list until |
96 // the size is under the configured maximum. | 96 // the size is under the configured maximum. |
97 void TrimTimeWaitListIfNeeded(); | 97 void TrimTimeWaitListIfNeeded(); |
98 | 98 |
99 // Given a ConnectionId that exists in the time wait list, returns the | 99 // Given a ConnectionId that exists in the time wait list, returns the |
100 // QuicVersion associated with it. | 100 // QuicVersion associated with it. |
101 QuicVersion GetQuicVersionFromConnectionId(QuicConnectionId connection_id); | 101 QuicVersion GetQuicVersionFromConnectionId(QuicConnectionId connection_id); |
102 | 102 |
103 // The number of connections on the time-wait list. | 103 // The number of connections on the time-wait list. |
104 size_t num_connections() const { return connection_id_map_.size(); } | 104 size_t num_connections() const { return num_connections_; } |
105 | 105 |
106 protected: | 106 protected: |
107 virtual QuicEncryptedPacket* BuildPublicReset( | 107 virtual QuicEncryptedPacket* BuildPublicReset( |
108 const QuicPublicResetPacket& packet); | 108 const QuicPublicResetPacket& packet); |
109 | 109 |
110 private: | 110 private: |
111 friend class test::QuicTimeWaitListManagerPeer; | 111 friend class test::QuicTimeWaitListManagerPeer; |
112 | 112 |
113 // Internal structure to store pending public reset packets. | 113 // Internal structure to store pending public reset packets. |
114 class QueuedPacket; | 114 class QueuedPacket; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 183 |
184 // Clock to efficiently measure approximate time. | 184 // Clock to efficiently measure approximate time. |
185 const QuicClock* clock_; | 185 const QuicClock* clock_; |
186 | 186 |
187 // Interface that writes given buffer to the socket. | 187 // Interface that writes given buffer to the socket. |
188 QuicPacketWriter* writer_; | 188 QuicPacketWriter* writer_; |
189 | 189 |
190 // Interface that manages blocked writers. | 190 // Interface that manages blocked writers. |
191 QuicServerSessionVisitor* visitor_; | 191 QuicServerSessionVisitor* visitor_; |
192 | 192 |
| 193 // Number of connection IDs in |connection_id_map_|. According to b/23531792, |
| 194 // cost of size() of linked_hash_map is linear instead of constant, and a |
| 195 // separate counter is maintained so that cost of num_connections() is |
| 196 // constant. TODO(b/23531792): Remove this counter. |
| 197 size_t num_connections_; |
| 198 |
193 DISALLOW_COPY_AND_ASSIGN(QuicTimeWaitListManager); | 199 DISALLOW_COPY_AND_ASSIGN(QuicTimeWaitListManager); |
194 }; | 200 }; |
195 | 201 |
196 } // namespace tools | 202 } // namespace tools |
197 } // namespace net | 203 } // namespace net |
198 | 204 |
199 #endif // NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ | 205 #endif // NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ |
OLD | NEW |