| 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 26 matching lines...) Expand all Loading... |
| 37 public ProcessPacketInterface, | 37 public ProcessPacketInterface, |
| 38 public QuicBlockedWriterInterface, | 38 public QuicBlockedWriterInterface, |
| 39 public QuicFramerVisitorInterface { | 39 public QuicFramerVisitorInterface { |
| 40 public: | 40 public: |
| 41 // Ideally we'd have a linked_hash_set: the boolean is unused. | 41 // Ideally we'd have a linked_hash_set: the boolean is unused. |
| 42 typedef linked_hash_map<QuicBlockedWriterInterface*, | 42 typedef linked_hash_map<QuicBlockedWriterInterface*, |
| 43 bool, | 43 bool, |
| 44 QuicBlockedWriterInterfacePtrHash> | 44 QuicBlockedWriterInterfacePtrHash> |
| 45 WriteBlockedList; | 45 WriteBlockedList; |
| 46 | 46 |
| 47 // Due to the way delete_sessions_closure_ is registered, the Dispatcher must | |
| 48 // live until server Shutdown. |supported_versions| specifies the std::list | |
| 49 // of supported QUIC versions. Takes ownership of |packet_writer_factory|, | |
| 50 // which is used to create per-connection writers. | |
| 51 QuicDispatcher(const QuicConfig& config, | 47 QuicDispatcher(const QuicConfig& config, |
| 52 const QuicCryptoServerConfig* crypto_config, | 48 const QuicCryptoServerConfig* crypto_config, |
| 53 const QuicVersionVector& supported_versions, | 49 const QuicVersionVector& supported_versions, |
| 54 QuicConnectionHelperInterface* helper); | 50 std::unique_ptr<QuicConnectionHelperInterface> helper, |
| 51 std::unique_ptr<QuicAlarmFactory> alarm_factory); |
| 55 | 52 |
| 56 ~QuicDispatcher() override; | 53 ~QuicDispatcher() override; |
| 57 | 54 |
| 58 // Takes ownership of |writer|. | 55 // Takes ownership of |writer|. |
| 59 void InitializeWithWriter(QuicPacketWriter* writer); | 56 void InitializeWithWriter(QuicPacketWriter* writer); |
| 60 | 57 |
| 61 // Process the incoming packet by creating a new session, passing it to | 58 // Process the incoming packet by creating a new session, passing it to |
| 62 // an existing session, or passing it to the time wait list. | 59 // an existing session, or passing it to the time wait list. |
| 63 void ProcessPacket(const IPEndPoint& server_address, | 60 void ProcessPacket(const IPEndPoint& server_address, |
| 64 const IPEndPoint& client_address, | 61 const IPEndPoint& client_address, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 const QuicCryptoServerConfig* crypto_config() const { return crypto_config_; } | 186 const QuicCryptoServerConfig* crypto_config() const { return crypto_config_; } |
| 190 | 187 |
| 191 QuicCompressedCertsCache* compressed_certs_cache() { | 188 QuicCompressedCertsCache* compressed_certs_cache() { |
| 192 return &compressed_certs_cache_; | 189 return &compressed_certs_cache_; |
| 193 } | 190 } |
| 194 | 191 |
| 195 QuicFramer* framer() { return &framer_; } | 192 QuicFramer* framer() { return &framer_; } |
| 196 | 193 |
| 197 QuicConnectionHelperInterface* helper() { return helper_.get(); } | 194 QuicConnectionHelperInterface* helper() { return helper_.get(); } |
| 198 | 195 |
| 196 QuicAlarmFactory* alarm_factory() { return alarm_factory_.get(); } |
| 197 |
| 199 QuicPacketWriter* writer() { return writer_.get(); } | 198 QuicPacketWriter* writer() { return writer_.get(); } |
| 200 | 199 |
| 201 // Creates per-connection packet writers out of the QuicDispatcher's shared | 200 // Creates per-connection packet writers out of the QuicDispatcher's shared |
| 202 // QuicPacketWriter. The per-connection writers' IsWriteBlocked() state must | 201 // QuicPacketWriter. The per-connection writers' IsWriteBlocked() state must |
| 203 // always be the same as the shared writer's IsWriteBlocked(), or else the | 202 // always be the same as the shared writer's IsWriteBlocked(), or else the |
| 204 // QuicDispatcher::OnCanWrite logic will not work. (This will hopefully be | 203 // QuicDispatcher::OnCanWrite logic will not work. (This will hopefully be |
| 205 // cleaned up for bug 16950226.) | 204 // cleaned up for bug 16950226.) |
| 206 virtual QuicPacketWriter* CreatePerConnectionWriter(); | 205 virtual QuicPacketWriter* CreatePerConnectionWriter(); |
| 207 | 206 |
| 208 // Returns true if a session should be created for a connection with an | 207 // Returns true if a session should be created for a connection with an |
| (...skipping 26 matching lines...) Expand all Loading... |
| 235 | 234 |
| 236 // Entity that manages connection_ids in time wait state. | 235 // Entity that manages connection_ids in time wait state. |
| 237 std::unique_ptr<QuicTimeWaitListManager> time_wait_list_manager_; | 236 std::unique_ptr<QuicTimeWaitListManager> time_wait_list_manager_; |
| 238 | 237 |
| 239 // The list of closed but not-yet-deleted sessions. | 238 // The list of closed but not-yet-deleted sessions. |
| 240 std::vector<QuicServerSessionBase*> closed_session_list_; | 239 std::vector<QuicServerSessionBase*> closed_session_list_; |
| 241 | 240 |
| 242 // The helper used for all connections. | 241 // The helper used for all connections. |
| 243 std::unique_ptr<QuicConnectionHelperInterface> helper_; | 242 std::unique_ptr<QuicConnectionHelperInterface> helper_; |
| 244 | 243 |
| 244 // Creates alarms. |
| 245 std::unique_ptr<QuicAlarmFactory> alarm_factory_; |
| 246 |
| 245 // An alarm which deletes closed sessions. | 247 // An alarm which deletes closed sessions. |
| 246 std::unique_ptr<QuicAlarm> delete_sessions_alarm_; | 248 std::unique_ptr<QuicAlarm> delete_sessions_alarm_; |
| 247 | 249 |
| 248 // The writer to write to the socket with. | 250 // The writer to write to the socket with. |
| 249 std::unique_ptr<QuicPacketWriter> writer_; | 251 std::unique_ptr<QuicPacketWriter> writer_; |
| 250 | 252 |
| 251 // This vector contains QUIC versions which we currently support. | 253 // This vector contains QUIC versions which we currently support. |
| 252 // This should be ordered such that the highest supported version is the first | 254 // This should be ordered such that the highest supported version is the first |
| 253 // element, with subsequent elements in descending order (versions can be | 255 // element, with subsequent elements in descending order (versions can be |
| 254 // skipped as necessary). | 256 // skipped as necessary). |
| (...skipping 10 matching lines...) Expand all Loading... |
| 265 // The last error set by SetLastError(), which is called by | 267 // The last error set by SetLastError(), which is called by |
| 266 // framer_visitor_->OnError(). | 268 // framer_visitor_->OnError(). |
| 267 QuicErrorCode last_error_; | 269 QuicErrorCode last_error_; |
| 268 | 270 |
| 269 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); | 271 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); |
| 270 }; | 272 }; |
| 271 | 273 |
| 272 } // namespace net | 274 } // namespace net |
| 273 | 275 |
| 274 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ | 276 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ |
| OLD | NEW |