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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 class QuicPacketWriterWrapper; | 44 class QuicPacketWriterWrapper; |
45 | 45 |
46 namespace test { | 46 namespace test { |
47 class QuicDispatcherPeer; | 47 class QuicDispatcherPeer; |
48 } // namespace test | 48 } // namespace test |
49 | 49 |
50 class DeleteSessionsAlarm; | 50 class DeleteSessionsAlarm; |
51 class QuicEpollConnectionHelper; | 51 class QuicEpollConnectionHelper; |
52 | 52 |
53 class QuicDispatcher : public QuicServerSessionVisitor { | 53 class ProcessPacketInterface { |
| 54 public: |
| 55 virtual ~ProcessPacketInterface() {} |
| 56 virtual void ProcessPacket(const IPEndPoint& server_address, |
| 57 const IPEndPoint& client_address, |
| 58 const QuicEncryptedPacket& packet) = 0; |
| 59 }; |
| 60 |
| 61 class QuicDispatcher : public QuicServerSessionVisitor, |
| 62 public ProcessPacketInterface { |
54 public: | 63 public: |
55 // Ideally we'd have a linked_hash_set: the boolean is unused. | 64 // Ideally we'd have a linked_hash_set: the boolean is unused. |
56 typedef linked_hash_map<QuicBlockedWriterInterface*, bool> WriteBlockedList; | 65 typedef linked_hash_map<QuicBlockedWriterInterface*, bool> WriteBlockedList; |
57 | 66 |
58 // Due to the way delete_sessions_closure_ is registered, the Dispatcher | 67 // Due to the way delete_sessions_closure_ is registered, the Dispatcher |
59 // must live until epoll_server Shutdown. |supported_versions| specifies the | 68 // must live until epoll_server Shutdown. |supported_versions| specifies the |
60 // list of supported QUIC versions. | 69 // list of supported QUIC versions. |
61 QuicDispatcher(const QuicConfig& config, | 70 QuicDispatcher(const QuicConfig& config, |
62 const QuicCryptoServerConfig& crypto_config, | 71 const QuicCryptoServerConfig& crypto_config, |
63 const QuicVersionVector& supported_versions, | 72 const QuicVersionVector& supported_versions, |
64 EpollServer* epoll_server); | 73 EpollServer* epoll_server); |
65 | 74 |
66 virtual ~QuicDispatcher(); | 75 virtual ~QuicDispatcher(); |
67 | 76 |
68 virtual void Initialize(int fd); | 77 virtual void Initialize(int fd); |
69 | 78 |
70 // Process the incoming packet by creating a new session, passing it to | 79 // Process the incoming packet by creating a new session, passing it to |
71 // an existing session, or passing it to the TimeWaitListManager. | 80 // an existing session, or passing it to the TimeWaitListManager. |
72 virtual void ProcessPacket(const IPEndPoint& server_address, | 81 virtual void ProcessPacket(const IPEndPoint& server_address, |
73 const IPEndPoint& client_address, | 82 const IPEndPoint& client_address, |
74 const QuicEncryptedPacket& packet); | 83 const QuicEncryptedPacket& packet) OVERRIDE; |
75 | 84 |
76 // Called when the socket becomes writable to allow queued writes to happen. | 85 // Called when the socket becomes writable to allow queued writes to happen. |
77 virtual void OnCanWrite(); | 86 virtual void OnCanWrite(); |
78 | 87 |
79 // Returns true if there's anything in the blocked writer list. | 88 // Returns true if there's anything in the blocked writer list. |
80 virtual bool HasPendingWrites() const; | 89 virtual bool HasPendingWrites() const; |
81 | 90 |
82 // Sends ConnectionClose frames to all connected clients. | 91 // Sends ConnectionClose frames to all connected clients. |
83 void Shutdown(); | 92 void Shutdown(); |
84 | 93 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 QuicTimeWaitListManager* time_wait_list_manager() { | 138 QuicTimeWaitListManager* time_wait_list_manager() { |
130 return time_wait_list_manager_.get(); | 139 return time_wait_list_manager_.get(); |
131 } | 140 } |
132 | 141 |
133 EpollServer* epoll_server() { return epoll_server_; } | 142 EpollServer* epoll_server() { return epoll_server_; } |
134 | 143 |
135 const QuicVersionVector& supported_versions() const { | 144 const QuicVersionVector& supported_versions() const { |
136 return supported_versions_; | 145 return supported_versions_; |
137 } | 146 } |
138 | 147 |
139 const QuicVersionVector& supported_versions_no_flow_control() const { | |
140 return supported_versions_no_flow_control_; | |
141 } | |
142 | |
143 const QuicVersionVector& supported_versions_no_connection_flow_control() | 148 const QuicVersionVector& supported_versions_no_connection_flow_control() |
144 const { | 149 const { |
145 return supported_versions_no_connection_flow_control_; | 150 return supported_versions_no_connection_flow_control_; |
146 } | 151 } |
147 | 152 |
148 const IPEndPoint& current_server_address() { | 153 const IPEndPoint& current_server_address() { |
149 return current_server_address_; | 154 return current_server_address_; |
150 } | 155 } |
151 const IPEndPoint& current_client_address() { | 156 const IPEndPoint& current_client_address() { |
152 return current_client_address_; | 157 return current_client_address_; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 209 |
205 // The writer to write to the socket with. | 210 // The writer to write to the socket with. |
206 scoped_ptr<QuicPacketWriter> writer_; | 211 scoped_ptr<QuicPacketWriter> writer_; |
207 | 212 |
208 // This vector contains QUIC versions which we currently support. | 213 // This vector contains QUIC versions which we currently support. |
209 // This should be ordered such that the highest supported version is the first | 214 // This should be ordered such that the highest supported version is the first |
210 // element, with subsequent elements in descending order (versions can be | 215 // element, with subsequent elements in descending order (versions can be |
211 // skipped as necessary). | 216 // skipped as necessary). |
212 const QuicVersionVector supported_versions_; | 217 const QuicVersionVector supported_versions_; |
213 | 218 |
214 // Versions which do not support flow control (introduced in QUIC_VERSION_17). | |
215 // This is used to construct new QuicConnections when flow control is disabled | |
216 // via flag. | |
217 // TODO(rjshade): Remove this when | |
218 // FLAGS_enable_quic_stream_flow_control_2 is removed. | |
219 QuicVersionVector supported_versions_no_flow_control_; | |
220 // Versions which do not support *connection* flow control (introduced in | 219 // Versions which do not support *connection* flow control (introduced in |
221 // QUIC_VERSION_19). | 220 // QUIC_VERSION_19). |
222 // This is used to construct new QuicConnections when connection flow control | 221 // This is used to construct new QuicConnections when connection flow control |
223 // is disabled via flag. | 222 // is disabled via flag. |
224 // TODO(rjshade): Remove this when | 223 // TODO(rjshade): Remove this when |
225 // FLAGS_enable_quic_connection_flow_control_2 is removed. | 224 // FLAGS_enable_quic_connection_flow_control_2 is removed. |
226 QuicVersionVector supported_versions_no_connection_flow_control_; | 225 QuicVersionVector supported_versions_no_connection_flow_control_; |
227 | 226 |
228 // Information about the packet currently being handled. | 227 // Information about the packet currently being handled. |
229 IPEndPoint current_client_address_; | 228 IPEndPoint current_client_address_; |
230 IPEndPoint current_server_address_; | 229 IPEndPoint current_server_address_; |
231 const QuicEncryptedPacket* current_packet_; | 230 const QuicEncryptedPacket* current_packet_; |
232 | 231 |
233 QuicFramer framer_; | 232 QuicFramer framer_; |
234 scoped_ptr<QuicFramerVisitor> framer_visitor_; | 233 scoped_ptr<QuicFramerVisitor> framer_visitor_; |
235 | 234 |
236 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); | 235 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); |
237 }; | 236 }; |
238 | 237 |
239 } // namespace tools | 238 } // namespace tools |
240 } // namespace net | 239 } // namespace net |
241 | 240 |
242 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ | 241 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ |
OLD | NEW |