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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 QuicConnection* connection) = 0; | 61 QuicConnection* connection) = 0; |
62 }; | 62 }; |
63 | 63 |
64 // Creates ordinary QuicPerConnectionPacketWriter instances. | 64 // Creates ordinary QuicPerConnectionPacketWriter instances. |
65 class DefaultPacketWriterFactory : public PacketWriterFactory { | 65 class DefaultPacketWriterFactory : public PacketWriterFactory { |
66 public: | 66 public: |
67 virtual ~DefaultPacketWriterFactory() {} | 67 virtual ~DefaultPacketWriterFactory() {} |
68 | 68 |
69 virtual QuicPacketWriter* Create( | 69 virtual QuicPacketWriter* Create( |
70 QuicPacketWriter* writer, | 70 QuicPacketWriter* writer, |
71 QuicConnection* connection) OVERRIDE; | 71 QuicConnection* connection) override; |
72 }; | 72 }; |
73 | 73 |
74 // Ideally we'd have a linked_hash_set: the boolean is unused. | 74 // Ideally we'd have a linked_hash_set: the boolean is unused. |
75 typedef linked_hash_map<QuicBlockedWriterInterface*, bool> WriteBlockedList; | 75 typedef linked_hash_map<QuicBlockedWriterInterface*, bool> WriteBlockedList; |
76 | 76 |
77 // Due to the way delete_sessions_closure_ is registered, the Dispatcher must | 77 // Due to the way delete_sessions_closure_ is registered, the Dispatcher must |
78 // live until epoll_server Shutdown. |supported_versions| specifies the list | 78 // live until epoll_server Shutdown. |supported_versions| specifies the list |
79 // of supported QUIC versions. Takes ownership of |packet_writer_factory|, | 79 // of supported QUIC versions. Takes ownership of |packet_writer_factory|, |
80 // which is used to create per-connection writers. | 80 // which is used to create per-connection writers. |
81 QuicDispatcher(const QuicConfig& config, | 81 QuicDispatcher(const QuicConfig& config, |
82 const QuicCryptoServerConfig& crypto_config, | 82 const QuicCryptoServerConfig& crypto_config, |
83 const QuicVersionVector& supported_versions, | 83 const QuicVersionVector& supported_versions, |
84 PacketWriterFactory* packet_writer_factory, | 84 PacketWriterFactory* packet_writer_factory, |
85 EpollServer* epoll_server); | 85 EpollServer* epoll_server); |
86 | 86 |
87 virtual ~QuicDispatcher(); | 87 virtual ~QuicDispatcher(); |
88 | 88 |
89 virtual void Initialize(int fd); | 89 virtual void Initialize(int fd); |
90 | 90 |
91 // Process the incoming packet by creating a new session, passing it to | 91 // Process the incoming packet by creating a new session, passing it to |
92 // an existing session, or passing it to the TimeWaitListManager. | 92 // an existing session, or passing it to the TimeWaitListManager. |
93 virtual void ProcessPacket(const IPEndPoint& server_address, | 93 virtual void ProcessPacket(const IPEndPoint& server_address, |
94 const IPEndPoint& client_address, | 94 const IPEndPoint& client_address, |
95 const QuicEncryptedPacket& packet) OVERRIDE; | 95 const QuicEncryptedPacket& packet) override; |
96 | 96 |
97 // Called when the socket becomes writable to allow queued writes to happen. | 97 // Called when the socket becomes writable to allow queued writes to happen. |
98 virtual void OnCanWrite(); | 98 virtual void OnCanWrite(); |
99 | 99 |
100 // Returns true if there's anything in the blocked writer list. | 100 // Returns true if there's anything in the blocked writer list. |
101 virtual bool HasPendingWrites() const; | 101 virtual bool HasPendingWrites() const; |
102 | 102 |
103 // Sends ConnectionClose frames to all connected clients. | 103 // Sends ConnectionClose frames to all connected clients. |
104 void Shutdown(); | 104 void Shutdown(); |
105 | 105 |
106 // QuicServerSessionVisitor interface implementation: | 106 // QuicServerSessionVisitor interface implementation: |
107 // Ensure that the closed connection is cleaned up asynchronously. | 107 // Ensure that the closed connection is cleaned up asynchronously. |
108 virtual void OnConnectionClosed(QuicConnectionId connection_id, | 108 virtual void OnConnectionClosed(QuicConnectionId connection_id, |
109 QuicErrorCode error) OVERRIDE; | 109 QuicErrorCode error) override; |
110 | 110 |
111 // Queues the blocked writer for later resumption. | 111 // Queues the blocked writer for later resumption. |
112 virtual void OnWriteBlocked( | 112 virtual void OnWriteBlocked( |
113 QuicBlockedWriterInterface* blocked_writer) OVERRIDE; | 113 QuicBlockedWriterInterface* blocked_writer) override; |
114 | 114 |
115 typedef base::hash_map<QuicConnectionId, QuicSession*> SessionMap; | 115 typedef base::hash_map<QuicConnectionId, QuicSession*> SessionMap; |
116 | 116 |
117 // Deletes all sessions on the closed session list and clears the list. | 117 // Deletes all sessions on the closed session list and clears the list. |
118 void DeleteSessions(); | 118 void DeleteSessions(); |
119 | 119 |
120 const SessionMap& session_map() const { return session_map_; } | 120 const SessionMap& session_map() const { return session_map_; } |
121 | 121 |
122 protected: | 122 protected: |
123 // Instantiates a new low-level packet writer. Caller takes ownership of the | 123 // Instantiates a new low-level packet writer. Caller takes ownership of the |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 186 |
187 // An adapter that creates packet writers using the dispatcher's | 187 // An adapter that creates packet writers using the dispatcher's |
188 // PacketWriterFactory and shared writer. Essentially, it just curries the | 188 // PacketWriterFactory and shared writer. Essentially, it just curries the |
189 // writer argument away from QuicDispatcher::PacketWriterFactory. | 189 // writer argument away from QuicDispatcher::PacketWriterFactory. |
190 class PacketWriterFactoryAdapter : | 190 class PacketWriterFactoryAdapter : |
191 public QuicConnection::PacketWriterFactory { | 191 public QuicConnection::PacketWriterFactory { |
192 public: | 192 public: |
193 PacketWriterFactoryAdapter(QuicDispatcher* dispatcher); | 193 PacketWriterFactoryAdapter(QuicDispatcher* dispatcher); |
194 virtual ~PacketWriterFactoryAdapter (); | 194 virtual ~PacketWriterFactoryAdapter (); |
195 | 195 |
196 virtual QuicPacketWriter* Create(QuicConnection* connection) const OVERRIDE; | 196 virtual QuicPacketWriter* Create(QuicConnection* connection) const override; |
197 | 197 |
198 private: | 198 private: |
199 QuicDispatcher* dispatcher_; | 199 QuicDispatcher* dispatcher_; |
200 }; | 200 }; |
201 | 201 |
202 // Called by |framer_visitor_| when the private header has been parsed | 202 // Called by |framer_visitor_| when the private header has been parsed |
203 // of a data packet that is destined for the time wait manager. | 203 // of a data packet that is destined for the time wait manager. |
204 void OnUnauthenticatedHeader(const QuicPacketHeader& header); | 204 void OnUnauthenticatedHeader(const QuicPacketHeader& header); |
205 | 205 |
206 // Removes the session from the session map and write blocked list, and | 206 // Removes the session from the session map and write blocked list, and |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 QuicFramer framer_; | 255 QuicFramer framer_; |
256 scoped_ptr<QuicFramerVisitor> framer_visitor_; | 256 scoped_ptr<QuicFramerVisitor> framer_visitor_; |
257 | 257 |
258 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); | 258 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); |
259 }; | 259 }; |
260 | 260 |
261 } // namespace tools | 261 } // namespace tools |
262 } // namespace net | 262 } // namespace net |
263 | 263 |
264 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ | 264 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ |
OLD | NEW |