| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 public: | 57 public: |
| 58 // Ideally we'd have a linked_hash_set: the boolean is unused. | 58 // Ideally we'd have a linked_hash_set: the boolean is unused. |
| 59 typedef linked_hash_map<QuicBlockedWriterInterface*, bool> WriteBlockedList; | 59 typedef linked_hash_map<QuicBlockedWriterInterface*, bool> WriteBlockedList; |
| 60 | 60 |
| 61 // Due to the way delete_sessions_closure_ is registered, the Dispatcher | 61 // Due to the way delete_sessions_closure_ is registered, the Dispatcher |
| 62 // must live until epoll_server Shutdown. |supported_versions| specifies the | 62 // must live until epoll_server Shutdown. |supported_versions| specifies the |
| 63 // list of supported QUIC versions. | 63 // list of supported QUIC versions. |
| 64 QuicDispatcher(const QuicConfig& config, | 64 QuicDispatcher(const QuicConfig& config, |
| 65 const QuicCryptoServerConfig& crypto_config, | 65 const QuicCryptoServerConfig& crypto_config, |
| 66 const QuicVersionVector& supported_versions, | 66 const QuicVersionVector& supported_versions, |
| 67 int fd, | |
| 68 EpollServer* epoll_server); | 67 EpollServer* epoll_server); |
| 68 |
| 69 virtual ~QuicDispatcher(); | 69 virtual ~QuicDispatcher(); |
| 70 | 70 |
| 71 void Initialize(int fd); |
| 72 |
| 71 // QuicPacketWriter | 73 // QuicPacketWriter |
| 72 virtual WriteResult WritePacket( | 74 virtual WriteResult WritePacket( |
| 73 const char* buffer, size_t buf_len, | 75 const char* buffer, size_t buf_len, |
| 74 const IPAddressNumber& self_address, | 76 const IPAddressNumber& self_address, |
| 75 const IPEndPoint& peer_address, | 77 const IPEndPoint& peer_address, |
| 76 QuicBlockedWriterInterface* writer) OVERRIDE; | 78 QuicBlockedWriterInterface* writer) OVERRIDE; |
| 77 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; | 79 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE; |
| 78 virtual bool IsWriteBlocked() const OVERRIDE; | 80 virtual bool IsWriteBlocked() const OVERRIDE; |
| 79 virtual void SetWritable() OVERRIDE; | 81 virtual void SetWritable() OVERRIDE; |
| 80 | 82 |
| 81 // Process the incoming packet by creating a new session, passing it to | 83 // Process the incoming packet by creating a new session, passing it to |
| 82 // an existing session, or passing it to the TimeWaitListManager. | 84 // an existing session, or passing it to the TimeWaitListManager. |
| 83 virtual void ProcessPacket(const IPEndPoint& server_address, | 85 virtual void ProcessPacket(const IPEndPoint& server_address, |
| 84 const IPEndPoint& client_address, | 86 const IPEndPoint& client_address, |
| 85 const QuicEncryptedPacket& packet); | 87 const QuicEncryptedPacket& packet); |
| 86 | 88 |
| 87 // Called when the underyling connection becomes writable to allow | 89 // Called when the underyling connection becomes writable to allow |
| 88 // queued writes to happen. | 90 // queued writes to happen. |
| 89 // | 91 // |
| 90 // Returns true if more writes are possible, false otherwise. | 92 // Returns true if more writes are possible, false otherwise. |
| 91 virtual bool OnCanWrite(); | 93 virtual bool OnCanWrite(); |
| 92 | 94 |
| 93 // Sends ConnectionClose frames to all connected clients. | 95 // Sends ConnectionClose frames to all connected clients. |
| 94 void Shutdown(); | 96 void Shutdown(); |
| 95 | 97 |
| 96 // Ensure that the closed connection is cleaned up asynchronously. | 98 // Ensure that the closed connection is cleaned up asynchronously. |
| 97 virtual void OnConnectionClosed(QuicGuid guid, QuicErrorCode error) OVERRIDE; | 99 virtual void OnConnectionClosed(QuicGuid guid, QuicErrorCode error) OVERRIDE; |
| 98 | 100 |
| 99 // Replaces the packet writer with one that uses |fd|. | |
| 100 void set_fd(int fd); | |
| 101 | |
| 102 typedef base::hash_map<QuicGuid, QuicSession*> SessionMap; | 101 typedef base::hash_map<QuicGuid, QuicSession*> SessionMap; |
| 103 | 102 |
| 104 virtual QuicSession* CreateQuicSession( | 103 virtual QuicSession* CreateQuicSession( |
| 105 QuicGuid guid, | 104 QuicGuid guid, |
| 106 const IPEndPoint& server_address, | 105 const IPEndPoint& server_address, |
| 107 const IPEndPoint& client_address); | 106 const IPEndPoint& client_address); |
| 108 | 107 |
| 109 // Deletes all sessions on the closed session list and clears the list. | 108 // Deletes all sessions on the closed session list and clears the list. |
| 110 void DeleteSessions(); | 109 void DeleteSessions(); |
| 111 | 110 |
| 112 const SessionMap& session_map() const { return session_map_; } | 111 const SessionMap& session_map() const { return session_map_; } |
| 113 | 112 |
| 114 WriteBlockedList* write_blocked_list() { return &write_blocked_list_; } | 113 WriteBlockedList* write_blocked_list() { return &write_blocked_list_; } |
| 115 | 114 |
| 116 protected: | 115 protected: |
| 116 // Instantiates a new low-level packet writer. Caller takes ownership of the |
| 117 // returned object. |
| 118 QuicPacketWriter* CreateWriter(int fd); |
| 119 |
| 120 // Instantiates a new top-level writer wrapper. Takes ownership of |writer|. |
| 121 // Caller takes ownership of the returned object. |
| 122 virtual QuicPacketWriterWrapper* CreateWriterWrapper( |
| 123 QuicPacketWriter* writer); |
| 124 |
| 125 // Replaces the packet writer with |writer|. Takes ownership of |writer|. |
| 126 void set_writer(QuicPacketWriter* writer); |
| 127 |
| 117 QuicTimeWaitListManager* time_wait_list_manager() { | 128 QuicTimeWaitListManager* time_wait_list_manager() { |
| 118 return time_wait_list_manager_.get(); | 129 return time_wait_list_manager_.get(); |
| 119 } | 130 } |
| 120 | 131 |
| 121 QuicEpollConnectionHelper* helper() { return helper_.get(); } | 132 QuicEpollConnectionHelper* helper() { return helper_.get(); } |
| 122 EpollServer* epoll_server() { return epoll_server_; } | 133 EpollServer* epoll_server() { return epoll_server_; } |
| 123 | 134 |
| 124 const QuicVersionVector& supported_versions() const { | 135 const QuicVersionVector& supported_versions() const { |
| 125 return supported_versions_; | 136 return supported_versions_; |
| 126 } | 137 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 QuicFramer framer_; | 211 QuicFramer framer_; |
| 201 scoped_ptr<QuicFramerVisitor> framer_visitor_; | 212 scoped_ptr<QuicFramerVisitor> framer_visitor_; |
| 202 | 213 |
| 203 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); | 214 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); |
| 204 }; | 215 }; |
| 205 | 216 |
| 206 } // namespace tools | 217 } // namespace tools |
| 207 } // namespace net | 218 } // namespace net |
| 208 | 219 |
| 209 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ | 220 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ |
| OLD | NEW |