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

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

Issue 131743009: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use size_t instead of int to fix win_x64 compile error Created 6 years, 11 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
« no previous file with comments | « net/tools/quic/end_to_end_test.cc ('k') | net/tools/quic/quic_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/command_line.h" 14 #include "base/command_line.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "net/base/ip_endpoint.h" 16 #include "net/base/ip_endpoint.h"
16 #include "net/quic/crypto/crypto_handshake.h" 17 #include "net/quic/crypto/crypto_handshake.h"
17 #include "net/quic/quic_config.h" 18 #include "net/quic/quic_config.h"
18 #include "net/quic/quic_framer.h" 19 #include "net/quic/quic_framer.h"
19 #include "net/quic/quic_packet_creator.h" 20 #include "net/quic/quic_packet_creator.h"
20 #include "net/tools/epoll_server/epoll_server.h" 21 #include "net/tools/epoll_server/epoll_server.h"
21 #include "net/tools/quic/quic_client_session.h" 22 #include "net/tools/quic/quic_client_session.h"
22 #include "net/tools/quic/quic_spdy_client_stream.h" 23 #include "net/tools/quic/quic_spdy_client_stream.h"
23 24
24 namespace net { 25 namespace net {
25 26
26 class ProofVerifier; 27 class ProofVerifier;
27 28
28 namespace tools { 29 namespace tools {
29 30
30 class QuicEpollConnectionHelper; 31 class QuicEpollConnectionHelper;
31 32
32 namespace test { 33 namespace test {
33 class QuicClientPeer; 34 class QuicClientPeer;
34 } // namespace test 35 } // namespace test
35 36
36 class QuicClient : public EpollCallbackInterface, 37 class QuicClient : public EpollCallbackInterface,
37 public QuicDataStream::Visitor { 38 public QuicDataStream::Visitor {
38 public: 39 public:
40 class ResponseListener {
41 public:
42 ResponseListener() {}
43 virtual ~ResponseListener() {}
44 virtual void OnCompleteResponse(QuicStreamId id,
45 const BalsaHeaders& response_headers,
46 const string& response_body) = 0;
47 };
48
39 QuicClient(IPEndPoint server_address, 49 QuicClient(IPEndPoint server_address,
40 const string& server_hostname, 50 const string& server_hostname,
41 const QuicVersionVector& supported_versions, 51 const QuicVersionVector& supported_versions,
42 bool print_response); 52 bool print_response);
43 QuicClient(IPEndPoint server_address, 53 QuicClient(IPEndPoint server_address,
44 const std::string& server_hostname, 54 const std::string& server_hostname,
45 const QuicConfig& config, 55 const QuicConfig& config,
46 const QuicVersionVector& supported_versions); 56 const QuicVersionVector& supported_versions);
47 57
48 virtual ~QuicClient(); 58 virtual ~QuicClient();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // given ChannelID. This object takes ownership of |signer|. 155 // given ChannelID. This object takes ownership of |signer|.
146 void SetChannelIDSigner(ChannelIDSigner* signer) { 156 void SetChannelIDSigner(ChannelIDSigner* signer) {
147 crypto_config_.SetChannelIDSigner(signer); 157 crypto_config_.SetChannelIDSigner(signer);
148 } 158 }
149 159
150 void SetSupportedVersions(const QuicVersionVector& versions) { 160 void SetSupportedVersions(const QuicVersionVector& versions) {
151 DCHECK(!session_.get()); 161 DCHECK(!session_.get());
152 supported_versions_ = versions; 162 supported_versions_ = versions;
153 } 163 }
154 164
165 // Takes ownership of the listener.
166 void set_response_listener(ResponseListener* listener) {
167 response_listener_.reset(listener);
168 }
169
155 protected: 170 protected:
156 virtual QuicGuid GenerateGuid(); 171 virtual QuicGuid GenerateGuid();
157 virtual QuicEpollConnectionHelper* CreateQuicConnectionHelper(); 172 virtual QuicEpollConnectionHelper* CreateQuicConnectionHelper();
158 virtual QuicPacketWriter* CreateQuicPacketWriter(); 173 virtual QuicPacketWriter* CreateQuicPacketWriter();
159 174
160 private: 175 private:
161 friend class net::tools::test::QuicClientPeer; 176 friend class net::tools::test::QuicClientPeer;
162 177
163 // Read a UDP packet and hand it to the framer. 178 // Read a UDP packet and hand it to the framer.
164 bool ReadAndProcessPacket(); 179 bool ReadAndProcessPacket();
(...skipping 20 matching lines...) Expand all
185 // Session which manages streams. 200 // Session which manages streams.
186 scoped_ptr<QuicClientSession> session_; 201 scoped_ptr<QuicClientSession> session_;
187 // Listens for events on the client socket. 202 // Listens for events on the client socket.
188 EpollServer epoll_server_; 203 EpollServer epoll_server_;
189 // UDP socket. 204 // UDP socket.
190 int fd_; 205 int fd_;
191 206
192 // Helper to be used by created connections. 207 // Helper to be used by created connections.
193 scoped_ptr<QuicEpollConnectionHelper> helper_; 208 scoped_ptr<QuicEpollConnectionHelper> helper_;
194 209
210 // Listens for full responses.
211 scoped_ptr<ResponseListener> response_listener_;
212
195 // Writer used to actually send packets to the wire. 213 // Writer used to actually send packets to the wire.
196 scoped_ptr<QuicPacketWriter> writer_; 214 scoped_ptr<QuicPacketWriter> writer_;
197 215
198 // Tracks if the client is initialized to connect. 216 // Tracks if the client is initialized to connect.
199 bool initialized_; 217 bool initialized_;
200 218
201 // If overflow_supported_ is true, this will be the number of packets dropped 219 // If overflow_supported_ is true, this will be the number of packets dropped
202 // during the lifetime of the server. This may overflow if enough packets 220 // during the lifetime of the server. This may overflow if enough packets
203 // are dropped. 221 // are dropped.
204 int packets_dropped_; 222 int packets_dropped_;
(...skipping 13 matching lines...) Expand all
218 // when the stream is closed (in OnClose). 236 // when the stream is closed (in OnClose).
219 bool print_response_; 237 bool print_response_;
220 238
221 DISALLOW_COPY_AND_ASSIGN(QuicClient); 239 DISALLOW_COPY_AND_ASSIGN(QuicClient);
222 }; 240 };
223 241
224 } // namespace tools 242 } // namespace tools
225 } // namespace net 243 } // namespace net
226 244
227 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ 245 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_
OLDNEW
« no previous file with comments | « net/tools/quic/end_to_end_test.cc ('k') | net/tools/quic/quic_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698