OLD | NEW |
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 // 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_QUIC_QUIC_DISPATCHER_H_ | 8 #ifndef NET_QUIC_QUIC_DISPATCHER_H_ |
9 #define NET_QUIC_QUIC_DISPATCHER_H_ | 9 #define NET_QUIC_QUIC_DISPATCHER_H_ |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "net/quic/quic_time_wait_list_manager.h" | 23 #include "net/quic/quic_time_wait_list_manager.h" |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 namespace test { | 26 namespace test { |
27 class QuicDispatcherPeer; | 27 class QuicDispatcherPeer; |
28 } // namespace test | 28 } // namespace test |
29 | 29 |
30 class DeleteSessionsAlarm; | 30 class DeleteSessionsAlarm; |
31 class QuicConfig; | 31 class QuicConfig; |
32 class QuicCryptoServerConfig; | 32 class QuicCryptoServerConfig; |
33 class QuicSession; | 33 class QuicServerSession; |
34 | 34 |
35 class ProcessPacketInterface { | 35 class ProcessPacketInterface { |
36 public: | 36 public: |
37 virtual ~ProcessPacketInterface() {} | 37 virtual ~ProcessPacketInterface() {} |
38 virtual void ProcessPacket(const IPEndPoint& server_address, | 38 virtual void ProcessPacket(const IPEndPoint& server_address, |
39 const IPEndPoint& client_address, | 39 const IPEndPoint& client_address, |
40 const QuicEncryptedPacket& packet) = 0; | 40 const QuicEncryptedPacket& packet) = 0; |
41 }; | 41 }; |
42 | 42 |
43 class QuicDispatcher : public QuicBlockedWriterInterface, | 43 class QuicDispatcher : public QuicBlockedWriterInterface, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 // Called whenever the QuicTimeWaitListManager adds a new connection to the | 111 // Called whenever the QuicTimeWaitListManager adds a new connection to the |
112 // time-wait list. | 112 // time-wait list. |
113 void OnConnectionAddedToTimeWaitList(QuicConnectionId connection_id) override; | 113 void OnConnectionAddedToTimeWaitList(QuicConnectionId connection_id) override; |
114 | 114 |
115 // Called whenever the QuicTimeWaitListManager removes an old connection from | 115 // Called whenever the QuicTimeWaitListManager removes an old connection from |
116 // the time-wait list. | 116 // the time-wait list. |
117 void OnConnectionRemovedFromTimeWaitList( | 117 void OnConnectionRemovedFromTimeWaitList( |
118 QuicConnectionId connection_id) override; | 118 QuicConnectionId connection_id) override; |
119 | 119 |
120 typedef base::hash_map<QuicConnectionId, QuicSession*> SessionMap; | 120 typedef base::hash_map<QuicConnectionId, QuicServerSession*> SessionMap; |
121 | 121 |
122 // Deletes all sessions on the closed session list and clears the list. | 122 // Deletes all sessions on the closed session list and clears the list. |
123 void DeleteSessions(); | 123 void DeleteSessions(); |
124 | 124 |
125 const SessionMap& session_map() const { return session_map_; } | 125 const SessionMap& session_map() const { return session_map_; } |
126 | 126 |
127 protected: | 127 protected: |
128 virtual QuicSession* CreateQuicSession(QuicConnectionId connection_id, | 128 virtual QuicServerSession* CreateQuicSession( |
129 const IPEndPoint& server_address, | 129 QuicConnectionId connection_id, |
130 const IPEndPoint& client_address); | 130 const IPEndPoint& server_address, |
| 131 const IPEndPoint& client_address); |
131 | 132 |
132 // Called by |framer_visitor_| when the public header has been parsed. | 133 // Called by |framer_visitor_| when the public header has been parsed. |
133 virtual bool OnUnauthenticatedPublicHeader( | 134 virtual bool OnUnauthenticatedPublicHeader( |
134 const QuicPacketPublicHeader& header); | 135 const QuicPacketPublicHeader& header); |
135 | 136 |
136 // Called by OnUnauthenticatedPublicHeader when the packet is not for a | 137 // Called by OnUnauthenticatedPublicHeader when the packet is not for a |
137 // connection that the dispatcher has a record of, but is not handled by | 138 // connection that the dispatcher has a record of, but is not handled by |
138 // certain simple processing rules. This method may apply validity checks to | 139 // certain simple processing rules. This method may apply validity checks to |
139 // reject stray packets. If the packet appears to be valid, it calls | 140 // reject stray packets. If the packet appears to be valid, it calls |
140 // CreateQuicSession to create a new session for the packet. Returns the | 141 // CreateQuicSession to create a new session for the packet. Returns the |
141 // QuicSession that was created, or nullptr if the packet failed the validity | 142 // QuicServerSession that was created, or nullptr if the packet failed the |
142 // checks. | 143 // validity checks. |
143 virtual QuicSession* AdditionalValidityChecksThenCreateSession( | 144 virtual QuicServerSession* AdditionalValidityChecksThenCreateSession( |
144 const QuicPacketPublicHeader& header, | 145 const QuicPacketPublicHeader& header, |
145 QuicConnectionId connection_id); | 146 QuicConnectionId connection_id); |
146 | 147 |
147 // Create and return the time wait list manager for this dispatcher, which | 148 // Create and return the time wait list manager for this dispatcher, which |
148 // will be owned by the dispatcher as time_wait_list_manager_ | 149 // will be owned by the dispatcher as time_wait_list_manager_ |
149 virtual QuicTimeWaitListManager* CreateQuicTimeWaitListManager(); | 150 virtual QuicTimeWaitListManager* CreateQuicTimeWaitListManager(); |
150 | 151 |
151 QuicTimeWaitListManager* time_wait_list_manager() { | 152 QuicTimeWaitListManager* time_wait_list_manager() { |
152 return time_wait_list_manager_.get(); | 153 return time_wait_list_manager_.get(); |
153 } | 154 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // Entity that manages connection_ids in time wait state. | 222 // Entity that manages connection_ids in time wait state. |
222 scoped_ptr<QuicTimeWaitListManager> time_wait_list_manager_; | 223 scoped_ptr<QuicTimeWaitListManager> time_wait_list_manager_; |
223 | 224 |
224 // The helper used for all connections. Owned by the server. | 225 // The helper used for all connections. Owned by the server. |
225 QuicConnectionHelperInterface* helper_; | 226 QuicConnectionHelperInterface* helper_; |
226 | 227 |
227 // An alarm which deletes closed sessions. | 228 // An alarm which deletes closed sessions. |
228 scoped_ptr<QuicAlarm> delete_sessions_alarm_; | 229 scoped_ptr<QuicAlarm> delete_sessions_alarm_; |
229 | 230 |
230 // The list of closed but not-yet-deleted sessions. | 231 // The list of closed but not-yet-deleted sessions. |
231 std::list<QuicSession*> closed_session_list_; | 232 std::list<QuicServerSession*> closed_session_list_; |
232 | 233 |
233 // The writer to write to the socket with. | 234 // The writer to write to the socket with. |
234 scoped_ptr<QuicServerPacketWriter> writer_; | 235 scoped_ptr<QuicServerPacketWriter> writer_; |
235 | 236 |
236 // Used to create per-connection packet writers, not |writer_| itself. | 237 // Used to create per-connection packet writers, not |writer_| itself. |
237 scoped_ptr<PacketWriterFactory> packet_writer_factory_; | 238 scoped_ptr<PacketWriterFactory> packet_writer_factory_; |
238 | 239 |
239 // Passed in to QuicConnection for it to create the per-connection writers | 240 // Passed in to QuicConnection for it to create the per-connection writers |
240 PacketWriterFactoryAdapter connection_writer_factory_; | 241 PacketWriterFactoryAdapter connection_writer_factory_; |
241 | 242 |
(...skipping 10 matching lines...) Expand all Loading... |
252 | 253 |
253 QuicFramer framer_; | 254 QuicFramer framer_; |
254 scoped_ptr<QuicFramerVisitor> framer_visitor_; | 255 scoped_ptr<QuicFramerVisitor> framer_visitor_; |
255 | 256 |
256 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); | 257 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); |
257 }; | 258 }; |
258 | 259 |
259 } // namespace net | 260 } // namespace net |
260 | 261 |
261 #endif // NET_QUIC_QUIC_DISPATCHER_H_ | 262 #endif // NET_QUIC_QUIC_DISPATCHER_H_ |
OLD | NEW |