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