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

Unified Diff: net/spdy/spdy_stream_unittest.cc

Issue 2156643002: Move ~1000 SpdySerializedFrame instances from heap to stack in tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « net/spdy/spdy_session_unittest.cc ('k') | net/spdy/spdy_test_util_common.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_stream_unittest.cc
diff --git a/net/spdy/spdy_stream_unittest.cc b/net/spdy/spdy_stream_unittest.cc
index 307ff5e6e791add8664bf8d4785575970aaaee76..355b8c2c6fc0c2a3b8d4063137b2b6b0a25b6dda 100644
--- a/net/spdy/spdy_stream_unittest.cc
+++ b/net/spdy/spdy_stream_unittest.cc
@@ -154,21 +154,20 @@ INSTANTIATE_TEST_CASE_P(ProtoPlusDepend,
TEST_P(SpdyStreamTest, SendDataAfterOpen) {
GURL url(kStreamUrl);
- std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost(
+ SpdySerializedFrame req(spdy_util_.ConstructSpdyPost(
kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0));
- AddWrite(*req);
+ AddWrite(req);
- std::unique_ptr<SpdySerializedFrame> resp(
- spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
- AddRead(*resp);
+ SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
+ AddRead(resp);
- std::unique_ptr<SpdySerializedFrame> msg(
- spdy_util_.ConstructSpdyBodyFrame(1, kPostBody, kPostBodyLength, false));
- AddWrite(*msg);
+ SpdySerializedFrame msg(
+ spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, false));
+ AddWrite(msg);
- std::unique_ptr<SpdySerializedFrame> echo(
- spdy_util_.ConstructSpdyBodyFrame(1, kPostBody, kPostBodyLength, false));
- AddRead(*echo);
+ SpdySerializedFrame echo(
+ spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, false));
+ AddRead(echo);
AddReadEOF();
@@ -230,28 +229,26 @@ class StreamDelegateWithTrailers : public test::StreamDelegateWithBody {
TEST_P(SpdyStreamTest, Trailers) {
GURL url(kStreamUrl);
- std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost(
+ SpdySerializedFrame req(spdy_util_.ConstructSpdyPost(
kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0));
- AddWrite(*req);
+ AddWrite(req);
- std::unique_ptr<SpdySerializedFrame> msg(
- spdy_util_.ConstructSpdyBodyFrame(1, kPostBody, kPostBodyLength, true));
- AddWrite(*msg);
+ SpdySerializedFrame msg(
+ spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, true));
+ AddWrite(msg);
- std::unique_ptr<SpdySerializedFrame> resp(
- spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
- AddRead(*resp);
+ SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
+ AddRead(resp);
- std::unique_ptr<SpdySerializedFrame> echo(
- spdy_util_.ConstructSpdyBodyFrame(1, kPostBody, kPostBodyLength, false));
- AddRead(*echo);
+ SpdySerializedFrame echo(
+ spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, false));
+ AddRead(echo);
SpdyHeaderBlock late_headers;
late_headers["foo"] = "bar";
- std::unique_ptr<SpdySerializedFrame> trailers(
- spdy_util_.ConstructSpdyResponseHeaders(1, std::move(late_headers),
- false));
- AddRead(*trailers);
+ SpdySerializedFrame trailers(spdy_util_.ConstructSpdyResponseHeaders(
+ 1, std::move(late_headers), false));
+ AddRead(trailers);
AddReadEOF();
@@ -361,21 +358,20 @@ TEST_P(SpdyStreamTest, PushedStream) {
TEST_P(SpdyStreamTest, StreamError) {
GURL url(kStreamUrl);
- std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost(
+ SpdySerializedFrame req(spdy_util_.ConstructSpdyPost(
kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0));
- AddWrite(*req);
+ AddWrite(req);
- std::unique_ptr<SpdySerializedFrame> resp(
- spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- AddRead(*resp);
+ SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ AddRead(resp);
- std::unique_ptr<SpdySerializedFrame> msg(
- spdy_util_.ConstructSpdyBodyFrame(1, kPostBody, kPostBodyLength, false));
- AddWrite(*msg);
+ SpdySerializedFrame msg(
+ spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, false));
+ AddWrite(msg);
- std::unique_ptr<SpdySerializedFrame> echo(
- spdy_util_.ConstructSpdyBodyFrame(1, kPostBody, kPostBodyLength, false));
- AddRead(*echo);
+ SpdySerializedFrame echo(
+ spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, false));
+ AddRead(echo);
AddReadEOF();
@@ -437,24 +433,22 @@ TEST_P(SpdyStreamTest, StreamError) {
TEST_P(SpdyStreamTest, SendLargeDataAfterOpenRequestResponse) {
GURL url(kStreamUrl);
- std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost(
+ SpdySerializedFrame req(spdy_util_.ConstructSpdyPost(
kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0));
- AddWrite(*req);
+ AddWrite(req);
std::string chunk_data(kMaxSpdyFrameChunkSize, 'x');
- std::unique_ptr<SpdySerializedFrame> chunk(spdy_util_.ConstructSpdyBodyFrame(
+ SpdySerializedFrame chunk(spdy_util_.ConstructSpdyDataFrame(
1, chunk_data.data(), chunk_data.length(), false));
- AddWrite(*chunk);
- AddWrite(*chunk);
+ AddWrite(chunk);
+ AddWrite(chunk);
- std::unique_ptr<SpdySerializedFrame> last_chunk(
- spdy_util_.ConstructSpdyBodyFrame(1, chunk_data.data(),
- chunk_data.length(), true));
- AddWrite(*last_chunk);
+ SpdySerializedFrame last_chunk(spdy_util_.ConstructSpdyDataFrame(
+ 1, chunk_data.data(), chunk_data.length(), true));
+ AddWrite(last_chunk);
- std::unique_ptr<SpdySerializedFrame> resp(
- spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
- AddRead(*resp);
+ SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
+ AddRead(resp);
AddReadEOF();
@@ -499,20 +493,19 @@ TEST_P(SpdyStreamTest, SendLargeDataAfterOpenRequestResponse) {
TEST_P(SpdyStreamTest, SendLargeDataAfterOpenBidirectional) {
GURL url(kStreamUrl);
- std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost(
+ SpdySerializedFrame req(spdy_util_.ConstructSpdyPost(
kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0));
- AddWrite(*req);
+ AddWrite(req);
- std::unique_ptr<SpdySerializedFrame> resp(
- spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
- AddRead(*resp);
+ SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
+ AddRead(resp);
std::string chunk_data(kMaxSpdyFrameChunkSize, 'x');
- std::unique_ptr<SpdySerializedFrame> chunk(spdy_util_.ConstructSpdyBodyFrame(
+ SpdySerializedFrame chunk(spdy_util_.ConstructSpdyDataFrame(
1, chunk_data.data(), chunk_data.length(), false));
- AddWrite(*chunk);
- AddWrite(*chunk);
- AddWrite(*chunk);
+ AddWrite(chunk);
+ AddWrite(chunk);
+ AddWrite(chunk);
AddReadEOF();
@@ -556,18 +549,18 @@ TEST_P(SpdyStreamTest, SendLargeDataAfterOpenBidirectional) {
TEST_P(SpdyStreamTest, UpperCaseHeaders) {
GURL url(kStreamUrl);
- std::unique_ptr<SpdySerializedFrame> syn(
+ SpdySerializedFrame syn(
spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true));
- AddWrite(*syn);
+ AddWrite(syn);
const char* const kExtraHeaders[] = {"X-UpperCase", "yes"};
- std::unique_ptr<SpdySerializedFrame> reply(
+ SpdySerializedFrame reply(
spdy_util_.ConstructSpdyGetSynReply(kExtraHeaders, 1, 1));
- AddRead(*reply);
+ AddRead(reply);
- std::unique_ptr<SpdySerializedFrame> rst(
+ SpdySerializedFrame rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
- AddWrite(*rst);
+ AddWrite(rst);
AddReadEOF();
@@ -605,22 +598,21 @@ TEST_P(SpdyStreamTest, UpperCaseHeaders) {
TEST_P(SpdyStreamTest, UpperCaseHeadersOnPush) {
GURL url(kStreamUrl);
- std::unique_ptr<SpdySerializedFrame> syn(
+ SpdySerializedFrame syn(
spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true));
- AddWrite(*syn);
+ AddWrite(syn);
- std::unique_ptr<SpdySerializedFrame> reply(
- spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- AddRead(*reply);
+ SpdySerializedFrame reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ AddRead(reply);
const char* const extra_headers[] = {"X-UpperCase", "yes"};
- std::unique_ptr<SpdySerializedFrame> push(
+ SpdySerializedFrame push(
spdy_util_.ConstructSpdyPush(extra_headers, 1, 2, 1, kStreamUrl));
- AddRead(*push);
+ AddRead(push);
- std::unique_ptr<SpdySerializedFrame> rst(
+ SpdySerializedFrame rst(
spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR));
- AddWrite(*rst);
+ AddWrite(rst);
AddReadPause();
@@ -668,31 +660,30 @@ TEST_P(SpdyStreamTest, UpperCaseHeadersOnPush) {
TEST_P(SpdyStreamTest, UpperCaseHeadersInHeadersFrame) {
GURL url(kStreamUrl);
- std::unique_ptr<SpdySerializedFrame> syn(
+ SpdySerializedFrame syn(
spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true));
- AddWrite(*syn);
+ AddWrite(syn);
- std::unique_ptr<SpdySerializedFrame> reply(
- spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- AddRead(*reply);
+ SpdySerializedFrame reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ AddRead(reply);
- std::unique_ptr<SpdySerializedFrame> push(
+ SpdySerializedFrame push(
spdy_util_.ConstructSpdyPush(NULL, 0, 2, 1, kStreamUrl));
- AddRead(*push);
+ AddRead(push);
AddReadPause();
SpdyHeaderBlock late_headers;
late_headers["X-UpperCase"] = "yes";
- std::unique_ptr<SpdySerializedFrame> headers_frame(
+ SpdySerializedFrame headers_frame(
spdy_util_.ConstructSpdyReply(2, std::move(late_headers)));
- AddRead(*headers_frame);
+ AddRead(headers_frame);
AddWritePause();
- std::unique_ptr<SpdySerializedFrame> rst(
+ SpdySerializedFrame rst(
spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR));
- AddWrite(*rst);
+ AddWrite(rst);
AddReadEOF();
@@ -744,31 +735,30 @@ TEST_P(SpdyStreamTest, UpperCaseHeadersInHeadersFrame) {
TEST_P(SpdyStreamTest, DuplicateHeaders) {
GURL url(kStreamUrl);
- std::unique_ptr<SpdySerializedFrame> syn(
+ SpdySerializedFrame syn(
spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true));
- AddWrite(*syn);
+ AddWrite(syn);
- std::unique_ptr<SpdySerializedFrame> reply(
- spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- AddRead(*reply);
+ SpdySerializedFrame reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ AddRead(reply);
- std::unique_ptr<SpdySerializedFrame> push(
+ SpdySerializedFrame push(
spdy_util_.ConstructSpdyPush(NULL, 0, 2, 1, kStreamUrl));
- AddRead(*push);
+ AddRead(push);
AddReadPause();
SpdyHeaderBlock late_headers;
late_headers[spdy_util_.GetStatusKey()] = "500 Server Error";
- std::unique_ptr<SpdySerializedFrame> headers_frame(
+ SpdySerializedFrame headers_frame(
spdy_util_.ConstructSpdyReply(2, std::move(late_headers)));
- AddRead(*headers_frame);
+ AddRead(headers_frame);
AddReadPause();
- std::unique_ptr<SpdySerializedFrame> rst(
+ SpdySerializedFrame rst(
spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR));
- AddWrite(*rst);
+ AddWrite(rst);
AddReadEOF();
@@ -819,17 +809,17 @@ TEST_P(SpdyStreamTest, DuplicateHeaders) {
// to overflow an int32_t. The SpdyStream should handle that case
// gracefully.
TEST_P(SpdyStreamTest, IncreaseSendWindowSizeOverflow) {
- std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost(
+ SpdySerializedFrame req(spdy_util_.ConstructSpdyPost(
kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0));
- AddWrite(*req);
+ AddWrite(req);
AddReadPause();
// Triggered by the overflowing call to IncreaseSendWindowSize
// below.
- std::unique_ptr<SpdySerializedFrame> rst(
+ SpdySerializedFrame rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_FLOW_CONTROL_ERROR));
- AddWrite(*rst);
+ AddWrite(rst);
AddReadEOF();
@@ -911,17 +901,16 @@ void SpdyStreamTest::RunResumeAfterUnstallRequestResponseTest(
const UnstallFunction& unstall_function) {
GURL url(kStreamUrl);
- std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost(
+ SpdySerializedFrame req(spdy_util_.ConstructSpdyPost(
kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0));
- AddWrite(*req);
+ AddWrite(req);
- std::unique_ptr<SpdySerializedFrame> body(
- spdy_util_.ConstructSpdyBodyFrame(1, kPostBody, kPostBodyLength, true));
- AddWrite(*body);
+ SpdySerializedFrame body(
+ spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, true));
+ AddWrite(body);
- std::unique_ptr<SpdySerializedFrame> resp(
- spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- AddRead(*resp);
+ SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ AddRead(resp);
AddReadEOF();
@@ -987,23 +976,22 @@ void SpdyStreamTest::RunResumeAfterUnstallBidirectionalTest(
const UnstallFunction& unstall_function) {
GURL url(kStreamUrl);
- std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost(
+ SpdySerializedFrame req(spdy_util_.ConstructSpdyPost(
kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0));
- AddWrite(*req);
+ AddWrite(req);
AddReadPause();
- std::unique_ptr<SpdySerializedFrame> resp(
- spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- AddRead(*resp);
+ SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ AddRead(resp);
- std::unique_ptr<SpdySerializedFrame> msg(
- spdy_util_.ConstructSpdyBodyFrame(1, kPostBody, kPostBodyLength, false));
- AddWrite(*msg);
+ SpdySerializedFrame msg(
+ spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, false));
+ AddWrite(msg);
- std::unique_ptr<SpdySerializedFrame> echo(
- spdy_util_.ConstructSpdyBodyFrame(1, kPostBody, kPostBodyLength, false));
- AddRead(*echo);
+ SpdySerializedFrame echo(
+ spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, false));
+ AddRead(echo);
AddReadEOF();
@@ -1071,21 +1059,20 @@ TEST_P(SpdyStreamTest, ResumeAfterSendWindowSizeAdjustBidirectional) {
TEST_P(SpdyStreamTest, ReceivedBytes) {
GURL url(kStreamUrl);
- std::unique_ptr<SpdySerializedFrame> syn(
+ SpdySerializedFrame syn(
spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true));
- AddWrite(*syn);
+ AddWrite(syn);
AddReadPause();
- std::unique_ptr<SpdySerializedFrame> reply(
- spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- AddRead(*reply);
+ SpdySerializedFrame reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ AddRead(reply);
AddReadPause();
- std::unique_ptr<SpdySerializedFrame> msg(
- spdy_util_.ConstructSpdyBodyFrame(1, kPostBody, kPostBodyLength, false));
- AddRead(*msg);
+ SpdySerializedFrame msg(
+ spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, false));
+ AddRead(msg);
AddReadPause();
@@ -1117,7 +1104,7 @@ TEST_P(SpdyStreamTest, ReceivedBytes) {
EXPECT_TRUE(stream->HasUrlFromHeaders());
EXPECT_EQ(kStreamUrl, stream->GetUrlFromHeaders().spec());
- int64_t reply_frame_len = reply->size();
+ int64_t reply_frame_len = reply.size();
int64_t data_header_len = SpdyConstants::GetDataFrameMinimumSize(HTTP2);
int64_t data_frame_len = data_header_len + kPostBodyLength;
int64_t response_len = reply_frame_len + data_frame_len;
« no previous file with comments | « net/spdy/spdy_session_unittest.cc ('k') | net/spdy/spdy_test_util_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698