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

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

Issue 2363393004: Remove usage of BalsaHeaders from QuicClient. Also move QuicDataToResend from QuicClient to QuicCli… (Closed)
Patch Set: Fix win Created 4 years, 2 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/tools/quic/quic_client_bin.cc ('k') | net/tools/quic/quic_simple_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_SIMPLE_CLIENT_H_ 8 #ifndef NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_
9 #define NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_ 9 #define NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 public: 43 public:
44 class ResponseListener { 44 class ResponseListener {
45 public: 45 public:
46 ResponseListener() {} 46 ResponseListener() {}
47 virtual ~ResponseListener() {} 47 virtual ~ResponseListener() {}
48 virtual void OnCompleteResponse(QuicStreamId id, 48 virtual void OnCompleteResponse(QuicStreamId id,
49 const HttpResponseHeaders& response_headers, 49 const HttpResponseHeaders& response_headers,
50 const std::string& response_body) = 0; 50 const std::string& response_body) = 0;
51 }; 51 };
52 52
53 // The client uses these objects to keep track of any data to resend upon
54 // receipt of a stateless reject. Recall that the client API allows callers
55 // to optimistically send data to the server prior to handshake-confirmation.
56 // If the client subsequently receives a stateless reject, it must tear down
57 // its existing session, create a new session, and resend all previously sent
58 // data. It uses these objects to keep track of all the sent data, and to
59 // resend the data upon a subsequent connection.
60 class QuicDataToResend {
61 public:
62 // Takes ownership of |headers|. |headers| may be null, since it's possible
63 // to send data without headers.
64 QuicDataToResend(HttpRequestInfo* headers,
65 base::StringPiece body,
66 bool fin);
67
68 virtual ~QuicDataToResend();
69
70 // Must be overridden by specific classes with the actual method for
71 // re-sending data.
72 virtual void Resend() = 0;
73
74 protected:
75 HttpRequestInfo* headers_;
76 base::StringPiece body_;
77 bool fin_;
78
79 private:
80 DISALLOW_COPY_AND_ASSIGN(QuicDataToResend);
81 };
82
83 // Create a quic client, which will have events managed by an externally owned 53 // Create a quic client, which will have events managed by an externally owned
84 // EpollServer. 54 // EpollServer.
85 QuicSimpleClient(IPEndPoint server_address, 55 QuicSimpleClient(IPEndPoint server_address,
86 const QuicServerId& server_id, 56 const QuicServerId& server_id,
87 const QuicVersionVector& supported_versions, 57 const QuicVersionVector& supported_versions,
88 std::unique_ptr<ProofVerifier> proof_verifier); 58 std::unique_ptr<ProofVerifier> proof_verifier);
89 QuicSimpleClient(IPEndPoint server_address, 59 QuicSimpleClient(IPEndPoint server_address,
90 const QuicServerId& server_id, 60 const QuicServerId& server_id,
91 const QuicVersionVector& supported_versions, 61 const QuicVersionVector& supported_versions,
92 const QuicConfig& config, 62 const QuicConfig& config,
(...skipping 12 matching lines...) Expand all
105 75
106 // Start the crypto handshake. This can be done in place of the synchronous 76 // Start the crypto handshake. This can be done in place of the synchronous
107 // Connect(), but callers are responsible for making sure the crypto handshake 77 // Connect(), but callers are responsible for making sure the crypto handshake
108 // completes. 78 // completes.
109 void StartConnect(); 79 void StartConnect();
110 80
111 // Disconnects from the QUIC server. 81 // Disconnects from the QUIC server.
112 void Disconnect(); 82 void Disconnect();
113 83
114 // Sends an HTTP request and does not wait for response before returning. 84 // Sends an HTTP request and does not wait for response before returning.
115 void SendRequest(const HttpRequestInfo& headers, 85 void SendRequest(const SpdyHeaderBlock& headers,
116 base::StringPiece body, 86 base::StringPiece body,
117 bool fin); 87 bool fin);
118 88
119 // Sends an HTTP request and waits for response before returning. 89 // Sends an HTTP request and waits for response before returning.
120 void SendRequestAndWaitForResponse(const HttpRequestInfo& headers, 90 void SendRequestAndWaitForResponse(const SpdyHeaderBlock& headers,
121 base::StringPiece body, 91 base::StringPiece body,
122 bool fin); 92 bool fin);
123 93
124 // Sends a request simple GET for each URL in |args|, and then waits for 94 // Sends a request simple GET for each URL in |args|, and then waits for
125 // each to complete. 95 // each to complete.
126 void SendRequestsAndWaitForResponse( 96 void SendRequestsAndWaitForResponse(
127 const base::CommandLine::StringVector& url_list); 97 const base::CommandLine::StringVector& url_list);
128 98
129 // Migrate to a new socket during an active connection. 99 // Migrate to a new socket during an active connection.
130 bool MigrateSocket(const IPAddress& new_host); 100 bool MigrateSocket(const IPAddress& new_host);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 virtual QuicChromiumConnectionHelper* CreateQuicConnectionHelper(); 142 virtual QuicChromiumConnectionHelper* CreateQuicConnectionHelper();
173 virtual QuicPacketWriter* CreateQuicPacketWriter(); 143 virtual QuicPacketWriter* CreateQuicPacketWriter();
174 144
175 private: 145 private:
176 friend class net::test::QuicClientPeer; 146 friend class net::test::QuicClientPeer;
177 147
178 // Specific QuicClient class for storing data to resend. 148 // Specific QuicClient class for storing data to resend.
179 class ClientQuicDataToResend : public QuicDataToResend { 149 class ClientQuicDataToResend : public QuicDataToResend {
180 public: 150 public:
181 // Takes ownership of |headers|. 151 // Takes ownership of |headers|.
182 ClientQuicDataToResend(HttpRequestInfo* headers, 152 ClientQuicDataToResend(std::unique_ptr<SpdyHeaderBlock> headers,
183 base::StringPiece body, 153 base::StringPiece body,
184 bool fin, 154 bool fin,
185 QuicSimpleClient* client) 155 QuicSimpleClient* client)
186 : QuicDataToResend(headers, body, fin), client_(client) { 156 : QuicDataToResend(std::move(headers), body, fin), client_(client) {
187 DCHECK(headers);
188 DCHECK(client); 157 DCHECK(client);
189 } 158 }
190 159
191 ~ClientQuicDataToResend() override {} 160 ~ClientQuicDataToResend() override {}
192 161
193 void Resend() override; 162 void Resend() override;
194 163
195 private: 164 private:
196 QuicSimpleClient* client_; 165 QuicSimpleClient* client_;
197 166
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 bool packet_reader_started_; 229 bool packet_reader_started_;
261 230
262 base::WeakPtrFactory<QuicSimpleClient> weak_factory_; 231 base::WeakPtrFactory<QuicSimpleClient> weak_factory_;
263 232
264 DISALLOW_COPY_AND_ASSIGN(QuicSimpleClient); 233 DISALLOW_COPY_AND_ASSIGN(QuicSimpleClient);
265 }; 234 };
266 235
267 } // namespace net 236 } // namespace net
268 237
269 #endif // NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_ 238 #endif // NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_
OLDNEW
« no previous file with comments | « net/tools/quic/quic_client_bin.cc ('k') | net/tools/quic/quic_simple_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698