| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // Queues the blocked writer for later resumption. | 85 // Queues the blocked writer for later resumption. |
| 86 void OnWriteBlocked(QuicBlockedWriterInterface* blocked_writer) override; | 86 void OnWriteBlocked(QuicBlockedWriterInterface* blocked_writer) override; |
| 87 | 87 |
| 88 // Called whenever the time wait list manager adds a new connection to the | 88 // Called whenever the time wait list manager adds a new connection to the |
| 89 // time-wait list. | 89 // time-wait list. |
| 90 void OnConnectionAddedToTimeWaitList(QuicConnectionId connection_id) override; | 90 void OnConnectionAddedToTimeWaitList(QuicConnectionId connection_id) override; |
| 91 | 91 |
| 92 void OnPacketBeingDispatchedToSession( | 92 void OnPacketBeingDispatchedToSession( |
| 93 QuicServerSessionBase* session) override {} | 93 QuicServerSessionBase* session) override {} |
| 94 | 94 |
| 95 typedef std::unordered_map<QuicConnectionId, QuicServerSessionBase*> | 95 using SessionMap = std::unordered_map<QuicConnectionId, |
| 96 SessionMap; | 96 std::unique_ptr<QuicServerSessionBase>>; |
| 97 | 97 |
| 98 const SessionMap& session_map() const { return session_map_; } | 98 const SessionMap& session_map() const { return session_map_; } |
| 99 | 99 |
| 100 // Deletes all sessions on the closed session list and clears the list. | 100 // Deletes all sessions on the closed session list and clears the list. |
| 101 virtual void DeleteSessions(); | 101 virtual void DeleteSessions(); |
| 102 | 102 |
| 103 // The largest packet number we expect to receive with a connection | 103 // The largest packet number we expect to receive with a connection |
| 104 // ID for a connection that is not established yet. The current design will | 104 // ID for a connection that is not established yet. The current design will |
| 105 // send a handshake and then up to 50 or so data packets, and then it may | 105 // send a handshake and then up to 50 or so data packets, and then it may |
| 106 // resend the handshake packet up to 10 times. (Retransmitted packets are | 106 // resend the handshake packet up to 10 times. (Retransmitted packets are |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 270 |
| 271 private: | 271 private: |
| 272 friend class net::test::QuicDispatcherPeer; | 272 friend class net::test::QuicDispatcherPeer; |
| 273 friend class StatelessRejectorProcessDoneCallback; | 273 friend class StatelessRejectorProcessDoneCallback; |
| 274 | 274 |
| 275 typedef std::unordered_set<QuicConnectionId> QuicConnectionIdSet; | 275 typedef std::unordered_set<QuicConnectionId> QuicConnectionIdSet; |
| 276 | 276 |
| 277 // Removes the session from the session map and write blocked list, and adds | 277 // Removes the session from the session map and write blocked list, and adds |
| 278 // the ConnectionId to the time-wait list. If |session_closed_statelessly| is | 278 // the ConnectionId to the time-wait list. If |session_closed_statelessly| is |
| 279 // true, any future packets for the ConnectionId will be black-holed. | 279 // true, any future packets for the ConnectionId will be black-holed. |
| 280 void CleanUpSession(SessionMap::iterator it, bool session_closed_statelessly); | 280 void CleanUpSession(SessionMap::iterator it, |
| 281 QuicConnection* connection, |
| 282 bool session_closed_statelessly); |
| 281 | 283 |
| 282 bool HandlePacketForTimeWait(const QuicPacketPublicHeader& header); | 284 bool HandlePacketForTimeWait(const QuicPacketPublicHeader& header); |
| 283 | 285 |
| 284 // Attempts to reject the connection statelessly, if stateless rejects are | 286 // Attempts to reject the connection statelessly, if stateless rejects are |
| 285 // possible and if the current packet contains a CHLO message. Determines a | 287 // possible and if the current packet contains a CHLO message. Determines a |
| 286 // fate which describes what subsequent processing should be performed on the | 288 // fate which describes what subsequent processing should be performed on the |
| 287 // packets, like ValidityChecks, and invokes ProcessUnauthenticatedHeaderFate. | 289 // packets, like ValidityChecks, and invokes ProcessUnauthenticatedHeaderFate. |
| 288 void MaybeRejectStatelessly(QuicConnectionId connection_id, | 290 void MaybeRejectStatelessly(QuicConnectionId connection_id, |
| 289 const QuicPacketHeader& header); | 291 const QuicPacketHeader& header); |
| 290 | 292 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 331 |
| 330 // The list of connections waiting to write. | 332 // The list of connections waiting to write. |
| 331 WriteBlockedList write_blocked_list_; | 333 WriteBlockedList write_blocked_list_; |
| 332 | 334 |
| 333 SessionMap session_map_; | 335 SessionMap session_map_; |
| 334 | 336 |
| 335 // Entity that manages connection_ids in time wait state. | 337 // Entity that manages connection_ids in time wait state. |
| 336 std::unique_ptr<QuicTimeWaitListManager> time_wait_list_manager_; | 338 std::unique_ptr<QuicTimeWaitListManager> time_wait_list_manager_; |
| 337 | 339 |
| 338 // The list of closed but not-yet-deleted sessions. | 340 // The list of closed but not-yet-deleted sessions. |
| 339 std::vector<QuicServerSessionBase*> closed_session_list_; | 341 std::vector<std::unique_ptr<QuicServerSessionBase>> closed_session_list_; |
| 340 | 342 |
| 341 // The helper used for all connections. | 343 // The helper used for all connections. |
| 342 std::unique_ptr<QuicConnectionHelperInterface> helper_; | 344 std::unique_ptr<QuicConnectionHelperInterface> helper_; |
| 343 | 345 |
| 344 // The helper used for all sessions. | 346 // The helper used for all sessions. |
| 345 std::unique_ptr<QuicCryptoServerStream::Helper> session_helper_; | 347 std::unique_ptr<QuicCryptoServerStream::Helper> session_helper_; |
| 346 | 348 |
| 347 // Creates alarms. | 349 // Creates alarms. |
| 348 std::unique_ptr<QuicAlarmFactory> alarm_factory_; | 350 std::unique_ptr<QuicAlarmFactory> alarm_factory_; |
| 349 | 351 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 380 // A backward counter of how many new sessions can be create within current | 382 // A backward counter of how many new sessions can be create within current |
| 381 // event loop. When reaches 0, it means can't create sessions for now. | 383 // event loop. When reaches 0, it means can't create sessions for now. |
| 382 int16_t new_sessions_allowed_per_event_loop_; | 384 int16_t new_sessions_allowed_per_event_loop_; |
| 383 | 385 |
| 384 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); | 386 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); |
| 385 }; | 387 }; |
| 386 | 388 |
| 387 } // namespace net | 389 } // namespace net |
| 388 | 390 |
| 389 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ | 391 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ |
| OLD | NEW |