| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 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/spdy/bidirectional_stream_spdy_impl.h" | 5 #include "net/spdy/bidirectional_stream_spdy_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 12 matching lines...) Expand all Loading... |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // Time to wait in millisecond to notify |delegate_| of data received. | 25 // Time to wait in millisecond to notify |delegate_| of data received. |
| 26 // Handing small chunks of data to the caller creates measurable overhead. | 26 // Handing small chunks of data to the caller creates measurable overhead. |
| 27 // So buffer data in short time-spans and send a single read notification. | 27 // So buffer data in short time-spans and send a single read notification. |
| 28 const int kBufferTimeMs = 1; | 28 const int kBufferTimeMs = 1; |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 BidirectionalStreamSpdyImpl::BidirectionalStreamSpdyImpl( | 32 BidirectionalStreamSpdyImpl::BidirectionalStreamSpdyImpl( |
| 33 const base::WeakPtr<SpdySession>& spdy_session) | 33 const base::WeakPtr<SpdySession>& spdy_session, |
| 34 NetLogSource source_dependency) |
| 34 : spdy_session_(spdy_session), | 35 : spdy_session_(spdy_session), |
| 35 request_info_(nullptr), | 36 request_info_(nullptr), |
| 36 delegate_(nullptr), | 37 delegate_(nullptr), |
| 38 source_dependency_(source_dependency), |
| 37 negotiated_protocol_(kProtoUnknown), | 39 negotiated_protocol_(kProtoUnknown), |
| 38 more_read_data_pending_(false), | 40 more_read_data_pending_(false), |
| 39 read_buffer_len_(0), | 41 read_buffer_len_(0), |
| 40 written_end_of_stream_(false), | 42 written_end_of_stream_(false), |
| 41 write_pending_(false), | 43 write_pending_(false), |
| 42 stream_closed_(false), | 44 stream_closed_(false), |
| 43 closed_stream_status_(ERR_FAILED), | 45 closed_stream_status_(ERR_FAILED), |
| 44 closed_stream_received_bytes_(0), | 46 closed_stream_received_bytes_(0), |
| 45 closed_stream_sent_bytes_(0), | 47 closed_stream_sent_bytes_(0), |
| 46 closed_has_load_timing_info_(false), | 48 closed_has_load_timing_info_(false), |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 timer_->Stop(); | 288 timer_->Stop(); |
| 287 | 289 |
| 288 // |this| might get destroyed after calling into |delegate_| in | 290 // |this| might get destroyed after calling into |delegate_| in |
| 289 // DoBufferedRead(). | 291 // DoBufferedRead(). |
| 290 auto weak_this = weak_factory_.GetWeakPtr(); | 292 auto weak_this = weak_factory_.GetWeakPtr(); |
| 291 DoBufferedRead(); | 293 DoBufferedRead(); |
| 292 if (weak_this.get() && write_pending_) | 294 if (weak_this.get() && write_pending_) |
| 293 OnDataSent(); | 295 OnDataSent(); |
| 294 } | 296 } |
| 295 | 297 |
| 298 NetLogSource BidirectionalStreamSpdyImpl::source_dependency() const { |
| 299 return source_dependency_; |
| 300 } |
| 301 |
| 296 int BidirectionalStreamSpdyImpl::SendRequestHeadersHelper() { | 302 int BidirectionalStreamSpdyImpl::SendRequestHeadersHelper() { |
| 297 SpdyHeaderBlock headers; | 303 SpdyHeaderBlock headers; |
| 298 HttpRequestInfo http_request_info; | 304 HttpRequestInfo http_request_info; |
| 299 http_request_info.url = request_info_->url; | 305 http_request_info.url = request_info_->url; |
| 300 http_request_info.method = request_info_->method; | 306 http_request_info.method = request_info_->method; |
| 301 http_request_info.extra_headers = request_info_->extra_headers; | 307 http_request_info.extra_headers = request_info_->extra_headers; |
| 302 | 308 |
| 303 CreateSpdyHeadersFromHttpRequest( | 309 CreateSpdyHeadersFromHttpRequest( |
| 304 http_request_info, http_request_info.extra_headers, true, &headers); | 310 http_request_info, http_request_info.extra_headers, true, &headers); |
| 305 written_end_of_stream_ = request_info_->end_stream_on_headers; | 311 written_end_of_stream_ = request_info_->end_stream_on_headers; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 return true; | 415 return true; |
| 410 } | 416 } |
| 411 LOG(ERROR) << "Trying to send data after stream has been destroyed."; | 417 LOG(ERROR) << "Trying to send data after stream has been destroyed."; |
| 412 base::ThreadTaskRunnerHandle::Get()->PostTask( | 418 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 413 FROM_HERE, base::Bind(&BidirectionalStreamSpdyImpl::NotifyError, | 419 FROM_HERE, base::Bind(&BidirectionalStreamSpdyImpl::NotifyError, |
| 414 weak_factory_.GetWeakPtr(), ERR_UNEXPECTED)); | 420 weak_factory_.GetWeakPtr(), ERR_UNEXPECTED)); |
| 415 return true; | 421 return true; |
| 416 } | 422 } |
| 417 | 423 |
| 418 } // namespace net | 424 } // namespace net |
| OLD | NEW |