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 17 matching lines...) Expand all Loading... |
28 delegate_(nullptr), | 28 delegate_(nullptr), |
29 response_status_(OK), | 29 response_status_(OK), |
30 negotiated_protocol_(kProtoUnknown), | 30 negotiated_protocol_(kProtoUnknown), |
31 read_buffer_len_(0), | 31 read_buffer_len_(0), |
32 headers_bytes_received_(0), | 32 headers_bytes_received_(0), |
33 headers_bytes_sent_(0), | 33 headers_bytes_sent_(0), |
34 closed_stream_received_bytes_(0), | 34 closed_stream_received_bytes_(0), |
35 closed_stream_sent_bytes_(0), | 35 closed_stream_sent_bytes_(0), |
36 closed_is_first_stream_(false), | 36 closed_is_first_stream_(false), |
37 has_sent_headers_(false), | 37 has_sent_headers_(false), |
38 has_received_headers_(false), | |
39 send_request_headers_automatically_(true), | 38 send_request_headers_automatically_(true), |
40 weak_factory_(this) {} | 39 weak_factory_(this) {} |
41 | 40 |
42 BidirectionalStreamQuicImpl::~BidirectionalStreamQuicImpl() { | 41 BidirectionalStreamQuicImpl::~BidirectionalStreamQuicImpl() { |
43 if (stream_) { | 42 if (stream_) { |
44 delegate_ = nullptr; | 43 delegate_ = nullptr; |
45 stream_->Reset(QUIC_STREAM_CANCELLED); | 44 stream_->Reset(QUIC_STREAM_CANCELLED); |
46 } | 45 } |
47 } | 46 } |
48 | 47 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 is_first_stream = stream_->IsFirstStream(); | 220 is_first_stream = stream_->IsFirstStream(); |
222 if (is_first_stream) { | 221 if (is_first_stream) { |
223 load_timing_info->socket_reused = false; | 222 load_timing_info->socket_reused = false; |
224 load_timing_info->connect_timing = connect_timing_; | 223 load_timing_info->connect_timing = connect_timing_; |
225 } else { | 224 } else { |
226 load_timing_info->socket_reused = true; | 225 load_timing_info->socket_reused = true; |
227 } | 226 } |
228 return true; | 227 return true; |
229 } | 228 } |
230 | 229 |
231 void BidirectionalStreamQuicImpl::OnHeadersAvailable( | 230 void BidirectionalStreamQuicImpl::OnInitialHeadersAvailable( |
232 const SpdyHeaderBlock& headers, | 231 const SpdyHeaderBlock& headers, |
233 size_t frame_len) { | 232 size_t frame_len) { |
234 headers_bytes_received_ += frame_len; | 233 headers_bytes_received_ += frame_len; |
235 negotiated_protocol_ = kProtoQUIC; | 234 negotiated_protocol_ = kProtoQUIC; |
236 if (!has_received_headers_) { | 235 connect_timing_ = session_->GetConnectTiming(); |
237 has_received_headers_ = true; | 236 if (delegate_) |
238 connect_timing_ = session_->GetConnectTiming(); | 237 delegate_->OnHeadersReceived(headers); |
239 if (delegate_) | 238 } |
240 delegate_->OnHeadersReceived(headers); | 239 |
241 } else { | 240 void BidirectionalStreamQuicImpl::OnTrailingHeadersAvailable( |
242 if (delegate_) | 241 const SpdyHeaderBlock& headers, |
243 delegate_->OnTrailersReceived(headers); | 242 size_t frame_len) { |
244 // |this| can be destroyed after this point. | 243 headers_bytes_received_ += frame_len; |
245 } | 244 if (delegate_) |
| 245 delegate_->OnTrailersReceived(headers); |
| 246 // |this| can be destroyed after this point. |
246 } | 247 } |
247 | 248 |
248 void BidirectionalStreamQuicImpl::OnDataAvailable() { | 249 void BidirectionalStreamQuicImpl::OnDataAvailable() { |
249 // Return early if ReadData has not been called. | 250 // Return early if ReadData has not been called. |
250 if (!read_buffer_) | 251 if (!read_buffer_) |
251 return; | 252 return; |
252 | 253 |
253 int rv = ReadData(read_buffer_.get(), read_buffer_len_); | 254 int rv = ReadData(read_buffer_.get(), read_buffer_len_); |
254 if (rv == ERR_IO_PENDING) { | 255 if (rv == ERR_IO_PENDING) { |
255 // Spurrious notification. Wait for the next one. | 256 // Spurrious notification. Wait for the next one. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 if (!stream_) | 339 if (!stream_) |
339 return; | 340 return; |
340 closed_stream_received_bytes_ = stream_->stream_bytes_read(); | 341 closed_stream_received_bytes_ = stream_->stream_bytes_read(); |
341 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); | 342 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); |
342 closed_is_first_stream_ = stream_->IsFirstStream(); | 343 closed_is_first_stream_ = stream_->IsFirstStream(); |
343 stream_->SetDelegate(nullptr); | 344 stream_->SetDelegate(nullptr); |
344 stream_ = nullptr; | 345 stream_ = nullptr; |
345 } | 346 } |
346 | 347 |
347 } // namespace net | 348 } // namespace net |
OLD | NEW |