Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(964)

Side by Side Diff: net/tools/quic/quic_dispatcher.h

Issue 1031243002: Unify the QUIC dispatcher and make the QuicServer work. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix iOS Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/test_tools/quic_test_utils.cc ('k') | net/tools/quic/quic_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 23 matching lines...) Expand all
34 34
35 class ProcessPacketInterface { 35 class ProcessPacketInterface {
36 public: 36 public:
37 virtual ~ProcessPacketInterface() {} 37 virtual ~ProcessPacketInterface() {}
38 virtual void ProcessPacket(const IPEndPoint& server_address, 38 virtual void ProcessPacket(const IPEndPoint& server_address,
39 const IPEndPoint& client_address, 39 const IPEndPoint& client_address,
40 const QuicEncryptedPacket& packet) = 0; 40 const QuicEncryptedPacket& packet) = 0;
41 }; 41 };
42 42
43 class QuicDispatcher : public QuicServerSessionVisitor, 43 class QuicDispatcher : public QuicServerSessionVisitor,
44 public ProcessPacketInterface { 44 public ProcessPacketInterface,
45 public QuicBlockedWriterInterface {
45 public: 46 public:
46 // Creates per-connection packet writers out of the QuicDispatcher's shared 47 // Creates per-connection packet writers out of the QuicDispatcher's shared
47 // QuicPacketWriter. The per-connection writers' IsWriteBlocked() state must 48 // QuicPacketWriter. The per-connection writers' IsWriteBlocked() state must
48 // always be the same as the shared writer's IsWriteBlocked(), or else the 49 // always be the same as the shared writer's IsWriteBlocked(), or else the
49 // QuicDispatcher::OnCanWrite logic will not work. (This will hopefully be 50 // QuicDispatcher::OnCanWrite logic will not work. (This will hopefully be
50 // cleaned up for bug 16950226.) 51 // cleaned up for bug 16950226.)
51 class PacketWriterFactory { 52 class PacketWriterFactory {
52 public: 53 public:
53 virtual ~PacketWriterFactory() {} 54 virtual ~PacketWriterFactory() {}
54 55
(...skipping 18 matching lines...) Expand all
73 // of supported QUIC versions. Takes ownership of |packet_writer_factory|, 74 // of supported QUIC versions. Takes ownership of |packet_writer_factory|,
74 // which is used to create per-connection writers. 75 // which is used to create per-connection writers.
75 QuicDispatcher(const QuicConfig& config, 76 QuicDispatcher(const QuicConfig& config,
76 const QuicCryptoServerConfig& crypto_config, 77 const QuicCryptoServerConfig& crypto_config,
77 const QuicVersionVector& supported_versions, 78 const QuicVersionVector& supported_versions,
78 PacketWriterFactory* packet_writer_factory, 79 PacketWriterFactory* packet_writer_factory,
79 QuicConnectionHelperInterface* helper); 80 QuicConnectionHelperInterface* helper);
80 81
81 ~QuicDispatcher() override; 82 ~QuicDispatcher() override;
82 83
83 virtual void Initialize(int fd); 84 // Takes ownership of |writer|.
85 void InitializeWithWriter(QuicPacketWriter* writer);
84 86
85 // Process the incoming packet by creating a new session, passing it to 87 // Process the incoming packet by creating a new session, passing it to
86 // an existing session, or passing it to the TimeWaitListManager. 88 // an existing session, or passing it to the TimeWaitListManager.
87 void ProcessPacket(const IPEndPoint& server_address, 89 void ProcessPacket(const IPEndPoint& server_address,
88 const IPEndPoint& client_address, 90 const IPEndPoint& client_address,
89 const QuicEncryptedPacket& packet) override; 91 const QuicEncryptedPacket& packet) override;
90 92
91 // Called when the socket becomes writable to allow queued writes to happen. 93 // Called When the socket becomes writable to allow queued writes to happen.
ramant (doing other things) 2015/03/26 00:01:38 overly overly nit: "Called When" -> "Called when"?
Ryan Hamilton 2015/03/26 03:50:26 Done.
92 virtual void OnCanWrite(); 94 void OnCanWrite() override;
93 95
94 // Returns true if there's anything in the blocked writer list. 96 // Returns true if there's anything in the blocked writer list.
95 virtual bool HasPendingWrites() const; 97 virtual bool HasPendingWrites() const;
96 98
97 // Sends ConnectionClose frames to all connected clients. 99 // Sends ConnectionClose frames to all connected clients.
98 void Shutdown(); 100 void Shutdown();
99 101
100 // QuicServerSessionVisitor interface implementation: 102 // QuicServerSessionVisitor interface implementation:
101 // Ensure that the closed connection is cleaned up asynchronously. 103 // Ensure that the closed connection is cleaned up asynchronously.
102 void OnConnectionClosed(QuicConnectionId connection_id, 104 void OnConnectionClosed(QuicConnectionId connection_id,
(...skipping 12 matching lines...) Expand all
115 QuicConnectionId connection_id) override; 117 QuicConnectionId connection_id) override;
116 118
117 typedef base::hash_map<QuicConnectionId, QuicServerSession*> SessionMap; 119 typedef base::hash_map<QuicConnectionId, QuicServerSession*> SessionMap;
118 120
119 const SessionMap& session_map() const { return session_map_; } 121 const SessionMap& session_map() const { return session_map_; }
120 122
121 // Deletes all sessions on the closed session list and clears the list. 123 // Deletes all sessions on the closed session list and clears the list.
122 void DeleteSessions(); 124 void DeleteSessions();
123 125
124 protected: 126 protected:
125 // Instantiates a new low-level packet writer. Caller takes ownership of the
126 // returned object.
127 virtual QuicPacketWriter* CreateWriter(int fd);
128
129 virtual QuicServerSession* CreateQuicSession( 127 virtual QuicServerSession* CreateQuicSession(
130 QuicConnectionId connection_id, 128 QuicConnectionId connection_id,
131 const IPEndPoint& server_address, 129 const IPEndPoint& server_address,
132 const IPEndPoint& client_address); 130 const IPEndPoint& client_address);
133 131
134 // Called by |framer_visitor_| when the public header has been parsed. 132 // Called by |framer_visitor_| when the public header has been parsed.
135 virtual bool OnUnauthenticatedPublicHeader( 133 virtual bool OnUnauthenticatedPublicHeader(
136 const QuicPacketPublicHeader& header); 134 const QuicPacketPublicHeader& header);
137 135
138 // Called by OnUnauthenticatedPublicHeader when the packet is not for a 136 // Called by OnUnauthenticatedPublicHeader when the packet is not for a
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 QuicFramer framer_; 253 QuicFramer framer_;
256 scoped_ptr<QuicFramerVisitor> framer_visitor_; 254 scoped_ptr<QuicFramerVisitor> framer_visitor_;
257 255
258 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); 256 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher);
259 }; 257 };
260 258
261 } // namespace tools 259 } // namespace tools
262 } // namespace net 260 } // namespace net
263 261
264 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ 262 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.cc ('k') | net/tools/quic/quic_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698