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

Side by Side Diff: net/quic/quic_time_wait_list_manager.h

Issue 1029463003: Improve tests. Correct things clang_tidy complains about. Make (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months 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/quic_time_wait_list_manager.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ 9 #ifndef NET_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_
10 #define NET_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ 10 #define NET_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_
(...skipping 13 matching lines...) Expand all
24 namespace net { 24 namespace net {
25 25
26 class ConnectionIdCleanUpAlarm; 26 class ConnectionIdCleanUpAlarm;
27 class QuicServerSessionVisitor; 27 class QuicServerSessionVisitor;
28 28
29 namespace test { 29 namespace test {
30 class QuicTimeWaitListManagerPeer; 30 class QuicTimeWaitListManagerPeer;
31 } // namespace test 31 } // namespace test
32 32
33 // Maintains a list of all connection_ids that have been recently closed. A 33 // Maintains a list of all connection_ids that have been recently closed. A
34 // connection_id lives in this state for kTimeWaitPeriod. All packets received 34 // connection_id lives in this state for time_wait_period_. All packets received
35 // for connection_ids in this state are handed over to the 35 // for connection_ids in this state are handed over to the
36 // QuicTimeWaitListManager by the QuicDispatcher. Decides whether to send a 36 // QuicTimeWaitListManager by the QuicDispatcher. Decides whether to send a
37 // public reset packet, a copy of the previously sent connection close packet, 37 // public reset packet, a copy of the previously sent connection close packet,
38 // or nothing to the client which sent a packet with the connection_id in time 38 // or nothing to the client which sent a packet with the connection_id in time
39 // wait state. After the connection_id expires its time wait period, a new 39 // wait state. After the connection_id expires its time wait period, a new
40 // connection/session will be created if a packet is received for this 40 // connection/session will be created if a packet is received for this
41 // connection_id. 41 // connection_id.
42 class QuicTimeWaitListManager : public QuicBlockedWriterInterface { 42 class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
43 public: 43 public:
44 // writer - the entity that writes to the socket. (Owned by the dispatcher) 44 // writer - the entity that writes to the socket. (Owned by the dispatcher)
45 // visitor - the entity that manages blocked writers. (The dispatcher) 45 // visitor - the entity that manages blocked writers. (The dispatcher)
46 // helper - used to run clean up alarms. (Owned by the owner of the server) 46 // helper - used to run clean up alarms. (Owned by the owner of the server)
47 QuicTimeWaitListManager(QuicPacketWriter* writer, 47 QuicTimeWaitListManager(QuicPacketWriter* writer,
48 QuicServerSessionVisitor* visitor, 48 QuicServerSessionVisitor* visitor,
49 QuicConnectionHelperInterface* helper, 49 QuicConnectionHelperInterface* helper,
50 const QuicVersionVector& supported_versions); 50 const QuicVersionVector& supported_versions);
51 ~QuicTimeWaitListManager() override; 51 ~QuicTimeWaitListManager() override;
52 52
53 // Adds the given connection_id to time wait state for kTimeWaitPeriod. 53 // Adds the given connection_id to time wait state for time_wait_period_.
54 // Henceforth, any packet bearing this connection_id should not be processed 54 // Henceforth, any packet bearing this connection_id should not be processed
55 // while the connection_id remains in this list. If a non-nullptr 55 // while the connection_id remains in this list. If a non-nullptr
56 // |close_packet| is provided, it is sent again when packets are received for 56 // |close_packet| is provided, the TimeWaitListManager takes ownership of it
57 // added connection_ids. If nullptr, a public reset packet is sent with the 57 // and sends it again when packets are received for added connection_ids. If
58 // specified |version|. DCHECKs that connection_id is not already on the list. 58 // nullptr, a public reset packet is sent with the specified |version|.
59 void AddConnectionIdToTimeWait(QuicConnectionId connection_id, 59 // DCHECKs that connection_id is not already on the list. "virtual" to
60 QuicVersion version, 60 // override in tests.
61 QuicEncryptedPacket* close_packet); // Owned. 61 virtual void AddConnectionIdToTimeWait(QuicConnectionId connection_id,
62 QuicVersion version,
63 QuicEncryptedPacket* close_packet);
62 64
63 // Returns true if the connection_id is in time wait state, false otherwise. 65 // Returns true if the connection_id is in time wait state, false otherwise.
64 // Packets received for this connection_id should not lead to creation of new 66 // Packets received for this connection_id should not lead to creation of new
65 // QuicSessions. 67 // QuicSessions.
66 bool IsConnectionIdInTimeWait(QuicConnectionId connection_id) const; 68 bool IsConnectionIdInTimeWait(QuicConnectionId connection_id) const;
67 69
68 // Called when a packet is received for a connection_id that is in time wait 70 // Called when a packet is received for a connection_id that is in time wait
69 // state. Sends a public reset packet to the client which sent this 71 // state. Sends a public reset packet to the client which sent this
70 // connection_id. Sending of the public reset packet is throttled by using 72 // connection_id. Sending of the public reset packet is throttled by using
71 // exponential back off. DCHECKs for the connection_id to be in time wait 73 // exponential back off. DCHECKs for the connection_id to be in time wait
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 164
163 // Pending public reset packets that need to be sent out to the client 165 // Pending public reset packets that need to be sent out to the client
164 // when we are given a chance to write by the dispatcher. 166 // when we are given a chance to write by the dispatcher.
165 std::deque<QueuedPacket*> pending_packets_queue_; 167 std::deque<QueuedPacket*> pending_packets_queue_;
166 168
167 // Used to schedule alarms to delete old connection_ids which have been in the 169 // Used to schedule alarms to delete old connection_ids which have been in the
168 // list for too long. 170 // list for too long.
169 QuicConnectionHelperInterface* helper_; 171 QuicConnectionHelperInterface* helper_;
170 172
171 // Time period for which connection_ids should remain in time wait state. 173 // Time period for which connection_ids should remain in time wait state.
172 const QuicTime::Delta kTimeWaitPeriod_; 174 const QuicTime::Delta time_wait_period_;
173 175
174 // Alarm registered with the connection helper to clean up connection_ids that 176 // Alarm registered with the connection helper to clean up connection_ids that
175 // have 177 // have
176 // out lived their duration in time wait state. 178 // out lived their duration in time wait state.
177 scoped_ptr<QuicAlarm> connection_id_clean_up_alarm_; 179 scoped_ptr<QuicAlarm> connection_id_clean_up_alarm_;
178 180
179 // Interface that writes given buffer to the socket. 181 // Interface that writes given buffer to the socket.
180 QuicPacketWriter* writer_; 182 QuicPacketWriter* writer_;
181 183
182 // Interface that manages blocked writers. 184 // Interface that manages blocked writers.
183 QuicServerSessionVisitor* visitor_; 185 QuicServerSessionVisitor* visitor_;
184 186
185 DISALLOW_COPY_AND_ASSIGN(QuicTimeWaitListManager); 187 DISALLOW_COPY_AND_ASSIGN(QuicTimeWaitListManager);
186 }; 188 };
187 189
188 } // namespace net 190 } // namespace net
189 191
190 #endif // NET_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ 192 #endif // NET_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | net/quic/quic_time_wait_list_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698