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

Side by Side Diff: net/tools/quic/quic_client_base.cc

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 | « net/tools/quic/quic_client_base.h ('k') | net/tools/quic/quic_simple_client.h » ('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) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 #include "net/tools/quic/quic_client_base.h" 5 #include "net/tools/quic/quic_client_base.h"
6 6
7 #include "net/quic/core/crypto/quic_random.h" 7 #include "net/quic/core/crypto/quic_random.h"
8 #include "net/quic/core/quic_server_id.h" 8 #include "net/quic/core/quic_server_id.h"
9 9
10 using base::StringPiece; 10 using base::StringPiece;
11 11
12 namespace net { 12 namespace net {
13 13
14 void QuicClientBase::ClientQuicDataToResend::Resend() {
15 client_->SendRequest(*headers_, body_, fin_);
16 headers_ = nullptr;
17 }
18
14 QuicClientBase::QuicDataToResend::QuicDataToResend( 19 QuicClientBase::QuicDataToResend::QuicDataToResend(
15 std::unique_ptr<SpdyHeaderBlock> headers, 20 std::unique_ptr<SpdyHeaderBlock> headers,
16 StringPiece body, 21 StringPiece body,
17 bool fin) 22 bool fin)
18 : headers_(std::move(headers)), body_(body), fin_(fin) {} 23 : headers_(std::move(headers)), body_(body), fin_(fin) {}
19 24
20 QuicClientBase::QuicDataToResend::~QuicDataToResend() {} 25 QuicClientBase::QuicDataToResend::~QuicDataToResend() {}
21 26
22 QuicClientBase::QuicClientBase(const QuicServerId& server_id, 27 QuicClientBase::QuicClientBase(const QuicServerId& server_id,
23 const QuicVersionVector& supported_versions, 28 const QuicVersionVector& supported_versions,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 << "unexpected nullptr."; 158 << "unexpected nullptr.";
154 return cached->has_server_designated_connection_id() 159 return cached->has_server_designated_connection_id()
155 ? cached->GetNextServerDesignatedConnectionId() 160 ? cached->GetNextServerDesignatedConnectionId()
156 : 0; 161 : 0;
157 } 162 }
158 163
159 QuicConnectionId QuicClientBase::GenerateNewConnectionId() { 164 QuicConnectionId QuicClientBase::GenerateNewConnectionId() {
160 return QuicRandom::GetInstance()->RandUint64(); 165 return QuicRandom::GetInstance()->RandUint64();
161 } 166 }
162 167
168 void QuicClientBase::MaybeAddDataToResend(const SpdyHeaderBlock& headers,
169 StringPiece body,
170 bool fin) {
171 if (!FLAGS_enable_quic_stateless_reject_support) {
172 return;
173 }
174
175 if (session()->IsCryptoHandshakeConfirmed()) {
176 // The handshake is confirmed. No need to continue saving requests to
177 // resend.
178 data_to_resend_on_connect_.clear();
179 return;
180 }
181
182 // The handshake is not confirmed. Push the data onto the queue of data to
183 // resend if statelessly rejected.
184 std::unique_ptr<SpdyHeaderBlock> new_headers(
185 new SpdyHeaderBlock(headers.Clone()));
186 std::unique_ptr<QuicDataToResend> data_to_resend(
187 new ClientQuicDataToResend(std::move(new_headers), body, fin, this));
188 MaybeAddQuicDataToResend(std::move(data_to_resend));
189 }
190
191 void QuicClientBase::MaybeAddQuicDataToResend(
192 std::unique_ptr<QuicDataToResend> data_to_resend) {
193 data_to_resend_on_connect_.push_back(std::move(data_to_resend));
194 }
195
196 void QuicClientBase::ClearDataToResend() {
197 data_to_resend_on_connect_.clear();
198 }
199
200 void QuicClientBase::ResendSavedData() {
201 for (const auto& data : data_to_resend_on_connect_) {
202 data->Resend();
203 }
204 data_to_resend_on_connect_.clear();
205 }
206
207 void QuicClientBase::AddPromiseDataToResend(const SpdyHeaderBlock& headers,
208 StringPiece body,
209 bool fin) {
210 std::unique_ptr<SpdyHeaderBlock> new_headers(
211 new SpdyHeaderBlock(headers.Clone()));
212 push_promise_data_to_resend_.reset(
213 new ClientQuicDataToResend(std::move(new_headers), body, fin, this));
214 }
215
216 bool QuicClientBase::CheckVary(const SpdyHeaderBlock& client_request,
217 const SpdyHeaderBlock& promise_request,
218 const SpdyHeaderBlock& promise_response) {
219 return true;
220 }
221
222 void QuicClientBase::OnRendezvousResult(QuicSpdyStream* stream) {
223 std::unique_ptr<ClientQuicDataToResend> data_to_resend =
224 std::move(push_promise_data_to_resend_);
225 if (stream) {
226 stream->set_visitor(this);
227 stream->OnDataAvailable();
228 } else if (data_to_resend.get()) {
229 data_to_resend->Resend();
230 }
231 }
232
163 } // namespace net 233 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_client_base.h ('k') | net/tools/quic/quic_simple_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698