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

Side by Side Diff: net/quic/bidirectional_stream_quic_impl.cc

Issue 2077683002: Move the logic for delaying 0-RTT QUIC POST from the QuicStreamFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@QuicHttpStream
Patch Set: tweak Created 4 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/quic/bidirectional_stream_quic_impl.h" 5 #include "net/quic/bidirectional_stream_quic_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
(...skipping 15 matching lines...) Expand all
26 response_status_(OK), 26 response_status_(OK),
27 negotiated_protocol_(kProtoUnknown), 27 negotiated_protocol_(kProtoUnknown),
28 read_buffer_len_(0), 28 read_buffer_len_(0),
29 headers_bytes_received_(0), 29 headers_bytes_received_(0),
30 headers_bytes_sent_(0), 30 headers_bytes_sent_(0),
31 closed_stream_received_bytes_(0), 31 closed_stream_received_bytes_(0),
32 closed_stream_sent_bytes_(0), 32 closed_stream_sent_bytes_(0),
33 has_sent_headers_(false), 33 has_sent_headers_(false),
34 has_received_headers_(false), 34 has_received_headers_(false),
35 send_request_headers_automatically_(true), 35 send_request_headers_automatically_(true),
36 waiting_for_confirmation_(false),
36 weak_factory_(this) { 37 weak_factory_(this) {
37 DCHECK(session_); 38 DCHECK(session_);
38 session_->AddObserver(this); 39 session_->AddObserver(this);
39 } 40 }
40 41
41 BidirectionalStreamQuicImpl::~BidirectionalStreamQuicImpl() { 42 BidirectionalStreamQuicImpl::~BidirectionalStreamQuicImpl() {
42 Cancel(); 43 Cancel();
43 if (session_) 44 if (session_)
44 session_->RemoveObserver(this); 45 session_->RemoveObserver(this);
45 } 46 }
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 void BidirectionalStreamQuicImpl::OnError(int error) { 275 void BidirectionalStreamQuicImpl::OnError(int error) {
275 NotifyError(error); 276 NotifyError(error);
276 } 277 }
277 278
278 bool BidirectionalStreamQuicImpl::HasSendHeadersComplete() { 279 bool BidirectionalStreamQuicImpl::HasSendHeadersComplete() {
279 return has_sent_headers_; 280 return has_sent_headers_;
280 } 281 }
281 282
282 void BidirectionalStreamQuicImpl::OnCryptoHandshakeConfirmed() { 283 void BidirectionalStreamQuicImpl::OnCryptoHandshakeConfirmed() {
283 was_handshake_confirmed_ = true; 284 was_handshake_confirmed_ = true;
285 if (waiting_for_confirmation_)
286 NotifyStreamReady();
284 } 287 }
285 288
286 void BidirectionalStreamQuicImpl::OnSessionClosed( 289 void BidirectionalStreamQuicImpl::OnSessionClosed(
287 int error, 290 int error,
288 bool /*port_migration_detected*/) { 291 bool /*port_migration_detected*/) {
289 DCHECK_NE(OK, error); 292 DCHECK_NE(OK, error);
290 session_.reset(); 293 session_.reset();
291 NotifyError(error); 294 NotifyError(error);
292 } 295 }
293 296
294 void BidirectionalStreamQuicImpl::OnStreamReady(int rv) { 297 void BidirectionalStreamQuicImpl::OnStreamReady(int rv) {
295 DCHECK_NE(ERR_IO_PENDING, rv); 298 DCHECK_NE(ERR_IO_PENDING, rv);
296 DCHECK(rv == OK || !stream_); 299 DCHECK(rv == OK || !stream_);
297 if (rv == OK) { 300 if (rv == OK) {
298 stream_->SetDelegate(this); 301 stream_->SetDelegate(this);
299 if (send_request_headers_automatically_) { 302 if (!was_handshake_confirmed_ && request_info_->method == "POST") {
300 SendRequestHeaders(); 303 waiting_for_confirmation_ = true;
304 return;
301 } 305 }
302 if (delegate_) 306 NotifyStreamReady();
303 delegate_->OnStreamReady(has_sent_headers_);
304 } else { 307 } else {
305 NotifyError(rv); 308 NotifyError(rv);
306 } 309 }
307 } 310 }
308 311
309 void BidirectionalStreamQuicImpl::OnSendDataComplete(int rv) { 312 void BidirectionalStreamQuicImpl::OnSendDataComplete(int rv) {
310 DCHECK(rv == OK || !stream_); 313 DCHECK(rv == OK || !stream_);
311 if (rv == OK) { 314 if (rv == OK) {
312 if (delegate_) 315 if (delegate_)
313 delegate_->OnDataSent(); 316 delegate_->OnDataSent();
(...skipping 11 matching lines...) Expand all
325 response_status_ = error; 328 response_status_ = error;
326 BidirectionalStreamImpl::Delegate* delegate = delegate_; 329 BidirectionalStreamImpl::Delegate* delegate = delegate_;
327 delegate_ = nullptr; 330 delegate_ = nullptr;
328 // Cancel any pending callback. 331 // Cancel any pending callback.
329 weak_factory_.InvalidateWeakPtrs(); 332 weak_factory_.InvalidateWeakPtrs();
330 delegate->OnFailed(error); 333 delegate->OnFailed(error);
331 // |this| might be destroyed at this point. 334 // |this| might be destroyed at this point.
332 } 335 }
333 } 336 }
334 337
338 void BidirectionalStreamQuicImpl::NotifyStreamReady() {
339 if (send_request_headers_automatically_) {
340 SendRequestHeaders();
341 }
342 if (delegate_)
343 delegate_->OnStreamReady(has_sent_headers_);
344 }
345
335 void BidirectionalStreamQuicImpl::ResetStream() { 346 void BidirectionalStreamQuicImpl::ResetStream() {
336 if (!stream_) 347 if (!stream_)
337 return; 348 return;
338 closed_stream_received_bytes_ = stream_->stream_bytes_read(); 349 closed_stream_received_bytes_ = stream_->stream_bytes_read();
339 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); 350 closed_stream_sent_bytes_ = stream_->stream_bytes_written();
340 stream_->SetDelegate(nullptr); 351 stream_->SetDelegate(nullptr);
341 stream_ = nullptr; 352 stream_ = nullptr;
342 } 353 }
343 354
344 } // namespace net 355 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/bidirectional_stream_quic_impl.h ('k') | net/quic/bidirectional_stream_quic_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698