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

Unified Diff: net/tools/quic/quic_in_memory_cache.cc

Issue 1036643003: Change the QuicInMemoryCache to store a SpdyHeaderBlock instead of BalsaHeaders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
Index: net/tools/quic/quic_in_memory_cache.cc
diff --git a/net/tools/quic/quic_in_memory_cache.cc b/net/tools/quic/quic_in_memory_cache.cc
index 4f55f73bedb408ff872d0f1631e1df2136b8638d..1e314fc4da8cf977e04a22201e641367d869e5dc 100644
--- a/net/tools/quic/quic_in_memory_cache.cc
+++ b/net/tools/quic/quic_in_memory_cache.cc
@@ -8,7 +8,10 @@
#include "base/files/file_util.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
+#include "net/tools/balsa/balsa_frame.h"
#include "net/tools/balsa/balsa_headers.h"
+#include "net/tools/balsa/noop_balsa_visitor.h"
+#include "net/tools/quic/spdy_utils.h"
using base::FilePath;
using base::StringPiece;
@@ -52,6 +55,10 @@ class CachingBalsaVisitor : public NoOpBalsaVisitor {
} // namespace
+QuicInMemoryCache::Response::Response() : response_type_(REGULAR_RESPONSE) {}
+
+QuicInMemoryCache::Response::~Response() {}
+
// static
QuicInMemoryCache* QuicInMemoryCache::GetInstance() {
return Singleton<QuicInMemoryCache>::get();
@@ -72,18 +79,18 @@ void QuicInMemoryCache::AddSimpleResponse(StringPiece host,
int response_code,
StringPiece response_detail,
StringPiece body) {
- BalsaHeaders response_headers;
- response_headers.SetRequestFirstlineFromStringPieces(
- "HTTP/1.1", base::IntToString(response_code), response_detail);
- response_headers.AppendHeader("content-length",
- base::IntToString(body.length()));
-
+ SpdyHeaderBlock response_headers;
+ response_headers[":version"] = "HTTP/1.1";
+ string status = base::IntToString(response_code) + " ";
+ response_detail.AppendToString(&status);
+ response_headers[":status"] = status;
+ response_headers["content-length"] = base::IntToString(body.length());
AddResponse(host, path, response_headers, body);
}
void QuicInMemoryCache::AddResponse(StringPiece host,
StringPiece path,
- const BalsaHeaders& response_headers,
+ const SpdyHeaderBlock& response_headers,
StringPiece response_body) {
AddResponseImpl(host, path, REGULAR_RESPONSE, response_headers,
response_body);
@@ -92,7 +99,7 @@ void QuicInMemoryCache::AddResponse(StringPiece host,
void QuicInMemoryCache::AddSpecialResponse(StringPiece host,
StringPiece path,
SpecialResponseType response_type) {
- AddResponseImpl(host, path, response_type, BalsaHeaders(), "");
+ AddResponseImpl(host, path, response_type, SpdyHeaderBlock(), "");
}
QuicInMemoryCache::QuicInMemoryCache() {
@@ -175,7 +182,9 @@ void QuicInMemoryCache::Initialize() {
if (path[path.length() - 1] == ',') {
path.remove_suffix(1);
}
- AddResponse(host, path, response_headers, caching_visitor.body());
+ AddResponse(host, path,
+ SpdyUtils::ResponseHeadersToSpdyHeaders(response_headers),
+ caching_visitor.body());
}
}
@@ -187,7 +196,7 @@ void QuicInMemoryCache::AddResponseImpl(
StringPiece host,
StringPiece path,
SpecialResponseType response_type,
- const BalsaHeaders& response_headers,
+ const SpdyHeaderBlock& response_headers,
StringPiece response_body) {
string key = GetKey(host, path);
VLOG(1) << "Adding response for: " << key;

Powered by Google App Engine
This is Rietveld 408576698