OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_stream.h" | 5 #include "net/spdy/spdy_stream.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 if (cancelled_ || !delegate_) | 169 if (cancelled_ || !delegate_) |
170 return; | 170 return; |
171 | 171 |
172 continue_buffering_data_ = false; | 172 continue_buffering_data_ = false; |
173 | 173 |
174 int rv = delegate_->OnResponseReceived(*response_, response_time_, OK); | 174 int rv = delegate_->OnResponseReceived(*response_, response_time_, OK); |
175 if (rv == ERR_INCOMPLETE_SPDY_HEADERS) { | 175 if (rv == ERR_INCOMPLETE_SPDY_HEADERS) { |
176 // We don't have complete headers. Assume we're waiting for another | 176 // We don't have complete headers. Assume we're waiting for another |
177 // HEADERS frame. Since we don't have headers, we had better not have | 177 // HEADERS frame. Since we don't have headers, we had better not have |
178 // any pending data frames. | 178 // any pending data frames. |
179 DCHECK_EQ(0U, pending_buffers_.size()); | 179 if (pending_buffers_.size() != 0U) { |
| 180 LogStreamError(ERR_SPDY_PROTOCOL_ERROR, |
| 181 "HEADERS incomplete headers, but pending data frames."); |
| 182 session_->CloseStream(stream_id_, ERR_SPDY_PROTOCOL_ERROR); |
| 183 } |
180 return; | 184 return; |
181 } | 185 } |
182 | 186 |
183 std::vector<scoped_refptr<IOBufferWithSize> > buffers; | 187 std::vector<scoped_refptr<IOBufferWithSize> > buffers; |
184 buffers.swap(pending_buffers_); | 188 buffers.swap(pending_buffers_); |
185 for (size_t i = 0; i < buffers.size(); ++i) { | 189 for (size_t i = 0; i < buffers.size(); ++i) { |
186 // It is always possible that a callback to the delegate results in | 190 // It is always possible that a callback to the delegate results in |
187 // the delegate no longer being available. | 191 // the delegate no longer being available. |
188 if (!delegate_) | 192 if (!delegate_) |
189 break; | 193 break; |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 487 |
484 if (!delegate_) { | 488 if (!delegate_) { |
485 // It should be valid for this to happen in the server push case. | 489 // It should be valid for this to happen in the server push case. |
486 // We'll return received data when delegate gets attached to the stream. | 490 // We'll return received data when delegate gets attached to the stream. |
487 IOBufferWithSize* buf = new IOBufferWithSize(length); | 491 IOBufferWithSize* buf = new IOBufferWithSize(length); |
488 memcpy(buf->data(), data, length); | 492 memcpy(buf->data(), data, length); |
489 pending_buffers_.push_back(make_scoped_refptr(buf)); | 493 pending_buffers_.push_back(make_scoped_refptr(buf)); |
490 return; | 494 return; |
491 } | 495 } |
492 | 496 |
493 delegate_->OnDataReceived(data, length); | 497 if (delegate_->OnDataReceived(data, length) != net::OK) { |
| 498 // |delegate_| rejected the data. |
| 499 LogStreamError(ERR_SPDY_PROTOCOL_ERROR, "Delegate rejected the data"); |
| 500 session_->CloseStream(stream_id_, ERR_SPDY_PROTOCOL_ERROR); |
| 501 return; |
| 502 } |
494 } | 503 } |
495 | 504 |
496 // This function is only called when an entire frame is written. | 505 // This function is only called when an entire frame is written. |
497 void SpdyStream::OnWriteComplete(int bytes) { | 506 void SpdyStream::OnWriteComplete(int bytes) { |
498 DCHECK_LE(0, bytes); | 507 DCHECK_LE(0, bytes); |
499 send_bytes_ += bytes; | 508 send_bytes_ += bytes; |
500 if (cancelled() || closed()) | 509 if (cancelled() || closed()) |
501 return; | 510 return; |
502 DoLoop(bytes); | 511 DoLoop(bytes); |
503 } | 512 } |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", | 807 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", |
799 recv_last_byte_time_ - recv_first_byte_time_); | 808 recv_last_byte_time_ - recv_first_byte_time_); |
800 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", | 809 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", |
801 recv_last_byte_time_ - send_time_); | 810 recv_last_byte_time_ - send_time_); |
802 | 811 |
803 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); | 812 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); |
804 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); | 813 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); |
805 } | 814 } |
806 | 815 |
807 } // namespace net | 816 } // namespace net |
OLD | NEW |