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 28 matching lines...) Expand all Loading... |
39 class QuicPacketWriterWrapper; | 39 class QuicPacketWriterWrapper; |
40 class QuicSession; | 40 class QuicSession; |
41 class UDPServerSocket; | 41 class UDPServerSocket; |
42 | 42 |
43 namespace test { | 43 namespace test { |
44 class QuicDispatcherPeer; | 44 class QuicDispatcherPeer; |
45 } // namespace test | 45 } // namespace test |
46 | 46 |
47 class DeleteSessionsAlarm; | 47 class DeleteSessionsAlarm; |
48 | 48 |
49 class QuicDispatcher : public QuicServerSessionVisitor { | 49 class ProcessPacketInterface { |
| 50 public: |
| 51 virtual ~ProcessPacketInterface() {} |
| 52 virtual void ProcessPacket(const IPEndPoint& server_address, |
| 53 const IPEndPoint& client_address, |
| 54 const QuicEncryptedPacket& packet) = 0; |
| 55 }; |
| 56 |
| 57 class QuicDispatcher : public QuicServerSessionVisitor, |
| 58 public ProcessPacketInterface { |
50 public: | 59 public: |
51 // Ideally we'd have a linked_hash_set: the boolean is unused. | 60 // Ideally we'd have a linked_hash_set: the boolean is unused. |
52 typedef linked_hash_map<QuicBlockedWriterInterface*, bool> WriteBlockedList; | 61 typedef linked_hash_map<QuicBlockedWriterInterface*, bool> WriteBlockedList; |
53 | 62 |
54 // Due to the way delete_sessions_closure_ is registered, the Dispatcher | 63 // Due to the way delete_sessions_closure_ is registered, the Dispatcher |
55 // must live until epoll_server Shutdown. |supported_versions| specifies the | 64 // must live until epoll_server Shutdown. |supported_versions| specifies the |
56 // list of supported QUIC versions. | 65 // list of supported QUIC versions. |
57 QuicDispatcher(const QuicConfig& config, | 66 QuicDispatcher(const QuicConfig& config, |
58 const QuicCryptoServerConfig& crypto_config, | 67 const QuicCryptoServerConfig& crypto_config, |
59 const QuicVersionVector& supported_versions, | 68 const QuicVersionVector& supported_versions, |
60 QuicConnectionHelperInterface* helper); | 69 QuicConnectionHelperInterface* helper); |
61 | 70 |
62 virtual ~QuicDispatcher(); | 71 virtual ~QuicDispatcher(); |
63 | 72 |
64 // Takes ownership of the packet writer | 73 // Takes ownership of the packet writer |
65 virtual void Initialize(QuicPacketWriter* writer); | 74 virtual void Initialize(QuicPacketWriter* writer); |
66 | 75 |
67 // Process the incoming packet by creating a new session, passing it to | 76 // Process the incoming packet by creating a new session, passing it to |
68 // an existing session, or passing it to the TimeWaitListManager. | 77 // an existing session, or passing it to the TimeWaitListManager. |
69 virtual void ProcessPacket(const IPEndPoint& server_address, | 78 virtual void ProcessPacket(const IPEndPoint& server_address, |
70 const IPEndPoint& client_address, | 79 const IPEndPoint& client_address, |
71 const QuicEncryptedPacket& packet); | 80 const QuicEncryptedPacket& packet) OVERRIDE; |
72 | 81 |
73 // Called when the socket becomes writable to allow queued writes to happen. | 82 // Called when the socket becomes writable to allow queued writes to happen. |
74 virtual void OnCanWrite(); | 83 virtual void OnCanWrite(); |
75 | 84 |
76 // Returns true if there's anything in the blocked writer list. | 85 // Returns true if there's anything in the blocked writer list. |
77 virtual bool HasPendingWrites() const; | 86 virtual bool HasPendingWrites() const; |
78 | 87 |
79 // Sends ConnectionClose frames to all connected clients. | 88 // Sends ConnectionClose frames to all connected clients. |
80 void Shutdown(); | 89 void Shutdown(); |
81 | 90 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 230 |
222 QuicFramer framer_; | 231 QuicFramer framer_; |
223 scoped_ptr<QuicFramerVisitor> framer_visitor_; | 232 scoped_ptr<QuicFramerVisitor> framer_visitor_; |
224 | 233 |
225 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); | 234 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); |
226 }; | 235 }; |
227 | 236 |
228 } // namespace net | 237 } // namespace net |
229 | 238 |
230 #endif // NET_QUIC_QUIC_DISPATCHER_H_ | 239 #endif // NET_QUIC_QUIC_DISPATCHER_H_ |
OLD | NEW |