| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 ResetStream(); | 259 ResetStream(); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void BidirectionalStreamQuicImpl::OnError(int error) { | 262 void BidirectionalStreamQuicImpl::OnError(int error) { |
| 263 NotifyError(error); | 263 NotifyError(error); |
| 264 } | 264 } |
| 265 | 265 |
| 266 void BidirectionalStreamQuicImpl::OnStreamReady(int rv) { | 266 void BidirectionalStreamQuicImpl::OnStreamReady(int rv) { |
| 267 DCHECK_NE(ERR_IO_PENDING, rv); | 267 DCHECK_NE(ERR_IO_PENDING, rv); |
| 268 DCHECK(rv == OK || !stream_); | 268 DCHECK(rv == OK || !stream_); |
| 269 if (rv == OK) { | 269 if (rv != OK) { |
| 270 stream_ = session_->ReleaseStream(this); | 270 NotifyError(rv); |
| 271 return; |
| 272 } |
| 271 | 273 |
| 272 base::ThreadTaskRunnerHandle::Get()->PostTask( | 274 stream_ = session_->ReleaseStream(this); |
| 273 FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::ReadInitialHeaders, | |
| 274 weak_factory_.GetWeakPtr())); | |
| 275 | 275 |
| 276 NotifyStreamReady(); | 276 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 277 } else { | 277 FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::ReadInitialHeaders, |
| 278 NotifyError(rv); | 278 weak_factory_.GetWeakPtr())); |
| 279 } | 279 |
| 280 NotifyStreamReady(); |
| 280 } | 281 } |
| 281 | 282 |
| 282 void BidirectionalStreamQuicImpl::OnSendDataComplete(int rv) { | 283 void BidirectionalStreamQuicImpl::OnSendDataComplete(int rv) { |
| 283 DCHECK(rv == OK || !stream_); | 284 DCHECK(rv == OK || !stream_); |
| 284 if (rv == OK) { | 285 if (rv != 0) { |
| 285 if (delegate_) | |
| 286 delegate_->OnDataSent(); | |
| 287 } else { | |
| 288 NotifyError(rv); | 286 NotifyError(rv); |
| 287 return; |
| 289 } | 288 } |
| 289 |
| 290 if (delegate_) |
| 291 delegate_->OnDataSent(); |
| 290 } | 292 } |
| 291 | 293 |
| 292 void BidirectionalStreamQuicImpl::OnReadInitialHeadersComplete(int rv) { | 294 void BidirectionalStreamQuicImpl::OnReadInitialHeadersComplete(int rv) { |
| 293 DCHECK_NE(ERR_IO_PENDING, rv); | 295 DCHECK_NE(ERR_IO_PENDING, rv); |
| 294 if (rv < 0) { | 296 if (rv < 0) { |
| 295 NotifyError(rv); | 297 NotifyError(rv); |
| 296 return; | 298 return; |
| 297 } | 299 } |
| 298 | 300 |
| 299 headers_bytes_received_ += rv; | 301 headers_bytes_received_ += rv; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 if (!stream_) | 388 if (!stream_) |
| 387 return; | 389 return; |
| 388 closed_stream_received_bytes_ = stream_->stream_bytes_read(); | 390 closed_stream_received_bytes_ = stream_->stream_bytes_read(); |
| 389 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); | 391 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); |
| 390 closed_is_first_stream_ = stream_->IsFirstStream(); | 392 closed_is_first_stream_ = stream_->IsFirstStream(); |
| 391 stream_->ClearDelegate(); | 393 stream_->ClearDelegate(); |
| 392 stream_ = nullptr; | 394 stream_ = nullptr; |
| 393 } | 395 } |
| 394 | 396 |
| 395 } // namespace net | 397 } // namespace net |
| OLD | NEW |