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

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

Issue 10828129: SPDY: WriteHeaders should not invoke OnDataSent callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add check for OnHeadersSent in tests 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // We must need to write stream data. 135 // We must need to write stream data.
136 // Until the headers have been completely sent, we can not be sure 136 // Until the headers have been completely sent, we can not be sure
137 // that our stream_id is correct. 137 // that our stream_id is correct.
138 DCHECK_GT(io_state_, STATE_SEND_HEADERS_COMPLETE); 138 DCHECK_GT(io_state_, STATE_SEND_HEADERS_COMPLETE);
139 DCHECK_GT(stream_id_, 0u); 139 DCHECK_GT(stream_id_, 0u);
140 DCHECK(!pending_frames_.empty()); 140 DCHECK(!pending_frames_.empty());
141 141
142 PendingFrame frame = pending_frames_.front(); 142 PendingFrame frame = pending_frames_.front();
143 pending_frames_.pop_front(); 143 pending_frames_.pop_front();
144 144
145 waiting_completions_.push_back(frame.type);
146
145 if (frame.type == TYPE_DATA) { 147 if (frame.type == TYPE_DATA) {
146 // Send queued data frame. 148 // Send queued data frame.
147 return frame.data_frame; 149 return frame.data_frame;
148 } else { 150 } else {
149 DCHECK(frame.type == TYPE_HEADER); 151 DCHECK(frame.type == TYPE_HEADERS);
Ryan Hamilton 2012/08/13 17:10:02 It doesn't look like the HEADERS frame is added to
Takashi Toyoshima 2012/08/14 09:14:02 I added frame.type at line 145 for both of TYPE_DA
150 // Create actual HEADERS frame just in time because it depends on 152 // Create actual HEADERS frame just in time because it depends on
151 // compression context and should not be reordered after the creation. 153 // compression context and should not be reordered after the creation.
152 SpdyFrame* header_frame = session_->CreateHeadersFrame( 154 SpdyFrame* header_frame = session_->CreateHeadersFrame(
153 stream_id_, *frame.header_block, SpdyControlFlags()); 155 stream_id_, *frame.header_block, SpdyControlFlags());
154 delete frame.header_block; 156 delete frame.header_block;
155 return header_frame; 157 return header_frame;
156 } 158 }
157 } 159 }
158 NOTREACHED(); 160 NOTREACHED();
159 } 161 }
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 return DoLoop(OK); 575 return DoLoop(OK);
574 } 576 }
575 577
576 int SpdyStream::WriteHeaders(SpdyHeaderBlock* headers) { 578 int SpdyStream::WriteHeaders(SpdyHeaderBlock* headers) {
577 // Until the first headers by SYN_STREAM have been completely sent, we can 579 // Until the first headers by SYN_STREAM have been completely sent, we can
578 // not be sure that our stream_id is correct. 580 // not be sure that our stream_id is correct.
579 DCHECK_GT(io_state_, STATE_SEND_HEADERS_COMPLETE); 581 DCHECK_GT(io_state_, STATE_SEND_HEADERS_COMPLETE);
580 CHECK_GT(stream_id_, 0u); 582 CHECK_GT(stream_id_, 0u);
581 583
582 PendingFrame frame; 584 PendingFrame frame;
583 frame.type = TYPE_HEADER; 585 frame.type = TYPE_HEADERS;
584 frame.header_block = headers; 586 frame.header_block = headers;
585 pending_frames_.push_back(frame); 587 pending_frames_.push_back(frame);
586 588
587 SetHasWriteAvailable(); 589 SetHasWriteAvailable();
588 return ERR_IO_PENDING; 590 return ERR_IO_PENDING;
589 } 591 }
590 592
591 int SpdyStream::WriteStreamData(IOBuffer* data, 593 int SpdyStream::WriteStreamData(IOBuffer* data,
592 int length, 594 int length,
593 SpdyDataFlags flags) { 595 SpdyDataFlags flags) {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 result = delegate_->OnSendBodyComplete(result, &eof); 817 result = delegate_->OnSendBodyComplete(result, &eof);
816 if (!eof) 818 if (!eof)
817 io_state_ = STATE_SEND_BODY; 819 io_state_ = STATE_SEND_BODY;
818 else 820 else
819 io_state_ = STATE_WAITING_FOR_RESPONSE; 821 io_state_ = STATE_WAITING_FOR_RESPONSE;
820 822
821 return result; 823 return result;
822 } 824 }
823 825
824 int SpdyStream::DoOpen(int result) { 826 int SpdyStream::DoOpen(int result) {
825 if (delegate_) 827 if (delegate_) {
826 delegate_->OnDataSent(result); 828 FrameType type = waiting_completions_.front();
829 waiting_completions_.pop_front();
830 if (type == TYPE_DATA) {
831 delegate_->OnDataSent(result);
832 } else {
833 DCHECK(type == TYPE_HEADERS);
834 delegate_->OnHeadersSent();
835 }
836 }
827 io_state_ = STATE_OPEN; 837 io_state_ = STATE_OPEN;
828 return result; 838 return result;
829 } 839 }
830 840
831 void SpdyStream::UpdateHistograms() { 841 void SpdyStream::UpdateHistograms() {
832 // We need all timers to be filled in, otherwise metrics can be bogus. 842 // We need all timers to be filled in, otherwise metrics can be bogus.
833 if (send_time_.is_null() || recv_first_byte_time_.is_null() || 843 if (send_time_.is_null() || recv_first_byte_time_.is_null() ||
834 recv_last_byte_time_.is_null()) 844 recv_last_byte_time_.is_null())
835 return; 845 return;
836 846
837 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTimeToFirstByte", 847 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTimeToFirstByte",
838 recv_first_byte_time_ - send_time_); 848 recv_first_byte_time_ - send_time_);
839 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", 849 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime",
840 recv_last_byte_time_ - recv_first_byte_time_); 850 recv_last_byte_time_ - recv_first_byte_time_);
841 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", 851 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime",
842 recv_last_byte_time_ - send_time_); 852 recv_last_byte_time_ - send_time_);
843 853
844 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); 854 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_);
845 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); 855 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_);
846 } 856 }
847 857
848 } // namespace net 858 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698