| 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 "components/cronet/ios/cronet_bidirectional_stream.h" | 5 #include "components/cronet/ios/cronet_bidirectional_stream.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 106 |
| 107 void CronetBidirectionalStream::Destroy() { | 107 void CronetBidirectionalStream::Destroy() { |
| 108 // Destroy could be called from any thread, including network thread (if | 108 // Destroy could be called from any thread, including network thread (if |
| 109 // posting task to executor throws an exception), but is posted, so |this| | 109 // posting task to executor throws an exception), but is posted, so |this| |
| 110 // is valid until calling task is complete. | 110 // is valid until calling task is complete. |
| 111 environment_->PostToNetworkThread( | 111 environment_->PostToNetworkThread( |
| 112 FROM_HERE, base::Bind(&CronetBidirectionalStream::DestroyOnNetworkThread, | 112 FROM_HERE, base::Bind(&CronetBidirectionalStream::DestroyOnNetworkThread, |
| 113 base::Unretained(this))); | 113 base::Unretained(this))); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void CronetBidirectionalStream::OnStreamReady() { | 116 void CronetBidirectionalStream::OnStreamReady(bool /*request_headers_sent*/) { |
| 117 DCHECK(environment_->IsOnNetworkThread()); | 117 DCHECK(environment_->IsOnNetworkThread()); |
| 118 DCHECK(write_state_ == STARTED); | 118 DCHECK(write_state_ == STARTED); |
| 119 write_state_ = WAITING_FOR_WRITE; | 119 write_state_ = WAITING_FOR_WRITE; |
| 120 if (write_end_of_stream_) | 120 if (write_end_of_stream_) |
| 121 write_state_ = WRITING_DONE; | 121 write_state_ = WRITING_DONE; |
| 122 delegate_->OnStreamReady(); | 122 delegate_->OnStreamReady(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void CronetBidirectionalStream::OnHeadersReceived( | 125 void CronetBidirectionalStream::OnHeadersReceived( |
| 126 const net::SpdyHeaderBlock& response_headers) { | 126 const net::SpdyHeaderBlock& response_headers) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 void CronetBidirectionalStream::MaybeOnSucceded() { | 266 void CronetBidirectionalStream::MaybeOnSucceded() { |
| 267 DCHECK(environment_->IsOnNetworkThread()); | 267 DCHECK(environment_->IsOnNetworkThread()); |
| 268 if (read_state_ == READING_DONE && write_state_ == WRITING_DONE) { | 268 if (read_state_ == READING_DONE && write_state_ == WRITING_DONE) { |
| 269 read_state_ = write_state_ = SUCCESS; | 269 read_state_ = write_state_ = SUCCESS; |
| 270 bidi_stream_.reset(); | 270 bidi_stream_.reset(); |
| 271 delegate_->OnSucceeded(); | 271 delegate_->OnSucceeded(); |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace cronet | 275 } // namespace cronet |
| OLD | NEW |