Add Wi-FI SSID to captive portal interstitial.
[chromium-blink-merge.git] / net / quic / quic_server.h
blobd53963e08306a746a3da51568feb2c6930dd32a8
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 QuicDispatcher;
29 class UDPServerSocket;
31 class QuicServer {
32 public:
33 QuicServer(const QuicConfig& config,
34 const QuicVersionVector& supported_versions);
36 virtual ~QuicServer();
38 // Start listening on the specified address. Returns an error code.
39 int Listen(const IPEndPoint& address);
41 // Server deletion is imminent. Start cleaning up.
42 void Shutdown();
44 // Start reading on the socket. On asynchronous reads, this registers
45 // OnReadComplete as the callback, which will then call StartReading again.
46 void StartReading();
48 // Called on reads that complete asynchronously. Dispatches the packet and
49 // continues the read loop.
50 void OnReadComplete(int result);
52 void SetStrikeRegisterNoStartupPeriod() {
53 crypto_config_.set_strike_register_no_startup_period();
56 // SetProofSource sets the ProofSource that will be used to verify the
57 // server's certificate, and takes ownership of |source|.
58 void SetProofSource(ProofSource* source) {
59 crypto_config_.SetProofSource(source);
62 private:
63 friend class net::test::QuicServerPeer;
65 // Initialize the internal state of the server.
66 void Initialize();
68 // Accepts data from the framer and demuxes clients to sessions.
69 scoped_ptr<QuicDispatcher> dispatcher_;
71 // Used by the helper_ to time alarms.
72 QuicClock clock_;
74 // Used to manage the message loop.
75 QuicConnectionHelper helper_;
77 // Listening socket. Also used for outbound client communication.
78 scoped_ptr<UDPServerSocket> socket_;
80 // config_ contains non-crypto parameters that are negotiated in the crypto
81 // handshake.
82 QuicConfig config_;
83 // crypto_config_ contains crypto parameters for the handshake.
84 QuicCryptoServerConfig crypto_config_;
86 // This vector contains QUIC versions which we currently support.
87 // This should be ordered such that the highest supported version is the first
88 // element, with subsequent elements in descending order (versions can be
89 // skipped as necessary).
90 QuicVersionVector supported_versions_;
92 // The address that the server listens on.
93 IPEndPoint server_address_;
95 // Keeps track of whether a read is currently in flight, after which
96 // OnReadComplete will be called.
97 bool read_pending_;
99 // The number of iterations of the read loop that have completed synchronously
100 // and without posting a new task to the message loop.
101 int synchronous_read_count_;
103 // The target buffer of the current read.
104 scoped_refptr<IOBufferWithSize> read_buffer_;
106 // The source address of the current read.
107 IPEndPoint client_address_;
109 // The log to use for the socket.
110 NetLog net_log_;
112 base::WeakPtrFactory<QuicServer> weak_factory_;
114 DISALLOW_COPY_AND_ASSIGN(QuicServer);
117 } // namespace net
119 #endif // NET_QUIC_QUIC_SERVER_H_