Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Side by Side Diff: net/spdy/spdy_stream.cc

Issue 10836084: SPDY - Handle incomplete headers during server push. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 // We haven't received all the required headers.
Ryan Hamilton 2012/08/03 19:52:14 This comment assumes something about the implement
ramant (doing other things) 2012/08/03 20:50:40 Done.
499 LogStreamError(ERR_SPDY_PROTOCOL_ERROR,
500 "Data is received but incomplete headers.");
Ryan Hamilton 2012/08/03 19:52:14 Same point as above for the error description.
ramant (doing other things) 2012/08/03 20:50:40 Done.
501 session_->CloseStream(stream_id_, ERR_SPDY_PROTOCOL_ERROR);
502 return;
503 }
494 } 504 }
495 505
496 // This function is only called when an entire frame is written. 506 // This function is only called when an entire frame is written.
497 void SpdyStream::OnWriteComplete(int bytes) { 507 void SpdyStream::OnWriteComplete(int bytes) {
498 DCHECK_LE(0, bytes); 508 DCHECK_LE(0, bytes);
499 send_bytes_ += bytes; 509 send_bytes_ += bytes;
500 if (cancelled() || closed()) 510 if (cancelled() || closed())
501 return; 511 return;
502 DoLoop(bytes); 512 DoLoop(bytes);
503 } 513 }
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", 808 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime",
799 recv_last_byte_time_ - recv_first_byte_time_); 809 recv_last_byte_time_ - recv_first_byte_time_);
800 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", 810 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime",
801 recv_last_byte_time_ - send_time_); 811 recv_last_byte_time_ - send_time_);
802 812
803 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); 813 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_);
804 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); 814 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_);
805 } 815 }
806 816
807 } // namespace net 817 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698