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

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

Issue 24493003: Factor out ServerThread from the QUIC EndToEndTest in order to reuse in (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 7 years, 3 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 6ed7dd5f8320fca1f0e7b0f368a5a4def7d50d4c..8e97f553ac08b313adfc68f93eec89a42234edf0 100644
--- a/net/tools/quic/quic_in_memory_cache.cc
+++ b/net/tools/quic/quic_in_memory_cache.cc
@@ -7,6 +7,7 @@
#include "base/file_util.h"
#include "base/files/file_enumerator.h"
#include "base/stl_util.h"
+#include "base/strings/string_number_conversions.h"
using base::FilePath;
using base::StringPiece;
@@ -93,6 +94,36 @@ const QuicInMemoryCache::Response* QuicInMemoryCache::GetResponse(
return it->second;
}
+void QuicInMemoryCache::AddOrVerifyResponse(StringPiece method,
+ StringPiece path,
+ StringPiece version,
+ StringPiece response_code,
+ StringPiece response_detail,
+ StringPiece body) {
+ BalsaHeaders request_headers, response_headers;
+ request_headers.SetRequestFirstlineFromStringPieces(method,
+ path,
+ version);
+ response_headers.SetRequestFirstlineFromStringPieces(version,
+ response_code,
+ response_detail);
+ response_headers.AppendHeader("content-length",
+ base::IntToString(body.length()));
+
+ // Check if response already exists and matches.
+ const QuicInMemoryCache::Response* cached_response =
+ GetResponse(request_headers);
+ if (cached_response == NULL) {
+ AddResponse(request_headers, response_headers, body);
+ return;
+ }
+ string cached_response_headers_str, response_headers_str;
+ cached_response->headers().DumpToString(&cached_response_headers_str);
+ response_headers.DumpToString(&response_headers_str);
+ CHECK_EQ(cached_response_headers_str, response_headers_str);
+ CHECK_EQ(cached_response->body(), body);
+}
+
void QuicInMemoryCache::AddResponse(const BalsaHeaders& request_headers,
const BalsaHeaders& response_headers,
StringPiece response_body) {

Powered by Google App Engine
This is Rietveld 408576698