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

Side by Side Diff: net/tools/quic/quic_spdy_server_stream_test.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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/tools/quic/quic_spdy_server_stream.h" 5 #include "net/tools/quic/quic_spdy_server_stream.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "net/quic/quic_connection.h" 9 #include "net/quic/quic_connection.h"
10 #include "net/quic/quic_protocol.h" 10 #include "net/quic/quic_protocol.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 session_.config()->SetInitialSessionFlowControlWindowToSend( 91 session_.config()->SetInitialSessionFlowControlWindowToSend(
92 kInitialSessionFlowControlWindowForTest); 92 kInitialSessionFlowControlWindowForTest);
93 stream_.reset(new QuicSpdyServerStreamPeer(3, &session_)); 93 stream_.reset(new QuicSpdyServerStreamPeer(3, &session_));
94 } 94 }
95 95
96 static void SetUpTestCase() { 96 static void SetUpTestCase() {
97 QuicInMemoryCachePeer::ResetForTests(); 97 QuicInMemoryCachePeer::ResetForTests();
98 } 98 }
99 99
100 void SetUp() override { 100 void SetUp() override {
101 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); 101 QuicInMemoryCachePeer::ResetForTests();
102
103 BalsaHeaders response_headers;
104 StringPiece body("Yum");
105 response_headers.SetRequestFirstlineFromStringPieces("HTTP/1.1",
106 "200",
107 "OK");
108 response_headers.AppendHeader("content-length",
109 base::IntToString(body.length()));
110
111 string host = ""; 102 string host = "";
112 string path = "/foo"; 103 string path = "/foo";
113 // Check if response already exists and matches. 104 SpdyHeaderBlock response_headers;
114 const QuicInMemoryCache::Response* cached_response = 105 StringPiece body("Yum");
115 cache->GetResponse(host, path); 106 QuicInMemoryCache::GetInstance()->AddResponse(host, path, response_headers,
116 if (cached_response != nullptr) { 107 body);
117 string cached_response_headers_str, response_headers_str;
118 cached_response->headers().DumpToString(&cached_response_headers_str);
119 response_headers.DumpToString(&response_headers_str);
120 CHECK_EQ(cached_response_headers_str, response_headers_str);
121 CHECK_EQ(cached_response->body(), body);
122 return;
123 }
124
125 cache->AddResponse(host, path, response_headers, body);
126 } 108 }
127 109
128 const string& StreamBody() { 110 const string& StreamBody() {
129 return QuicSpdyServerStreamPeer::body(stream_.get()); 111 return QuicSpdyServerStreamPeer::body(stream_.get());
130 } 112 }
131 113
132 const BalsaHeaders& StreamHeaders() { 114 const BalsaHeaders& StreamHeaders() {
133 return QuicSpdyServerStreamPeer::headers(stream_.get()); 115 return QuicSpdyServerStreamPeer::headers(stream_.get());
134 } 116 }
135 117
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 StringPiece data(arr, arraysize(arr)); 244 StringPiece data(arr, arraysize(arr));
263 QuicStreamFrame frame(stream_->id(), true, 0, MakeIOVector(data)); 245 QuicStreamFrame frame(stream_->id(), true, 0, MakeIOVector(data));
264 // Verify that we don't crash when we get a invalid headers in stream frame. 246 // Verify that we don't crash when we get a invalid headers in stream frame.
265 stream_->OnStreamFrame(frame); 247 stream_->OnStreamFrame(frame);
266 } 248 }
267 249
268 } // namespace 250 } // namespace
269 } // namespace test 251 } // namespace test
270 } // namespace tools 252 } // namespace tools
271 } // namespace net 253 } // namespace net
OLDNEW
« net/tools/quic/quic_spdy_server_stream.h ('K') | « net/tools/quic/quic_spdy_server_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698