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

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

Issue 10810069: SPDY: Add WriteHeaders interface to SpdySession and SpdyStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for commit 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
« no previous file with comments | « net/spdy/spdy_stream.h ('k') | net/spdy/spdy_stream_spdy2_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 stream_id_, priority_, slot_, flags, *request_); 129 stream_id_, priority_, slot_, flags, *request_);
130 send_time_ = base::TimeTicks::Now(); 130 send_time_ = base::TimeTicks::Now();
131 return frame; 131 return frame;
132 } else { 132 } else {
133 CHECK(!cancelled()); 133 CHECK(!cancelled());
134 // We must need to write stream data. 134 // We must need to write stream data.
135 // Until the headers have been completely sent, we can not be sure 135 // Until the headers have been completely sent, we can not be sure
136 // that our stream_id is correct. 136 // that our stream_id is correct.
137 DCHECK_GT(io_state_, STATE_SEND_HEADERS_COMPLETE); 137 DCHECK_GT(io_state_, STATE_SEND_HEADERS_COMPLETE);
138 DCHECK_GT(stream_id_, 0u); 138 DCHECK_GT(stream_id_, 0u);
139 DCHECK(!pending_data_frames_.empty()); 139 DCHECK(!pending_frames_.empty());
140 SpdyFrame* frame = pending_data_frames_.front(); 140
141 pending_data_frames_.pop_front(); 141 PendingFrame frame = pending_frames_.front();
142 return frame; 142 pending_frames_.pop_front();
143
144 if (frame.type == TYPE_DATA) {
145 // Send queued data frame.
146 return frame.data_frame;
147 } else {
148 DCHECK(frame.type == TYPE_HEADER);
149 // Create actual HEADERS frame just in time because it depends on
150 // compression context and should not be reordered after the creation.
151 SpdyFrame* header_frame = session_->CreateHeadersFrame(
152 stream_id_, *frame.header_block, SpdyControlFlags());
153 delete frame.header_block;
154 return header_frame;
155 }
143 } 156 }
157 NOTREACHED();
144 } 158 }
145 159
146 SpdyStream::~SpdyStream() { 160 SpdyStream::~SpdyStream() {
147 UpdateHistograms(); 161 UpdateHistograms();
148 while (!pending_data_frames_.empty()) { 162 while (!pending_frames_.empty()) {
149 SpdyFrame* frame = pending_data_frames_.back(); 163 PendingFrame frame = pending_frames_.back();
150 pending_data_frames_.pop_back(); 164 pending_frames_.pop_back();
151 delete frame; 165 if (frame.type == TYPE_DATA)
166 delete frame.data_frame;
167 else
168 delete frame.header_block;
152 } 169 }
153 } 170 }
154 171
155 void SpdyStream::SetDelegate(Delegate* delegate) { 172 void SpdyStream::SetDelegate(Delegate* delegate) {
156 CHECK(delegate); 173 CHECK(delegate);
157 delegate_ = delegate; 174 delegate_ = delegate;
158 175
159 if (pushed_) { 176 if (pushed_) {
160 CHECK(response_received()); 177 CHECK(response_received());
161 MessageLoop::current()->PostTask( 178 MessageLoop::current()->PostTask(
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 send_time_ = base::TimeTicks::Now(); 565 send_time_ = base::TimeTicks::Now();
549 DCHECK(!has_upload_data_); 566 DCHECK(!has_upload_data_);
550 DCHECK(response_received()); 567 DCHECK(response_received());
551 return ERR_IO_PENDING; 568 return ERR_IO_PENDING;
552 } 569 }
553 CHECK_EQ(STATE_NONE, io_state_); 570 CHECK_EQ(STATE_NONE, io_state_);
554 io_state_ = STATE_GET_DOMAIN_BOUND_CERT; 571 io_state_ = STATE_GET_DOMAIN_BOUND_CERT;
555 return DoLoop(OK); 572 return DoLoop(OK);
556 } 573 }
557 574
558 int SpdyStream::WriteStreamData(IOBuffer* data, int length, 575 int SpdyStream::WriteHeaders(SpdyHeaderBlock* headers) {
576 // Until the first headers by SYN_STREAM have been completely sent, we can
577 // not be sure that our stream_id is correct.
578 DCHECK_GT(io_state_, STATE_SEND_HEADERS_COMPLETE);
579 CHECK_GT(stream_id_, 0u);
580
581 PendingFrame frame;
582 frame.type = TYPE_HEADER;
583 frame.header_block = headers;
584 pending_frames_.push_back(frame);
585
586 SetHasWriteAvailable();
587 return ERR_IO_PENDING;
588 }
589
590 int SpdyStream::WriteStreamData(IOBuffer* data,
591 int length,
559 SpdyDataFlags flags) { 592 SpdyDataFlags flags) {
560 // Until the headers have been completely sent, we can not be sure 593 // Until the headers have been completely sent, we can not be sure
561 // that our stream_id is correct. 594 // that our stream_id is correct.
562 DCHECK_GT(io_state_, STATE_SEND_HEADERS_COMPLETE); 595 DCHECK_GT(io_state_, STATE_SEND_HEADERS_COMPLETE);
563 CHECK_GT(stream_id_, 0u); 596 CHECK_GT(stream_id_, 0u);
564 597
565 pending_data_frames_.push_back( 598 SpdyDataFrame* data_frame = session_->CreateDataFrame(
566 session_->CreateDataFrame(stream_id_, data, length, flags)); 599 stream_id_, data, length, flags);
600 if (!data_frame)
601 return ERR_IO_PENDING;
602
603 PendingFrame frame;
604 frame.type = TYPE_DATA;
605 frame.data_frame = data_frame;
606 pending_frames_.push_back(frame);
567 607
568 SetHasWriteAvailable(); 608 SetHasWriteAvailable();
569 return ERR_IO_PENDING; 609 return ERR_IO_PENDING;
570 } 610 }
571 611
572 bool SpdyStream::GetSSLInfo(SSLInfo* ssl_info, 612 bool SpdyStream::GetSSLInfo(SSLInfo* ssl_info,
573 bool* was_npn_negotiated, 613 bool* was_npn_negotiated,
574 NextProto* protocol_negotiated) { 614 NextProto* protocol_negotiated) {
575 return session_->GetSSLInfo( 615 return session_->GetSSLInfo(
576 ssl_info, was_npn_negotiated, protocol_negotiated); 616 ssl_info, was_npn_negotiated, protocol_negotiated);
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", 838 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime",
799 recv_last_byte_time_ - recv_first_byte_time_); 839 recv_last_byte_time_ - recv_first_byte_time_);
800 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", 840 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime",
801 recv_last_byte_time_ - send_time_); 841 recv_last_byte_time_ - send_time_);
802 842
803 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); 843 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_);
804 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); 844 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_);
805 } 845 }
806 846
807 } // namespace net 847 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_stream.h ('k') | net/spdy/spdy_stream_spdy2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698