Chromium Code Reviews| Index: net/quic/quic_server.h |
| diff --git a/net/tools/quic/quic_server.h b/net/quic/quic_server.h |
| similarity index 49% |
| copy from net/tools/quic/quic_server.h |
| copy to net/quic/quic_server.h |
| index 119fa78ee4e01352ad0f886843adab9759d9e9aa..788bb3c0463600a1fa7ff002a311dec9921fcc37 100644 |
| --- a/net/tools/quic/quic_server.h |
| +++ b/net/quic/quic_server.h |
| @@ -5,31 +5,32 @@ |
| // A toy server, which listens on a specified address for QUIC traffic and |
| // handles incoming responses. |
| -#ifndef NET_TOOLS_QUIC_QUIC_SERVER_H_ |
| -#define NET_TOOLS_QUIC_QUIC_SERVER_H_ |
| +#ifndef NET_QUIC_QUIC_SERVER_H_ |
| +#define NET_QUIC_QUIC_SERVER_H_ |
| #include "base/basictypes.h" |
| +#include "base/file_util.h" |
|
wtc
2014/06/18 02:04:47
It doesn't seem necessary to include "base/file_ut
dmziegler
2014/06/18 20:13:41
Removed.
|
| #include "base/memory/scoped_ptr.h" |
| +#include "net/base/io_buffer.h" |
| #include "net/base/ip_endpoint.h" |
| #include "net/quic/crypto/quic_crypto_server_config.h" |
| +#include "net/quic/quic_clock.h" |
| #include "net/quic/quic_config.h" |
| #include "net/quic/quic_framer.h" |
|
wtc
2014/06/18 02:04:47
It doesn't seem necessary to include "net/quic/qui
dmziegler
2014/06/18 20:13:41
Removed.
|
| -#include "net/tools/epoll_server/epoll_server.h" |
| -#include "net/tools/quic/quic_dispatcher.h" |
| namespace net { |
| -namespace tools { |
| namespace test { |
| class QuicServerPeer; |
| } // namespace test |
| +class QuicConnectionHelperInterface; |
| class QuicDispatcher; |
| +class UDPServerSocket; |
| -class QuicServer : public EpollCallbackInterface { |
| +class NET_EXPORT_PRIVATE QuicServer { |
| public: |
| - QuicServer(); |
| QuicServer(const QuicConfig& config, |
| const QuicVersionVector& supported_versions, |
| uint32 server_initial_flow_control_receive_window); |
| @@ -39,31 +40,14 @@ class QuicServer : public EpollCallbackInterface { |
| // Start listening on the specified address. |
| bool Listen(const IPEndPoint& address); |
| - // Wait up to 50ms, and handle any events which occur. |
| - void WaitForEvents(); |
| - |
| - // Server deletion is imminent. Start cleaning up the epoll server. |
| + // Server deletion is imminent. Start cleaning up. |
| void Shutdown(); |
| - // From EpollCallbackInterface |
| - virtual void OnRegistration(EpollServer* eps, |
| - int fd, |
| - int event_mask) OVERRIDE {} |
| - virtual void OnModification(int fd, int event_mask) OVERRIDE {} |
| - virtual void OnEvent(int fd, EpollEvent* event) OVERRIDE; |
| - virtual void OnUnregistration(int fd, bool replaced) OVERRIDE {} |
| - |
| - // Reads a packet from the given fd, and then passes it off to |
| - // the QuicDispatcher. Returns true if a packet is read, false |
| - // otherwise. |
| - // If packets_dropped is non-null, the socket is configured to track |
| - // dropped packets, and some packets are read, it will be set to the number of |
| - // dropped packets. |
| - static bool ReadAndDispatchSinglePacket(int fd, int port, |
| - QuicDispatcher* dispatcher, |
| - uint32* packets_dropped); |
| - |
| - virtual void OnShutdown(EpollServer* eps, int fd) OVERRIDE {} |
| + void OnReadComplete(int result); |
|
wtc
2014/06/18 02:04:47
Document this method.
dmziegler
2014/06/18 20:13:41
Done.
|
| + |
| + // Start reading on the socket. After each asynchronous read, OnReadComplete |
| + // will call StartReading again. |
| + void StartReading(); |
| void SetStrikeRegisterNoStartupPeriod() { |
| crypto_config_.set_strike_register_no_startup_period(); |
| @@ -75,40 +59,21 @@ class QuicServer : public EpollCallbackInterface { |
| crypto_config_.SetProofSource(source); |
| } |
| - bool overflow_supported() { return overflow_supported_; } |
| - |
| - uint32 packets_dropped() { return packets_dropped_; } |
| - |
| - int port() { return port_; } |
| - |
| private: |
| - friend class net::tools::test::QuicServerPeer; |
| + friend class net::test::QuicServerPeer; |
| // Initialize the internal state of the server. |
| void Initialize(); |
| // Accepts data from the framer and demuxes clients to sessions. |
| scoped_ptr<QuicDispatcher> dispatcher_; |
| - // Frames incoming packets and hands them to the dispatcher. |
| - EpollServer epoll_server_; |
| - |
| - // The port the server is listening on. |
| - int port_; |
| - |
| - // Listening connection. Also used for outbound client communication. |
| - int fd_; |
| - // If overflow_supported_ is true this will be the number of packets dropped |
| - // during the lifetime of the server. This may overflow if enough packets |
| - // are dropped. |
| - uint32 packets_dropped_; |
| + QuicClock clock_; |
| - // True if the kernel supports SO_RXQ_OVFL, the number of packets dropped |
| - // because the socket would otherwise overflow. |
| - bool overflow_supported_; |
| + QuicConnectionHelperInterface* helper_; |
| - // If true, use recvmmsg for reading. |
| - bool use_recvmmsg_; |
| + // Listening connection. Also used for outbound client communication. |
|
wtc
2014/06/18 02:04:47
"Listening connection" seems wrong. I think this s
dmziegler
2014/06/18 20:13:41
Done.
|
| + scoped_ptr<UDPServerSocket> socket_; |
| // config_ contains non-crypto parameters that are negotiated in the crypto |
| // handshake. |
| @@ -126,10 +91,21 @@ class QuicServer : public EpollCallbackInterface { |
| // connections. |
| uint32 server_initial_flow_control_receive_window_; |
| + IPEndPoint server_address_; |
|
wtc
2014/06/18 02:04:46
Add a comment. Perhaps adapting the original comme
dmziegler
2014/06/18 20:13:41
Done.
|
| + |
| + bool read_pending_; |
| + |
| + int synchronous_read_count_; |
| + |
| + scoped_refptr<IOBufferWithSize> read_buffer_; |
| + |
| + IPEndPoint read_addr_; |
| + |
| + base::WeakPtrFactory<QuicServer> weak_factory_; |
|
wtc
2014/06/18 02:04:47
Except for weak_factory_, all the new data members
dmziegler
2014/06/18 20:13:41
Done.
|
| + |
| DISALLOW_COPY_AND_ASSIGN(QuicServer); |
| }; |
| -} // namespace tools |
| } // namespace net |
| -#endif // NET_TOOLS_QUIC_QUIC_SERVER_H_ |
| +#endif // NET_QUIC_QUIC_SERVER_H_ |