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

Unified 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: cleanup Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« net/spdy/spdy_stream.h ('K') | « net/spdy/spdy_stream.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_stream.cc
diff --git a/net/spdy/spdy_stream.cc b/net/spdy/spdy_stream.cc
index 277188662eb1ea68559e2d2178b112b7021ecb15..78f36b9d836ee55cbf4252f3ef51e57cf99aec55 100644
--- a/net/spdy/spdy_stream.cc
+++ b/net/spdy/spdy_stream.cc
@@ -137,18 +137,39 @@ SpdyFrame* SpdyStream::ProduceNextFrame() {
DCHECK_GT(io_state_, STATE_SEND_HEADERS_COMPLETE);
DCHECK_GT(stream_id_, 0u);
DCHECK(!pending_data_frames_.empty());
- SpdyFrame* frame = pending_data_frames_.front();
+
+ PendingFrame frame = pending_data_frames_.front();
+ SpdyHeaderBlock* headers = frame.first;
+ SpdyDataFrame* data_frame = frame.second;
pending_data_frames_.pop_front();
- return frame;
+
+ // |frame| should have one valid data.
+ DCHECK(!headers != !data_frame);
+
+ // Send queued data frame.
+ if (data_frame)
+ return data_frame;
+
+ // Create actual HEADERS frame just in time because it depends on
+ // compression context and should not be reordered after the creation.
+ SpdyFrame* header_frame = session_->CreateHeadersFrame(
+ stream_id_, *headers, SpdyControlFlags());
+ delete headers;
+ return header_frame;
}
}
SpdyStream::~SpdyStream() {
UpdateHistograms();
while (!pending_data_frames_.empty()) {
- SpdyFrame* frame = pending_data_frames_.back();
+ PendingFrame frame = pending_data_frames_.back();
+ SpdyHeaderBlock* headers = frame.first;
+ SpdyDataFrame* data_frame = frame.second;
pending_data_frames_.pop_back();
- delete frame;
+ if (headers)
+ delete headers;
+ if (data_frame)
+ delete data_frame;
}
}
@@ -555,17 +576,32 @@ int SpdyStream::SendRequest(bool has_upload_data) {
return DoLoop(OK);
}
-int SpdyStream::WriteStreamData(IOBuffer* data, int length,
+int SpdyStream::WriteHeaders(SpdyHeaderBlock* headers) {
+ // Until the first headers by SYN_STREAM have been completely sent, we can
+ // not be sure that our stream_id is correct.
+ DCHECK_GT(io_state_, STATE_SEND_HEADERS_COMPLETE);
+ CHECK_GT(stream_id_, 0u);
+
+ pending_data_frames_.push_back(PendingFrame(headers, NULL));
+
+ SetHasWriteAvailable();
+ return ERR_IO_PENDING;
+}
+
+int SpdyStream::WriteStreamData(IOBuffer* data,
+ int length,
SpdyDataFlags flags) {
// Until the headers have been completely sent, we can not be sure
// that our stream_id is correct.
DCHECK_GT(io_state_, STATE_SEND_HEADERS_COMPLETE);
CHECK_GT(stream_id_, 0u);
- pending_data_frames_.push_back(
- session_->CreateDataFrame(stream_id_, data, length, flags));
-
- SetHasWriteAvailable();
+ SpdyDataFrame* frame = session_->CreateDataFrame(
+ stream_id_, data, length, flags);
+ if (frame) {
+ pending_data_frames_.push_back(PendingFrame(NULL, frame));
+ SetHasWriteAvailable();
+ }
return ERR_IO_PENDING;
}
« net/spdy/spdy_stream.h ('K') | « net/spdy/spdy_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698