OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/spdy_http_stream.h" | 5 #include "net/spdy/spdy_http_stream.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 384 |
385 if (user_callback_) | 385 if (user_callback_) |
386 DoCallback(status); | 386 DoCallback(status); |
387 return status; | 387 return status; |
388 } | 388 } |
389 | 389 |
390 void SpdyHttpStream::OnDataReceived(const char* data, int length) { | 390 void SpdyHttpStream::OnDataReceived(const char* data, int length) { |
391 // Note that data may be received for a SpdyStream prior to the user calling | 391 // Note that data may be received for a SpdyStream prior to the user calling |
392 // ReadResponseBody(), therefore user_buffer_ may be NULL. This may often | 392 // ReadResponseBody(), therefore user_buffer_ may be NULL. This may often |
393 // happen for server initiated streams. | 393 // happen for server initiated streams. |
394 if (length > 0 && !stream_->closed()) { | 394 DCHECK(!stream_->closed() || stream_->pushed()); |
| 395 if (length > 0) { |
395 // Save the received data. | 396 // Save the received data. |
396 IOBufferWithSize* io_buffer = new IOBufferWithSize(length); | 397 IOBufferWithSize* io_buffer = new IOBufferWithSize(length); |
397 memcpy(io_buffer->data(), data, length); | 398 memcpy(io_buffer->data(), data, length); |
398 response_body_.push_back(io_buffer); | 399 response_body_.push_back(io_buffer); |
399 | 400 |
400 if (user_buffer_) { | 401 if (user_buffer_) { |
401 // Handing small chunks of data to the caller creates measurable overhead. | 402 // Handing small chunks of data to the caller creates measurable overhead. |
402 // We buffer data in short time-spans and send a single read notification. | 403 // We buffer data in short time-spans and send a single read notification. |
403 ScheduleBufferedReadCallback(); | 404 ScheduleBufferedReadCallback(); |
404 } | 405 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 stream_->GetSSLInfo(ssl_info, &using_npn); | 500 stream_->GetSSLInfo(ssl_info, &using_npn); |
500 } | 501 } |
501 | 502 |
502 void SpdyHttpStream::GetSSLCertRequestInfo( | 503 void SpdyHttpStream::GetSSLCertRequestInfo( |
503 SSLCertRequestInfo* cert_request_info) { | 504 SSLCertRequestInfo* cert_request_info) { |
504 DCHECK(stream_); | 505 DCHECK(stream_); |
505 stream_->GetSSLCertRequestInfo(cert_request_info); | 506 stream_->GetSSLCertRequestInfo(cert_request_info); |
506 } | 507 } |
507 | 508 |
508 } // namespace net | 509 } // namespace net |
OLD | NEW |