Actually implement header compression for quic streams.
[email protected]
Review URL: https://codereview.chromium.org/15042010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200617 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/net/quic/quic_http_stream.cc b/net/quic/quic_http_stream.cc
index f81f826..4cc95352 100644
--- a/net/quic/quic_http_stream.cc
+++ b/net/quic/quic_http_stream.cc
@@ -67,11 +67,7 @@
SpdyHeaderBlock headers;
CreateSpdyHeadersFromHttpRequest(*request_info_, request_headers,
&headers, 3, /*direct=*/true);
- size_t len = SpdyFramer::GetSerializedLength(3, &headers);
- SpdyFrameBuilder builder(len);
- SpdyFramer::WriteHeaderBlock(&builder, 3, &headers);
- scoped_ptr<SpdyFrame> frame(builder.take());
- request_ = std::string(frame->data(), len);
+ request_ = stream_->compressor()->CompressHeaders(headers);
// Log the actual request with the URL Request's net log.
stream_net_log_.AddEvent(
NetLog::TYPE_HTTP_TRANSACTION_SPDY_SEND_REQUEST_HEADERS,
diff --git a/net/quic/quic_http_stream_test.cc b/net/quic/quic_http_stream_test.cc
index ff82ab4..1c10cdbd 100644
--- a/net/quic/quic_http_stream_test.cc
+++ b/net/quic/quic_http_stream_test.cc
@@ -205,15 +205,12 @@
headers[":status"] = status;
headers[":version"] = "HTTP/1.1";
headers["content-type"] = "text/plain";
- response_data_ = session_->compressor()->CompressHeaders(headers) + body;
+ response_data_ = SerializeHeaderBlock(headers) + body;
}
std::string SerializeHeaderBlock(const SpdyHeaderBlock& headers) {
- size_t len = SpdyFramer::GetSerializedLength(3, &headers);
- SpdyFrameBuilder builder(len);
- SpdyFramer::WriteHeaderBlock(&builder, 3, &headers);
- scoped_ptr<SpdyFrame> frame(builder.take());
- return std::string(frame->data(), len);
+ QuicSpdyCompressor compressor;
+ return compressor.CompressHeaders(headers);
}
// Returns a newly created packet to send kData on stream 1.
diff --git a/net/quic/quic_network_transaction_unittest.cc b/net/quic/quic_network_transaction_unittest.cc
index 36be0f2..79517ad8 100644
--- a/net/quic/quic_network_transaction_unittest.cc
+++ b/net/quic/quic_network_transaction_unittest.cc
@@ -180,11 +180,8 @@
}
std::string SerializeHeaderBlock(const SpdyHeaderBlock& headers) {
- size_t len = SpdyFramer::GetSerializedLength(3, &headers);
- SpdyFrameBuilder builder(len);
- SpdyFramer::WriteHeaderBlock(&builder, 3, &headers);
- scoped_ptr<SpdyFrame> frame(builder.take());
- return std::string(frame->data(), len);
+ QuicSpdyCompressor compressor;
+ return compressor.CompressHeaders(headers);
}
// Returns a newly created packet to send kData on stream 1.
diff --git a/net/quic/reliable_quic_stream.cc b/net/quic/reliable_quic_stream.cc
index c293eed..6a82cce 100644
--- a/net/quic/reliable_quic_stream.cc
+++ b/net/quic/reliable_quic_stream.cc
@@ -150,6 +150,10 @@
return session_->peer_address();
}
+QuicSpdyCompressor* ReliableQuicStream::compressor() {
+ return session_->compressor();
+}
+
QuicConsumedData ReliableQuicStream::WriteData(StringPiece data, bool fin) {
return WriteOrBuffer(data, fin);
}
@@ -281,8 +285,8 @@
// If we are head-of-line blocked on decompression, then back up.
if (current_header_id != headers_id_) {
session_->MarkDecompressionBlocked(headers_id_, id());
- DVLOG(1) << "Unable to decmpress header data for stream: " << id()
- << " header_id: " << headers_id_;
+ DVLOG(1) << "Unable to decompress header data for stream: " << id()
+ << " header_id: " << headers_id_;
return total_bytes_consumed;
}
diff --git a/net/quic/reliable_quic_stream.h b/net/quic/reliable_quic_stream.h
index a22f90d1..51ca55e7 100644
--- a/net/quic/reliable_quic_stream.h
+++ b/net/quic/reliable_quic_stream.h
@@ -14,6 +14,7 @@
#include "base/strings/string_piece.h"
#include "net/base/iovec.h"
#include "net/base/net_export.h"
+#include "net/quic/quic_spdy_compressor.h"
#include "net/quic/quic_spdy_decompressor.h"
#include "net/quic/quic_stream_sequencer.h"
@@ -110,6 +111,8 @@
Visitor* visitor() { return visitor_; }
void set_visitor(Visitor* visitor) { visitor_ = visitor; }
+ QuicSpdyCompressor* compressor();
+
protected:
// Returns a pair with the number of bytes consumed from data, and a boolean
// indicating if the fin bit was consumed. This does not indicate the data