OLD | NEW |
---|---|
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 is_first_stream = stream_->IsFirstStream(); | 225 is_first_stream = stream_->IsFirstStream(); |
226 if (is_first_stream) { | 226 if (is_first_stream) { |
227 load_timing_info->socket_reused = false; | 227 load_timing_info->socket_reused = false; |
228 load_timing_info->connect_timing = connect_timing_; | 228 load_timing_info->connect_timing = connect_timing_; |
229 } else { | 229 } else { |
230 load_timing_info->socket_reused = true; | 230 load_timing_info->socket_reused = true; |
231 } | 231 } |
232 return true; | 232 return true; |
233 } | 233 } |
234 | 234 |
235 void BidirectionalStreamQuicImpl::OnTrailingHeadersAvailable( | |
236 const SpdyHeaderBlock& headers, | |
237 size_t frame_len) { | |
238 headers_bytes_received_ += frame_len; | |
239 if (delegate_) | |
240 delegate_->OnTrailersReceived(headers); | |
241 // |this| can be destroyed after this point. | |
242 } | |
243 | |
244 void BidirectionalStreamQuicImpl::OnClose() { | 235 void BidirectionalStreamQuicImpl::OnClose() { |
245 DCHECK(stream_); | 236 DCHECK(stream_); |
246 | 237 |
247 if (stream_->connection_error() != QUIC_NO_ERROR || | 238 if (stream_->connection_error() != QUIC_NO_ERROR || |
248 stream_->stream_error() != QUIC_STREAM_NO_ERROR) { | 239 stream_->stream_error() != QUIC_STREAM_NO_ERROR) { |
249 NotifyError(session_->IsCryptoHandshakeConfirmed() | 240 NotifyError(session_->IsCryptoHandshakeConfirmed() |
250 ? ERR_QUIC_PROTOCOL_ERROR | 241 ? ERR_QUIC_PROTOCOL_ERROR |
251 : ERR_QUIC_HANDSHAKE_FAILED); | 242 : ERR_QUIC_HANDSHAKE_FAILED); |
252 return; | 243 return; |
253 } | 244 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 if (rv < 0) { | 294 if (rv < 0) { |
304 NotifyError(rv); | 295 NotifyError(rv); |
305 return; | 296 return; |
306 } | 297 } |
307 | 298 |
308 headers_bytes_received_ += rv; | 299 headers_bytes_received_ += rv; |
309 negotiated_protocol_ = kProtoQUIC; | 300 negotiated_protocol_ = kProtoQUIC; |
310 connect_timing_ = session_->GetConnectTiming(); | 301 connect_timing_ = session_->GetConnectTiming(); |
311 if (delegate_) | 302 if (delegate_) |
312 delegate_->OnHeadersReceived(initial_headers_); | 303 delegate_->OnHeadersReceived(initial_headers_); |
304 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
305 FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::ReadTrailingHeaders, | |
306 weak_factory_.GetWeakPtr())); | |
xunjieli
2017/05/26 15:53:05
Should we post this task before calling into the |
Ryan Hamilton
2017/05/26 22:35:50
Indeed! I noticed this in a followup, but forgot t
| |
307 } | |
308 | |
309 void BidirectionalStreamQuicImpl::ReadTrailingHeaders() { | |
310 int rv = stream_->ReadTrailingHeaders( | |
311 &trailing_headers_, | |
312 base::Bind(&BidirectionalStreamQuicImpl::OnReadTrailingHeadersComplete, | |
313 weak_factory_.GetWeakPtr())); | |
314 | |
315 if (rv != ERR_IO_PENDING) | |
316 OnReadTrailingHeadersComplete(rv); | |
317 } | |
318 | |
319 void BidirectionalStreamQuicImpl::OnReadTrailingHeadersComplete(int rv) { | |
320 DCHECK_NE(ERR_IO_PENDING, rv); | |
321 if (rv < 0) { | |
322 NotifyError(rv); | |
323 return; | |
324 } | |
325 | |
326 headers_bytes_received_ += rv; | |
327 | |
328 if (delegate_) | |
329 delegate_->OnTrailersReceived(trailing_headers_); | |
313 } | 330 } |
314 | 331 |
315 void BidirectionalStreamQuicImpl::OnReadDataComplete(int rv) { | 332 void BidirectionalStreamQuicImpl::OnReadDataComplete(int rv) { |
316 DCHECK_GE(rv, 0); | 333 DCHECK_GE(rv, 0); |
317 read_buffer_ = nullptr; | 334 read_buffer_ = nullptr; |
318 read_buffer_len_ = 0; | 335 read_buffer_len_ = 0; |
319 if (delegate_) | 336 if (delegate_) |
320 delegate_->OnDataRead(rv); | 337 delegate_->OnDataRead(rv); |
321 } | 338 } |
322 | 339 |
(...skipping 25 matching lines...) Expand all Loading... | |
348 if (!stream_) | 365 if (!stream_) |
349 return; | 366 return; |
350 closed_stream_received_bytes_ = stream_->stream_bytes_read(); | 367 closed_stream_received_bytes_ = stream_->stream_bytes_read(); |
351 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); | 368 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); |
352 closed_is_first_stream_ = stream_->IsFirstStream(); | 369 closed_is_first_stream_ = stream_->IsFirstStream(); |
353 stream_->ClearDelegate(); | 370 stream_->ClearDelegate(); |
354 stream_ = nullptr; | 371 stream_ = nullptr; |
355 } | 372 } |
356 | 373 |
357 } // namespace net | 374 } // namespace net |
OLD | NEW |