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

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

Issue 2326073002: Refactor QuicCryptoServerStream. (Closed)
Patch Set: Created 4 years, 3 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
11 #include <memory> 11 #include <memory>
12 #include <unordered_map> 12 #include <unordered_map>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "net/base/ip_endpoint.h" 16 #include "net/base/ip_endpoint.h"
17 #include "net/base/linked_hash_map.h" 17 #include "net/base/linked_hash_map.h"
18 #include "net/quic/core/crypto/quic_compressed_certs_cache.h" 18 #include "net/quic/core/crypto/quic_compressed_certs_cache.h"
19 #include "net/quic/core/crypto/quic_random.h" 19 #include "net/quic/core/crypto/quic_random.h"
20 #include "net/quic/core/quic_blocked_writer_interface.h" 20 #include "net/quic/core/quic_blocked_writer_interface.h"
21 #include "net/quic/core/quic_buffered_packet_store.h" 21 #include "net/quic/core/quic_buffered_packet_store.h"
22 #include "net/quic/core/quic_connection.h" 22 #include "net/quic/core/quic_connection.h"
23 #include "net/quic/core/quic_crypto_server_stream.h"
23 #include "net/quic/core/quic_protocol.h" 24 #include "net/quic/core/quic_protocol.h"
24 #include "net/quic/core/quic_server_session_base.h" 25 #include "net/quic/core/quic_server_session_base.h"
25 26
26 #include "net/tools/quic/stateless_rejector.h" 27 #include "net/tools/quic/stateless_rejector.h"
27 #include "net/tools/quic/quic_process_packet_interface.h" 28 #include "net/tools/quic/quic_process_packet_interface.h"
28 #include "net/tools/quic/quic_time_wait_list_manager.h" 29 #include "net/tools/quic/quic_time_wait_list_manager.h"
29 30
30 namespace net { 31 namespace net {
31 32
32 class QuicConfig; 33 class QuicConfig;
33 class QuicCryptoServerConfig; 34 class QuicCryptoServerConfig;
34 class QuicServerSessionBase;
35 35
36 namespace test { 36 namespace test {
37 class QuicDispatcherPeer; 37 class QuicDispatcherPeer;
38 } // namespace test 38 } // namespace test
39 39
40 class QuicDispatcher : public QuicServerSessionBase::Visitor, 40 class QuicDispatcher : public QuicServerSessionBase::Visitor,
41 public ProcessPacketInterface, 41 public ProcessPacketInterface,
42 public QuicBlockedWriterInterface, 42 public QuicBlockedWriterInterface,
43 public QuicFramerVisitorInterface, 43 public QuicFramerVisitorInterface,
44 public QuicBufferedPacketStore::VisitorInterface { 44 public QuicBufferedPacketStore::VisitorInterface {
45 public: 45 public:
46 // Ideally we'd have a linked_hash_set: the boolean is unused. 46 // Ideally we'd have a linked_hash_set: the boolean is unused.
47 typedef linked_hash_map<QuicBlockedWriterInterface*, 47 typedef linked_hash_map<QuicBlockedWriterInterface*,
48 bool, 48 bool,
49 QuicBlockedWriterInterfacePtrHash> 49 QuicBlockedWriterInterfacePtrHash>
50 WriteBlockedList; 50 WriteBlockedList;
51 51
52 QuicDispatcher(const QuicConfig& config, 52 QuicDispatcher(const QuicConfig& config,
53 const QuicCryptoServerConfig* crypto_config, 53 const QuicCryptoServerConfig* crypto_config,
54 QuicVersionManager* version_manager, 54 QuicVersionManager* version_manager,
55 std::unique_ptr<QuicConnectionHelperInterface> helper, 55 std::unique_ptr<QuicConnectionHelperInterface> helper,
56 std::unique_ptr<QuicServerSessionBase::Helper> session_helper, 56 std::unique_ptr<QuicCryptoServerStream::Helper> session_helper,
57 std::unique_ptr<QuicAlarmFactory> alarm_factory); 57 std::unique_ptr<QuicAlarmFactory> alarm_factory);
58 58
59 ~QuicDispatcher() override; 59 ~QuicDispatcher() override;
60 60
61 // Takes ownership of |writer|. 61 // Takes ownership of |writer|.
62 void InitializeWithWriter(QuicPacketWriter* writer); 62 void InitializeWithWriter(QuicPacketWriter* writer);
63 63
64 // Process the incoming packet by creating a new session, passing it to 64 // Process the incoming packet by creating a new session, passing it to
65 // an existing session, or passing it to the time wait list. 65 // an existing session, or passing it to the time wait list.
66 void ProcessPacket(const IPEndPoint& server_address, 66 void ProcessPacket(const IPEndPoint& server_address,
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 const QuicCryptoServerConfig* crypto_config() const { return crypto_config_; } 220 const QuicCryptoServerConfig* crypto_config() const { return crypto_config_; }
221 221
222 QuicCompressedCertsCache* compressed_certs_cache() { 222 QuicCompressedCertsCache* compressed_certs_cache() {
223 return &compressed_certs_cache_; 223 return &compressed_certs_cache_;
224 } 224 }
225 225
226 QuicFramer* framer() { return &framer_; } 226 QuicFramer* framer() { return &framer_; }
227 227
228 QuicConnectionHelperInterface* helper() { return helper_.get(); } 228 QuicConnectionHelperInterface* helper() { return helper_.get(); }
229 229
230 QuicServerSessionBase::Helper* session_helper() { 230 QuicCryptoServerStream::Helper* session_helper() {
231 return session_helper_.get(); 231 return session_helper_.get();
232 } 232 }
233 233
234 QuicAlarmFactory* alarm_factory() { return alarm_factory_.get(); } 234 QuicAlarmFactory* alarm_factory() { return alarm_factory_.get(); }
235 235
236 QuicPacketWriter* writer() { return writer_.get(); } 236 QuicPacketWriter* writer() { return writer_.get(); }
237 237
238 // Creates per-connection packet writers out of the QuicDispatcher's shared 238 // Creates per-connection packet writers out of the QuicDispatcher's shared
239 // QuicPacketWriter. The per-connection writers' IsWriteBlocked() state must 239 // QuicPacketWriter. The per-connection writers' IsWriteBlocked() state must
240 // always be the same as the shared writer's IsWriteBlocked(), or else the 240 // always be the same as the shared writer's IsWriteBlocked(), or else the
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 // Entity that manages connection_ids in time wait state. 321 // Entity that manages connection_ids in time wait state.
322 std::unique_ptr<QuicTimeWaitListManager> time_wait_list_manager_; 322 std::unique_ptr<QuicTimeWaitListManager> time_wait_list_manager_;
323 323
324 // The list of closed but not-yet-deleted sessions. 324 // The list of closed but not-yet-deleted sessions.
325 std::vector<QuicServerSessionBase*> closed_session_list_; 325 std::vector<QuicServerSessionBase*> closed_session_list_;
326 326
327 // The helper used for all connections. 327 // The helper used for all connections.
328 std::unique_ptr<QuicConnectionHelperInterface> helper_; 328 std::unique_ptr<QuicConnectionHelperInterface> helper_;
329 329
330 // The helper used for all sessions. 330 // The helper used for all sessions.
331 std::unique_ptr<QuicServerSessionBase::Helper> session_helper_; 331 std::unique_ptr<QuicCryptoServerStream::Helper> session_helper_;
332 332
333 // Creates alarms. 333 // Creates alarms.
334 std::unique_ptr<QuicAlarmFactory> alarm_factory_; 334 std::unique_ptr<QuicAlarmFactory> alarm_factory_;
335 335
336 // An alarm which deletes closed sessions. 336 // An alarm which deletes closed sessions.
337 std::unique_ptr<QuicAlarm> delete_sessions_alarm_; 337 std::unique_ptr<QuicAlarm> delete_sessions_alarm_;
338 338
339 // The writer to write to the socket with. 339 // The writer to write to the socket with.
340 std::unique_ptr<QuicPacketWriter> writer_; 340 std::unique_ptr<QuicPacketWriter> writer_;
341 341
(...skipping 19 matching lines...) Expand all
361 // A backward counter of how many new sessions can be create within current 361 // A backward counter of how many new sessions can be create within current
362 // event loop. When reaches 0, it means can't create sessions for now. 362 // event loop. When reaches 0, it means can't create sessions for now.
363 int16_t new_sessions_allowed_per_event_loop_; 363 int16_t new_sessions_allowed_per_event_loop_;
364 364
365 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); 365 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher);
366 }; 366 };
367 367
368 } // namespace net 368 } // namespace net
369 369
370 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ 370 #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