| 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/http/bidirectional_stream.h" | 5 #include "net/http/bidirectional_stream.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 206 |
| 207 int64_t BidirectionalStream::GetTotalSentBytes() const { | 207 int64_t BidirectionalStream::GetTotalSentBytes() const { |
| 208 if (!stream_impl_) | 208 if (!stream_impl_) |
| 209 return 0; | 209 return 0; |
| 210 | 210 |
| 211 return stream_impl_->GetTotalSentBytes(); | 211 return stream_impl_->GetTotalSentBytes(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void BidirectionalStream::OnStreamReady(bool request_headers_sent) { | 214 void BidirectionalStream::OnStreamReady(bool request_headers_sent) { |
| 215 request_headers_sent_ = request_headers_sent; | 215 request_headers_sent_ = request_headers_sent; |
| 216 if (net_log_.IsCapturing()) { |
| 217 net_log_.AddEvent( |
| 218 NetLog::TYPE_BIDIRECTIONAL_STREAM_READY, |
| 219 NetLog::BoolCallback("request_headers_sent", request_headers_sent)); |
| 220 } |
| 216 delegate_->OnStreamReady(request_headers_sent); | 221 delegate_->OnStreamReady(request_headers_sent); |
| 217 } | 222 } |
| 218 | 223 |
| 219 void BidirectionalStream::OnHeadersReceived( | 224 void BidirectionalStream::OnHeadersReceived( |
| 220 const SpdyHeaderBlock& response_headers) { | 225 const SpdyHeaderBlock& response_headers) { |
| 221 HttpResponseInfo response_info; | 226 HttpResponseInfo response_info; |
| 222 if (!SpdyHeadersToHttpResponse(response_headers, HTTP2, &response_info)) { | 227 if (!SpdyHeadersToHttpResponse(response_headers, HTTP2, &response_info)) { |
| 223 DLOG(WARNING) << "Invalid headers"; | 228 DLOG(WARNING) << "Invalid headers"; |
| 224 NotifyFailed(ERR_FAILED); | 229 NotifyFailed(ERR_FAILED); |
| 225 return; | 230 return; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 244 } | 249 } |
| 245 read_buffer_ = nullptr; | 250 read_buffer_ = nullptr; |
| 246 delegate_->OnDataRead(bytes_read); | 251 delegate_->OnDataRead(bytes_read); |
| 247 } | 252 } |
| 248 | 253 |
| 249 void BidirectionalStream::OnDataSent() { | 254 void BidirectionalStream::OnDataSent() { |
| 250 DCHECK(!write_buffer_list_.empty()); | 255 DCHECK(!write_buffer_list_.empty()); |
| 251 DCHECK_EQ(write_buffer_list_.size(), write_buffer_len_list_.size()); | 256 DCHECK_EQ(write_buffer_list_.size(), write_buffer_len_list_.size()); |
| 252 | 257 |
| 253 if (net_log_.IsCapturing()) { | 258 if (net_log_.IsCapturing()) { |
| 259 if (write_buffer_list_.size() > 1) { |
| 260 net_log_.BeginEvent( |
| 261 NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_SENT_COALESCED, |
| 262 NetLog::IntCallback("num_buffers_coalesced", |
| 263 write_buffer_list_.size())); |
| 264 } |
| 254 for (size_t i = 0; i < write_buffer_list_.size(); ++i) { | 265 for (size_t i = 0; i < write_buffer_list_.size(); ++i) { |
| 255 net_log_.AddByteTransferEvent( | 266 net_log_.AddByteTransferEvent( |
| 256 NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_SENT, | 267 NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_SENT, |
| 257 write_buffer_len_list_[i], write_buffer_list_[i]->data()); | 268 write_buffer_len_list_[i], write_buffer_list_[i]->data()); |
| 258 } | 269 } |
| 270 if (write_buffer_list_.size() > 1) { |
| 271 net_log_.EndEvent(NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_SENT_COALESCED); |
| 272 } |
| 259 } | 273 } |
| 260 write_buffer_list_.clear(); | 274 write_buffer_list_.clear(); |
| 261 write_buffer_len_list_.clear(); | 275 write_buffer_len_list_.clear(); |
| 262 delegate_->OnDataSent(); | 276 delegate_->OnDataSent(); |
| 263 } | 277 } |
| 264 | 278 |
| 265 void BidirectionalStream::OnTrailersReceived(const SpdyHeaderBlock& trailers) { | 279 void BidirectionalStream::OnTrailersReceived(const SpdyHeaderBlock& trailers) { |
| 266 if (net_log_.IsCapturing()) { | 280 if (net_log_.IsCapturing()) { |
| 267 net_log_.AddEvent(NetLog::TYPE_BIDIRECTIONAL_STREAM_RECV_TRAILERS, | 281 net_log_.AddEvent(NetLog::TYPE_BIDIRECTIONAL_STREAM_RECV_TRAILERS, |
| 268 base::Bind(&NetLogHeadersCallback, &trailers)); | 282 base::Bind(&NetLogHeadersCallback, &trailers)); |
| 269 } | 283 } |
| 270 delegate_->OnTrailersReceived(trailers); | 284 delegate_->OnTrailersReceived(trailers); |
| 271 } | 285 } |
| 272 | 286 |
| 273 void BidirectionalStream::OnFailed(int status) { | 287 void BidirectionalStream::OnFailed(int status) { |
| 288 if (net_log_.IsCapturing()) { |
| 289 net_log_.AddEvent(NetLog::TYPE_BIDIRECTIONAL_STREAM_FAILED, |
| 290 NetLog::IntCallback("net_error", status)); |
| 291 } |
| 274 NotifyFailed(status); | 292 NotifyFailed(status); |
| 275 } | 293 } |
| 276 | 294 |
| 277 void BidirectionalStream::OnStreamReady(const SSLConfig& used_ssl_config, | 295 void BidirectionalStream::OnStreamReady(const SSLConfig& used_ssl_config, |
| 278 const ProxyInfo& used_proxy_info, | 296 const ProxyInfo& used_proxy_info, |
| 279 HttpStream* stream) { | 297 HttpStream* stream) { |
| 280 NOTREACHED(); | 298 NOTREACHED(); |
| 281 } | 299 } |
| 282 | 300 |
| 283 void BidirectionalStream::OnBidirectionalStreamImplReady( | 301 void BidirectionalStream::OnBidirectionalStreamImplReady( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 NotifyFailed(ERR_HTTPS_PROXY_TUNNEL_RESPONSE); | 365 NotifyFailed(ERR_HTTPS_PROXY_TUNNEL_RESPONSE); |
| 348 } | 366 } |
| 349 | 367 |
| 350 void BidirectionalStream::OnQuicBroken() {} | 368 void BidirectionalStream::OnQuicBroken() {} |
| 351 | 369 |
| 352 void BidirectionalStream::NotifyFailed(int error) { | 370 void BidirectionalStream::NotifyFailed(int error) { |
| 353 delegate_->OnFailed(error); | 371 delegate_->OnFailed(error); |
| 354 } | 372 } |
| 355 | 373 |
| 356 } // namespace net | 374 } // namespace net |
| OLD | NEW |