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

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

Issue 2368183003: Move QuicClient::ClientQuicDataToResend from QuicClient to QuicClientBase. (Closed)
Patch Set: Rebase 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 | « no previous file | 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
(...skipping 20 matching lines...) Expand all
31 class QuicServerId; 31 class QuicServerId;
32 32
33 class QuicEpollConnectionHelper; 33 class QuicEpollConnectionHelper;
34 34
35 namespace test { 35 namespace test {
36 class QuicClientPeer; 36 class QuicClientPeer;
37 } // namespace test 37 } // namespace test
38 38
39 class QuicClient : public QuicClientBase, 39 class QuicClient : public QuicClientBase,
40 public EpollCallbackInterface, 40 public EpollCallbackInterface,
41 public QuicSpdyStream::Visitor, 41 public ProcessPacketInterface {
42 public ProcessPacketInterface,
43 public QuicClientPushPromiseIndex::Delegate {
44 public: 42 public:
45 class ResponseListener { 43 class ResponseListener {
46 public: 44 public:
47 ResponseListener() {} 45 ResponseListener() {}
48 virtual ~ResponseListener() {} 46 virtual ~ResponseListener() {}
49 virtual void OnCompleteResponse(QuicStreamId id, 47 virtual void OnCompleteResponse(QuicStreamId id,
50 const SpdyHeaderBlock& response_headers, 48 const SpdyHeaderBlock& response_headers,
51 const std::string& response_body) = 0; 49 const std::string& response_body) = 0;
52 }; 50 };
53 51
(...skipping 26 matching lines...) Expand all
80 // Connect(), but callers are responsible for making sure the crypto handshake 78 // Connect(), but callers are responsible for making sure the crypto handshake
81 // completes. 79 // completes.
82 void StartConnect(); 80 void StartConnect();
83 81
84 // Disconnects from the QUIC server. 82 // Disconnects from the QUIC server.
85 void Disconnect(); 83 void Disconnect();
86 84
87 // Sends an HTTP request and does not wait for response before returning. 85 // Sends an HTTP request and does not wait for response before returning.
88 void SendRequest(const SpdyHeaderBlock& headers, 86 void SendRequest(const SpdyHeaderBlock& headers,
89 base::StringPiece body, 87 base::StringPiece body,
90 bool fin); 88 bool fin) override;
91 89
92 // Sends an HTTP request and waits for response before returning. 90 // Sends an HTTP request and waits for response before returning.
93 void SendRequestAndWaitForResponse(const SpdyHeaderBlock& headers, 91 void SendRequestAndWaitForResponse(const SpdyHeaderBlock& headers,
94 base::StringPiece body, 92 base::StringPiece body,
95 bool fin); 93 bool fin);
96 94
97 // Sends a request simple GET for each URL in |url_list|, and then waits for 95 // Sends a request simple GET for each URL in |url_list|, and then waits for
98 // each to complete. 96 // each to complete.
99 void SendRequestsAndWaitForResponse(const std::vector<std::string>& url_list); 97 void SendRequestsAndWaitForResponse(const std::vector<std::string>& url_list);
100 98
101 // Migrate to a new socket during an active connection. 99 // Migrate to a new socket during an active connection.
102 bool MigrateSocket(const IPAddress& new_host); 100 bool MigrateSocket(const IPAddress& new_host);
103 101
104 // From EpollCallbackInterface 102 // From EpollCallbackInterface
105 void OnRegistration(EpollServer* eps, int fd, int event_mask) override {} 103 void OnRegistration(EpollServer* eps, int fd, int event_mask) override {}
106 void OnModification(int fd, int event_mask) override {} 104 void OnModification(int fd, int event_mask) override {}
107 void OnEvent(int fd, EpollEvent* event) override; 105 void OnEvent(int fd, EpollEvent* event) override;
108 // |fd_| can be unregistered without the client being disconnected. This 106 // |fd_| can be unregistered without the client being disconnected. This
109 // happens in b3m QuicProber where we unregister |fd_| to feed in events to 107 // happens in b3m QuicProber where we unregister |fd_| to feed in events to
110 // the client from the SelectServer. 108 // the client from the SelectServer.
111 void OnUnregistration(int fd, bool replaced) override {} 109 void OnUnregistration(int fd, bool replaced) override {}
112 void OnShutdown(EpollServer* eps, int fd) override {} 110 void OnShutdown(EpollServer* eps, int fd) override {}
113 111
114 // QuicSpdyStream::Visitor 112 // QuicSpdyStream::Visitor
115 void OnClose(QuicSpdyStream* stream) override; 113 void OnClose(QuicSpdyStream* stream) override;
116 114
117 bool CheckVary(const SpdyHeaderBlock& client_request,
118 const SpdyHeaderBlock& promise_request,
119 const SpdyHeaderBlock& promise_response) override;
120 void OnRendezvousResult(QuicSpdyStream*) override;
121
122 // If the crypto handshake has not yet been confirmed, adds the data to the
123 // queue of data to resend if the client receives a stateless reject.
124 // Otherwise, deletes the data.
125 void MaybeAddQuicDataToResend(
126 std::unique_ptr<QuicDataToResend> data_to_resend);
127
128 // If the client has at least one UDP socket, return address of the latest 115 // If the client has at least one UDP socket, return address of the latest
129 // created one. Otherwise, return an empty socket address. 116 // created one. Otherwise, return an empty socket address.
130 const IPEndPoint GetLatestClientAddress() const; 117 const IPEndPoint GetLatestClientAddress() const;
131 118
132 // If the client has at least one UDP socket, return the latest created one. 119 // If the client has at least one UDP socket, return the latest created one.
133 // Otherwise, return -1. 120 // Otherwise, return -1.
134 int GetLatestFD() const; 121 int GetLatestFD() const;
135 122
136 void set_bind_to_address(const IPAddress& address) { 123 void set_bind_to_address(const IPAddress& address) {
137 bind_to_address_ = address; 124 bind_to_address_ = address;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 165
179 EpollServer* epoll_server() { return epoll_server_; } 166 EpollServer* epoll_server() { return epoll_server_; }
180 167
181 const linked_hash_map<int, IPEndPoint>& fd_address_map() const { 168 const linked_hash_map<int, IPEndPoint>& fd_address_map() const {
182 return fd_address_map_; 169 return fd_address_map_;
183 } 170 }
184 171
185 private: 172 private:
186 friend class net::test::QuicClientPeer; 173 friend class net::test::QuicClientPeer;
187 174
188 // Specific QuicClient class for storing data to resend.
189 class ClientQuicDataToResend : public QuicDataToResend {
190 public:
191 ClientQuicDataToResend(std::unique_ptr<SpdyHeaderBlock> headers,
192 base::StringPiece body,
193 bool fin,
194 QuicClient* client)
195 : QuicDataToResend(std::move(headers), body, fin), client_(client) {
196 DCHECK(headers_);
197 DCHECK(client);
198 }
199
200 ~ClientQuicDataToResend() override {}
201
202 void Resend() override;
203
204 private:
205 QuicClient* client_;
206
207 DISALLOW_COPY_AND_ASSIGN(ClientQuicDataToResend);
208 };
209
210 // Used during initialization: creates the UDP socket FD, sets socket options, 175 // Used during initialization: creates the UDP socket FD, sets socket options,
211 // and binds the socket to our address. 176 // and binds the socket to our address.
212 bool CreateUDPSocketAndBind(); 177 bool CreateUDPSocketAndBind();
213 178
214 // Actually clean up |fd|. 179 // Actually clean up |fd|.
215 void CleanUpUDPSocketImpl(int fd); 180 void CleanUpUDPSocketImpl(int fd);
216 181
217 // Address of the server. 182 // Address of the server.
218 IPEndPoint server_address_; 183 IPEndPoint server_address_;
219 184
(...skipping 30 matching lines...) Expand all
250 int latest_response_code_; 215 int latest_response_code_;
251 // HTTP/2 headers from most recent response. 216 // HTTP/2 headers from most recent response.
252 std::string latest_response_headers_; 217 std::string latest_response_headers_;
253 // HTTP/2 header black from most recent response. 218 // HTTP/2 header black from most recent response.
254 SpdyHeaderBlock latest_response_header_block_; 219 SpdyHeaderBlock latest_response_header_block_;
255 // Body of most recent response. 220 // Body of most recent response.
256 std::string latest_response_body_; 221 std::string latest_response_body_;
257 // HTTP/2 trailers from most recent response. 222 // HTTP/2 trailers from most recent response.
258 std::string latest_response_trailers_; 223 std::string latest_response_trailers_;
259 224
260 // Keeps track of any data that must be resent upon a subsequent successful
261 // connection, in case the client receives a stateless reject.
262 std::vector<std::unique_ptr<QuicDataToResend>> data_to_resend_on_connect_;
263
264 // Point to a QuicPacketReader object on the heap. The reader allocates more 225 // Point to a QuicPacketReader object on the heap. The reader allocates more
265 // space than allowed on the stack. 226 // space than allowed on the stack.
266 // 227 //
267 // TODO(rtenneti): Chromium code doesn't use |packet_reader_|. Add support for 228 // TODO(rtenneti): Chromium code doesn't use |packet_reader_|. Add support for
268 // QuicPacketReader 229 // QuicPacketReader
269 std::unique_ptr<QuicPacketReader> packet_reader_; 230 std::unique_ptr<QuicPacketReader> packet_reader_;
270 231
271 std::unique_ptr<ClientQuicDataToResend> push_promise_data_to_resend_;
272
273 DISALLOW_COPY_AND_ASSIGN(QuicClient); 232 DISALLOW_COPY_AND_ASSIGN(QuicClient);
274 }; 233 };
275 234
276 } // namespace net 235 } // namespace net
277 236
278 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ 237 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_
OLDNEW
« no previous file with comments | « no previous file | net/tools/quic/quic_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698