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 18 matching lines...) Expand all Loading... |
29 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); | 29 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); |
30 } | 30 } |
31 }; | 31 }; |
32 } | 32 } |
33 #endif | 33 #endif |
34 | 34 |
35 namespace gfe2 { | 35 namespace gfe2 { |
36 class EpollServer; | 36 class EpollServer; |
37 } | 37 } |
38 | 38 |
| 39 namespace net { |
| 40 |
| 41 class QuicConfig; |
| 42 class QuicCryptoServerConfig; |
39 class QuicSession; | 43 class QuicSession; |
40 | 44 |
41 namespace net { | |
42 namespace tools { | 45 namespace tools { |
43 | 46 |
44 namespace test { | 47 namespace test { |
45 class QuicDispatcherPeer; | 48 class QuicDispatcherPeer; |
46 } // namespace test | 49 } // namespace test |
47 | 50 |
48 class DeleteSessionsAlarm; | 51 class DeleteSessionsAlarm; |
49 | |
50 class QuicDispatcher : public QuicPacketWriter, public QuicSessionOwner { | 52 class QuicDispatcher : public QuicPacketWriter, public QuicSessionOwner { |
51 public: | 53 public: |
52 typedef BlockedList<QuicBlockedWriterInterface*> WriteBlockedList; | 54 typedef BlockedList<QuicBlockedWriterInterface*> WriteBlockedList; |
53 | 55 |
54 // Due to the way delete_sessions_closure_ is registered, the Dispatcher | 56 // Due to the way delete_sessions_closure_ is registered, the Dispatcher |
55 // must live until epoll_server Shutdown. | 57 // must live until epoll_server Shutdown. |
56 QuicDispatcher(int fd, EpollServer* epoll_server); | 58 QuicDispatcher(const QuicConfig& config, |
| 59 const QuicCryptoServerConfig& crypto_config, |
| 60 int fd, |
| 61 EpollServer* epoll_server); |
57 virtual ~QuicDispatcher(); | 62 virtual ~QuicDispatcher(); |
58 | 63 |
59 // QuicPacketWriter | 64 // QuicPacketWriter |
60 virtual int WritePacket(const char* buffer, size_t buf_len, | 65 virtual int WritePacket(const char* buffer, size_t buf_len, |
61 const IPAddressNumber& self_address, | 66 const IPAddressNumber& self_address, |
62 const IPEndPoint& peer_address, | 67 const IPEndPoint& peer_address, |
63 QuicBlockedWriterInterface* writer, | 68 QuicBlockedWriterInterface* writer, |
64 int* error) OVERRIDE; | 69 int* error) OVERRIDE; |
65 | 70 |
66 virtual void ProcessPacket(const IPEndPoint& server_address, | 71 virtual void ProcessPacket(const IPEndPoint& server_address, |
(...skipping 24 matching lines...) Expand all Loading... |
91 int fd, | 96 int fd, |
92 EpollServer* epoll_server); | 97 EpollServer* epoll_server); |
93 | 98 |
94 // Deletes all sessions on the closed session list and clears the list. | 99 // Deletes all sessions on the closed session list and clears the list. |
95 void DeleteSessions(); | 100 void DeleteSessions(); |
96 | 101 |
97 const SessionMap& session_map() const { return session_map_; } | 102 const SessionMap& session_map() const { return session_map_; } |
98 | 103 |
99 WriteBlockedList* write_blocked_list() { return &write_blocked_list_; } | 104 WriteBlockedList* write_blocked_list() { return &write_blocked_list_; } |
100 | 105 |
| 106 protected: |
| 107 const QuicConfig& config_; |
| 108 const QuicCryptoServerConfig& crypto_config_; |
| 109 |
101 private: | 110 private: |
102 friend class net::tools::test::QuicDispatcherPeer; | 111 friend class net::tools::test::QuicDispatcherPeer; |
103 | 112 |
104 // Removes the session from the session map and write blocked list, and | 113 // Removes the session from the session map and write blocked list, and |
105 // adds the GUID to the time-wait list. | 114 // adds the GUID to the time-wait list. |
106 void CleanUpSession(SessionMap::iterator it); | 115 void CleanUpSession(SessionMap::iterator it); |
107 | 116 |
108 // The list of connections waiting to write. | 117 // The list of connections waiting to write. |
109 WriteBlockedList write_blocked_list_; | 118 WriteBlockedList write_blocked_list_; |
110 | 119 |
(...skipping 17 matching lines...) Expand all Loading... |
128 // False if we have gotten a call to OnCanWrite after the last failed write. | 137 // False if we have gotten a call to OnCanWrite after the last failed write. |
129 bool write_blocked_; | 138 bool write_blocked_; |
130 | 139 |
131 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); | 140 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); |
132 }; | 141 }; |
133 | 142 |
134 } // namespace tools | 143 } // namespace tools |
135 } // namespace net | 144 } // namespace net |
136 | 145 |
137 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ | 146 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ |
OLD | NEW |