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

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

Issue 2918663002: Clean up error handling in BidirectionalStreamQuicImpl::Start (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | net/quic/chromium/bidirectional_stream_quic_impl_unittest.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 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/chromium/bidirectional_stream_quic_impl.h" 5 #include "net/quic/chromium/bidirectional_stream_quic_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 47
48 void BidirectionalStreamQuicImpl::Start( 48 void BidirectionalStreamQuicImpl::Start(
49 const BidirectionalStreamRequestInfo* request_info, 49 const BidirectionalStreamRequestInfo* request_info,
50 const NetLogWithSource& net_log, 50 const NetLogWithSource& net_log,
51 bool send_request_headers_automatically, 51 bool send_request_headers_automatically,
52 BidirectionalStreamImpl::Delegate* delegate, 52 BidirectionalStreamImpl::Delegate* delegate,
53 std::unique_ptr<base::Timer> /* timer */) { 53 std::unique_ptr<base::Timer> /* timer */) {
54 DCHECK(!stream_); 54 DCHECK(!stream_);
55 CHECK(delegate); 55 CHECK(delegate);
56 DLOG_IF(WARNING, !session_->IsConnected())
57 << "Trying to start request headers after session has been closed.";
56 58
57 send_request_headers_automatically_ = send_request_headers_automatically; 59 send_request_headers_automatically_ = send_request_headers_automatically;
58 if (!session_->IsConnected()) {
59 NotifyError(session_->IsCryptoHandshakeConfirmed()
60 ? ERR_QUIC_PROTOCOL_ERROR
61 : ERR_QUIC_HANDSHAKE_FAILED);
62 return;
63 }
Ryan Hamilton 2017/05/31 21:51:59 Since both the handle's RequestStream and the sess
xunjieli 2017/05/31 23:40:12 Acknowledged.
64
65 delegate_ = delegate; 60 delegate_ = delegate;
66 request_info_ = request_info; 61 request_info_ = request_info;
67 62
68 int rv = session_->RequestStream( 63 int rv = session_->RequestStream(
69 request_info_->method == "POST", 64 request_info_->method == "POST",
70 base::Bind(&BidirectionalStreamQuicImpl::OnStreamReady, 65 base::Bind(&BidirectionalStreamQuicImpl::OnStreamReady,
71 weak_factory_.GetWeakPtr())); 66 weak_factory_.GetWeakPtr()));
72 if (rv == ERR_IO_PENDING) 67 if (rv == ERR_IO_PENDING)
73 return; 68 return;
74 69
75 if (rv == OK) { 70 if (rv != OK) {
76 OnStreamReady(rv); 71 base::ThreadTaskRunnerHandle::Get()->PostTask(
77 } else if (!session_->IsCryptoHandshakeConfirmed()) { 72 FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::NotifyError,
Ryan Hamilton 2017/05/31 21:51:59 I'm pretty sure we need to do a PostTask here, oth
xunjieli 2017/05/31 23:40:12 Per offline discussion, I think the PostTask is no
Ryan Hamilton 2017/06/01 02:15:36 I'm not worried about the delegate calling back in
xunjieli 2017/06/01 11:57:54 I thought about this some more yesterday. I think
78 NotifyError(ERR_QUIC_HANDSHAKE_FAILED); 73 weak_factory_.GetWeakPtr(),
74 session_->IsCryptoHandshakeConfirmed()
75 ? ERR_QUIC_PROTOCOL_ERROR
Ryan Hamilton 2017/05/31 21:51:59 We could use |rv| instead of ERR_QUIC_PROTOCOL_ERR
xunjieli 2017/05/31 23:40:12 SG. Let's use |rv| here.
Ryan Hamilton 2017/06/01 02:15:36 Done.
76 : ERR_QUIC_HANDSHAKE_FAILED));
77 return;
79 } 78 }
79
80 OnStreamReady(rv);
80 } 81 }
81 82
82 void BidirectionalStreamQuicImpl::SendRequestHeaders() { 83 void BidirectionalStreamQuicImpl::SendRequestHeaders() {
83 DCHECK(!has_sent_headers_); 84 DCHECK(!has_sent_headers_);
84 if (!stream_) { 85 if (!stream_) {
85 LOG(ERROR) 86 LOG(ERROR)
86 << "Trying to send request headers after stream has been destroyed."; 87 << "Trying to send request headers after stream has been destroyed.";
87 base::ThreadTaskRunnerHandle::Get()->PostTask( 88 base::ThreadTaskRunnerHandle::Get()->PostTask(
88 FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::NotifyError, 89 FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::NotifyError,
89 weak_factory_.GetWeakPtr(), ERR_UNEXPECTED)); 90 weak_factory_.GetWeakPtr(), ERR_UNEXPECTED));
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 if (!stream_) 389 if (!stream_)
389 return; 390 return;
390 closed_stream_received_bytes_ = stream_->stream_bytes_read(); 391 closed_stream_received_bytes_ = stream_->stream_bytes_read();
391 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); 392 closed_stream_sent_bytes_ = stream_->stream_bytes_written();
392 closed_is_first_stream_ = stream_->IsFirstStream(); 393 closed_is_first_stream_ = stream_->IsFirstStream();
393 stream_->ClearDelegate(); 394 stream_->ClearDelegate();
394 stream_ = nullptr; 395 stream_ = nullptr;
395 } 396 }
396 397
397 } // namespace net 398 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/chromium/bidirectional_stream_quic_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698