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

Side by Side Diff: net/tools/quic/quic_client.h

Issue 192583004: QUIC - use QuicSessionKey tuple (host, port, is_https) instead of server_hostname (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with TOT Created 6 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 | Annotate | Revision Log
OLDNEW
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 toy client, which connects to a specified port and sends QUIC 5 // A toy client, which connects to a specified port and sends QUIC
6 // request to that endpoint. 6 // request to that endpoint.
7 7
8 #ifndef NET_TOOLS_QUIC_QUIC_CLIENT_H_ 8 #ifndef NET_TOOLS_QUIC_QUIC_CLIENT_H_
9 #define NET_TOOLS_QUIC_QUIC_CLIENT_H_ 9 #define NET_TOOLS_QUIC_QUIC_CLIENT_H_
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "net/base/ip_endpoint.h" 16 #include "net/base/ip_endpoint.h"
17 #include "net/quic/crypto/crypto_handshake.h" 17 #include "net/quic/crypto/crypto_handshake.h"
18 #include "net/quic/quic_config.h" 18 #include "net/quic/quic_config.h"
19 #include "net/quic/quic_framer.h" 19 #include "net/quic/quic_framer.h"
20 #include "net/quic/quic_packet_creator.h" 20 #include "net/quic/quic_packet_creator.h"
21 #include "net/tools/epoll_server/epoll_server.h" 21 #include "net/tools/epoll_server/epoll_server.h"
22 #include "net/tools/quic/quic_client_session.h" 22 #include "net/tools/quic/quic_client_session.h"
23 #include "net/tools/quic/quic_spdy_client_stream.h" 23 #include "net/tools/quic/quic_spdy_client_stream.h"
24 24
25 namespace net { 25 namespace net {
26 26
27 class ProofVerifier; 27 class ProofVerifier;
28 class QuicSessionKey;
28 29
29 namespace tools { 30 namespace tools {
30 31
31 class QuicEpollConnectionHelper; 32 class QuicEpollConnectionHelper;
32 33
33 namespace test { 34 namespace test {
34 class QuicClientPeer; 35 class QuicClientPeer;
35 } // namespace test 36 } // namespace test
36 37
37 class QuicClient : public EpollCallbackInterface, 38 class QuicClient : public EpollCallbackInterface,
38 public QuicDataStream::Visitor { 39 public QuicDataStream::Visitor {
39 public: 40 public:
40 class ResponseListener { 41 class ResponseListener {
41 public: 42 public:
42 ResponseListener() {} 43 ResponseListener() {}
43 virtual ~ResponseListener() {} 44 virtual ~ResponseListener() {}
44 virtual void OnCompleteResponse(QuicStreamId id, 45 virtual void OnCompleteResponse(QuicStreamId id,
45 const BalsaHeaders& response_headers, 46 const BalsaHeaders& response_headers,
46 const string& response_body) = 0; 47 const string& response_body) = 0;
47 }; 48 };
48 49
49 QuicClient(IPEndPoint server_address, 50 QuicClient(IPEndPoint server_address,
50 const string& server_hostname, 51 const QuicSessionKey& server_key,
51 const QuicVersionVector& supported_versions, 52 const QuicVersionVector& supported_versions,
52 bool print_response); 53 bool print_response);
53 QuicClient(IPEndPoint server_address, 54 QuicClient(IPEndPoint server_address,
54 const std::string& server_hostname, 55 const QuicSessionKey& server_key,
55 const QuicConfig& config, 56 const QuicConfig& config,
56 const QuicVersionVector& supported_versions); 57 const QuicVersionVector& supported_versions);
57 58
58 virtual ~QuicClient(); 59 virtual ~QuicClient();
59 60
60 // Initializes the client to create a connection. Should be called exactly 61 // Initializes the client to create a connection. Should be called exactly
61 // once before calling StartConnect or Connect. Returns true if the 62 // once before calling StartConnect or Connect. Returns true if the
62 // initialization succeeds, false otherwise. 63 // initialization succeeds, false otherwise.
63 bool Initialize(); 64 bool Initialize();
64 65
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 void set_local_port(int local_port) { local_port_ = local_port; } 128 void set_local_port(int local_port) { local_port_ = local_port; }
128 129
129 const IPEndPoint& server_address() const { return server_address_; } 130 const IPEndPoint& server_address() const { return server_address_; }
130 131
131 const IPEndPoint& client_address() const { return client_address_; } 132 const IPEndPoint& client_address() const { return client_address_; }
132 133
133 EpollServer* epoll_server() { return &epoll_server_; } 134 EpollServer* epoll_server() { return &epoll_server_; }
134 135
135 int fd() { return fd_; } 136 int fd() { return fd_; }
136 137
137 string server_hostname() { 138 const QuicSessionKey& server_key() const { return server_key_; }
138 return server_hostname_;
139 }
140 139
141 // This should only be set before the initial Connect() 140 // This should only be set before the initial Connect()
142 void set_server_hostname(const string& hostname) { 141 void set_server_key(const QuicSessionKey& server_key) {
143 server_hostname_ = hostname; 142 server_key_ = server_key;
144 } 143 }
145 144
146 // SetProofVerifier sets the ProofVerifier that will be used to verify the 145 // SetProofVerifier sets the ProofVerifier that will be used to verify the
147 // server's certificate and takes ownership of |verifier|. 146 // server's certificate and takes ownership of |verifier|.
148 void SetProofVerifier(ProofVerifier* verifier) { 147 void SetProofVerifier(ProofVerifier* verifier) {
149 // TODO(rtenneti): We should set ProofVerifier in QuicClientSession. 148 // TODO(rtenneti): We should set ProofVerifier in QuicClientSession.
150 crypto_config_.SetProofVerifier(verifier); 149 crypto_config_.SetProofVerifier(verifier);
151 } 150 }
152 151
153 // SetChannelIDSigner sets a ChannelIDSigner that will be called when the 152 // SetChannelIDSigner sets a ChannelIDSigner that will be called when the
(...skipping 20 matching lines...) Expand all
174 173
175 private: 174 private:
176 friend class net::tools::test::QuicClientPeer; 175 friend class net::tools::test::QuicClientPeer;
177 176
178 // Read a UDP packet and hand it to the framer. 177 // Read a UDP packet and hand it to the framer.
179 bool ReadAndProcessPacket(); 178 bool ReadAndProcessPacket();
180 179
181 // Address of the server. 180 // Address of the server.
182 const IPEndPoint server_address_; 181 const IPEndPoint server_address_;
183 182
184 // Hostname of the server. This may be a DNS name or an IP address literal. 183 // |server_key_| is a tuple (hostname, port, is_https) of the server.
185 std::string server_hostname_; 184 QuicSessionKey server_key_;
186 185
187 // config_ and crypto_config_ contain configuration and cached state about 186 // config_ and crypto_config_ contain configuration and cached state about
188 // servers. 187 // servers.
189 QuicConfig config_; 188 QuicConfig config_;
190 QuicCryptoClientConfig crypto_config_; 189 QuicCryptoClientConfig crypto_config_;
191 190
192 // Address of the client if the client is connected to the server. 191 // Address of the client if the client is connected to the server.
193 IPEndPoint client_address_; 192 IPEndPoint client_address_;
194 193
195 // If initialized, the address to bind to. 194 // If initialized, the address to bind to.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // when the stream is closed (in OnClose). 235 // when the stream is closed (in OnClose).
237 bool print_response_; 236 bool print_response_;
238 237
239 DISALLOW_COPY_AND_ASSIGN(QuicClient); 238 DISALLOW_COPY_AND_ASSIGN(QuicClient);
240 }; 239 };
241 240
242 } // namespace tools 241 } // namespace tools
243 } // namespace net 242 } // namespace net
244 243
245 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ 244 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698