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

Side by Side Diff: net/quic/quic_server.h

Issue 1036023002: Move remaining QUIC server files from net/quic/ to net/tools/quic/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: correctly fix cronet Created 5 years, 9 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/quic_per_connection_packet_writer.cc ('k') | net/quic/quic_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
7
8 #ifndef NET_QUIC_QUIC_SERVER_H_
9 #define NET_QUIC_QUIC_SERVER_H_
10
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"
20
21 namespace net {
22
23
24 namespace test {
25 class QuicServerPeer;
26 } // namespace test
27
28 namespace tools {
29 class QuicDispatcher;
30 } // namespace tools
31
32 class UDPServerSocket;
33
34 class QuicServer {
35 public:
36 QuicServer(const QuicConfig& config,
37 const QuicVersionVector& supported_versions);
38
39 virtual ~QuicServer();
40
41 // Start listening on the specified address. Returns an error code.
42 int Listen(const IPEndPoint& address);
43
44 // Server deletion is imminent. Start cleaning up.
45 void Shutdown();
46
47 // Start reading on the socket. On asynchronous reads, this registers
48 // OnReadComplete as the callback, which will then call StartReading again.
49 void StartReading();
50
51 // Called on reads that complete asynchronously. Dispatches the packet and
52 // continues the read loop.
53 void OnReadComplete(int result);
54
55 void SetStrikeRegisterNoStartupPeriod() {
56 crypto_config_.set_strike_register_no_startup_period();
57 }
58
59 // SetProofSource sets the ProofSource that will be used to verify the
60 // server's certificate, and takes ownership of |source|.
61 void SetProofSource(ProofSource* source) {
62 crypto_config_.SetProofSource(source);
63 }
64
65 tools::QuicDispatcher* dispatcher() { return dispatcher_.get(); }
66
67 private:
68 friend class net::test::QuicServerPeer;
69
70 // Initialize the internal state of the server.
71 void Initialize();
72
73 // Accepts data from the framer and demuxes clients to sessions.
74 scoped_ptr<tools::QuicDispatcher> dispatcher_;
75
76 // Used by the helper_ to time alarms.
77 QuicClock clock_;
78
79 // Used to manage the message loop.
80 QuicConnectionHelper helper_;
81
82 // Listening socket. Also used for outbound client communication.
83 scoped_ptr<UDPServerSocket> socket_;
84
85 // config_ contains non-crypto parameters that are negotiated in the crypto
86 // handshake.
87 QuicConfig config_;
88 // crypto_config_ contains crypto parameters for the handshake.
89 QuicCryptoServerConfig crypto_config_;
90
91 // This vector contains QUIC versions which we currently support.
92 // This should be ordered such that the highest supported version is the first
93 // element, with subsequent elements in descending order (versions can be
94 // skipped as necessary).
95 QuicVersionVector supported_versions_;
96
97 // The address that the server listens on.
98 IPEndPoint server_address_;
99
100 // Keeps track of whether a read is currently in flight, after which
101 // OnReadComplete will be called.
102 bool read_pending_;
103
104 // The number of iterations of the read loop that have completed synchronously
105 // and without posting a new task to the message loop.
106 int synchronous_read_count_;
107
108 // The target buffer of the current read.
109 scoped_refptr<IOBufferWithSize> read_buffer_;
110
111 // The source address of the current read.
112 IPEndPoint client_address_;
113
114 // The log to use for the socket.
115 NetLog net_log_;
116
117 base::WeakPtrFactory<QuicServer> weak_factory_;
118
119 DISALLOW_COPY_AND_ASSIGN(QuicServer);
120 };
121
122 } // namespace net
123
124 #endif // NET_QUIC_QUIC_SERVER_H_
OLDNEW
« no previous file with comments | « net/quic/quic_per_connection_packet_writer.cc ('k') | net/quic/quic_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698