Hookup the PDF extension to the chrome extensions zoom API
[chromium-blink-merge.git] / net / quic / quic_server.h
bloba25627c68cf55e08c319dda4482c966a5108137f
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
3 // found in the LICENSE file.
4 //
5 // A toy server, which listens on a specified address for QUIC traffic and
6 // handles incoming responses.
8 #ifndef NET_QUIC_QUIC_SERVER_H_
9 #define NET_QUIC_QUIC_SERVER_H_
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "net/base/io_buffer.h"
14 #include "net/base/ip_endpoint.h"
15 #include "net/base/net_log.h"
16 #include "net/quic/crypto/quic_crypto_server_config.h"
17 #include "net/quic/quic_clock.h"
18 #include "net/quic/quic_config.h"
19 #include "net/quic/quic_connection_helper.h"
21 namespace net {
24 namespace test {
25 class QuicServerPeer;
26 } // namespace test
28 class QuicConnectionHelperInterface;
29 class QuicDispatcher;
30 class UDPServerSocket;
32 class QuicServer {
33 public:
34 QuicServer(const QuicConfig& config,
35 const QuicVersionVector& supported_versions);
37 virtual ~QuicServer();
39 // Start listening on the specified address. Returns an error code.
40 int Listen(const IPEndPoint& address);
42 // Server deletion is imminent. Start cleaning up.
43 void Shutdown();
45 // Start reading on the socket. On asynchronous reads, this registers
46 // OnReadComplete as the callback, which will then call StartReading again.
47 void StartReading();
49 // Called on reads that complete asynchronously. Dispatches the packet and
50 // continues the read loop.
51 void OnReadComplete(int result);
53 void SetStrikeRegisterNoStartupPeriod() {
54 crypto_config_.set_strike_register_no_startup_period();
57 // SetProofSource sets the ProofSource that will be used to verify the
58 // server's certificate, and takes ownership of |source|.
59 void SetProofSource(ProofSource* source) {
60 crypto_config_.SetProofSource(source);
63 private:
64 friend class net::test::QuicServerPeer;
66 // Initialize the internal state of the server.
67 void Initialize();
69 // Accepts data from the framer and demuxes clients to sessions.
70 scoped_ptr<QuicDispatcher> dispatcher_;
72 // Used by the helper_ to time alarms.
73 QuicClock clock_;
75 // Used to manage the message loop.
76 QuicConnectionHelper helper_;
78 // Listening socket. Also used for outbound client communication.
79 scoped_ptr<UDPServerSocket> socket_;
81 // config_ contains non-crypto parameters that are negotiated in the crypto
82 // handshake.
83 QuicConfig config_;
84 // crypto_config_ contains crypto parameters for the handshake.
85 QuicCryptoServerConfig crypto_config_;
87 // This vector contains QUIC versions which we currently support.
88 // This should be ordered such that the highest supported version is the first
89 // element, with subsequent elements in descending order (versions can be
90 // skipped as necessary).
91 QuicVersionVector supported_versions_;
93 // The address that the server listens on.
94 IPEndPoint server_address_;
96 // Keeps track of whether a read is currently in flight, after which
97 // OnReadComplete will be called.
98 bool read_pending_;
100 // The number of iterations of the read loop that have completed synchronously
101 // and without posting a new task to the message loop.
102 int synchronous_read_count_;
104 // The target buffer of the current read.
105 scoped_refptr<IOBufferWithSize> read_buffer_;
107 // The source address of the current read.
108 IPEndPoint client_address_;
110 // The log to use for the socket.
111 NetLog net_log_;
113 base::WeakPtrFactory<QuicServer> weak_factory_;
115 DISALLOW_COPY_AND_ASSIGN(QuicServer);
118 } // namespace net
120 #endif // NET_QUIC_QUIC_SERVER_H_