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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 EpollServer* epoll_server); | 64 EpollServer* epoll_server); |
65 virtual ~QuicDispatcher(); | 65 virtual ~QuicDispatcher(); |
66 | 66 |
67 // QuicPacketWriter | 67 // QuicPacketWriter |
68 virtual WriteResult WritePacket( | 68 virtual WriteResult WritePacket( |
69 const char* buffer, size_t buf_len, | 69 const char* buffer, size_t buf_len, |
70 const IPAddressNumber& self_address, | 70 const IPAddressNumber& self_address, |
71 const IPEndPoint& peer_address, | 71 const IPEndPoint& peer_address, |
72 QuicBlockedWriterInterface* writer) OVERRIDE; | 72 QuicBlockedWriterInterface* writer) OVERRIDE; |
73 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; | 73 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; |
| 74 virtual bool IsWriteBlocked() const OVERRIDE; |
| 75 virtual void SetWritable() OVERRIDE; |
74 | 76 |
75 // Process the incoming packet by creating a new session, passing it to | 77 // Process the incoming packet by creating a new session, passing it to |
76 // an existing session, or passing it to the TimeWaitListManager. | 78 // an existing session, or passing it to the TimeWaitListManager. |
77 virtual void ProcessPacket(const IPEndPoint& server_address, | 79 virtual void ProcessPacket(const IPEndPoint& server_address, |
78 const IPEndPoint& client_address, | 80 const IPEndPoint& client_address, |
79 const QuicEncryptedPacket& packet); | 81 const QuicEncryptedPacket& packet); |
80 | 82 |
81 // Called when the underyling connection becomes writable to allow | 83 // Called when the underyling connection becomes writable to allow |
82 // queued writes to happen. | 84 // queued writes to happen. |
83 // | 85 // |
(...skipping 14 matching lines...) Expand all Loading... |
98 virtual QuicSession* CreateQuicSession( | 100 virtual QuicSession* CreateQuicSession( |
99 QuicGuid guid, | 101 QuicGuid guid, |
100 const IPEndPoint& server_address, | 102 const IPEndPoint& server_address, |
101 const IPEndPoint& client_address); | 103 const IPEndPoint& client_address); |
102 | 104 |
103 // Deletes all sessions on the closed session list and clears the list. | 105 // Deletes all sessions on the closed session list and clears the list. |
104 void DeleteSessions(); | 106 void DeleteSessions(); |
105 | 107 |
106 const SessionMap& session_map() const { return session_map_; } | 108 const SessionMap& session_map() const { return session_map_; } |
107 | 109 |
108 // Uses the specified |writer| instead of QuicSocketUtils and takes ownership | |
109 // of writer. | |
110 void UseWriter(QuicPacketWriter* writer); | |
111 | |
112 WriteBlockedList* write_blocked_list() { return &write_blocked_list_; } | 110 WriteBlockedList* write_blocked_list() { return &write_blocked_list_; } |
113 | 111 |
114 protected: | 112 protected: |
115 const QuicConfig& config_; | 113 const QuicConfig& config_; |
116 const QuicCryptoServerConfig& crypto_config_; | 114 const QuicCryptoServerConfig& crypto_config_; |
117 | 115 |
118 QuicTimeWaitListManager* time_wait_list_manager() { | 116 QuicTimeWaitListManager* time_wait_list_manager() { |
119 return time_wait_list_manager_.get(); | 117 return time_wait_list_manager_.get(); |
120 } | 118 } |
121 | 119 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 scoped_ptr<DeleteSessionsAlarm> delete_sessions_alarm_; | 166 scoped_ptr<DeleteSessionsAlarm> delete_sessions_alarm_; |
169 | 167 |
170 // The list of closed but not-yet-deleted sessions. | 168 // The list of closed but not-yet-deleted sessions. |
171 std::list<QuicSession*> closed_session_list_; | 169 std::list<QuicSession*> closed_session_list_; |
172 | 170 |
173 EpollServer* epoll_server_; // Owned by the server. | 171 EpollServer* epoll_server_; // Owned by the server. |
174 | 172 |
175 // The connection for client-server communication | 173 // The connection for client-server communication |
176 int fd_; | 174 int fd_; |
177 | 175 |
178 // True if the session is write blocked due to the socket returning EAGAIN. | |
179 // False if we have gotten a call to OnCanWrite after the last failed write. | |
180 bool write_blocked_; | |
181 | |
182 // The helper used for all connections. | 176 // The helper used for all connections. |
183 scoped_ptr<QuicEpollConnectionHelper> helper_; | 177 scoped_ptr<QuicEpollConnectionHelper> helper_; |
184 | 178 |
185 // The writer to write to the socket with. | 179 // The writer to write to the socket with. |
186 scoped_ptr<QuicPacketWriter> writer_; | 180 scoped_ptr<QuicPacketWriter> writer_; |
187 | 181 |
188 // This vector contains QUIC versions which we currently support. | 182 // This vector contains QUIC versions which we currently support. |
189 // This should be ordered such that the highest supported version is the first | 183 // This should be ordered such that the highest supported version is the first |
190 // element, with subsequent elements in descending order (versions can be | 184 // element, with subsequent elements in descending order (versions can be |
191 // skipped as necessary). | 185 // skipped as necessary). |
192 const QuicVersionVector supported_versions_; | 186 const QuicVersionVector supported_versions_; |
193 | 187 |
194 // Information about the packet currently being handled. | 188 // Information about the packet currently being handled. |
195 IPEndPoint current_client_address_; | 189 IPEndPoint current_client_address_; |
196 IPEndPoint current_server_address_; | 190 IPEndPoint current_server_address_; |
197 const QuicEncryptedPacket* current_packet_; | 191 const QuicEncryptedPacket* current_packet_; |
198 | 192 |
199 QuicFramer framer_; | 193 QuicFramer framer_; |
200 scoped_ptr<QuicFramerVisitor> framer_visitor_; | 194 scoped_ptr<QuicFramerVisitor> framer_visitor_; |
201 | 195 |
202 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); | 196 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); |
203 }; | 197 }; |
204 | 198 |
205 } // namespace tools | 199 } // namespace tools |
206 } // namespace net | 200 } // namespace net |
207 | 201 |
208 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ | 202 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ |
OLD | NEW |