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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...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::OnHeadersSent() { | 116 void CronetBidirectionalStream::OnStreamReady() { |
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_->OnHeadersSent(); | 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) { |
127 DCHECK(environment_->IsOnNetworkThread()); | 127 DCHECK(environment_->IsOnNetworkThread()); |
128 DCHECK(read_state_ == STARTED); | 128 DCHECK(read_state_ == STARTED); |
129 read_state_ = WAITING_FOR_READ; | 129 read_state_ = WAITING_FOR_READ; |
130 // Get http status code from response headers. | 130 // Get http status code from response headers. |
131 int http_status_code = 0; | 131 int http_status_code = 0; |
132 const auto http_status_header = response_headers.find(":status"); | 132 const auto http_status_header = response_headers.find(":status"); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 void CronetBidirectionalStream::MaybeOnSucceded() { | 262 void CronetBidirectionalStream::MaybeOnSucceded() { |
263 DCHECK(environment_->IsOnNetworkThread()); | 263 DCHECK(environment_->IsOnNetworkThread()); |
264 if (read_state_ == READING_DONE && write_state_ == WRITING_DONE) { | 264 if (read_state_ == READING_DONE && write_state_ == WRITING_DONE) { |
265 read_state_ = write_state_ = SUCCESS; | 265 read_state_ = write_state_ = SUCCESS; |
266 bidi_stream_.reset(); | 266 bidi_stream_.reset(); |
267 delegate_->OnSucceeded(); | 267 delegate_->OnSucceeded(); |
268 } | 268 } |
269 } | 269 } |
270 | 270 |
271 } // namespace cronet | 271 } // namespace cronet |
OLD | NEW |