Chromium Code Reviews| 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 8e97f553ac08b313adfc68f93eec89a42234edf0..b0b2f1f1eec45b7f994e943f7f263acb7386bf4c 100644 |
| --- a/net/tools/quic/quic_in_memory_cache.cc |
| +++ b/net/tools/quic/quic_in_memory_cache.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/files/file_enumerator.h" |
| #include "base/stl_util.h" |
| #include "base/strings/string_number_conversions.h" |
| +#include "net/tools/flip_server/balsa_headers.h" |
| using base::FilePath; |
| using base::StringPiece; |
| @@ -20,20 +21,17 @@ using std::string; |
| namespace net { |
| namespace tools { |
| -std::string FLAGS_quic_in_memory_cache_dir = "/tmp/quic-data"; |
| +std::string FLAGS_quic_in_memory_cache_dir = ""; |
| namespace { |
| // BalsaVisitor implementation (glue) which caches response bodies. |
| -class CachingBalsaVisitor : public BalsaVisitorInterface { |
| +class CachingBalsaVisitor : public NoOpBalsaVisitor { |
| public: |
| CachingBalsaVisitor() : done_framing_(false) {} |
| virtual void ProcessBodyData(const char* input, size_t size) OVERRIDE { |
| AppendToBody(input, size); |
| } |
| - virtual void ProcessTrailers(const BalsaHeaders& trailer) { |
| - LOG(DFATAL) << "Trailers not supported."; |
| - } |
| virtual void MessageDone() OVERRIDE { |
| done_framing_ = true; |
| } |
| @@ -43,31 +41,15 @@ class CachingBalsaVisitor : public BalsaVisitorInterface { |
| virtual void HandleHeaderWarning(BalsaFrame* framer) OVERRIDE { |
| UnhandledError(); |
| } |
| - virtual void HandleTrailerError(BalsaFrame* framer) { UnhandledError(); } |
| - virtual void HandleTrailerWarning(BalsaFrame* framer) { UnhandledError(); } |
|
ramant (doing other things)
2013/09/26 15:32:50
nit: internal code seems to have these two methods
Ryan Hamilton
2013/09/26 17:58:08
Yes, they're in the internal version... but they'r
|
| virtual void HandleChunkingError(BalsaFrame* framer) OVERRIDE { |
| UnhandledError(); |
| } |
| virtual void HandleBodyError(BalsaFrame* framer) OVERRIDE { |
| UnhandledError(); |
| - } |
| +} |
|
ramant (doing other things)
2013/09/26 15:32:50
nit: indentation at line# 49.
Ryan Hamilton
2013/09/26 17:58:08
Done.
|
| void UnhandledError() { |
| LOG(DFATAL) << "Unhandled error framing HTTP."; |
| } |
| - virtual void ProcessBodyInput(const char*, size_t) OVERRIDE {} |
| - virtual void ProcessHeaderInput(const char*, size_t) OVERRIDE {} |
| - virtual void ProcessTrailerInput(const char*, size_t) OVERRIDE {} |
| - virtual void ProcessHeaders(const net::BalsaHeaders&) OVERRIDE {} |
| - virtual void ProcessRequestFirstLine( |
| - const char*, size_t, const char*, size_t, |
| - const char*, size_t, const char*, size_t) OVERRIDE {} |
| - virtual void ProcessResponseFirstLine( |
| - const char*, size_t, const char*, |
| - size_t, const char*, size_t, const char*, size_t) OVERRIDE {} |
| - virtual void ProcessChunkLength(size_t) OVERRIDE {} |
| - virtual void ProcessChunkExtensions(const char*, size_t) OVERRIDE {} |
| - virtual void HeaderDone() OVERRIDE {} |
| - |
| void AppendToBody(const char* input, size_t size) { |
| body_.append(input, size); |
| } |
| @@ -81,6 +63,7 @@ class CachingBalsaVisitor : public BalsaVisitorInterface { |
| } // namespace |
| +// static |
| QuicInMemoryCache* QuicInMemoryCache::GetInstance() { |
| return Singleton<QuicInMemoryCache>::get(); |
| } |
| @@ -94,12 +77,12 @@ 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) { |
| +void QuicInMemoryCache::AddSimpleResponse(StringPiece method, |
| + StringPiece path, |
| + StringPiece version, |
| + StringPiece response_code, |
| + StringPiece response_detail, |
| + StringPiece body) { |
| BalsaHeaders request_headers, response_headers; |
| request_headers.SetRequestFirstlineFromStringPieces(method, |
| path, |
| @@ -110,18 +93,7 @@ void QuicInMemoryCache::AddOrVerifyResponse(StringPiece method, |
| 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); |
| + AddResponse(request_headers, response_headers, body); |
| } |
| void QuicInMemoryCache::AddResponse(const BalsaHeaders& request_headers, |