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 // A server side dispatcher which dispatches a given client's data to their | 5 // A server side dispatcher which dispatches a given client's data to their |
6 // stream. | 6 // stream. |
7 | 7 |
8 #ifndef NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ | 8 #ifndef NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ |
9 #define NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ | 9 #define NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ |
10 | 10 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // Create and return the time wait list manager for this dispatcher, which | 192 // Create and return the time wait list manager for this dispatcher, which |
193 // will be owned by the dispatcher as time_wait_list_manager_ | 193 // will be owned by the dispatcher as time_wait_list_manager_ |
194 virtual QuicTimeWaitListManager* CreateQuicTimeWaitListManager(); | 194 virtual QuicTimeWaitListManager* CreateQuicTimeWaitListManager(); |
195 | 195 |
196 // Called when |connection_id| doesn't have an open connection yet, to buffer | 196 // Called when |connection_id| doesn't have an open connection yet, to buffer |
197 // |current_packet_| until it can be delivered to the connection. | 197 // |current_packet_| until it can be delivered to the connection. |
198 void BufferEarlyPacket(QuicConnectionId connection_id); | 198 void BufferEarlyPacket(QuicConnectionId connection_id); |
199 | 199 |
200 // Called when |current_packet_| is a CHLO packet. Creates a new connection | 200 // Called when |current_packet_| is a CHLO packet. Creates a new connection |
201 // and delivers any buffered packets for that connection id. | 201 // and delivers any buffered packets for that connection id. |
202 void ProcessChlo(); | 202 void ProcessChlo(QuicPacketNumber packet_number); |
203 | 203 |
204 QuicTimeWaitListManager* time_wait_list_manager() { | 204 QuicTimeWaitListManager* time_wait_list_manager() { |
205 return time_wait_list_manager_.get(); | 205 return time_wait_list_manager_.get(); |
206 } | 206 } |
207 | 207 |
208 const QuicVersionVector& GetSupportedVersions(); | 208 const QuicVersionVector& GetSupportedVersions(); |
209 | 209 |
210 QuicConnectionId current_connection_id() { return current_connection_id_; } | 210 QuicConnectionId current_connection_id() { return current_connection_id_; } |
211 const QuicSocketAddress& current_server_address() { | 211 const QuicSocketAddress& current_server_address() { |
212 return current_server_address_; | 212 return current_server_address_; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 virtual bool ShouldCreateOrBufferPacketForConnection( | 262 virtual bool ShouldCreateOrBufferPacketForConnection( |
263 QuicConnectionId connection_id); | 263 QuicConnectionId connection_id); |
264 | 264 |
265 bool HasBufferedPackets(QuicConnectionId connection_id); | 265 bool HasBufferedPackets(QuicConnectionId connection_id); |
266 | 266 |
267 // Called when BufferEarlyPacket() fail to buffer the packet. | 267 // Called when BufferEarlyPacket() fail to buffer the packet. |
268 virtual void OnBufferPacketFailure( | 268 virtual void OnBufferPacketFailure( |
269 QuicBufferedPacketStore::EnqueuePacketResult result, | 269 QuicBufferedPacketStore::EnqueuePacketResult result, |
270 QuicConnectionId connection_id); | 270 QuicConnectionId connection_id); |
271 | 271 |
| 272 // Removes the session from the session map and write blocked list, and adds |
| 273 // the ConnectionId to the time-wait list. If |session_closed_statelessly| is |
| 274 // true, any future packets for the ConnectionId will be black-holed. |
| 275 virtual void CleanUpSession(SessionMap::iterator it, |
| 276 QuicConnection* connection, |
| 277 bool session_closed_statelessly); |
| 278 |
| 279 void StopAcceptingNewConnections(); |
| 280 |
272 private: | 281 private: |
273 friend class test::QuicDispatcherPeer; | 282 friend class test::QuicDispatcherPeer; |
274 friend class StatelessRejectorProcessDoneCallback; | 283 friend class StatelessRejectorProcessDoneCallback; |
275 | 284 |
276 typedef std::unordered_set<QuicConnectionId> QuicConnectionIdSet; | 285 typedef std::unordered_set<QuicConnectionId> QuicConnectionIdSet; |
277 | 286 |
278 // Removes the session from the session map and write blocked list, and adds | |
279 // the ConnectionId to the time-wait list. If |session_closed_statelessly| is | |
280 // true, any future packets for the ConnectionId will be black-holed. | |
281 void CleanUpSession(SessionMap::iterator it, | |
282 QuicConnection* connection, | |
283 bool session_closed_statelessly); | |
284 | |
285 bool HandlePacketForTimeWait(const QuicPacketPublicHeader& header); | 287 bool HandlePacketForTimeWait(const QuicPacketPublicHeader& header); |
286 | 288 |
287 // Attempts to reject the connection statelessly, if stateless rejects are | 289 // Attempts to reject the connection statelessly, if stateless rejects are |
288 // possible and if the current packet contains a CHLO message. Determines a | 290 // possible and if the current packet contains a CHLO message. Determines a |
289 // fate which describes what subsequent processing should be performed on the | 291 // fate which describes what subsequent processing should be performed on the |
290 // packets, like ValidityChecks, and invokes ProcessUnauthenticatedHeaderFate. | 292 // packets, like ValidityChecks, and invokes ProcessUnauthenticatedHeaderFate. |
291 void MaybeRejectStatelessly(QuicConnectionId connection_id, | 293 void MaybeRejectStatelessly(QuicConnectionId connection_id, |
292 const QuicPacketHeader& header); | 294 const QuicPacketHeader& header); |
293 | 295 |
294 // Deliver |packets| to |session| for further processing. | 296 // Deliver |packets| to |session| for further processing. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 QuicFramer framer_; | 379 QuicFramer framer_; |
378 | 380 |
379 // The last error set by SetLastError(), which is called by | 381 // The last error set by SetLastError(), which is called by |
380 // framer_visitor_->OnError(). | 382 // framer_visitor_->OnError(). |
381 QuicErrorCode last_error_; | 383 QuicErrorCode last_error_; |
382 | 384 |
383 // A backward counter of how many new sessions can be create within current | 385 // A backward counter of how many new sessions can be create within current |
384 // event loop. When reaches 0, it means can't create sessions for now. | 386 // event loop. When reaches 0, it means can't create sessions for now. |
385 int16_t new_sessions_allowed_per_event_loop_; | 387 int16_t new_sessions_allowed_per_event_loop_; |
386 | 388 |
| 389 // True if this dispatcher is not draining. |
| 390 bool accept_new_connections_; |
| 391 |
387 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); | 392 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); |
388 }; | 393 }; |
389 | 394 |
390 } // namespace net | 395 } // namespace net |
391 | 396 |
392 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ | 397 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ |
OLD | NEW |