| 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 |
| 11 #include <list> | 11 #include <list> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
| 17 #include "net/base/linked_hash_map.h" | 17 #include "net/base/linked_hash_map.h" |
| 18 #include "net/quic/quic_blocked_writer_interface.h" | 18 #include "net/quic/quic_blocked_writer_interface.h" |
| 19 #include "net/quic/quic_protocol.h" | 19 #include "net/quic/quic_protocol.h" |
| 20 #include "net/tools/quic/quic_server_session.h" | 20 #include "net/tools/quic/quic_server_session.h" |
| 21 #include "net/tools/quic/quic_time_wait_list_manager.h" | 21 #include "net/tools/quic/quic_time_wait_list_manager.h" |
| 22 | 22 |
| 23 namespace net { | 23 namespace net { |
| 24 | 24 |
| 25 class EpollServer; | 25 class EpollServer; |
| 26 class QuicConfig; | 26 class QuicConfig; |
| 27 class QuicCryptoServerConfig; | 27 class QuicCryptoServerConfig; |
| 28 class QuicSession; | 28 class QuicServerSession; |
| 29 | 29 |
| 30 namespace tools { | 30 namespace tools { |
| 31 | 31 |
| 32 class DeleteSessionsAlarm; | 32 class DeleteSessionsAlarm; |
| 33 class QuicEpollConnectionHelper; | 33 class QuicEpollConnectionHelper; |
| 34 class QuicPacketWriterWrapper; | 34 class QuicPacketWriterWrapper; |
| 35 | 35 |
| 36 namespace test { | 36 namespace test { |
| 37 class QuicDispatcherPeer; | 37 class QuicDispatcherPeer; |
| 38 } // namespace test | 38 } // namespace test |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 112 |
| 113 // Called whenever the QuicTimeWaitListManager adds a new connection to the | 113 // Called whenever the QuicTimeWaitListManager adds a new connection to the |
| 114 // time-wait list. | 114 // time-wait list. |
| 115 void OnConnectionAddedToTimeWaitList(QuicConnectionId connection_id) override; | 115 void OnConnectionAddedToTimeWaitList(QuicConnectionId connection_id) override; |
| 116 | 116 |
| 117 // Called whenever the QuicTimeWaitListManager removes an old connection from | 117 // Called whenever the QuicTimeWaitListManager removes an old connection from |
| 118 // the time-wait list. | 118 // the time-wait list. |
| 119 void OnConnectionRemovedFromTimeWaitList( | 119 void OnConnectionRemovedFromTimeWaitList( |
| 120 QuicConnectionId connection_id) override; | 120 QuicConnectionId connection_id) override; |
| 121 | 121 |
| 122 typedef base::hash_map<QuicConnectionId, QuicSession*> SessionMap; | 122 typedef base::hash_map<QuicConnectionId, QuicServerSession*> SessionMap; |
| 123 | 123 |
| 124 // Deletes all sessions on the closed session list and clears the list. | 124 // Deletes all sessions on the closed session list and clears the list. |
| 125 void DeleteSessions(); | 125 void DeleteSessions(); |
| 126 | 126 |
| 127 const SessionMap& session_map() const { return session_map_; } | 127 const SessionMap& session_map() const { return session_map_; } |
| 128 | 128 |
| 129 protected: | 129 protected: |
| 130 // Instantiates a new low-level packet writer. Caller takes ownership of the | 130 // Instantiates a new low-level packet writer. Caller takes ownership of the |
| 131 // returned object. | 131 // returned object. |
| 132 virtual QuicPacketWriter* CreateWriter(int fd); | 132 virtual QuicPacketWriter* CreateWriter(int fd); |
| 133 | 133 |
| 134 virtual QuicSession* CreateQuicSession(QuicConnectionId connection_id, | 134 virtual QuicServerSession* CreateQuicSession( |
| 135 const IPEndPoint& server_address, | 135 QuicConnectionId connection_id, |
| 136 const IPEndPoint& client_address); | 136 const IPEndPoint& server_address, |
| 137 const IPEndPoint& client_address); |
| 137 | 138 |
| 138 // Called by |framer_visitor_| when the public header has been parsed. | 139 // Called by |framer_visitor_| when the public header has been parsed. |
| 139 virtual bool OnUnauthenticatedPublicHeader( | 140 virtual bool OnUnauthenticatedPublicHeader( |
| 140 const QuicPacketPublicHeader& header); | 141 const QuicPacketPublicHeader& header); |
| 141 | 142 |
| 142 // Called by OnUnauthenticatedPublicHeader when the packet is not for a | 143 // Called by OnUnauthenticatedPublicHeader when the packet is not for a |
| 143 // connection that the dispatcher has a record of, but is not handled by | 144 // connection that the dispatcher has a record of, but is not handled by |
| 144 // certain simple processing rules. This method may apply validity checks to | 145 // certain simple processing rules. This method may apply validity checks to |
| 145 // reject stray packets. If the packet appears to be valid, it calls | 146 // reject stray packets. If the packet appears to be valid, it calls |
| 146 // CreateQuicSession to create a new session for the packet. Returns the | 147 // CreateQuicSession to create a new session for the packet. Returns the |
| 147 // QuicSession that was created, or nullptr if the packet failed the validity | 148 // QuicServerSession that was created, or nullptr if the packet failed the |
| 148 // checks. | 149 // validity checks. |
| 149 virtual QuicSession* AdditionalValidityChecksThenCreateSession( | 150 virtual QuicServerSession* AdditionalValidityChecksThenCreateSession( |
| 150 const QuicPacketPublicHeader& header, | 151 const QuicPacketPublicHeader& header, |
| 151 QuicConnectionId connection_id); | 152 QuicConnectionId connection_id); |
| 152 | 153 |
| 153 // Create and return the time wait list manager for this dispatcher, which | 154 // Create and return the time wait list manager for this dispatcher, which |
| 154 // will be owned by the dispatcher as time_wait_list_manager_ | 155 // will be owned by the dispatcher as time_wait_list_manager_ |
| 155 virtual QuicTimeWaitListManager* CreateQuicTimeWaitListManager(); | 156 virtual QuicTimeWaitListManager* CreateQuicTimeWaitListManager(); |
| 156 | 157 |
| 157 QuicTimeWaitListManager* time_wait_list_manager() { | 158 QuicTimeWaitListManager* time_wait_list_manager() { |
| 158 return time_wait_list_manager_.get(); | 159 return time_wait_list_manager_.get(); |
| 159 } | 160 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 227 |
| 227 SessionMap session_map_; | 228 SessionMap session_map_; |
| 228 | 229 |
| 229 // Entity that manages connection_ids in time wait state. | 230 // Entity that manages connection_ids in time wait state. |
| 230 scoped_ptr<QuicTimeWaitListManager> time_wait_list_manager_; | 231 scoped_ptr<QuicTimeWaitListManager> time_wait_list_manager_; |
| 231 | 232 |
| 232 // An alarm which deletes closed sessions. | 233 // An alarm which deletes closed sessions. |
| 233 scoped_ptr<DeleteSessionsAlarm> delete_sessions_alarm_; | 234 scoped_ptr<DeleteSessionsAlarm> delete_sessions_alarm_; |
| 234 | 235 |
| 235 // The list of closed but not-yet-deleted sessions. | 236 // The list of closed but not-yet-deleted sessions. |
| 236 std::list<QuicSession*> closed_session_list_; | 237 std::list<QuicServerSession*> closed_session_list_; |
| 237 | 238 |
| 238 EpollServer* epoll_server_; // Owned by the server. | 239 EpollServer* epoll_server_; // Owned by the server. |
| 239 | 240 |
| 240 // The helper used for all connections. | 241 // The helper used for all connections. |
| 241 scoped_ptr<QuicEpollConnectionHelper> helper_; | 242 scoped_ptr<QuicEpollConnectionHelper> helper_; |
| 242 | 243 |
| 243 // The writer to write to the socket with. | 244 // The writer to write to the socket with. |
| 244 scoped_ptr<QuicPacketWriter> writer_; | 245 scoped_ptr<QuicPacketWriter> writer_; |
| 245 | 246 |
| 246 // Used to create per-connection packet writers, not |writer_| itself. | 247 // Used to create per-connection packet writers, not |writer_| itself. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 263 QuicFramer framer_; | 264 QuicFramer framer_; |
| 264 scoped_ptr<QuicFramerVisitor> framer_visitor_; | 265 scoped_ptr<QuicFramerVisitor> framer_visitor_; |
| 265 | 266 |
| 266 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); | 267 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); |
| 267 }; | 268 }; |
| 268 | 269 |
| 269 } // namespace tools | 270 } // namespace tools |
| 270 } // namespace net | 271 } // namespace net |
| 271 | 272 |
| 272 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ | 273 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ |
| OLD | NEW |