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

Unified Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/spdy/spdy_network_transaction_unittest.cc
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc
index 790c395fd251a6756dc651fde423366f46c18a53..f2de29fcc1918101a8a6ccc261aa588129740881 100644
--- a/net/spdy/spdy_network_transaction_unittest.cc
+++ b/net/spdy/spdy_network_transaction_unittest.cc
@@ -56,14 +56,11 @@ enum SpdyNetworkTransactionTestSSLType {
struct SpdyNetworkTransactionTestParams {
SpdyNetworkTransactionTestParams()
- : protocol(kProtoSPDY3),
- ssl_type(SPDYNPN) {}
+ : protocol(kProtoSPDY3), ssl_type(SPDYNPN) {}
- SpdyNetworkTransactionTestParams(
- NextProto protocol,
- SpdyNetworkTransactionTestSSLType ssl_type)
- : protocol(protocol),
- ssl_type(ssl_type) {}
+ SpdyNetworkTransactionTestParams(NextProto protocol,
+ SpdyNetworkTransactionTestSSLType ssl_type)
+ : protocol(protocol), ssl_type(ssl_type) {}
NextProto protocol;
SpdyNetworkTransactionTestSSLType ssl_type;
@@ -124,11 +121,11 @@ class SpdyNetworkTransactionTest
SpdySessionDependencies* session_deps)
: request_(request),
priority_(priority),
- session_deps_(session_deps == NULL ?
- CreateSpdySessionDependencies(test_params) :
- session_deps),
- session_(SpdySessionDependencies::SpdyCreateSession(
- session_deps_.get())),
+ session_deps_(session_deps == NULL
+ ? CreateSpdySessionDependencies(test_params)
+ : session_deps),
+ session_(
+ SpdySessionDependencies::SpdyCreateSession(session_deps_.get())),
log_(log),
test_params_(test_params),
deterministic_(false),
@@ -174,8 +171,8 @@ class SpdyNetworkTransactionTest
if (!session_deps_.get())
session_deps_.reset(CreateSpdySessionDependencies(test_params_));
if (!session_.get())
- session_ = SpdySessionDependencies::SpdyCreateSession(
- session_deps_.get());
+ session_ =
+ SpdySessionDependencies::SpdyCreateSession(session_deps_.get());
HttpStreamFactory::set_use_alternate_protocols(false);
HttpStreamFactory::set_force_spdy_over_ssl(false);
HttpStreamFactory::set_force_spdy_always(false);
@@ -185,7 +182,8 @@ class SpdyNetworkTransactionTest
switch (test_params_.ssl_type) {
case SPDYNPN:
session_->http_server_properties()->SetAlternateProtocol(
- HostPortPair("www.google.com", 80), 443,
+ HostPortPair("www.google.com", 80),
+ 443,
AlternateProtocolFromNextProto(test_params_.protocol));
HttpStreamFactory::set_use_alternate_protocols(true);
HttpStreamFactory::SetNextProtos(next_protos);
@@ -238,10 +236,9 @@ class SpdyNetworkTransactionTest
EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
EXPECT_EQ(spdy_enabled_, response->was_fetched_via_spdy);
if (HttpStreamFactory::spdy_enabled()) {
- EXPECT_EQ(
- HttpResponseInfo::ConnectionInfoFromNextProto(
- test_params_.protocol),
- response->connection_info);
+ EXPECT_EQ(HttpResponseInfo::ConnectionInfoFromNextProto(
+ test_params_.protocol),
+ response->connection_info);
} else {
EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_HTTP1,
response->connection_info);
@@ -254,8 +251,7 @@ class SpdyNetworkTransactionTest
// If SPDY is not enabled, a HTTP request should not be diverted
// over a SSL session.
if (!spdy_enabled_) {
- EXPECT_EQ(request_.url.SchemeIs("https"),
- response->was_npn_negotiated);
+ EXPECT_EQ(request_.url.SchemeIs("https"), response->was_npn_negotiated);
}
EXPECT_EQ("127.0.0.1", response->socket_address.host());
EXPECT_EQ(port_, response->socket_address.port());
@@ -269,15 +265,14 @@ class SpdyNetworkTransactionTest
// ensure proper deletion of the spdy_session_pool.
void VerifyDataConsumed() {
for (DataVector::iterator it = data_vector_.begin();
- it != data_vector_.end(); ++it) {
- EXPECT_TRUE((*it)->at_read_eof()) << "Read count: "
- << (*it)->read_count()
- << " Read index: "
- << (*it)->read_index();
- EXPECT_TRUE((*it)->at_write_eof()) << "Write count: "
- << (*it)->write_count()
- << " Write index: "
- << (*it)->write_index();
+ it != data_vector_.end();
+ ++it) {
+ EXPECT_TRUE((*it)->at_read_eof())
+ << "Read count: " << (*it)->read_count()
+ << " Read index: " << (*it)->read_index();
+ EXPECT_TRUE((*it)->at_write_eof())
+ << "Write count: " << (*it)->write_count()
+ << " Write index: " << (*it)->write_index();
}
}
@@ -286,15 +281,14 @@ class SpdyNetworkTransactionTest
// not processed.
void VerifyDataNotConsumed() {
for (DataVector::iterator it = data_vector_.begin();
- it != data_vector_.end(); ++it) {
- EXPECT_TRUE(!(*it)->at_read_eof()) << "Read count: "
- << (*it)->read_count()
- << " Read index: "
- << (*it)->read_index();
- EXPECT_TRUE(!(*it)->at_write_eof()) << "Write count: "
- << (*it)->write_count()
- << " Write index: "
- << (*it)->write_index();
+ it != data_vector_.end();
+ ++it) {
+ EXPECT_TRUE(!(*it)->at_read_eof())
+ << "Read count: " << (*it)->read_count()
+ << " Read index: " << (*it)->read_index();
+ EXPECT_TRUE(!(*it)->at_write_eof())
+ << "Write count: " << (*it)->write_count()
+ << " Write index: " << (*it)->write_index();
}
}
@@ -341,8 +335,8 @@ class SpdyNetworkTransactionTest
ssl_vector_.push_back(ssl_provider);
if (test_params_.ssl_type == SPDYNPN ||
test_params_.ssl_type == SPDYSSL) {
- session_deps_->deterministic_socket_factory->
- AddSSLSocketDataProvider(ssl_provider);
+ session_deps_->deterministic_socket_factory->AddSSLSocketDataProvider(
+ ssl_provider);
}
session_deps_->deterministic_socket_factory->AddSocketDataProvider(data);
if (test_params_.ssl_type == SPDYNPN) {
@@ -492,8 +486,7 @@ class SpdyNetworkTransactionTest
0,
kUploadDataSize,
base::Time()));
- upload_data_stream_.reset(
- new UploadDataStream(element_readers.Pass(), 0));
+ upload_data_stream_.reset(new UploadDataStream(element_readers.Pass(), 0));
google_post_request_.method = "POST";
google_post_request_.url = GURL(kDefaultURL);
@@ -587,8 +580,8 @@ class SpdyNetworkTransactionTest
const GURL& url = helper.request().url;
int port = helper.test_params().ssl_type == SPDYNPN ? 443 : 80;
HostPortPair host_port_pair(url.host(), port);
- SpdySessionKey key(host_port_pair, ProxyServer::Direct(),
- PRIVACY_MODE_DISABLED);
+ SpdySessionKey key(
+ host_port_pair, ProxyServer::Direct(), PRIVACY_MODE_DISABLED);
BoundNetLog log;
const scoped_refptr<HttpNetworkSession>& session = helper.session();
base::WeakPtr<SpdySession> spdy_session =
@@ -602,8 +595,8 @@ class SpdyNetworkTransactionTest
HttpResponseInfo* response,
HttpResponseInfo* push_response,
const std::string& expected) {
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(data);
@@ -611,8 +604,8 @@ class SpdyNetworkTransactionTest
// Start the transaction with basic parameters.
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
@@ -639,10 +632,8 @@ class SpdyNetworkTransactionTest
EXPECT_TRUE(data->at_write_eof());
// Verify that the received push data is same as the expected push data.
- EXPECT_EQ(result2.compare(expected), 0) << "Received data: "
- << result2
- << "||||| Expected data: "
- << expected;
+ EXPECT_EQ(result2.compare(expected), 0)
+ << "Received data: " << result2 << "||||| Expected data: " << expected;
// Verify the SYN_REPLY.
// Copy the response info, because trans goes away.
@@ -728,20 +719,18 @@ TEST_P(SpdyNetworkTransactionTest, Get) {
// Construct the request.
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req)};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(OK, out.rv);
@@ -755,7 +744,7 @@ TEST_P(SpdyNetworkTransactionTest, GetAtEachPriority) {
// Construct the request.
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, p, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req)};
SpdyPriority spdy_prio = 0;
EXPECT_TRUE(GetSpdyPriority(spdy_util_.spdy_version(), *req, &spdy_prio));
@@ -763,7 +752,7 @@ TEST_P(SpdyNetworkTransactionTest, GetAtEachPriority) {
// SpdyFramer::ConvertRequestPriorityToSpdyPriority to make
// sure it's being done right.
if (spdy_util_.spdy_version() < SPDY3) {
- switch(p) {
+ switch (p) {
case HIGHEST:
EXPECT_EQ(0, spdy_prio);
break;
@@ -781,7 +770,7 @@ TEST_P(SpdyNetworkTransactionTest, GetAtEachPriority) {
FAIL();
}
} else {
- switch(p) {
+ switch (p) {
case HIGHEST:
EXPECT_EQ(0, spdy_prio);
break;
@@ -805,17 +794,16 @@ TEST_P(SpdyNetworkTransactionTest, GetAtEachPriority) {
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ DelayedSocketData data(
+ 1, reads, arraysize(reads), writes, arraysize(writes));
HttpRequestInfo http_req = CreateGetRequest();
- NormalSpdyTransactionHelper helper(http_req, p, BoundNetLog(),
- GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ http_req, p, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(OK, out.rv);
@@ -854,32 +842,22 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGets) {
scoped_ptr<SpdyFrame> fbody3(spdy_util_.ConstructSpdyBodyFrame(5, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*req2),
- CreateMockWrite(*req3),
+ CreateMockWrite(*req), CreateMockWrite(*req2), CreateMockWrite(*req3),
};
MockRead reads[] = {
- CreateMockRead(*resp, 1),
- CreateMockRead(*body),
- CreateMockRead(*resp2, 4),
- CreateMockRead(*body2),
- CreateMockRead(*resp3, 7),
- CreateMockRead(*body3),
-
- CreateMockRead(*fbody),
- CreateMockRead(*fbody2),
- CreateMockRead(*fbody3),
-
- MockRead(ASYNC, 0, 0), // EOF
+ CreateMockRead(*resp, 1), CreateMockRead(*body),
+ CreateMockRead(*resp2, 4), CreateMockRead(*body2),
+ CreateMockRead(*resp3, 7), CreateMockRead(*body3),
+ CreateMockRead(*fbody), CreateMockRead(*fbody2),
+ CreateMockRead(*fbody3), MockRead(ASYNC, 0, 0), // EOF
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
OrderedSocketData data_placeholder(NULL, 0, NULL, 0);
BoundNetLog log;
TransactionHelperResult out;
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
// We require placeholder data because three get requests are sent out, so
@@ -944,20 +922,15 @@ TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBinding) {
scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*req2),
+ CreateMockWrite(*req), CreateMockWrite(*req2),
};
MockRead reads[] = {
- CreateMockRead(*resp, 1),
- CreateMockRead(*body),
- CreateMockRead(*resp2, 4),
- CreateMockRead(*body2),
- CreateMockRead(*fbody),
- CreateMockRead(*fbody2),
- MockRead(ASYNC, 0, 0), // EOF
+ CreateMockRead(*resp, 1), CreateMockRead(*body),
+ CreateMockRead(*resp2, 4), CreateMockRead(*body2),
+ CreateMockRead(*fbody), CreateMockRead(*fbody2),
+ MockRead(ASYNC, 0, 0), // EOF
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING);
@@ -966,8 +939,8 @@ TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBinding) {
BoundNetLog log;
TransactionHelperResult out;
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
// We require placeholder data because two get requests are sent out, so
@@ -1031,20 +1004,16 @@ TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBindingFromPreconnect) {
scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*req2),
+ CreateMockWrite(*req), CreateMockWrite(*req2),
};
MockRead reads[] = {
- CreateMockRead(*resp, 1),
- CreateMockRead(*body),
- CreateMockRead(*resp2, 4),
- CreateMockRead(*body2),
- CreateMockRead(*fbody),
- CreateMockRead(*fbody2),
- MockRead(ASYNC, 0, 0), // EOF
+ CreateMockRead(*resp, 1), CreateMockRead(*body),
+ CreateMockRead(*resp2, 4), CreateMockRead(*body2),
+ CreateMockRead(*fbody), CreateMockRead(*fbody2),
+ MockRead(ASYNC, 0, 0), // EOF
};
- OrderedSocketData preconnect_data(reads, arraysize(reads),
- writes, arraysize(writes));
+ OrderedSocketData preconnect_data(
+ reads, arraysize(reads), writes, arraysize(writes));
MockConnect never_finishing_connect(ASYNC, ERR_IO_PENDING);
@@ -1053,8 +1022,8 @@ TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBindingFromPreconnect) {
BoundNetLog log;
TransactionHelperResult out;
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&preconnect_data);
// We require placeholder data because 3 connections are attempted (first is
@@ -1081,9 +1050,11 @@ TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBindingFromPreconnect) {
preconnect_ssl_config.next_protos = http_stream_factory->next_protos();
}
- http_stream_factory->PreconnectStreams(
- 1, httpreq, DEFAULT_PRIORITY,
- preconnect_ssl_config, preconnect_ssl_config);
+ http_stream_factory->PreconnectStreams(1,
+ httpreq,
+ DEFAULT_PRIORITY,
+ preconnect_ssl_config,
+ preconnect_ssl_config);
out.rv = trans1->Start(&httpreq, callback1.callback(), log);
ASSERT_EQ(ERR_IO_PENDING, out.rv);
@@ -1151,35 +1122,26 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrent) {
spdy_util_.ConstructSpdySettings(settings));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*req2),
- CreateMockWrite(*req3),
+ CreateMockWrite(*req), CreateMockWrite(*req2), CreateMockWrite(*req3),
};
MockRead reads[] = {
- CreateMockRead(*settings_frame, 1),
- CreateMockRead(*resp),
- CreateMockRead(*body),
- CreateMockRead(*fbody),
- CreateMockRead(*resp2, 7),
- CreateMockRead(*body2),
- CreateMockRead(*fbody2),
- CreateMockRead(*resp3, 12),
- CreateMockRead(*body3),
- CreateMockRead(*fbody3),
-
- MockRead(ASYNC, 0, 0), // EOF
- };
-
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ CreateMockRead(*settings_frame, 1), CreateMockRead(*resp),
+ CreateMockRead(*body), CreateMockRead(*fbody),
+ CreateMockRead(*resp2, 7), CreateMockRead(*body2),
+ CreateMockRead(*fbody2), CreateMockRead(*resp3, 12),
+ CreateMockRead(*body3), CreateMockRead(*fbody3),
+ MockRead(ASYNC, 0, 0), // EOF
+ };
+
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
OrderedSocketData data_placeholder(NULL, 0, NULL, 0);
BoundNetLog log;
TransactionHelperResult out;
{
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
// We require placeholder data because three get requests are sent out, so
@@ -1288,36 +1250,27 @@ TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) {
scoped_ptr<SpdyFrame> settings_frame(
spdy_util_.ConstructSpdySettings(settings));
- MockWrite writes[] = { CreateMockWrite(*req),
- CreateMockWrite(*req2),
- CreateMockWrite(*req4),
- CreateMockWrite(*req3),
+ MockWrite writes[] = {
+ CreateMockWrite(*req), CreateMockWrite(*req2), CreateMockWrite(*req4),
+ CreateMockWrite(*req3),
};
MockRead reads[] = {
- CreateMockRead(*settings_frame, 1),
- CreateMockRead(*resp),
- CreateMockRead(*body),
- CreateMockRead(*fbody),
- CreateMockRead(*resp2, 7),
- CreateMockRead(*body2),
- CreateMockRead(*fbody2),
- CreateMockRead(*resp4, 13),
- CreateMockRead(*fbody4),
- CreateMockRead(*resp3, 16),
- CreateMockRead(*body3),
- CreateMockRead(*fbody3),
-
- MockRead(ASYNC, 0, 0), // EOF
- };
-
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ CreateMockRead(*settings_frame, 1), CreateMockRead(*resp),
+ CreateMockRead(*body), CreateMockRead(*fbody),
+ CreateMockRead(*resp2, 7), CreateMockRead(*body2),
+ CreateMockRead(*fbody2), CreateMockRead(*resp4, 13),
+ CreateMockRead(*fbody4), CreateMockRead(*resp3, 16),
+ CreateMockRead(*body3), CreateMockRead(*fbody3),
+ MockRead(ASYNC, 0, 0), // EOF
+ };
+
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
OrderedSocketData data_placeholder(NULL, 0, NULL, 0);
BoundNetLog log;
TransactionHelperResult out;
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
// We require placeholder data because four get requests are sent out, so
@@ -1430,28 +1383,23 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) {
scoped_ptr<SpdyFrame> settings_frame(
spdy_util_.ConstructSpdySettings(settings));
- MockWrite writes[] = { CreateMockWrite(*req),
- CreateMockWrite(*req2),
+ MockWrite writes[] = {
+ CreateMockWrite(*req), CreateMockWrite(*req2),
};
MockRead reads[] = {
- CreateMockRead(*settings_frame, 1),
- CreateMockRead(*resp),
- CreateMockRead(*body),
- CreateMockRead(*fbody),
- CreateMockRead(*resp2, 7),
- CreateMockRead(*body2),
- CreateMockRead(*fbody2),
- MockRead(ASYNC, 0, 0), // EOF
- };
-
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ CreateMockRead(*settings_frame, 1), CreateMockRead(*resp),
+ CreateMockRead(*body), CreateMockRead(*fbody),
+ CreateMockRead(*resp2, 7), CreateMockRead(*body2),
+ CreateMockRead(*fbody2), MockRead(ASYNC, 0, 0), // EOF
+ };
+
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
OrderedSocketData data_placeholder(NULL, 0, NULL, 0);
BoundNetLog log;
TransactionHelperResult out;
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
// We require placeholder data because three get requests are sent out, so
@@ -1520,9 +1468,8 @@ class KillerCallback : public TestCompletionCallbackBase {
public:
explicit KillerCallback(HttpNetworkTransaction* transaction)
: transaction_(transaction),
- callback_(base::Bind(&KillerCallback::OnComplete,
- base::Unretained(this))) {
- }
+ callback_(
+ base::Bind(&KillerCallback::OnComplete, base::Unretained(this))) {}
virtual ~KillerCallback() {}
@@ -1564,26 +1511,25 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentSocketClose) {
scoped_ptr<SpdyFrame> settings_frame(
spdy_util_.ConstructSpdySettings(settings));
- MockWrite writes[] = { CreateMockWrite(*req),
- CreateMockWrite(*req2),
+ MockWrite writes[] = {
+ CreateMockWrite(*req), CreateMockWrite(*req2),
};
MockRead reads[] = {
- CreateMockRead(*settings_frame, 1),
- CreateMockRead(*resp),
- CreateMockRead(*body),
- CreateMockRead(*fin_body),
- CreateMockRead(*resp2, 7),
- MockRead(ASYNC, ERR_CONNECTION_RESET, 0), // Abort!
+ CreateMockRead(*settings_frame, 1),
+ CreateMockRead(*resp),
+ CreateMockRead(*body),
+ CreateMockRead(*fin_body),
+ CreateMockRead(*resp2, 7),
+ MockRead(ASYNC, ERR_CONNECTION_RESET, 0), // Abort!
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
OrderedSocketData data_placeholder(NULL, 0, NULL, 0);
BoundNetLog log;
TransactionHelperResult out;
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
// We require placeholder data because three get requests are sent out, so
@@ -1645,58 +1591,54 @@ TEST_P(SpdyNetworkTransactionTest, Put) {
request.url = GURL("http://www.google.com/");
const SpdyHeaderInfo kSynStartHeader = {
- SYN_STREAM, // Kind = Syn
- 1, // Stream ID
- 0, // Associated stream ID
- ConvertRequestPriorityToSpdyPriority(
- LOWEST, spdy_util_.spdy_version()),
- kSpdyCredentialSlotUnused,
- CONTROL_FLAG_FIN, // Control Flags
- false, // Compressed
- RST_STREAM_INVALID, // Status
- NULL, // Data
- 0, // Length
- DATA_FLAG_NONE // Data Flags
+ SYN_STREAM, // Kind = Syn
+ 1, // Stream ID
+ 0, // Associated stream ID
+ ConvertRequestPriorityToSpdyPriority(LOWEST, spdy_util_.spdy_version()),
+ kSpdyCredentialSlotUnused,
+ CONTROL_FLAG_FIN, // Control Flags
+ false, // Compressed
+ RST_STREAM_INVALID, // Status
+ NULL, // Data
+ 0, // Length
+ DATA_FLAG_NONE // Data Flags
};
scoped_ptr<SpdyHeaderBlock> put_headers(
spdy_util_.ConstructPutHeaderBlock("http://www.google.com", 0));
- scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyFrame(
- kSynStartHeader, put_headers.Pass()));
+ scoped_ptr<SpdyFrame> req(
+ spdy_util_.ConstructSpdyFrame(kSynStartHeader, put_headers.Pass()));
MockWrite writes[] = {
- CreateMockWrite(*req),
+ CreateMockWrite(*req),
};
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
const SpdyHeaderInfo kSynReplyHeader = {
- SYN_REPLY, // Kind = SynReply
- 1, // Stream ID
- 0, // Associated stream ID
- ConvertRequestPriorityToSpdyPriority(
- LOWEST, spdy_util_.spdy_version()),
- kSpdyCredentialSlotUnused,
- CONTROL_FLAG_NONE, // Control Flags
- false, // Compressed
- RST_STREAM_INVALID, // Status
- NULL, // Data
- 0, // Length
- DATA_FLAG_NONE // Data Flags
+ SYN_REPLY, // Kind = SynReply
+ 1, // Stream ID
+ 0, // Associated stream ID
+ ConvertRequestPriorityToSpdyPriority(LOWEST, spdy_util_.spdy_version()),
+ kSpdyCredentialSlotUnused,
+ CONTROL_FLAG_NONE, // Control Flags
+ false, // Compressed
+ RST_STREAM_INVALID, // Status
+ NULL, // Data
+ 0, // Length
+ DATA_FLAG_NONE // Data Flags
};
scoped_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock());
(*reply_headers)[spdy_util_.GetStatusKey()] = "200";
(*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1";
(*reply_headers)["content-length"] = "1234";
- scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyFrame(
- kSynReplyHeader, reply_headers.Pass()));
+ scoped_ptr<SpdyFrame> resp(
+ spdy_util_.ConstructSpdyFrame(kSynReplyHeader, reply_headers.Pass()));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
@@ -1712,59 +1654,54 @@ TEST_P(SpdyNetworkTransactionTest, Head) {
request.url = GURL("http://www.google.com/");
const SpdyHeaderInfo kSynStartHeader = {
- SYN_STREAM, // Kind = Syn
- 1, // Stream ID
- 0, // Associated stream ID
- ConvertRequestPriorityToSpdyPriority(
- LOWEST, spdy_util_.spdy_version()),
- kSpdyCredentialSlotUnused,
- CONTROL_FLAG_FIN, // Control Flags
- false, // Compressed
- RST_STREAM_INVALID, // Status
- NULL, // Data
- 0, // Length
- DATA_FLAG_NONE // Data Flags
+ SYN_STREAM, // Kind = Syn
+ 1, // Stream ID
+ 0, // Associated stream ID
+ ConvertRequestPriorityToSpdyPriority(LOWEST, spdy_util_.spdy_version()),
+ kSpdyCredentialSlotUnused,
+ CONTROL_FLAG_FIN, // Control Flags
+ false, // Compressed
+ RST_STREAM_INVALID, // Status
+ NULL, // Data
+ 0, // Length
+ DATA_FLAG_NONE // Data Flags
};
scoped_ptr<SpdyHeaderBlock> head_headers(
spdy_util_.ConstructHeadHeaderBlock("http://www.google.com", 0));
- scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyFrame(
- kSynStartHeader, head_headers.Pass()));
+ scoped_ptr<SpdyFrame> req(
+ spdy_util_.ConstructSpdyFrame(kSynStartHeader, head_headers.Pass()));
MockWrite writes[] = {
- CreateMockWrite(*req),
+ CreateMockWrite(*req),
};
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
const SpdyHeaderInfo kSynReplyHeader = {
- SYN_REPLY, // Kind = SynReply
- 1, // Stream ID
- 0, // Associated stream ID
- ConvertRequestPriorityToSpdyPriority(
- LOWEST, spdy_util_.spdy_version()),
- kSpdyCredentialSlotUnused,
- CONTROL_FLAG_NONE, // Control Flags
- false, // Compressed
- RST_STREAM_INVALID, // Status
- NULL, // Data
- 0, // Length
- DATA_FLAG_NONE // Data Flags
+ SYN_REPLY, // Kind = SynReply
+ 1, // Stream ID
+ 0, // Associated stream ID
+ ConvertRequestPriorityToSpdyPriority(LOWEST, spdy_util_.spdy_version()),
+ kSpdyCredentialSlotUnused,
+ CONTROL_FLAG_NONE, // Control Flags
+ false, // Compressed
+ RST_STREAM_INVALID, // Status
+ NULL, // Data
+ 0, // Length
+ DATA_FLAG_NONE // Data Flags
};
scoped_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock());
(*reply_headers)[spdy_util_.GetStatusKey()] = "200";
(*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1";
(*reply_headers)["content-length"] = "1234";
- scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyFrame(
- kSynReplyHeader,
- reply_headers.Pass()));
+ scoped_ptr<SpdyFrame> resp(
+ spdy_util_.ConstructSpdyFrame(kSynReplyHeader, reply_headers.Pass()));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
@@ -1774,26 +1711,23 @@ TEST_P(SpdyNetworkTransactionTest, Head) {
// Test that a simple POST works.
TEST_P(SpdyNetworkTransactionTest, Post) {
- scoped_ptr<SpdyFrame> req(
- spdy_util_.ConstructSpdyPost(
- kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0));
+ scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyPost(
+ kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*body), // POST upload frame
+ CreateMockWrite(*req),
+ CreateMockWrite(*body), // POST upload frame
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(2, reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreatePostRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(2, reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreatePostRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(OK, out.rv);
@@ -1803,26 +1737,26 @@ TEST_P(SpdyNetworkTransactionTest, Post) {
// Test that a POST with a file works.
TEST_P(SpdyNetworkTransactionTest, FilePost) {
- scoped_ptr<SpdyFrame> req(
- spdy_util_.ConstructSpdyPost(
- kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0));
+ scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyPost(
+ kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*body), // POST upload frame
+ CreateMockWrite(*req),
+ CreateMockWrite(*body), // POST upload frame
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(2, reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateFilePostRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(2, reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(CreateFilePostRequest(),
+ DEFAULT_PRIORITY,
+ BoundNetLog(),
+ GetParam(),
+ NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(OK, out.rv);
@@ -1833,16 +1767,18 @@ TEST_P(SpdyNetworkTransactionTest, FilePost) {
// Test that a POST with a unreadable file fails.
TEST_P(SpdyNetworkTransactionTest, UnreadableFilePost) {
MockWrite writes[] = {
- MockWrite(ASYNC, 0, 0) // EOF
+ MockWrite(ASYNC, 0, 0) // EOF
};
MockRead reads[] = {
- MockRead(ASYNC, 0, 0) // EOF
+ MockRead(ASYNC, 0, 0) // EOF
};
DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateUnreadableFilePostRequest(),
DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ BoundNetLog(),
+ GetParam(),
+ NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
helper.RunDefaultTest();
@@ -1854,27 +1790,26 @@ TEST_P(SpdyNetworkTransactionTest, UnreadableFilePost) {
// Test that a complex POST works.
TEST_P(SpdyNetworkTransactionTest, ComplexPost) {
- scoped_ptr<SpdyFrame> req(
- spdy_util_.ConstructSpdyPost(
- kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0));
+ scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyPost(
+ kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*body), // POST upload frame
+ CreateMockWrite(*req),
+ CreateMockWrite(*body), // POST upload frame
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(2, reads, arraysize(reads),
- writes, arraysize(writes));
+ DelayedSocketData data(2, reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateComplexPostRequest(),
DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ BoundNetLog(),
+ GetParam(),
+ NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(OK, out.rv);
@@ -1887,25 +1822,24 @@ TEST_P(SpdyNetworkTransactionTest, ChunkedPost) {
scoped_ptr<SpdyFrame> req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*body),
+ CreateMockWrite(*req), CreateMockWrite(*body),
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(2, reads, arraysize(reads),
- writes, arraysize(writes));
+ DelayedSocketData data(2, reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(),
DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ BoundNetLog(),
+ GetParam(),
+ NULL);
// These chunks get merged into a single frame when being sent.
- const int kFirstChunkSize = kUploadDataSize/2;
+ const int kFirstChunkSize = kUploadDataSize / 2;
helper.request().upload_data_stream->AppendChunk(
kUploadData, kFirstChunkSize, false);
helper.request().upload_data_stream->AppendChunk(
@@ -1925,26 +1859,22 @@ TEST_P(SpdyNetworkTransactionTest, DelayedChunkedPost) {
scoped_ptr<SpdyFrame> chunk2(spdy_util_.ConstructSpdyBodyFrame(1, false));
scoped_ptr<SpdyFrame> chunk3(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*chunk1),
- CreateMockWrite(*chunk2),
- CreateMockWrite(*chunk3),
+ CreateMockWrite(*req), CreateMockWrite(*chunk1), CreateMockWrite(*chunk2),
+ CreateMockWrite(*chunk3),
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*chunk1),
- CreateMockRead(*chunk2),
- CreateMockRead(*chunk3),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*chunk1), CreateMockRead(*chunk2),
+ CreateMockRead(*chunk3), MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(4, reads, arraysize(reads),
- writes, arraysize(writes));
+ DelayedSocketData data(4, reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(),
DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ BoundNetLog(),
+ GetParam(),
+ NULL);
helper.request().upload_data_stream->AppendChunk(
kUploadData, kUploadDataSize, false);
@@ -1990,27 +1920,25 @@ TEST_P(SpdyNetworkTransactionTest, NullPost) {
syn_ir.set_name_value_block(
*spdy_util_.ConstructPostHeaderBlock(kRequestUrl, 0));
syn_ir.set_fin(true); // No body.
- syn_ir.set_priority(ConvertRequestPriorityToSpdyPriority(
- LOWEST, spdy_util_.spdy_version()));
+ syn_ir.set_priority(
+ ConvertRequestPriorityToSpdyPriority(LOWEST, spdy_util_.spdy_version()));
scoped_ptr<SpdyFrame> req(framer.SerializeFrame(syn_ir));
MockWrite writes[] = {
- CreateMockWrite(*req),
+ CreateMockWrite(*req),
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(OK, out.rv);
@@ -2037,26 +1965,25 @@ TEST_P(SpdyNetworkTransactionTest, EmptyPost) {
syn_ir.set_name_value_block(
*spdy_util_.ConstructPostHeaderBlock(kRequestUrl, kContentLength));
syn_ir.set_fin(true); // No body.
- syn_ir.set_priority(ConvertRequestPriorityToSpdyPriority(
- LOWEST, spdy_util_.spdy_version()));
+ syn_ir.set_priority(
+ ConvertRequestPriorityToSpdyPriority(LOWEST, spdy_util_.spdy_version()));
scoped_ptr<SpdyFrame> req(framer.SerializeFrame(syn_ir));
MockWrite writes[] = {
- CreateMockWrite(*req),
+ CreateMockWrite(*req),
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(OK, out.rv);
@@ -2069,23 +1996,23 @@ TEST_P(SpdyNetworkTransactionTest, ResponseBeforePostCompletes) {
scoped_ptr<SpdyFrame> req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*req, 0),
- CreateMockWrite(*body, 3),
+ CreateMockWrite(*req, 0), CreateMockWrite(*body, 3),
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
MockRead reads[] = {
- CreateMockRead(*resp, 1),
- CreateMockRead(*body, 2),
- MockRead(ASYNC, 0, 4) // EOF
+ CreateMockRead(*resp, 1), CreateMockRead(*body, 2),
+ MockRead(ASYNC, 0, 4) // EOF
};
// Write the request headers, and read the complete response
// while still waiting for chunked request data.
- DeterministicSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ DeterministicSocketData data(
+ reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(),
DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ BoundNetLog(),
+ GetParam(),
+ NULL);
helper.SetDeterministic();
helper.RunPreTestSetup();
helper.AddDeterministicData(&data);
@@ -2119,29 +2046,28 @@ TEST_P(SpdyNetworkTransactionTest, SocketWriteReturnsZero) {
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL));
MockWrite writes[] = {
- CreateMockWrite(*req.get(), 0, SYNCHRONOUS),
- MockWrite(SYNCHRONOUS, 0, 0, 2),
- CreateMockWrite(*rst.get(), 3, SYNCHRONOUS),
+ CreateMockWrite(*req.get(), 0, SYNCHRONOUS),
+ MockWrite(SYNCHRONOUS, 0, 0, 2),
+ CreateMockWrite(*rst.get(), 3, SYNCHRONOUS),
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
MockRead reads[] = {
- CreateMockRead(*resp.get(), 1, ASYNC),
- MockRead(ASYNC, 0, 0, 4) // EOF
+ CreateMockRead(*resp.get(), 1, ASYNC), MockRead(ASYNC, 0, 0, 4) // EOF
};
- DeterministicSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DeterministicSocketData data(
+ reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.SetDeterministic();
helper.RunPreTestSetup();
helper.AddDeterministicData(&data);
HttpNetworkTransaction* trans = helper.trans();
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
data.SetStop(2);
@@ -2157,13 +2083,12 @@ TEST_P(SpdyNetworkTransactionTest, SocketWriteReturnsZero) {
TEST_P(SpdyNetworkTransactionTest, ResponseWithoutSynReply) {
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*body), MockRead(ASYNC, 0, 0) // EOF
};
DelayedSocketData data(1, reads, arraysize(reads), NULL, 0);
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
@@ -2177,24 +2102,20 @@ TEST_P(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) {
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*rst),
+ CreateMockWrite(*req), CreateMockWrite(*rst),
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
@@ -2224,27 +2145,21 @@ TEST_P(SpdyNetworkTransactionTest, ResetReplyWithTransferEncoding) {
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*rst),
+ CreateMockWrite(*req), CreateMockWrite(*rst),
};
- const char* const headers[] = {
- "transfer-encoding", "chunked"
- };
+ const char* const headers[] = {"transfer-encoding", "chunked"};
scoped_ptr<SpdyFrame> resp(
spdy_util_.ConstructSpdyGetSynReply(headers, 1, 1));
- scoped_ptr<SpdyFrame> body(
- spdy_util_.ConstructSpdyBodyFrame(1, true));
+ scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
@@ -2260,29 +2175,22 @@ TEST_P(SpdyNetworkTransactionTest, ResetPushWithTransferEncoding) {
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*rst),
+ CreateMockWrite(*req), CreateMockWrite(*rst),
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- const char* const headers[] = {
- "transfer-encoding", "chunked"
- };
- scoped_ptr<SpdyFrame> push(
- spdy_util_.ConstructSpdyPush(headers, arraysize(headers) / 2,
- 2, 1, "http://www.google.com/1"));
+ const char* const headers[] = {"transfer-encoding", "chunked"};
+ scoped_ptr<SpdyFrame> push(spdy_util_.ConstructSpdyPush(
+ headers, arraysize(headers) / 2, 2, 1, "http://www.google.com/1"));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*push),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*push), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(OK, out.rv);
@@ -2298,31 +2206,31 @@ TEST_P(SpdyNetworkTransactionTest, CancelledTransaction) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
+ CreateMockWrite(*req),
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
MockRead reads[] = {
- CreateMockRead(*resp),
- // This following read isn't used by the test, except during the
- // RunUntilIdle() call at the end since the SpdySession survives the
- // HttpNetworkTransaction and still tries to continue Read()'ing. Any
- // MockRead will do here.
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp),
+ // This following read isn't used by the test, except during the
+ // RunUntilIdle() call at the end since the SpdySession survives the
+ // HttpNetworkTransaction and still tries to continue Read()'ing. Any
+ // MockRead will do here.
+ MockRead(ASYNC, 0, 0) // EOF
};
- StaticSocketDataProvider data(reads, arraysize(reads),
- writes, arraysize(writes));
+ StaticSocketDataProvider data(
+ reads, arraysize(reads), writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
HttpNetworkTransaction* trans = helper.trans();
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
helper.ResetTrans(); // Cancel the transaction.
@@ -2339,22 +2247,20 @@ TEST_P(SpdyNetworkTransactionTest, CancelledTransactionSendRst) {
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL));
MockWrite writes[] = {
- CreateMockWrite(*req, 0, SYNCHRONOUS),
- CreateMockWrite(*rst, 2, SYNCHRONOUS),
+ CreateMockWrite(*req, 0, SYNCHRONOUS),
+ CreateMockWrite(*rst, 2, SYNCHRONOUS),
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
MockRead reads[] = {
- CreateMockRead(*resp, 1, ASYNC),
- MockRead(ASYNC, 0, 0, 3) // EOF
+ CreateMockRead(*resp, 1, ASYNC), MockRead(ASYNC, 0, 0, 3) // EOF
};
- DeterministicSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ DeterministicSocketData data(
+ reads, arraysize(reads), writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(),
- GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.SetDeterministic();
helper.RunPreTestSetup();
helper.AddDeterministicData(&data);
@@ -2362,8 +2268,8 @@ TEST_P(SpdyNetworkTransactionTest, CancelledTransactionSendRst) {
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
data.SetStop(2);
@@ -2381,39 +2287,38 @@ TEST_P(SpdyNetworkTransactionTest, CancelledTransactionSendRst) {
TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
- MockWrite writes2[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req)};
+ MockWrite writes2[] = {CreateMockWrite(*req)};
// The indicated length of this frame is longer than its actual length. When
// the session receives an empty frame after this one, it shuts down the
// session, and calls the read callback with the incomplete data.
const uint8 kGetBodyFrame2[] = {
- 0x00, 0x00, 0x00, 0x01,
- 0x01, 0x00, 0x00, 0x07,
- 'h', 'e', 'l', 'l', 'o', '!',
+ 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
+ 0x07, 'h', 'e', 'l', 'l', 'o', '!',
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
MockRead reads[] = {
- CreateMockRead(*resp, 2),
- MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause
- MockRead(ASYNC, reinterpret_cast<const char*>(kGetBodyFrame2),
- arraysize(kGetBodyFrame2), 4),
- MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause
- MockRead(ASYNC, 0, 0, 6), // EOF
+ CreateMockRead(*resp, 2),
+ MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause
+ MockRead(ASYNC,
+ reinterpret_cast<const char*>(kGetBodyFrame2),
+ arraysize(kGetBodyFrame2),
+ 4),
+ MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause
+ MockRead(ASYNC, 0, 0, 6), // EOF
};
MockRead reads2[] = {
- CreateMockRead(*resp, 2),
- MockRead(ASYNC, 0, 0, 3), // EOF
+ CreateMockRead(*resp, 2), MockRead(ASYNC, 0, 0, 3), // EOF
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- DelayedSocketData data2(1, reads2, arraysize(reads2),
- writes2, arraysize(writes2));
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ DelayedSocketData data2(
+ 1, reads2, arraysize(reads2), writes2, arraysize(writes2));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
helper.AddData(&data2);
@@ -2445,22 +2350,20 @@ TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) {
TEST_P(SpdyNetworkTransactionTest, DeleteSessionOnReadCallback) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req)};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp.get(), 2),
- MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause
- CreateMockRead(*body.get(), 4),
- MockRead(ASYNC, 0, 0, 5), // EOF
+ CreateMockRead(*resp.get(), 2),
+ MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause
+ CreateMockRead(*body.get(), 4), MockRead(ASYNC, 0, 0, 5), // EOF
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
HttpNetworkTransaction* trans = helper.trans();
@@ -2475,11 +2378,11 @@ TEST_P(SpdyNetworkTransactionTest, DeleteSessionOnReadCallback) {
// memory holding the stream object. Note that the callback deletes trans.
const int kSize = 3000;
scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize));
- rv = trans->Read(
- buf.get(),
- kSize,
- base::Bind(&SpdyNetworkTransactionTest::DeleteSessionCallback,
- base::Unretained(&helper)));
+ rv =
+ trans->Read(buf.get(),
+ kSize,
+ base::Bind(&SpdyNetworkTransactionTest::DeleteSessionCallback,
+ base::Unretained(&helper)));
ASSERT_EQ(ERR_IO_PENDING, rv);
data.CompleteRead();
@@ -2501,34 +2404,31 @@ TEST_P(SpdyNetworkTransactionTest, RedirectGetRequest) {
(*headers2)["accept-encoding"] = "gzip,deflate";
// Setup writes/reads to www.google.com
- scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyFrame(
- kSynStartHeader, headers.Pass()));
- scoped_ptr<SpdyFrame> req2(spdy_util_.ConstructSpdyFrame(
- kSynStartHeader, headers2.Pass()));
+ scoped_ptr<SpdyFrame> req(
+ spdy_util_.ConstructSpdyFrame(kSynStartHeader, headers.Pass()));
+ scoped_ptr<SpdyFrame> req2(
+ spdy_util_.ConstructSpdyFrame(kSynStartHeader, headers2.Pass()));
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReplyRedirect(1));
MockWrite writes[] = {
- CreateMockWrite(*req, 1),
+ CreateMockWrite(*req, 1),
};
MockRead reads[] = {
- CreateMockRead(*resp, 2),
- MockRead(ASYNC, 0, 0, 3) // EOF
+ CreateMockRead(*resp, 2), MockRead(ASYNC, 0, 0, 3) // EOF
};
// Setup writes/reads to www.foo.com
scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes2[] = {
- CreateMockWrite(*req2, 1),
+ CreateMockWrite(*req2, 1),
};
MockRead reads2[] = {
- CreateMockRead(*resp2, 2),
- CreateMockRead(*body2, 3),
- MockRead(ASYNC, 0, 0, 4) // EOF
+ CreateMockRead(*resp2, 2), CreateMockRead(*body2, 3),
+ MockRead(ASYNC, 0, 0, 4) // EOF
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- OrderedSocketData data2(reads2, arraysize(reads2),
- writes2, arraysize(writes2));
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ OrderedSocketData data2(
+ reads2, arraysize(reads2), writes2, arraysize(writes2));
// TODO(erikchen): Make test support SPDYSSL, SPDYNPN
HttpStreamFactory::set_force_spdy_over_ssl(false);
@@ -2540,10 +2440,8 @@ TEST_P(SpdyNetworkTransactionTest, RedirectGetRequest) {
DEFAULT_PRIORITY,
&d,
&spdy_url_request_context);
- spdy_url_request_context.socket_factory().
- AddSocketDataProvider(&data);
- spdy_url_request_context.socket_factory().
- AddSocketDataProvider(&data2);
+ spdy_url_request_context.socket_factory().AddSocketDataProvider(&data);
+ spdy_url_request_context.socket_factory().AddSocketDataProvider(&data2);
d.set_quit_on_redirect(true);
r.Start();
@@ -2581,25 +2479,23 @@ TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) {
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
scoped_ptr<SpdyFrame> rep(
spdy_util_.ConstructSpdyPush(NULL,
- 0,
- 2,
- 1,
- "http://www.google.com/foo.dat",
- "301 Moved Permanently",
- "http://www.foo.com/index.php"));
+ 0,
+ 2,
+ 1,
+ "http://www.google.com/foo.dat",
+ "301 Moved Permanently",
+ "http://www.foo.com/index.php"));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_CANCEL));
MockWrite writes[] = {
- CreateMockWrite(*req, 1),
- CreateMockWrite(*rst, 6),
+ CreateMockWrite(*req, 1), CreateMockWrite(*rst, 6),
};
MockRead reads[] = {
- CreateMockRead(*resp, 2),
- CreateMockRead(*rep, 3),
- CreateMockRead(*body, 4),
- MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause
- MockRead(ASYNC, 0, 0, 7) // EOF
+ CreateMockRead(*resp, 2), CreateMockRead(*rep, 3),
+ CreateMockRead(*body, 4),
+ MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause
+ MockRead(ASYNC, 0, 0, 7) // EOF
};
// Setup writes/reads to www.foo.com
@@ -2612,17 +2508,15 @@ TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) {
scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes2[] = {
- CreateMockWrite(*req2, 1),
+ CreateMockWrite(*req2, 1),
};
MockRead reads2[] = {
- CreateMockRead(*resp2, 2),
- CreateMockRead(*body2, 3),
- MockRead(ASYNC, 0, 0, 5) // EOF
+ CreateMockRead(*resp2, 2), CreateMockRead(*body2, 3),
+ MockRead(ASYNC, 0, 0, 5) // EOF
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- OrderedSocketData data2(reads2, arraysize(reads2),
- writes2, arraysize(writes2));
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ OrderedSocketData data2(
+ reads2, arraysize(reads2), writes2, arraysize(writes2));
// TODO(erikchen): Make test support SPDYSSL, SPDYNPN
HttpStreamFactory::set_force_spdy_over_ssl(false);
@@ -2635,8 +2529,7 @@ TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) {
DEFAULT_PRIORITY,
&d,
&spdy_url_request_context);
- spdy_url_request_context.socket_factory().
- AddSocketDataProvider(&data);
+ spdy_url_request_context.socket_factory().AddSocketDataProvider(&data);
r.Start();
base::RunLoop().Run();
@@ -2649,8 +2542,7 @@ TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) {
DEFAULT_PRIORITY,
&d2,
&spdy_url_request_context);
- spdy_url_request_context.socket_factory().
- AddSocketDataProvider(&data2);
+ spdy_url_request_context.socket_factory().AddSocketDataProvider(&data2);
d2.set_quit_on_redirect(true);
r2.Start();
@@ -2679,38 +2571,29 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame) {
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
+ CreateMockWrite(*stream1_syn, 1),
};
- scoped_ptr<SpdyFrame>
- stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- scoped_ptr<SpdyFrame>
- stream2_syn(spdy_util_.ConstructSpdyPush(NULL,
- 0,
- 2,
- 1,
- "http://www.google.com/foo.dat"));
+ scoped_ptr<SpdyFrame> stream1_reply(
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> stream2_syn(spdy_util_.ConstructSpdyPush(
+ NULL, 0, 2, 1, "http://www.google.com/foo.dat"));
const char kPushedData[] = "pushed";
- scoped_ptr<SpdyFrame> stream2_body(
- spdy_util_.ConstructSpdyBodyFrame(
- 2, kPushedData, strlen(kPushedData), true));
+ scoped_ptr<SpdyFrame> stream2_body(spdy_util_.ConstructSpdyBodyFrame(
+ 2, kPushedData, strlen(kPushedData), true));
MockRead reads[] = {
- CreateMockRead(*stream1_reply, 2),
- CreateMockRead(*stream2_syn, 3),
- CreateMockRead(*stream1_body, 4, SYNCHRONOUS),
- CreateMockRead(*stream2_body, 5),
- MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause
+ CreateMockRead(*stream1_reply, 2),
+ CreateMockRead(*stream2_syn, 3),
+ CreateMockRead(*stream1_body, 4, SYNCHRONOUS),
+ CreateMockRead(*stream2_body, 5),
+ MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause
};
HttpResponseInfo response;
HttpResponseInfo response2;
std::string expected_push_result("pushed");
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- RunServerPushTest(&data,
- &response,
- &response2,
- expected_push_result);
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ RunServerPushTest(&data, &response, &response2, expected_push_result);
// Verify the SYN_REPLY.
EXPECT_TRUE(response.headers.get() != NULL);
@@ -2727,38 +2610,29 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushBeforeSynReply) {
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
+ CreateMockWrite(*stream1_syn, 1),
};
- scoped_ptr<SpdyFrame>
- stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- scoped_ptr<SpdyFrame>
- stream2_syn(spdy_util_.ConstructSpdyPush(NULL,
- 0,
- 2,
- 1,
- "http://www.google.com/foo.dat"));
+ scoped_ptr<SpdyFrame> stream1_reply(
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> stream2_syn(spdy_util_.ConstructSpdyPush(
+ NULL, 0, 2, 1, "http://www.google.com/foo.dat"));
const char kPushedData[] = "pushed";
- scoped_ptr<SpdyFrame> stream2_body(
- spdy_util_.ConstructSpdyBodyFrame(
- 2, kPushedData, strlen(kPushedData), true));
+ scoped_ptr<SpdyFrame> stream2_body(spdy_util_.ConstructSpdyBodyFrame(
+ 2, kPushedData, strlen(kPushedData), true));
MockRead reads[] = {
- CreateMockRead(*stream2_syn, 2),
- CreateMockRead(*stream1_reply, 3),
- CreateMockRead(*stream1_body, 4, SYNCHRONOUS),
- CreateMockRead(*stream2_body, 5),
- MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause
+ CreateMockRead(*stream2_syn, 2),
+ CreateMockRead(*stream1_reply, 3),
+ CreateMockRead(*stream1_body, 4, SYNCHRONOUS),
+ CreateMockRead(*stream2_body, 5),
+ MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause
};
HttpResponseInfo response;
HttpResponseInfo response2;
std::string expected_push_result("pushed");
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- RunServerPushTest(&data,
- &response,
- &response2,
- expected_push_result);
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ RunServerPushTest(&data, &response, &response2, expected_push_result);
// Verify the SYN_REPLY.
EXPECT_TRUE(response.headers.get() != NULL);
@@ -2772,39 +2646,32 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushBeforeSynReply) {
TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame2) {
scoped_ptr<SpdyFrame> stream1_syn(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*stream1_syn, 1), };
+ MockWrite writes[] = {
+ CreateMockWrite(*stream1_syn, 1),
+ };
- scoped_ptr<SpdyFrame>
- stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- scoped_ptr<SpdyFrame>
- stream2_syn(spdy_util_.ConstructSpdyPush(NULL,
- 0,
- 2,
- 1,
- "http://www.google.com/foo.dat"));
+ scoped_ptr<SpdyFrame> stream1_reply(
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> stream2_syn(spdy_util_.ConstructSpdyPush(
+ NULL, 0, 2, 1, "http://www.google.com/foo.dat"));
const char kPushedData[] = "pushed";
- scoped_ptr<SpdyFrame> stream2_body(
- spdy_util_.ConstructSpdyBodyFrame(
- 2, kPushedData, strlen(kPushedData), true));
- scoped_ptr<SpdyFrame>
- stream1_body(spdy_util_.ConstructSpdyBodyFrame(1, true));
+ scoped_ptr<SpdyFrame> stream2_body(spdy_util_.ConstructSpdyBodyFrame(
+ 2, kPushedData, strlen(kPushedData), true));
+ scoped_ptr<SpdyFrame> stream1_body(
+ spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*stream1_reply, 2),
- CreateMockRead(*stream2_syn, 3),
- CreateMockRead(*stream2_body, 4),
- CreateMockRead(*stream1_body, 5, SYNCHRONOUS),
- MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause
+ CreateMockRead(*stream1_reply, 2),
+ CreateMockRead(*stream2_syn, 3),
+ CreateMockRead(*stream2_body, 4),
+ CreateMockRead(*stream1_body, 5, SYNCHRONOUS),
+ MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause
};
HttpResponseInfo response;
HttpResponseInfo response2;
std::string expected_push_result("pushed");
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- RunServerPushTest(&data,
- &response,
- &response2,
- expected_push_result);
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ RunServerPushTest(&data, &response, &response2, expected_push_result);
// Verify the SYN_REPLY.
EXPECT_TRUE(response.headers.get() != NULL);
@@ -2821,31 +2688,26 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushServerAborted) {
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
+ CreateMockWrite(*stream1_syn, 1),
};
- scoped_ptr<SpdyFrame>
- stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- scoped_ptr<SpdyFrame>
- stream2_syn(spdy_util_.ConstructSpdyPush(NULL,
- 0,
- 2,
- 1,
- "http://www.google.com/foo.dat"));
+ scoped_ptr<SpdyFrame> stream1_reply(
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> stream2_syn(spdy_util_.ConstructSpdyPush(
+ NULL, 0, 2, 1, "http://www.google.com/foo.dat"));
scoped_ptr<SpdyFrame> stream2_rst(
spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR));
MockRead reads[] = {
- CreateMockRead(*stream1_reply, 2),
- CreateMockRead(*stream2_syn, 3),
- CreateMockRead(*stream2_rst, 4),
- CreateMockRead(*stream1_body, 5, SYNCHRONOUS),
- MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause
+ CreateMockRead(*stream1_reply, 2),
+ CreateMockRead(*stream2_syn, 3),
+ CreateMockRead(*stream2_rst, 4),
+ CreateMockRead(*stream1_body, 5, SYNCHRONOUS),
+ MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
@@ -2854,21 +2716,17 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushServerAborted) {
// Start the transaction with basic parameters.
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
EXPECT_EQ(OK, rv);
// Verify that we consumed all test data.
- EXPECT_TRUE(data.at_read_eof()) << "Read count: "
- << data.read_count()
- << " Read index: "
- << data.read_index();
- EXPECT_TRUE(data.at_write_eof()) << "Write count: "
- << data.write_count()
- << " Write index: "
- << data.write_index();
+ EXPECT_TRUE(data.at_read_eof()) << "Read count: " << data.read_count()
+ << " Read index: " << data.read_index();
+ EXPECT_TRUE(data.at_write_eof()) << "Write count: " << data.write_count()
+ << " Write index: " << data.write_index();
// Verify the SYN_REPLY.
HttpResponseInfo response = *trans->GetResponseInfo();
@@ -2886,46 +2744,32 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushDuplicate) {
scoped_ptr<SpdyFrame> stream3_rst(
spdy_util_.ConstructSpdyRstStream(4, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
- CreateMockWrite(*stream3_rst, 5),
+ CreateMockWrite(*stream1_syn, 1), CreateMockWrite(*stream3_rst, 5),
};
- scoped_ptr<SpdyFrame>
- stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- scoped_ptr<SpdyFrame>
- stream2_syn(spdy_util_.ConstructSpdyPush(NULL,
- 0,
- 2,
- 1,
- "http://www.google.com/foo.dat"));
+ scoped_ptr<SpdyFrame> stream1_reply(
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> stream2_syn(spdy_util_.ConstructSpdyPush(
+ NULL, 0, 2, 1, "http://www.google.com/foo.dat"));
const char kPushedData[] = "pushed";
- scoped_ptr<SpdyFrame> stream2_body(
- spdy_util_.ConstructSpdyBodyFrame(
- 2, kPushedData, strlen(kPushedData), true));
- scoped_ptr<SpdyFrame>
- stream3_syn(spdy_util_.ConstructSpdyPush(NULL,
- 0,
- 4,
- 1,
- "http://www.google.com/foo.dat"));
+ scoped_ptr<SpdyFrame> stream2_body(spdy_util_.ConstructSpdyBodyFrame(
+ 2, kPushedData, strlen(kPushedData), true));
+ scoped_ptr<SpdyFrame> stream3_syn(spdy_util_.ConstructSpdyPush(
+ NULL, 0, 4, 1, "http://www.google.com/foo.dat"));
MockRead reads[] = {
- CreateMockRead(*stream1_reply, 2),
- CreateMockRead(*stream2_syn, 3),
- CreateMockRead(*stream3_syn, 4),
- CreateMockRead(*stream1_body, 6, SYNCHRONOUS),
- CreateMockRead(*stream2_body, 7),
- MockRead(ASYNC, ERR_IO_PENDING, 8), // Force a pause
+ CreateMockRead(*stream1_reply, 2),
+ CreateMockRead(*stream2_syn, 3),
+ CreateMockRead(*stream3_syn, 4),
+ CreateMockRead(*stream1_body, 6, SYNCHRONOUS),
+ CreateMockRead(*stream2_body, 7),
+ MockRead(ASYNC, ERR_IO_PENDING, 8), // Force a pause
};
HttpResponseInfo response;
HttpResponseInfo response2;
std::string expected_push_result("pushed");
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- RunServerPushTest(&data,
- &response,
- &response2,
- expected_push_result);
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ RunServerPushTest(&data, &response, &response2, expected_push_result);
// Verify the SYN_REPLY.
EXPECT_TRUE(response.headers.get() != NULL);
@@ -2942,48 +2786,42 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrame) {
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
+ CreateMockWrite(*stream1_syn, 1),
};
- scoped_ptr<SpdyFrame>
- stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- scoped_ptr<SpdyFrame>
- stream2_syn(spdy_util_.ConstructSpdyPush(NULL,
- 0,
- 2,
- 1,
- "http://www.google.com/foo.dat"));
+ scoped_ptr<SpdyFrame> stream1_reply(
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> stream2_syn(spdy_util_.ConstructSpdyPush(
+ NULL, 0, 2, 1, "http://www.google.com/foo.dat"));
static const char kPushedData[] = "pushed my darling hello my baby";
- scoped_ptr<SpdyFrame> stream2_body_base(
- spdy_util_.ConstructSpdyBodyFrame(
- 2, kPushedData, strlen(kPushedData), true));
+ scoped_ptr<SpdyFrame> stream2_body_base(spdy_util_.ConstructSpdyBodyFrame(
+ 2, kPushedData, strlen(kPushedData), true));
const size_t kChunkSize = strlen(kPushedData) / 4;
scoped_ptr<SpdyFrame> stream2_body1(
new SpdyFrame(stream2_body_base->data(), kChunkSize, false));
scoped_ptr<SpdyFrame> stream2_body2(
new SpdyFrame(stream2_body_base->data() + kChunkSize, kChunkSize, false));
- scoped_ptr<SpdyFrame> stream2_body3(
- new SpdyFrame(stream2_body_base->data() + 2 * kChunkSize,
- kChunkSize, false));
+ scoped_ptr<SpdyFrame> stream2_body3(new SpdyFrame(
+ stream2_body_base->data() + 2 * kChunkSize, kChunkSize, false));
scoped_ptr<SpdyFrame> stream2_body4(
new SpdyFrame(stream2_body_base->data() + 3 * kChunkSize,
- stream2_body_base->size() - 3 * kChunkSize, false));
+ stream2_body_base->size() - 3 * kChunkSize,
+ false));
MockRead reads[] = {
- CreateMockRead(*stream1_reply, 2),
- CreateMockRead(*stream2_syn, 3),
- CreateMockRead(*stream2_body1, 4),
- CreateMockRead(*stream2_body2, 5),
- CreateMockRead(*stream2_body3, 6),
- CreateMockRead(*stream2_body4, 7),
- CreateMockRead(*stream1_body, 8, SYNCHRONOUS),
- MockRead(ASYNC, ERR_IO_PENDING, 9), // Force a pause
+ CreateMockRead(*stream1_reply, 2),
+ CreateMockRead(*stream2_syn, 3),
+ CreateMockRead(*stream2_body1, 4),
+ CreateMockRead(*stream2_body2, 5),
+ CreateMockRead(*stream2_body3, 6),
+ CreateMockRead(*stream2_body4, 7),
+ CreateMockRead(*stream1_body, 8, SYNCHRONOUS),
+ MockRead(ASYNC, ERR_IO_PENDING, 9), // Force a pause
};
HttpResponseInfo response;
HttpResponseInfo response2;
std::string expected_push_result("pushed my darling hello my baby");
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
RunServerPushTest(&data, &response, &response2, kPushedData);
// Verify the SYN_REPLY.
@@ -3001,48 +2839,39 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrameInterrupted) {
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
+ CreateMockWrite(*stream1_syn, 1),
};
- scoped_ptr<SpdyFrame>
- stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- scoped_ptr<SpdyFrame>
- stream2_syn(spdy_util_.ConstructSpdyPush(NULL,
- 0,
- 2,
- 1,
- "http://www.google.com/foo.dat"));
+ scoped_ptr<SpdyFrame> stream1_reply(
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> stream2_syn(spdy_util_.ConstructSpdyPush(
+ NULL, 0, 2, 1, "http://www.google.com/foo.dat"));
static const char kPushedData[] = "pushed my darling hello my baby";
- scoped_ptr<SpdyFrame> stream2_body_base(
- spdy_util_.ConstructSpdyBodyFrame(
- 2, kPushedData, strlen(kPushedData), true));
+ scoped_ptr<SpdyFrame> stream2_body_base(spdy_util_.ConstructSpdyBodyFrame(
+ 2, kPushedData, strlen(kPushedData), true));
const size_t kChunkSize = strlen(kPushedData) / 4;
scoped_ptr<SpdyFrame> stream2_body1(
new SpdyFrame(stream2_body_base->data(), kChunkSize, false));
scoped_ptr<SpdyFrame> stream2_body2(
new SpdyFrame(stream2_body_base->data() + kChunkSize, kChunkSize, false));
- scoped_ptr<SpdyFrame> stream2_body3(
- new SpdyFrame(stream2_body_base->data() + 2 * kChunkSize,
- kChunkSize, false));
+ scoped_ptr<SpdyFrame> stream2_body3(new SpdyFrame(
+ stream2_body_base->data() + 2 * kChunkSize, kChunkSize, false));
scoped_ptr<SpdyFrame> stream2_body4(
new SpdyFrame(stream2_body_base->data() + 3 * kChunkSize,
- stream2_body_base->size() - 3 * kChunkSize, false));
+ stream2_body_base->size() - 3 * kChunkSize,
+ false));
MockRead reads[] = {
- CreateMockRead(*stream1_reply, 2),
- CreateMockRead(*stream2_syn, 3),
- CreateMockRead(*stream2_body1, 4),
- CreateMockRead(*stream2_body2, 5),
- MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause
- CreateMockRead(*stream2_body3, 7),
- CreateMockRead(*stream2_body4, 8),
- CreateMockRead(*stream1_body.get(), 9, SYNCHRONOUS),
- MockRead(ASYNC, ERR_IO_PENDING, 10) // Force a pause.
+ CreateMockRead(*stream1_reply, 2), CreateMockRead(*stream2_syn, 3),
+ CreateMockRead(*stream2_body1, 4), CreateMockRead(*stream2_body2, 5),
+ MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause
+ CreateMockRead(*stream2_body3, 7), CreateMockRead(*stream2_body4, 8),
+ CreateMockRead(*stream1_body.get(), 9, SYNCHRONOUS),
+ MockRead(ASYNC, ERR_IO_PENDING, 10) // Force a pause.
};
HttpResponseInfo response;
HttpResponseInfo response2;
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
RunServerPushTest(&data, &response, &response2, kPushedData);
// Verify the SYN_REPLY.
@@ -3067,29 +2896,22 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID0) {
scoped_ptr<SpdyFrame> stream2_rst(
spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
- CreateMockWrite(*stream2_rst, 4),
+ CreateMockWrite(*stream1_syn, 1), CreateMockWrite(*stream2_rst, 4),
};
- scoped_ptr<SpdyFrame>
- stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- scoped_ptr<SpdyFrame>
- stream2_syn(spdy_util_.ConstructSpdyPush(NULL,
- 0,
- 2,
- 0,
- "http://www.google.com/foo.dat"));
+ scoped_ptr<SpdyFrame> stream1_reply(
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> stream2_syn(spdy_util_.ConstructSpdyPush(
+ NULL, 0, 2, 0, "http://www.google.com/foo.dat"));
MockRead reads[] = {
- CreateMockRead(*stream1_reply, 2),
- CreateMockRead(*stream2_syn, 3),
- CreateMockRead(*stream1_body, 4),
- MockRead(ASYNC, ERR_IO_PENDING, 5) // Force a pause
+ CreateMockRead(*stream1_reply, 2), CreateMockRead(*stream2_syn, 3),
+ CreateMockRead(*stream1_body, 4),
+ MockRead(ASYNC, ERR_IO_PENDING, 5) // Force a pause
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
@@ -3098,21 +2920,17 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID0) {
// Start the transaction with basic parameters.
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
EXPECT_EQ(OK, rv);
// Verify that we consumed all test data.
- EXPECT_TRUE(data.at_read_eof()) << "Read count: "
- << data.read_count()
- << " Read index: "
- << data.read_index();
- EXPECT_TRUE(data.at_write_eof()) << "Write count: "
- << data.write_count()
- << " Write index: "
- << data.write_index();
+ EXPECT_TRUE(data.at_read_eof()) << "Read count: " << data.read_count()
+ << " Read index: " << data.read_index();
+ EXPECT_TRUE(data.at_write_eof()) << "Write count: " << data.write_count()
+ << " Write index: " << data.write_index();
// Verify the SYN_REPLY.
HttpResponseInfo response = *trans->GetResponseInfo();
@@ -3133,29 +2951,22 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) {
scoped_ptr<SpdyFrame> stream2_rst(
spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_INVALID_STREAM));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
- CreateMockWrite(*stream2_rst, 4),
+ CreateMockWrite(*stream1_syn, 1), CreateMockWrite(*stream2_rst, 4),
};
- scoped_ptr<SpdyFrame>
- stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- scoped_ptr<SpdyFrame>
- stream2_syn(spdy_util_.ConstructSpdyPush(NULL,
- 0,
- 2,
- 9,
- "http://www.google.com/foo.dat"));
+ scoped_ptr<SpdyFrame> stream1_reply(
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> stream2_syn(spdy_util_.ConstructSpdyPush(
+ NULL, 0, 2, 9, "http://www.google.com/foo.dat"));
MockRead reads[] = {
- CreateMockRead(*stream1_reply, 2),
- CreateMockRead(*stream2_syn, 3),
- CreateMockRead(*stream1_body, 4),
- MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause
+ CreateMockRead(*stream1_reply, 2), CreateMockRead(*stream2_syn, 3),
+ CreateMockRead(*stream1_body, 4),
+ MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
@@ -3164,21 +2975,17 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) {
// Start the transaction with basic parameters.
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
EXPECT_EQ(OK, rv);
// Verify that we consumed all test data.
- EXPECT_TRUE(data.at_read_eof()) << "Read count: "
- << data.read_count()
- << " Read index: "
- << data.read_index();
- EXPECT_TRUE(data.at_write_eof()) << "Write count: "
- << data.write_count()
- << " Write index: "
- << data.write_index();
+ EXPECT_TRUE(data.at_read_eof()) << "Read count: " << data.read_count()
+ << " Read index: " << data.read_index();
+ EXPECT_TRUE(data.at_write_eof()) << "Write count: " << data.write_count()
+ << " Write index: " << data.write_index();
// Verify the SYN_REPLY.
HttpResponseInfo response = *trans->GetResponseInfo();
@@ -3194,12 +3001,11 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) {
scoped_ptr<SpdyFrame> stream2_rst(
spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
- CreateMockWrite(*stream2_rst, 4),
+ CreateMockWrite(*stream1_syn, 1), CreateMockWrite(*stream2_rst, 4),
};
- scoped_ptr<SpdyFrame>
- stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> stream1_reply(
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
scoped_ptr<SpdyHeaderBlock> incomplete_headers(new SpdyHeaderBlock());
(*incomplete_headers)["hello"] = "bye";
(*incomplete_headers)[spdy_util_.GetStatusKey()] = "200 OK";
@@ -3214,16 +3020,14 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) {
// Associated stream ID
1));
MockRead reads[] = {
- CreateMockRead(*stream1_reply, 2),
- CreateMockRead(*stream2_syn, 3),
- CreateMockRead(*stream1_body, 4),
- MockRead(ASYNC, ERR_IO_PENDING, 5) // Force a pause
+ CreateMockRead(*stream1_reply, 2), CreateMockRead(*stream2_syn, 3),
+ CreateMockRead(*stream1_body, 4),
+ MockRead(ASYNC, ERR_IO_PENDING, 5) // Force a pause
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
@@ -3232,20 +3036,16 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) {
// Start the transaction with basic parameters.
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
EXPECT_EQ(OK, rv);
// Verify that we consumed all test data.
- EXPECT_TRUE(data.at_read_eof()) << "Read count: "
- << data.read_count()
- << " Read index: "
- << data.read_index();
- EXPECT_TRUE(data.at_write_eof()) << "Write count: "
- << data.write_count()
- << " Write index: "
- << data.write_index();
+ EXPECT_TRUE(data.at_read_eof()) << "Read count: " << data.read_count()
+ << " Read index: " << data.read_index();
+ EXPECT_TRUE(data.at_write_eof()) << "Write count: " << data.write_count()
+ << " Write index: " << data.write_index();
// Verify the SYN_REPLY.
HttpResponseInfo response = *trans->GetResponseInfo();
@@ -3260,25 +3060,21 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) {
int num_headers;
const char* extra_headers[5];
SpdyHeaderBlock expected_headers;
- } test_cases[] = {
- // This uses a multi-valued cookie header.
- { 2,
- { "cookie", "val1",
- "cookie", "val2", // will get appended separated by NULL
- NULL
- },
- },
- // This is the minimalist set of headers.
- { 0,
- { NULL },
- },
- // Headers with a comma separated list.
- { 1,
- { "cookie", "val1,val2",
- NULL
- },
- }
- };
+ } test_cases[] = {// This uses a multi-valued cookie header.
+ {
+ 2,
+ {"cookie", "val1", "cookie",
+ "val2", // will get appended separated by NULL
+ NULL},
+ },
+ // This is the minimalist set of headers.
+ {
+ 0, {NULL},
+ },
+ // Headers with a comma separated list.
+ {
+ 1, {"cookie", "val1,val2", NULL},
+ }};
test_cases[0].expected_headers["cookie"] = "val1";
test_cases[0].expected_headers["cookie"] += '\0';
@@ -3303,23 +3099,20 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req)};
- scoped_ptr<SpdyFrame> resp(
- spdy_util_.ConstructSpdyGetSynReply(test_cases[i].extra_headers,
- test_cases[i].num_headers,
- 1));
+ scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(
+ test_cases[i].extra_headers, test_cases[i].num_headers, 1));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(
+ 1, reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
@@ -3348,18 +3141,17 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) {
// through the HTTP layer, and the response matches the request.
TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) {
static const SpdyHeaderInfo syn_reply_info = {
- SYN_REPLY, // Syn Reply
- 1, // Stream ID
- 0, // Associated Stream ID
- ConvertRequestPriorityToSpdyPriority(
- LOWEST, spdy_util_.spdy_version()),
- kSpdyCredentialSlotUnused,
- CONTROL_FLAG_NONE, // Control Flags
- false, // Compressed
- RST_STREAM_INVALID, // Status
- NULL, // Data
- 0, // Data Length
- DATA_FLAG_NONE // Data Flags
+ SYN_REPLY, // Syn Reply
+ 1, // Stream ID
+ 0, // Associated Stream ID
+ ConvertRequestPriorityToSpdyPriority(LOWEST, spdy_util_.spdy_version()),
+ kSpdyCredentialSlotUnused,
+ CONTROL_FLAG_NONE, // Control Flags
+ false, // Compressed
+ RST_STREAM_INVALID, // Status
+ NULL, // Data
+ 0, // Data Length
+ DATA_FLAG_NONE // Data Flags
};
// Modify the following data to change/add test cases:
struct SynReplyTests {
@@ -3368,94 +3160,66 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) {
int num_headers[2];
const char* extra_headers[2][16];
} test_cases[] = {
- // Test the case of a multi-valued cookie. When the value is delimited
- // with NUL characters, it needs to be unfolded into multiple headers.
- {
- &syn_reply_info,
- true,
- { 1, 4 },
- { { "cookie", "val1,val2",
- NULL
- },
- { "vary", "cookie",
- spdy_util_.GetStatusKey(), "200",
- spdy_util_.GetPathKey(), "/index.php",
- spdy_util_.GetVersionKey(), "HTTP/1.1",
- NULL
- }
- }
- }, { // Multiple vary fields.
- &syn_reply_info,
- true,
- { 2, 5 },
- { { "friend", "barney",
- "enemy", "snaggletooth",
- NULL
- },
- { "vary", "friend",
- "vary", "enemy",
- spdy_util_.GetStatusKey(), "200",
- spdy_util_.GetPathKey(), "/index.php",
- spdy_util_.GetVersionKey(), "HTTP/1.1",
- NULL
- }
- }
- }, { // Test a '*' vary field.
- &syn_reply_info,
- false,
- { 1, 4 },
- { { "cookie", "val1,val2",
- NULL
- },
- { "vary", "*",
- spdy_util_.GetStatusKey(), "200",
- spdy_util_.GetPathKey(), "/index.php",
- spdy_util_.GetVersionKey(), "HTTP/1.1",
- NULL
- }
- }
- }, { // Multiple comma-separated vary fields.
- &syn_reply_info,
- true,
- { 2, 4 },
- { { "friend", "barney",
- "enemy", "snaggletooth",
- NULL
- },
- { "vary", "friend,enemy",
- spdy_util_.GetStatusKey(), "200",
- spdy_util_.GetPathKey(), "/index.php",
- spdy_util_.GetVersionKey(), "HTTP/1.1",
- NULL
- }
- }
- }
- };
+ // Test the case of a multi-valued cookie. When the value is delimited
+ // with NUL characters, it needs to be unfolded into multiple headers.
+ {&syn_reply_info,
+ true,
+ {1, 4},
+ {{"cookie", "val1,val2", NULL},
+ {"vary", "cookie", spdy_util_.GetStatusKey(), "200",
+ spdy_util_.GetPathKey(), "/index.php", spdy_util_.GetVersionKey(),
+ "HTTP/1.1", NULL}}},
+ {// Multiple vary fields.
+ &syn_reply_info,
+ true,
+ {2, 5},
+ {{"friend", "barney", "enemy", "snaggletooth", NULL},
+ {"vary", "friend", "vary", "enemy", spdy_util_.GetStatusKey(), "200",
+ spdy_util_.GetPathKey(), "/index.php", spdy_util_.GetVersionKey(),
+ "HTTP/1.1", NULL}}},
+ {// Test a '*' vary field.
+ &syn_reply_info,
+ false,
+ {1, 4},
+ {{"cookie", "val1,val2", NULL},
+ {"vary", "*", spdy_util_.GetStatusKey(), "200",
+ spdy_util_.GetPathKey(), "/index.php", spdy_util_.GetVersionKey(),
+ "HTTP/1.1", NULL}}},
+ {// Multiple comma-separated vary fields.
+ &syn_reply_info,
+ true,
+ {2, 4},
+ {{"friend", "barney", "enemy", "snaggletooth", NULL},
+ {"vary", "friend,enemy", spdy_util_.GetStatusKey(), "200",
+ spdy_util_.GetPathKey(), "/index.php", spdy_util_.GetVersionKey(),
+ "HTTP/1.1", NULL}}}};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
// Construct the request.
scoped_ptr<SpdyFrame> frame_req(
spdy_util_.ConstructSpdyGet(test_cases[i].extra_headers[0],
test_cases[i].num_headers[0],
- false, 1, LOWEST, true));
+ false,
+ 1,
+ LOWEST,
+ true));
MockWrite writes[] = {
- CreateMockWrite(*frame_req),
+ CreateMockWrite(*frame_req),
};
// Construct the reply.
scoped_ptr<SpdyFrame> frame_reply(
- spdy_util_.ConstructSpdyFrame(*test_cases[i].syn_reply,
- test_cases[i].extra_headers[1],
- test_cases[i].num_headers[1],
- NULL,
- 0));
+ spdy_util_.ConstructSpdyFrame(*test_cases[i].syn_reply,
+ test_cases[i].extra_headers[1],
+ test_cases[i].num_headers[1],
+ NULL,
+ 0));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*frame_reply),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*frame_reply), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
// Attach the headers to the request.
@@ -3468,10 +3232,10 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) {
request.extra_headers.SetHeader(header_key, header_value);
}
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(
+ 1, reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
@@ -3481,15 +3245,18 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) {
// Test the response information.
EXPECT_TRUE(out.response_info.response_time >
- out.response_info.request_time) << i;
- base::TimeDelta test_delay = out.response_info.response_time -
- out.response_info.request_time;
+ out.response_info.request_time)
+ << i;
+ base::TimeDelta test_delay =
+ out.response_info.response_time - out.response_info.request_time;
base::TimeDelta min_expected_delay;
min_expected_delay.FromMilliseconds(10);
EXPECT_GT(test_delay.InMillisecondsF(),
- min_expected_delay.InMillisecondsF()) << i;
+ min_expected_delay.InMillisecondsF())
+ << i;
EXPECT_EQ(out.response_info.vary_data.is_valid(),
- test_cases[i].vary_matches) << i;
+ test_cases[i].vary_matches)
+ << i;
// Check the headers.
scoped_refptr<HttpResponseHeaders> headers = out.response_info.headers;
@@ -3517,69 +3284,63 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) {
// Verify that we don't crash on invalid SynReply responses.
TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) {
const SpdyHeaderInfo kSynStartHeader = {
- SYN_REPLY, // Kind = SynReply
- 1, // Stream ID
- 0, // Associated stream ID
- ConvertRequestPriorityToSpdyPriority(
- LOWEST, spdy_util_.spdy_version()),
- kSpdyCredentialSlotUnused,
- CONTROL_FLAG_NONE, // Control Flags
- false, // Compressed
- RST_STREAM_INVALID, // Status
- NULL, // Data
- 0, // Length
- DATA_FLAG_NONE // Data Flags
+ SYN_REPLY, // Kind = SynReply
+ 1, // Stream ID
+ 0, // Associated stream ID
+ ConvertRequestPriorityToSpdyPriority(LOWEST, spdy_util_.spdy_version()),
+ kSpdyCredentialSlotUnused,
+ CONTROL_FLAG_NONE, // Control Flags
+ false, // Compressed
+ RST_STREAM_INVALID, // Status
+ NULL, // Data
+ 0, // Length
+ DATA_FLAG_NONE // Data Flags
};
struct InvalidSynReplyTests {
int num_headers;
const char* headers[10];
} test_cases[] = {
- // SYN_REPLY missing status header
- { 4,
- { "cookie", "val1",
- "cookie", "val2",
- spdy_util_.GetPathKey(), "/index.php",
- spdy_util_.GetVersionKey(), "HTTP/1.1",
- NULL
- },
- },
- // SYN_REPLY missing version header
- { 2,
- { "status", "200",
- spdy_util_.GetPathKey(), "/index.php",
- NULL
- },
- },
- // SYN_REPLY with no headers
- { 0, { NULL }, },
- };
+ // SYN_REPLY missing status header
+ {
+ 4,
+ {"cookie", "val1", "cookie", "val2", spdy_util_.GetPathKey(),
+ "/index.php", spdy_util_.GetVersionKey(), "HTTP/1.1", NULL},
+ },
+ // SYN_REPLY missing version header
+ {
+ 2, {"status", "200", spdy_util_.GetPathKey(), "/index.php", NULL},
+ },
+ // SYN_REPLY with no headers
+ {
+ 0, {NULL},
+ },
+ };
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
scoped_ptr<SpdyFrame> rst(
- spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
+ spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*rst),
+ CreateMockWrite(*req), CreateMockWrite(*rst),
};
scoped_ptr<SpdyFrame> resp(
- spdy_util_.ConstructSpdyFrame(kSynStartHeader,
- NULL, 0,
- test_cases[i].headers,
- test_cases[i].num_headers));
+ spdy_util_.ConstructSpdyFrame(kSynStartHeader,
+ NULL,
+ 0,
+ test_cases[i].headers,
+ test_cases[i].num_headers));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(
+ 1, reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
@@ -3598,19 +3359,20 @@ TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionError) {
spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
BufferedSpdyFramer framer(spdy_util_.spdy_version(), false);
size_t right_size =
- (spdy_util_.spdy_version() < SPDY4) ?
- syn_reply_wrong_length->size() - framer.GetControlFrameHeaderSize() :
- syn_reply_wrong_length->size();
+ (spdy_util_.spdy_version() < SPDY4)
+ ? syn_reply_wrong_length->size() - framer.GetControlFrameHeaderSize()
+ : syn_reply_wrong_length->size();
size_t wrong_size = right_size - 4;
- test::SetFrameLength(syn_reply_wrong_length.get(),
- wrong_size,
- spdy_util_.spdy_version());
+ test::SetFrameLength(
+ syn_reply_wrong_length.get(), wrong_size, spdy_util_.spdy_version());
struct SynReplyTests {
const SpdyFrame* syn_reply;
} test_cases[] = {
- { syn_reply_wrong_length.get(), },
- };
+ {
+ syn_reply_wrong_length.get(),
+ },
+ };
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
scoped_ptr<SpdyFrame> req(
@@ -3618,21 +3380,19 @@ TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionError) {
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*rst),
+ CreateMockWrite(*req), CreateMockWrite(*rst),
};
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- MockRead(ASYNC, test_cases[i].syn_reply->data(), wrong_size),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ MockRead(ASYNC, test_cases[i].syn_reply->data(), wrong_size),
+ CreateMockRead(*body), MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(
+ 1, reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
@@ -3651,28 +3411,27 @@ TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionErrorSpdy4) {
size_t right_size =
syn_reply_wrong_length->size() - framer.GetControlFrameHeaderSize();
size_t wrong_size = right_size - 4;
- test::SetFrameLength(syn_reply_wrong_length.get(),
- wrong_size,
- spdy_util_.spdy_version());
+ test::SetFrameLength(
+ syn_reply_wrong_length.get(), wrong_size, spdy_util_.spdy_version());
// TODO(jgraettinger): SpdySession::OnError() should send a GOAWAY before
// breaking the connection.
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
+ CreateMockWrite(*req),
};
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- MockRead(ASYNC, syn_reply_wrong_length->data(),
- syn_reply_wrong_length->size() - 4),
+ MockRead(ASYNC,
+ syn_reply_wrong_length->data(),
+ syn_reply_wrong_length->size() - 4),
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
@@ -3682,22 +3441,21 @@ TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionErrorSpdy4) {
TEST_P(SpdyNetworkTransactionTest, WriteError) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = {
- // We'll write 10 bytes successfully
- MockWrite(ASYNC, req->data(), 10, 0),
- // Followed by ERROR!
- MockWrite(ASYNC, ERR_FAILED, 1),
+ MockWrite writes[] = {// We'll write 10 bytes successfully
+ MockWrite(ASYNC, req->data(), 10, 0),
+ // Followed by ERROR!
+ MockWrite(ASYNC, ERR_FAILED, 1),
};
MockRead reads[] = {
- MockRead(ASYNC, 0, 2) // EOF
+ MockRead(ASYNC, 0, 2) // EOF
};
- DeterministicSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ DeterministicSocketData data(
+ reads, arraysize(reads), writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.SetDeterministic();
helper.RunPreTestSetup();
helper.AddDeterministicData(&data);
@@ -3721,15 +3479,14 @@ TEST_P(SpdyNetworkTransactionTest, PartialWrite) {
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(kChunks, reads, arraysize(reads),
- writes.get(), kChunks);
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(
+ kChunks, reads, arraysize(reads), writes.get(), kChunks);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(OK, out.rv);
@@ -3749,22 +3506,24 @@ TEST_P(SpdyNetworkTransactionTest, DecompressFailureOnSynReply) {
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*compressed),
+ CreateMockWrite(*compressed),
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
+ CreateMockRead(*resp),
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
SpdySessionDependencies* session_deps =
CreateSpdySessionDependencies(GetParam());
session_deps->enable_compression = true;
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), session_deps);
+ NormalSpdyTransactionHelper helper(CreateGetRequest(),
+ DEFAULT_PRIORITY,
+ BoundNetLog(),
+ GetParam(),
+ session_deps);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
@@ -3774,27 +3533,27 @@ TEST_P(SpdyNetworkTransactionTest, DecompressFailureOnSynReply) {
// Test that the NetLog contains good data for a simple GET request.
TEST_P(SpdyNetworkTransactionTest, NetLog) {
static const char* const kExtraHeaders[] = {
- "user-agent", "Chrome",
+ "user-agent", "Chrome",
};
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(kExtraHeaders, 1, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req)};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
CapturingBoundNetLog log;
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequestWithUserAgent(),
DEFAULT_PRIORITY,
- log.bound(), GetParam(), NULL);
+ log.bound(),
+ GetParam(),
+ NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(OK, out.rv);
@@ -3810,30 +3569,43 @@ TEST_P(SpdyNetworkTransactionTest, NetLog) {
EXPECT_LT(0u, entries.size());
int pos = 0;
- pos = net::ExpectLogContainsSomewhere(entries, 0,
+ pos = net::ExpectLogContainsSomewhere(
+ entries,
+ 0,
net::NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST,
net::NetLog::PHASE_BEGIN);
- pos = net::ExpectLogContainsSomewhere(entries, pos + 1,
+ pos = net::ExpectLogContainsSomewhere(
+ entries,
+ pos + 1,
net::NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST,
net::NetLog::PHASE_END);
- pos = net::ExpectLogContainsSomewhere(entries, pos + 1,
+ pos = net::ExpectLogContainsSomewhere(
+ entries,
+ pos + 1,
net::NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS,
net::NetLog::PHASE_BEGIN);
- pos = net::ExpectLogContainsSomewhere(entries, pos + 1,
+ pos = net::ExpectLogContainsSomewhere(
+ entries,
+ pos + 1,
net::NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS,
net::NetLog::PHASE_END);
- pos = net::ExpectLogContainsSomewhere(entries, pos + 1,
+ pos = net::ExpectLogContainsSomewhere(
+ entries,
+ pos + 1,
net::NetLog::TYPE_HTTP_TRANSACTION_READ_BODY,
net::NetLog::PHASE_BEGIN);
- pos = net::ExpectLogContainsSomewhere(entries, pos + 1,
+ pos = net::ExpectLogContainsSomewhere(
+ entries,
+ pos + 1,
net::NetLog::TYPE_HTTP_TRANSACTION_READ_BODY,
net::NetLog::PHASE_END);
// Check that we logged all the headers correctly
- pos = net::ExpectLogContainsSomewhere(
- entries, 0,
- net::NetLog::TYPE_SPDY_SESSION_SYN_STREAM,
- net::NetLog::PHASE_NONE);
+ pos =
+ net::ExpectLogContainsSomewhere(entries,
+ 0,
+ net::NetLog::TYPE_SPDY_SESSION_SYN_STREAM,
+ net::NetLog::PHASE_NONE);
base::ListValue* header_list;
ASSERT_TRUE(entries[pos].params.get());
@@ -3854,8 +3626,8 @@ TEST_P(SpdyNetworkTransactionTest, NetLog) {
it != expected.end();
++it) {
base::StringValue header(*it);
- EXPECT_NE(header_list->end(), header_list->Find(header)) <<
- "Header not found: " << *it;
+ EXPECT_NE(header_list->end(), header_list->Find(header))
+ << "Header not found: " << *it;
}
}
@@ -3868,7 +3640,7 @@ TEST_P(SpdyNetworkTransactionTest, BufferFull) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req)};
// 2 data frames in a single read.
scoped_ptr<SpdyFrame> data_frame_1(
@@ -3876,38 +3648,35 @@ TEST_P(SpdyNetworkTransactionTest, BufferFull) {
scoped_ptr<SpdyFrame> data_frame_2(
framer.CreateDataFrame(1, "e worl", 6, DATA_FLAG_NONE));
const SpdyFrame* data_frames[2] = {
- data_frame_1.get(),
- data_frame_2.get(),
+ data_frame_1.get(), data_frame_2.get(),
};
char combined_data_frames[100];
- int combined_data_frames_len =
- CombineFrames(data_frames, arraysize(data_frames),
- combined_data_frames, arraysize(combined_data_frames));
+ int combined_data_frames_len = CombineFrames(data_frames,
+ arraysize(data_frames),
+ combined_data_frames,
+ arraysize(combined_data_frames));
scoped_ptr<SpdyFrame> last_frame(
framer.CreateDataFrame(1, "d", 1, DATA_FLAG_FIN));
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
MockRead reads[] = {
- CreateMockRead(*resp),
- MockRead(ASYNC, ERR_IO_PENDING), // Force a pause
- MockRead(ASYNC, combined_data_frames, combined_data_frames_len),
- MockRead(ASYNC, ERR_IO_PENDING), // Force a pause
- CreateMockRead(*last_frame),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), MockRead(ASYNC, ERR_IO_PENDING), // Force a pause
+ MockRead(ASYNC, combined_data_frames, combined_data_frames_len),
+ MockRead(ASYNC, ERR_IO_PENDING), // Force a pause
+ CreateMockRead(*last_frame), MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
TestCompletionCallback callback;
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
HttpNetworkTransaction* trans = helper.trans();
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
TransactionHelperResult out = helper.output();
@@ -3962,44 +3731,39 @@ TEST_P(SpdyNetworkTransactionTest, Buffering) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req)};
// 4 data frames in a single read.
scoped_ptr<SpdyFrame> data_frame(
framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE));
scoped_ptr<SpdyFrame> data_frame_fin(
framer.CreateDataFrame(1, "message", 7, DATA_FLAG_FIN));
- const SpdyFrame* data_frames[4] = {
- data_frame.get(),
- data_frame.get(),
- data_frame.get(),
- data_frame_fin.get()
- };
+ const SpdyFrame* data_frames[4] = {data_frame.get(), data_frame.get(),
+ data_frame.get(), data_frame_fin.get()};
char combined_data_frames[100];
- int combined_data_frames_len =
- CombineFrames(data_frames, arraysize(data_frames),
- combined_data_frames, arraysize(combined_data_frames));
+ int combined_data_frames_len = CombineFrames(data_frames,
+ arraysize(data_frames),
+ combined_data_frames,
+ arraysize(combined_data_frames));
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
MockRead reads[] = {
- CreateMockRead(*resp),
- MockRead(ASYNC, ERR_IO_PENDING), // Force a pause
- MockRead(ASYNC, combined_data_frames, combined_data_frames_len),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), MockRead(ASYNC, ERR_IO_PENDING), // Force a pause
+ MockRead(ASYNC, combined_data_frames, combined_data_frames_len),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
HttpNetworkTransaction* trans = helper.trans();
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
TransactionHelperResult out = helper.output();
@@ -4057,7 +3821,7 @@ TEST_P(SpdyNetworkTransactionTest, BufferedAll) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req)};
// 5 data frames in a single read.
SpdySynReplyIR reply_ir(1);
@@ -4069,35 +3833,29 @@ TEST_P(SpdyNetworkTransactionTest, BufferedAll) {
framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE));
scoped_ptr<SpdyFrame> data_frame_fin(
framer.CreateDataFrame(1, "message", 7, DATA_FLAG_FIN));
- const SpdyFrame* frames[5] = {
- syn_reply.get(),
- data_frame.get(),
- data_frame.get(),
- data_frame.get(),
- data_frame_fin.get()
- };
+ const SpdyFrame* frames[5] = {syn_reply.get(), data_frame.get(),
+ data_frame.get(), data_frame.get(),
+ data_frame_fin.get()};
char combined_frames[200];
- int combined_frames_len =
- CombineFrames(frames, arraysize(frames),
- combined_frames, arraysize(combined_frames));
+ int combined_frames_len = CombineFrames(
+ frames, arraysize(frames), combined_frames, arraysize(combined_frames));
MockRead reads[] = {
- MockRead(ASYNC, combined_frames, combined_frames_len),
- MockRead(ASYNC, 0, 0) // EOF
+ MockRead(ASYNC, combined_frames, combined_frames_len),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
HttpNetworkTransaction* trans = helper.trans();
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
TransactionHelperResult out = helper.output();
@@ -4151,43 +3909,38 @@ TEST_P(SpdyNetworkTransactionTest, BufferedClosed) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req)};
// All data frames in a single read.
// NOTE: We don't FIN the stream.
scoped_ptr<SpdyFrame> data_frame(
framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE));
- const SpdyFrame* data_frames[4] = {
- data_frame.get(),
- data_frame.get(),
- data_frame.get(),
- data_frame.get()
- };
+ const SpdyFrame* data_frames[4] = {data_frame.get(), data_frame.get(),
+ data_frame.get(), data_frame.get()};
char combined_data_frames[100];
- int combined_data_frames_len =
- CombineFrames(data_frames, arraysize(data_frames),
- combined_data_frames, arraysize(combined_data_frames));
+ int combined_data_frames_len = CombineFrames(data_frames,
+ arraysize(data_frames),
+ combined_data_frames,
+ arraysize(combined_data_frames));
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
MockRead reads[] = {
- CreateMockRead(*resp),
- MockRead(ASYNC, ERR_IO_PENDING), // Force a wait
- MockRead(ASYNC, combined_data_frames, combined_data_frames_len),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), MockRead(ASYNC, ERR_IO_PENDING), // Force a wait
+ MockRead(ASYNC, combined_data_frames, combined_data_frames_len),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
HttpNetworkTransaction* trans = helper.trans();
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
TransactionHelperResult out = helper.output();
@@ -4242,7 +3995,7 @@ TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req)};
// NOTE: We don't FIN the stream.
scoped_ptr<SpdyFrame> data_frame(
@@ -4250,24 +4003,21 @@ TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) {
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
MockRead reads[] = {
- CreateMockRead(*resp),
- MockRead(ASYNC, ERR_IO_PENDING), // Force a wait
- CreateMockRead(*data_frame),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), MockRead(ASYNC, ERR_IO_PENDING), // Force a wait
+ CreateMockRead(*data_frame), MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
HttpNetworkTransaction* trans = helper.trans();
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
TransactionHelperResult out = helper.output();
@@ -4311,42 +4061,42 @@ TEST_P(SpdyNetworkTransactionTest, SettingsSaved) {
return;
}
static const SpdyHeaderInfo kSynReplyInfo = {
- SYN_REPLY, // Syn Reply
- 1, // Stream ID
- 0, // Associated Stream ID
- ConvertRequestPriorityToSpdyPriority(
- LOWEST, spdy_util_.spdy_version()),
- kSpdyCredentialSlotUnused,
- CONTROL_FLAG_NONE, // Control Flags
- false, // Compressed
- RST_STREAM_INVALID, // Status
- NULL, // Data
- 0, // Data Length
- DATA_FLAG_NONE // Data Flags
+ SYN_REPLY, // Syn Reply
+ 1, // Stream ID
+ 0, // Associated Stream ID
+ ConvertRequestPriorityToSpdyPriority(LOWEST, spdy_util_.spdy_version()),
+ kSpdyCredentialSlotUnused,
+ CONTROL_FLAG_NONE, // Control Flags
+ false, // Compressed
+ RST_STREAM_INVALID, // Status
+ NULL, // Data
+ 0, // Data Length
+ DATA_FLAG_NONE // Data Flags
};
BoundNetLog net_log;
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- net_log, GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, net_log, GetParam(), NULL);
helper.RunPreTestSetup();
// Verify that no settings exist initially.
HostPortPair host_port_pair("www.google.com", helper.port());
SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool();
- EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings(
- host_port_pair).empty());
+ EXPECT_TRUE(spdy_session_pool->http_server_properties()
+ ->GetSpdySettings(host_port_pair)
+ .empty());
// Construct the request.
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req)};
// Construct the reply.
scoped_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock());
(*reply_headers)[spdy_util_.GetStatusKey()] = "200";
(*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1";
scoped_ptr<SpdyFrame> reply(
- spdy_util_.ConstructSpdyFrame(kSynReplyInfo, reply_headers.Pass()));
+ spdy_util_.ConstructSpdyFrame(kSynReplyInfo, reply_headers.Pass()));
const SpdySettingsIds kSampleId1 = SETTINGS_UPLOAD_BANDWIDTH;
unsigned int kSampleValue1 = 0x0a0a0a0a;
@@ -4372,14 +4122,11 @@ TEST_P(SpdyNetworkTransactionTest, SettingsSaved) {
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*reply),
- CreateMockRead(*body),
- CreateMockRead(*settings_frame),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*reply), CreateMockRead(*body),
+ CreateMockRead(*settings_frame), MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
helper.AddData(&data);
helper.RunDefaultTest();
helper.VerifyDataConsumed();
@@ -4416,23 +4163,22 @@ TEST_P(SpdyNetworkTransactionTest, SettingsSaved) {
TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) {
// TODO(jgraettinger): Remove settings persistence mechanisms altogether.
static const SpdyHeaderInfo kSynReplyInfo = {
- SYN_REPLY, // Syn Reply
- 1, // Stream ID
- 0, // Associated Stream ID
- ConvertRequestPriorityToSpdyPriority(
- LOWEST, spdy_util_.spdy_version()),
- kSpdyCredentialSlotUnused,
- CONTROL_FLAG_NONE, // Control Flags
- false, // Compressed
- RST_STREAM_INVALID, // Status
- NULL, // Data
- 0, // Data Length
- DATA_FLAG_NONE // Data Flags
+ SYN_REPLY, // Syn Reply
+ 1, // Stream ID
+ 0, // Associated Stream ID
+ ConvertRequestPriorityToSpdyPriority(LOWEST, spdy_util_.spdy_version()),
+ kSpdyCredentialSlotUnused,
+ CONTROL_FLAG_NONE, // Control Flags
+ false, // Compressed
+ RST_STREAM_INVALID, // Status
+ NULL, // Data
+ 0, // Data Length
+ DATA_FLAG_NONE // Data Flags
};
BoundNetLog net_log;
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- net_log, GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, net_log, GetParam(), NULL);
helper.RunPreTestSetup();
SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool();
@@ -4442,8 +4188,9 @@ TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) {
// Verify that no settings exist initially.
HostPortPair host_port_pair("www.google.com", helper.port());
- EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings(
- host_port_pair).empty());
+ EXPECT_TRUE(spdy_session_pool->http_server_properties()
+ ->GetSpdySettings(host_port_pair)
+ .empty());
const SpdySettingsIds kSampleId1 = SETTINGS_MAX_CONCURRENT_STREAMS;
unsigned int kSampleValue1 = 0x0a0a0a0a;
@@ -4452,20 +4199,16 @@ TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) {
// First add a persisted setting.
spdy_session_pool->http_server_properties()->SetSpdySetting(
- host_port_pair,
- kSampleId1,
- SETTINGS_FLAG_PLEASE_PERSIST,
- kSampleValue1);
+ host_port_pair, kSampleId1, SETTINGS_FLAG_PLEASE_PERSIST, kSampleValue1);
// Next add another persisted setting.
spdy_session_pool->http_server_properties()->SetSpdySetting(
- host_port_pair,
- kSampleId2,
- SETTINGS_FLAG_PLEASE_PERSIST,
- kSampleValue2);
+ host_port_pair, kSampleId2, SETTINGS_FLAG_PLEASE_PERSIST, kSampleValue2);
- EXPECT_EQ(2u, spdy_session_pool->http_server_properties()->GetSpdySettings(
- host_port_pair).size());
+ EXPECT_EQ(2u,
+ spdy_session_pool->http_server_properties()
+ ->GetSpdySettings(host_port_pair)
+ .size());
// Construct the initial SETTINGS frame.
SettingsMap initial_settings;
@@ -4493,10 +4236,8 @@ TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) {
std::vector<MockWrite> writes;
if (GetParam().protocol == kProtoSPDY4) {
- writes.push_back(
- MockWrite(ASYNC,
- kHttp2ConnectionHeaderPrefix,
- kHttp2ConnectionHeaderPrefixSize));
+ writes.push_back(MockWrite(
+ ASYNC, kHttp2ConnectionHeaderPrefix, kHttp2ConnectionHeaderPrefixSize));
}
writes.push_back(CreateMockWrite(*initial_settings_frame));
if (GetParam().protocol >= kProtoSPDY31) {
@@ -4510,17 +4251,16 @@ TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) {
(*reply_headers)[spdy_util_.GetStatusKey()] = "200";
(*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1";
scoped_ptr<SpdyFrame> reply(
- spdy_util_.ConstructSpdyFrame(kSynReplyInfo, reply_headers.Pass()));
+ spdy_util_.ConstructSpdyFrame(kSynReplyInfo, reply_headers.Pass()));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*reply),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*reply), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(2, reads, arraysize(reads),
- vector_as_array(&writes), writes.size());
+ DelayedSocketData data(
+ 2, reads, arraysize(reads), vector_as_array(&writes), writes.size());
helper.AddData(&data);
helper.RunDefaultTest();
helper.VerifyDataConsumed();
@@ -4555,17 +4295,16 @@ TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) {
TEST_P(SpdyNetworkTransactionTest, GoAwayWithActiveStream) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req)};
scoped_ptr<SpdyFrame> go_away(spdy_util_.ConstructSpdyGoAway());
MockRead reads[] = {
- CreateMockRead(*go_away),
+ CreateMockRead(*go_away),
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.AddData(&data);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
@@ -4575,19 +4314,17 @@ TEST_P(SpdyNetworkTransactionTest, GoAwayWithActiveStream) {
TEST_P(SpdyNetworkTransactionTest, CloseWithActiveStream) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req)};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
MockRead reads[] = {
- CreateMockRead(*resp),
- MockRead(SYNCHRONOUS, 0, 0) // EOF
+ CreateMockRead(*resp), MockRead(SYNCHRONOUS, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
BoundNetLog log;
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- log, GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, log, GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
HttpNetworkTransaction* trans = helper.trans();
@@ -4612,22 +4349,23 @@ TEST_P(SpdyNetworkTransactionTest, CloseWithActiveStream) {
// Test to make sure we can correctly connect through a proxy.
TEST_P(SpdyNetworkTransactionTest, ProxyConnect) {
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.session_deps().reset(CreateSpdySessionDependencies(
- GetParam(),
- ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")));
+ GetParam(), ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")));
helper.SetSession(make_scoped_refptr(
SpdySessionDependencies::SpdyCreateSession(helper.session_deps().get())));
helper.RunPreTestSetup();
HttpNetworkTransaction* trans = helper.trans();
- const char kConnect443[] = {"CONNECT www.google.com:443 HTTP/1.1\r\n"
- "Host: www.google.com\r\n"
- "Proxy-Connection: keep-alive\r\n\r\n"};
- const char kConnect80[] = {"CONNECT www.google.com:80 HTTP/1.1\r\n"
- "Host: www.google.com\r\n"
- "Proxy-Connection: keep-alive\r\n\r\n"};
+ const char kConnect443[] = {
+ "CONNECT www.google.com:443 HTTP/1.1\r\n"
+ "Host: www.google.com\r\n"
+ "Proxy-Connection: keep-alive\r\n\r\n"};
+ const char kConnect80[] = {
+ "CONNECT www.google.com:80 HTTP/1.1\r\n"
+ "Host: www.google.com\r\n"
+ "Proxy-Connection: keep-alive\r\n\r\n"};
const char kHTTP200[] = {"HTTP/1.1 200 OK\r\n\r\n"};
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
@@ -4635,39 +4373,36 @@ TEST_P(SpdyNetworkTransactionTest, ProxyConnect) {
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes_SPDYNPN[] = {
- MockWrite(SYNCHRONOUS, kConnect443, arraysize(kConnect443) - 1, 0),
- CreateMockWrite(*req, 2),
+ MockWrite(SYNCHRONOUS, kConnect443, arraysize(kConnect443) - 1, 0),
+ CreateMockWrite(*req, 2),
};
MockRead reads_SPDYNPN[] = {
- MockRead(SYNCHRONOUS, kHTTP200, arraysize(kHTTP200) - 1, 1),
- CreateMockRead(*resp, 3),
- CreateMockRead(*body.get(), 4),
- MockRead(ASYNC, 0, 0, 5),
+ MockRead(SYNCHRONOUS, kHTTP200, arraysize(kHTTP200) - 1, 1),
+ CreateMockRead(*resp, 3), CreateMockRead(*body.get(), 4),
+ MockRead(ASYNC, 0, 0, 5),
};
MockWrite writes_SPDYSSL[] = {
- MockWrite(SYNCHRONOUS, kConnect80, arraysize(kConnect80) - 1, 0),
- CreateMockWrite(*req, 2),
+ MockWrite(SYNCHRONOUS, kConnect80, arraysize(kConnect80) - 1, 0),
+ CreateMockWrite(*req, 2),
};
MockRead reads_SPDYSSL[] = {
- MockRead(SYNCHRONOUS, kHTTP200, arraysize(kHTTP200) - 1, 1),
- CreateMockRead(*resp, 3),
- CreateMockRead(*body.get(), 4),
- MockRead(ASYNC, 0, 0, 5),
+ MockRead(SYNCHRONOUS, kHTTP200, arraysize(kHTTP200) - 1, 1),
+ CreateMockRead(*resp, 3), CreateMockRead(*body.get(), 4),
+ MockRead(ASYNC, 0, 0, 5),
};
MockWrite writes_SPDYNOSSL[] = {
- CreateMockWrite(*req, 0),
+ CreateMockWrite(*req, 0),
};
MockRead reads_SPDYNOSSL[] = {
- CreateMockRead(*resp, 1),
- CreateMockRead(*body.get(), 2),
- MockRead(ASYNC, 0, 0, 3),
+ CreateMockRead(*resp, 1), CreateMockRead(*body.get(), 2),
+ MockRead(ASYNC, 0, 0, 3),
};
scoped_ptr<OrderedSocketData> data;
- switch(GetParam().ssl_type) {
+ switch (GetParam().ssl_type) {
case SPDYNOSSL:
data.reset(new OrderedSocketData(reads_SPDYNOSSL,
arraysize(reads_SPDYNOSSL),
@@ -4693,8 +4428,8 @@ TEST_P(SpdyNetworkTransactionTest, ProxyConnect) {
helper.AddData(data.get());
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
@@ -4717,8 +4452,8 @@ TEST_P(SpdyNetworkTransactionTest, ProxyConnect) {
TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) {
// When setting up the first transaction, we store the SpdySessionPool so that
// we can use the same pool in the second transaction.
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
// Use a proxy service which returns a proxy fallback list from DIRECT to
// myproxy:70. For this test there will be no fallback, so it is equivalent
@@ -4737,26 +4472,24 @@ TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
MockWrite writes[] = {
- CreateMockWrite(*req, 1),
+ CreateMockWrite(*req, 1),
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp, 2),
- CreateMockRead(*body, 3),
- MockRead(ASYNC, ERR_IO_PENDING, 4), // Force a pause
- MockRead(ASYNC, 0, 5) // EOF
+ CreateMockRead(*resp, 2), CreateMockRead(*body, 3),
+ MockRead(ASYNC, ERR_IO_PENDING, 4), // Force a pause
+ MockRead(ASYNC, 0, 5) // EOF
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
helper.AddData(&data);
HttpNetworkTransaction* trans = helper.trans();
TestCompletionCallback callback;
TransactionHelperResult out;
- out.rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ out.rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(out.rv, ERR_IO_PENDING);
out.rv = callback.WaitForResult();
@@ -4783,12 +4516,14 @@ TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) {
EXPECT_FALSE(HasSpdySession(spdy_session_pool, session_pool_key_proxy));
// Set up data for the proxy connection.
- const char kConnect443[] = {"CONNECT www.google.com:443 HTTP/1.1\r\n"
- "Host: www.google.com\r\n"
- "Proxy-Connection: keep-alive\r\n\r\n"};
- const char kConnect80[] = {"CONNECT www.google.com:80 HTTP/1.1\r\n"
- "Host: www.google.com\r\n"
- "Proxy-Connection: keep-alive\r\n\r\n"};
+ const char kConnect443[] = {
+ "CONNECT www.google.com:443 HTTP/1.1\r\n"
+ "Host: www.google.com\r\n"
+ "Proxy-Connection: keep-alive\r\n\r\n"};
+ const char kConnect80[] = {
+ "CONNECT www.google.com:80 HTTP/1.1\r\n"
+ "Host: www.google.com\r\n"
+ "Proxy-Connection: keep-alive\r\n\r\n"};
const char kHTTP200[] = {"HTTP/1.1 200 OK\r\n\r\n"};
scoped_ptr<SpdyFrame> req2(spdy_util_.ConstructSpdyGet(
"http://www.google.com/foo.dat", false, 1, LOWEST));
@@ -4796,38 +4531,35 @@ TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) {
scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes_SPDYNPN[] = {
- MockWrite(SYNCHRONOUS, kConnect443, arraysize(kConnect443) - 1, 0),
- CreateMockWrite(*req2, 2),
+ MockWrite(SYNCHRONOUS, kConnect443, arraysize(kConnect443) - 1, 0),
+ CreateMockWrite(*req2, 2),
};
MockRead reads_SPDYNPN[] = {
- MockRead(SYNCHRONOUS, kHTTP200, arraysize(kHTTP200) - 1, 1),
- CreateMockRead(*resp2, 3),
- CreateMockRead(*body2, 4),
- MockRead(ASYNC, 0, 5) // EOF
+ MockRead(SYNCHRONOUS, kHTTP200, arraysize(kHTTP200) - 1, 1),
+ CreateMockRead(*resp2, 3), CreateMockRead(*body2, 4),
+ MockRead(ASYNC, 0, 5) // EOF
};
MockWrite writes_SPDYNOSSL[] = {
- CreateMockWrite(*req2, 0),
+ CreateMockWrite(*req2, 0),
};
MockRead reads_SPDYNOSSL[] = {
- CreateMockRead(*resp2, 1),
- CreateMockRead(*body2, 2),
- MockRead(ASYNC, 0, 3) // EOF
+ CreateMockRead(*resp2, 1), CreateMockRead(*body2, 2),
+ MockRead(ASYNC, 0, 3) // EOF
};
MockWrite writes_SPDYSSL[] = {
- MockWrite(SYNCHRONOUS, kConnect80, arraysize(kConnect80) - 1, 0),
- CreateMockWrite(*req2, 2),
+ MockWrite(SYNCHRONOUS, kConnect80, arraysize(kConnect80) - 1, 0),
+ CreateMockWrite(*req2, 2),
};
MockRead reads_SPDYSSL[] = {
- MockRead(SYNCHRONOUS, kHTTP200, arraysize(kHTTP200) - 1, 1),
- CreateMockRead(*resp2, 3),
- CreateMockRead(*body2, 4),
- MockRead(ASYNC, 0, 0, 5),
+ MockRead(SYNCHRONOUS, kHTTP200, arraysize(kHTTP200) - 1, 1),
+ CreateMockRead(*resp2, 3), CreateMockRead(*body2, 4),
+ MockRead(ASYNC, 0, 0, 5),
};
scoped_ptr<OrderedSocketData> data_proxy;
- switch(GetParam().ssl_type) {
+ switch (GetParam().ssl_type) {
case SPDYNPN:
data_proxy.reset(new OrderedSocketData(reads_SPDYNPN,
arraysize(reads_SPDYNPN),
@@ -4860,11 +4592,11 @@ TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) {
// Ensure that this transaction uses the same SpdySessionPool.
scoped_refptr<HttpNetworkSession> session_proxy(
SpdySessionDependencies::SpdyCreateSession(ssd_proxy.get()));
- NormalSpdyTransactionHelper helper_proxy(request_proxy, DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper_proxy(
+ request_proxy, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
HttpNetworkSessionPeer session_peer(session_proxy);
scoped_ptr<net::ProxyService> proxy_service(
- ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"));
+ ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"));
session_peer.SetProxyService(proxy_service.get());
helper_proxy.session_deps().swap(ssd_proxy);
helper_proxy.SetSession(session_proxy);
@@ -4899,16 +4631,13 @@ TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) {
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, ERR_IO_PENDING),
- MockRead(ASYNC, ERR_CONNECTION_RESET),
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, ERR_IO_PENDING), MockRead(ASYNC, ERR_CONNECTION_RESET),
};
MockRead reads2[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
// This test has a couple of variants.
@@ -4927,8 +4656,8 @@ TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) {
DelayedSocketData data2(1, reads2, arraysize(reads2), NULL, 0);
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.AddData(&data1);
helper.AddData(&data2);
helper.RunPreTestSetup();
@@ -4938,8 +4667,8 @@ TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) {
new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get()));
TestCompletionCallback callback;
- int rv = trans->Start(
- &helper.request(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&helper.request(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// On the second transaction, we trigger the RST.
if (i == 1) {
@@ -4977,20 +4706,22 @@ TEST_P(SpdyNetworkTransactionTest, SpdyOnOffToggle) {
net::HttpStreamFactory::set_spdy_enabled(true);
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite spdy_writes[] = { CreateMockWrite(*req) };
+ MockWrite spdy_writes[] = {CreateMockWrite(*req)};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead spdy_reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp), CreateMockRead(*body),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, spdy_reads, arraysize(spdy_reads),
- spdy_writes, arraysize(spdy_writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(1,
+ spdy_reads,
+ arraysize(spdy_reads),
+ spdy_writes,
+ arraysize(spdy_writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(OK, out.rv);
@@ -4999,13 +4730,12 @@ TEST_P(SpdyNetworkTransactionTest, SpdyOnOffToggle) {
net::HttpStreamFactory::set_spdy_enabled(false);
MockRead http_reads[] = {
- MockRead("HTTP/1.1 200 OK\r\n\r\n"),
- MockRead("hello from http"),
- MockRead(SYNCHRONOUS, OK),
+ MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello from http"),
+ MockRead(SYNCHRONOUS, OK),
};
DelayedSocketData data2(1, http_reads, arraysize(http_reads), NULL, 0);
- NormalSpdyTransactionHelper helper2(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper2(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper2.SetSpdyDisabled();
helper2.RunToCompletion(&data2);
TransactionHelperResult out2 = helper2.output();
@@ -5024,25 +4754,24 @@ TEST_P(SpdyNetworkTransactionTest, SpdyBasicAuth) {
// GET with an Authorization header.
scoped_ptr<SpdyFrame> req_get(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- const char* const kExtraAuthorizationHeaders[] = {
- "authorization", "Basic Zm9vOmJhcg=="
- };
+ const char* const kExtraAuthorizationHeaders[] = {"authorization",
+ "Basic Zm9vOmJhcg=="};
scoped_ptr<SpdyFrame> req_get_authorization(
spdy_util_.ConstructSpdyGet(kExtraAuthorizationHeaders,
arraysize(kExtraAuthorizationHeaders) / 2,
- false, 3, LOWEST, true));
+ false,
+ 3,
+ LOWEST,
+ true));
MockWrite spdy_writes[] = {
- CreateMockWrite(*req_get, 1),
- CreateMockWrite(*req_get_authorization, 4),
+ CreateMockWrite(*req_get, 1), CreateMockWrite(*req_get_authorization, 4),
};
// The first response is a 401 authentication challenge, and the second
// response will be a 200 response since the second request includes a valid
// Authorization header.
- const char* const kExtraAuthenticationHeaders[] = {
- "www-authenticate",
- "Basic realm=\"MyRealm\""
- };
+ const char* const kExtraAuthenticationHeaders[] = {"www-authenticate",
+ "Basic realm=\"MyRealm\""};
scoped_ptr<SpdyFrame> resp_authentication(
spdy_util_.ConstructSpdySynReplyError(
"401 Authentication Required",
@@ -5055,19 +4784,19 @@ TEST_P(SpdyNetworkTransactionTest, SpdyBasicAuth) {
spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3));
scoped_ptr<SpdyFrame> body_data(spdy_util_.ConstructSpdyBodyFrame(3, true));
MockRead spdy_reads[] = {
- CreateMockRead(*resp_authentication, 2),
- CreateMockRead(*body_authentication, 3),
- CreateMockRead(*resp_data, 5),
- CreateMockRead(*body_data, 6),
- MockRead(ASYNC, 0, 7),
+ CreateMockRead(*resp_authentication, 2),
+ CreateMockRead(*body_authentication, 3),
+ CreateMockRead(*resp_data, 5),
+ CreateMockRead(*body_data, 6),
+ MockRead(ASYNC, 0, 7),
};
- OrderedSocketData data(spdy_reads, arraysize(spdy_reads),
- spdy_writes, arraysize(spdy_writes));
+ OrderedSocketData data(
+ spdy_reads, arraysize(spdy_reads), spdy_writes, arraysize(spdy_writes));
HttpRequestInfo request(CreateGetRequest());
BoundNetLog net_log;
- NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
- net_log, GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ request, DEFAULT_PRIORITY, net_log, GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
@@ -5094,8 +4823,8 @@ TEST_P(SpdyNetworkTransactionTest, SpdyBasicAuth) {
AuthCredentials credentials(base::ASCIIToUTF16("foo"),
base::ASCIIToUTF16("bar"));
TestCompletionCallback callback_restart;
- const int rv_restart = trans->RestartWithAuth(
- credentials, callback_restart.callback());
+ const int rv_restart =
+ trans->RestartWithAuth(credentials, callback_restart.callback());
EXPECT_EQ(ERR_IO_PENDING, rv_restart);
const int rv_restart_complete = callback_restart.WaitForResult();
EXPECT_EQ(OK, rv_restart_complete);
@@ -5114,12 +4843,12 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushWithHeaders) {
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
+ CreateMockWrite(*stream1_syn, 1),
};
scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock());
- spdy_util_.AddUrlToHeaderBlock(
- "http://www.google.com/foo.dat", initial_headers.get());
+ spdy_util_.AddUrlToHeaderBlock("http://www.google.com/foo.dat",
+ initial_headers.get());
scoped_ptr<SpdyFrame> stream2_syn(
spdy_util_.ConstructSpdyControlFrame(initial_headers.Pass(),
false,
@@ -5133,39 +4862,28 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushWithHeaders) {
(*late_headers)["hello"] = "bye";
(*late_headers)[spdy_util_.GetStatusKey()] = "200";
(*late_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1";
- scoped_ptr<SpdyFrame> stream2_headers(
- spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(),
- false,
- 2,
- LOWEST,
- HEADERS,
- CONTROL_FLAG_NONE,
- 0));
+ scoped_ptr<SpdyFrame> stream2_headers(spdy_util_.ConstructSpdyControlFrame(
+ late_headers.Pass(), false, 2, LOWEST, HEADERS, CONTROL_FLAG_NONE, 0));
- scoped_ptr<SpdyFrame>
- stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> stream1_reply(
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
const char kPushedData[] = "pushed";
- scoped_ptr<SpdyFrame> stream2_body(
- spdy_util_.ConstructSpdyBodyFrame(
- 2, kPushedData, strlen(kPushedData), true));
+ scoped_ptr<SpdyFrame> stream2_body(spdy_util_.ConstructSpdyBodyFrame(
+ 2, kPushedData, strlen(kPushedData), true));
MockRead reads[] = {
- CreateMockRead(*stream1_reply, 2),
- CreateMockRead(*stream2_syn, 3),
- CreateMockRead(*stream2_headers, 4),
- CreateMockRead(*stream1_body, 5, SYNCHRONOUS),
- CreateMockRead(*stream2_body, 5),
- MockRead(ASYNC, ERR_IO_PENDING, 7), // Force a pause
+ CreateMockRead(*stream1_reply, 2),
+ CreateMockRead(*stream2_syn, 3),
+ CreateMockRead(*stream2_headers, 4),
+ CreateMockRead(*stream1_body, 5, SYNCHRONOUS),
+ CreateMockRead(*stream2_body, 5),
+ MockRead(ASYNC, ERR_IO_PENDING, 7), // Force a pause
};
HttpResponseInfo response;
HttpResponseInfo response2;
std::string expected_push_result("pushed");
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- RunServerPushTest(&data,
- &response,
- &response2,
- expected_push_result);
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ RunServerPushTest(&data, &response, &response2, expected_push_result);
// Verify the SYN_REPLY.
EXPECT_TRUE(response.headers.get() != NULL);
@@ -5183,12 +4901,12 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushClaimBeforeHeaders) {
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS),
+ CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS),
};
scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock());
- spdy_util_.AddUrlToHeaderBlock(
- "http://www.google.com/foo.dat", initial_headers.get());
+ spdy_util_.AddUrlToHeaderBlock("http://www.google.com/foo.dat",
+ initial_headers.get());
scoped_ptr<SpdyFrame> stream2_syn(
spdy_util_.ConstructSpdyControlFrame(initial_headers.Pass(),
false,
@@ -5202,38 +4920,28 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushClaimBeforeHeaders) {
(*late_headers)["hello"] = "bye";
(*late_headers)[spdy_util_.GetStatusKey()] = "200";
(*late_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1";
- scoped_ptr<SpdyFrame> stream2_headers(
- spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(),
- false,
- 2,
- LOWEST,
- HEADERS,
- CONTROL_FLAG_NONE,
- 0));
+ scoped_ptr<SpdyFrame> stream2_headers(spdy_util_.ConstructSpdyControlFrame(
+ late_headers.Pass(), false, 2, LOWEST, HEADERS, CONTROL_FLAG_NONE, 0));
- scoped_ptr<SpdyFrame>
- stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> stream1_reply(
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
const char kPushedData[] = "pushed";
- scoped_ptr<SpdyFrame> stream2_body(
- spdy_util_.ConstructSpdyBodyFrame(
- 2, kPushedData, strlen(kPushedData), true));
+ scoped_ptr<SpdyFrame> stream2_body(spdy_util_.ConstructSpdyBodyFrame(
+ 2, kPushedData, strlen(kPushedData), true));
MockRead reads[] = {
- CreateMockRead(*stream1_reply, 1),
- CreateMockRead(*stream2_syn, 2),
- CreateMockRead(*stream1_body, 3),
- CreateMockRead(*stream2_headers, 4),
- CreateMockRead(*stream2_body, 5),
- MockRead(ASYNC, 0, 6), // EOF
+ CreateMockRead(*stream1_reply, 1), CreateMockRead(*stream2_syn, 2),
+ CreateMockRead(*stream1_body, 3), CreateMockRead(*stream2_headers, 4),
+ CreateMockRead(*stream2_body, 5), MockRead(ASYNC, 0, 6), // EOF
};
HttpResponseInfo response;
HttpResponseInfo response2;
std::string expected_push_result("pushed");
- DeterministicSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ DeterministicSocketData data(
+ reads, arraysize(reads), writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.SetDeterministic();
helper.AddDeterministicData(&data);
helper.RunPreTestSetup();
@@ -5247,8 +4955,8 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushClaimBeforeHeaders) {
// Start the transaction.
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
data.Run();
rv = callback.WaitForResult();
@@ -5273,10 +4981,8 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushClaimBeforeHeaders) {
// Verify that the received push data is same as the expected push data.
EXPECT_EQ(result2.compare(expected_push_result), 0)
- << "Received data: "
- << result2
- << "||||| Expected data: "
- << expected_push_result;
+ << "Received data: " << result2
+ << "||||| Expected data: " << expected_push_result;
// Verify the SYN_REPLY.
// Copy the response info, because trans goes away.
@@ -5308,12 +5014,12 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) {
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS),
+ CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS),
};
scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock());
- spdy_util_.AddUrlToHeaderBlock(
- "http://www.google.com/foo.dat", initial_headers.get());
+ spdy_util_.AddUrlToHeaderBlock("http://www.google.com/foo.dat",
+ initial_headers.get());
scoped_ptr<SpdyFrame> stream2_syn(
spdy_util_.ConstructSpdyControlFrame(initial_headers.Pass(),
false,
@@ -5325,14 +5031,8 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) {
scoped_ptr<SpdyHeaderBlock> middle_headers(new SpdyHeaderBlock());
(*middle_headers)["hello"] = "bye";
- scoped_ptr<SpdyFrame> stream2_headers1(
- spdy_util_.ConstructSpdyControlFrame(middle_headers.Pass(),
- false,
- 2,
- LOWEST,
- HEADERS,
- CONTROL_FLAG_NONE,
- 0));
+ scoped_ptr<SpdyFrame> stream2_headers1(spdy_util_.ConstructSpdyControlFrame(
+ middle_headers.Pass(), false, 2, LOWEST, HEADERS, CONTROL_FLAG_NONE, 0));
scoped_ptr<SpdyHeaderBlock> late_headers(new SpdyHeaderBlock());
(*late_headers)[spdy_util_.GetStatusKey()] = "200";
@@ -5340,39 +5040,32 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) {
// SPDY4/HTTP2 eliminates use of the :version header.
(*late_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1";
}
- scoped_ptr<SpdyFrame> stream2_headers2(
- spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(),
- false,
- 2,
- LOWEST,
- HEADERS,
- CONTROL_FLAG_NONE,
- 0));
+ scoped_ptr<SpdyFrame> stream2_headers2(spdy_util_.ConstructSpdyControlFrame(
+ late_headers.Pass(), false, 2, LOWEST, HEADERS, CONTROL_FLAG_NONE, 0));
- scoped_ptr<SpdyFrame>
- stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> stream1_reply(
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
const char kPushedData[] = "pushed";
- scoped_ptr<SpdyFrame> stream2_body(
- spdy_util_.ConstructSpdyBodyFrame(
- 2, kPushedData, strlen(kPushedData), true));
+ scoped_ptr<SpdyFrame> stream2_body(spdy_util_.ConstructSpdyBodyFrame(
+ 2, kPushedData, strlen(kPushedData), true));
MockRead reads[] = {
- CreateMockRead(*stream1_reply, 1),
- CreateMockRead(*stream2_syn, 2),
- CreateMockRead(*stream1_body, 3),
- CreateMockRead(*stream2_headers1, 4),
- CreateMockRead(*stream2_headers2, 5),
- CreateMockRead(*stream2_body, 6),
- MockRead(ASYNC, 0, 7), // EOF
+ CreateMockRead(*stream1_reply, 1),
+ CreateMockRead(*stream2_syn, 2),
+ CreateMockRead(*stream1_body, 3),
+ CreateMockRead(*stream2_headers1, 4),
+ CreateMockRead(*stream2_headers2, 5),
+ CreateMockRead(*stream2_body, 6),
+ MockRead(ASYNC, 0, 7), // EOF
};
HttpResponseInfo response;
HttpResponseInfo response2;
std::string expected_push_result("pushed");
- DeterministicSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ DeterministicSocketData data(
+ reads, arraysize(reads), writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.SetDeterministic();
helper.AddDeterministicData(&data);
helper.RunPreTestSetup();
@@ -5386,8 +5079,8 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) {
// Start the transaction.
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
data.Run();
rv = callback.WaitForResult();
@@ -5431,19 +5124,15 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) {
// Verify we got all the headers
if (spdy_util_.spdy_version() < SPDY3) {
EXPECT_TRUE(response2.headers->HasHeaderValue(
- "url",
- "http://www.google.com/foo.dat"));
+ "url", "http://www.google.com/foo.dat"));
} else {
- EXPECT_TRUE(response2.headers->HasHeaderValue(
- "scheme", "http"));
- EXPECT_TRUE(response2.headers->HasHeaderValue(
- "path", "/foo.dat"));
+ EXPECT_TRUE(response2.headers->HasHeaderValue("scheme", "http"));
+ EXPECT_TRUE(response2.headers->HasHeaderValue("path", "/foo.dat"));
if (spdy_util_.spdy_version() < SPDY4) {
- EXPECT_TRUE(response2.headers->HasHeaderValue(
- "host", "www.google.com"));
+ EXPECT_TRUE(response2.headers->HasHeaderValue("host", "www.google.com"));
} else {
- EXPECT_TRUE(response2.headers->HasHeaderValue(
- "authority", "www.google.com"));
+ EXPECT_TRUE(
+ response2.headers->HasHeaderValue("authority", "www.google.com"));
}
}
EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye"));
@@ -5464,12 +5153,12 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushWithNoStatusHeaderFrames) {
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS),
+ CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS),
};
scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock());
- spdy_util_.AddUrlToHeaderBlock(
- "http://www.google.com/foo.dat", initial_headers.get());
+ spdy_util_.AddUrlToHeaderBlock("http://www.google.com/foo.dat",
+ initial_headers.get());
scoped_ptr<SpdyFrame> stream2_syn(
spdy_util_.ConstructSpdyControlFrame(initial_headers.Pass(),
false,
@@ -5481,35 +5170,25 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushWithNoStatusHeaderFrames) {
scoped_ptr<SpdyHeaderBlock> middle_headers(new SpdyHeaderBlock());
(*middle_headers)["hello"] = "bye";
- scoped_ptr<SpdyFrame> stream2_headers1(
- spdy_util_.ConstructSpdyControlFrame(middle_headers.Pass(),
- false,
- 2,
- LOWEST,
- HEADERS,
- CONTROL_FLAG_NONE,
- 0));
+ scoped_ptr<SpdyFrame> stream2_headers1(spdy_util_.ConstructSpdyControlFrame(
+ middle_headers.Pass(), false, 2, LOWEST, HEADERS, CONTROL_FLAG_NONE, 0));
- scoped_ptr<SpdyFrame>
- stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> stream1_reply(
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
const char kPushedData[] = "pushed";
- scoped_ptr<SpdyFrame> stream2_body(
- spdy_util_.ConstructSpdyBodyFrame(
- 2, kPushedData, strlen(kPushedData), true));
+ scoped_ptr<SpdyFrame> stream2_body(spdy_util_.ConstructSpdyBodyFrame(
+ 2, kPushedData, strlen(kPushedData), true));
MockRead reads[] = {
- CreateMockRead(*stream1_reply, 1),
- CreateMockRead(*stream2_syn, 2),
- CreateMockRead(*stream1_body, 3),
- CreateMockRead(*stream2_headers1, 4),
- CreateMockRead(*stream2_body, 5),
- MockRead(ASYNC, 0, 6), // EOF
+ CreateMockRead(*stream1_reply, 1), CreateMockRead(*stream2_syn, 2),
+ CreateMockRead(*stream1_body, 3), CreateMockRead(*stream2_headers1, 4),
+ CreateMockRead(*stream2_body, 5), MockRead(ASYNC, 0, 6), // EOF
};
- DeterministicSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ DeterministicSocketData data(
+ reads, arraysize(reads), writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.SetDeterministic();
helper.AddDeterministicData(&data);
helper.RunPreTestSetup();
@@ -5523,8 +5202,8 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushWithNoStatusHeaderFrames) {
// Start the transaction.
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
data.Run();
rv = callback.WaitForResult();
@@ -5576,9 +5255,8 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) {
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*rst),
- };
+ CreateMockWrite(*req), CreateMockWrite(*rst),
+ };
scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock());
(*initial_headers)[spdy_util_.GetStatusKey()] = "200 OK";
@@ -5594,27 +5272,18 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) {
scoped_ptr<SpdyHeaderBlock> late_headers(new SpdyHeaderBlock());
(*late_headers)["hello"] = "bye";
- scoped_ptr<SpdyFrame> stream1_headers(
- spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(),
- false,
- 1,
- LOWEST,
- HEADERS,
- CONTROL_FLAG_NONE,
- 0));
+ scoped_ptr<SpdyFrame> stream1_headers(spdy_util_.ConstructSpdyControlFrame(
+ late_headers.Pass(), false, 1, LOWEST, HEADERS, CONTROL_FLAG_NONE, 0));
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*stream1_reply),
- CreateMockRead(*stream1_headers),
- CreateMockRead(*stream1_body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*stream1_reply), CreateMockRead(*stream1_headers),
+ CreateMockRead(*stream1_body), MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
@@ -5626,8 +5295,7 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyWithLateHeaders) {
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*rst),
+ CreateMockWrite(*req), CreateMockWrite(*rst),
};
scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock());
@@ -5644,30 +5312,21 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyWithLateHeaders) {
scoped_ptr<SpdyHeaderBlock> late_headers(new SpdyHeaderBlock());
(*late_headers)["hello"] = "bye";
- scoped_ptr<SpdyFrame> stream1_headers(
- spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(),
- false,
- 1,
- LOWEST,
- HEADERS,
- CONTROL_FLAG_NONE,
- 0));
+ scoped_ptr<SpdyFrame> stream1_headers(spdy_util_.ConstructSpdyControlFrame(
+ late_headers.Pass(), false, 1, LOWEST, HEADERS, CONTROL_FLAG_NONE, 0));
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, false));
scoped_ptr<SpdyFrame> stream1_body2(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*stream1_reply),
- CreateMockRead(*stream1_body),
- CreateMockRead(*stream1_headers),
- CreateMockRead(*stream1_body2),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*stream1_reply), CreateMockRead(*stream1_body),
+ CreateMockRead(*stream1_headers), CreateMockRead(*stream1_body2),
+ MockRead(ASYNC, 0, 0) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
@@ -5687,20 +5346,16 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) {
// A list of the URL to fetch, followed by the URL being pushed.
static const char* const kTestCases[] = {
- "http://www.google.com/foo.html",
- "http://www.google.com:81/foo.js", // Bad port
-
- "http://www.google.com/foo.html",
- "https://www.google.com/foo.js", // Bad protocol
-
- "http://www.google.com/foo.html",
- "ftp://www.google.com/foo.js", // Invalid Protocol
-
- "http://www.google.com/foo.html",
- "http://blat.www.google.com/foo.js", // Cross subdomain
-
- "http://www.google.com/foo.html",
- "http://www.foo.com/foo.js", // Cross domain
+ "http://www.google.com/foo.html",
+ "http://www.google.com:81/foo.js", // Bad port
+ "http://www.google.com/foo.html",
+ "https://www.google.com/foo.js", // Bad protocol
+ "http://www.google.com/foo.html",
+ "ftp://www.google.com/foo.js", // Invalid Protocol
+ "http://www.google.com/foo.html",
+ "http://blat.www.google.com/foo.js", // Cross subdomain
+ "http://www.google.com/foo.html",
+ "http://www.foo.com/foo.js", // Cross domain
};
for (size_t index = 0; index < arraysize(kTestCases); index += 2) {
@@ -5714,36 +5369,29 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) {
scoped_ptr<SpdyFrame> push_rst(
spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
- CreateMockWrite(*push_rst, 4),
+ CreateMockWrite(*stream1_syn, 1), CreateMockWrite(*push_rst, 4),
};
- scoped_ptr<SpdyFrame>
- stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
- scoped_ptr<SpdyFrame>
- stream2_syn(spdy_util_.ConstructSpdyPush(NULL,
- 0,
- 2,
- 1,
- url_to_push));
+ scoped_ptr<SpdyFrame> stream1_reply(
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> stream2_syn(
+ spdy_util_.ConstructSpdyPush(NULL, 0, 2, 1, url_to_push));
const char kPushedData[] = "pushed";
- scoped_ptr<SpdyFrame> stream2_body(
- spdy_util_.ConstructSpdyBodyFrame(
- 2, kPushedData, strlen(kPushedData), true));
+ scoped_ptr<SpdyFrame> stream2_body(spdy_util_.ConstructSpdyBodyFrame(
+ 2, kPushedData, strlen(kPushedData), true));
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_CANCEL));
MockRead reads[] = {
- CreateMockRead(*stream1_reply, 2),
- CreateMockRead(*stream2_syn, 3),
- CreateMockRead(*stream1_body, 5, SYNCHRONOUS),
- CreateMockRead(*stream2_body, 6),
- MockRead(ASYNC, ERR_IO_PENDING, 7), // Force a pause
+ CreateMockRead(*stream1_reply, 2),
+ CreateMockRead(*stream2_syn, 3),
+ CreateMockRead(*stream1_body, 5, SYNCHRONOUS),
+ CreateMockRead(*stream2_body, 6),
+ MockRead(ASYNC, ERR_IO_PENDING, 7), // Force a pause
};
HttpResponseInfo response;
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
HttpRequestInfo request;
request.method = "GET";
@@ -5755,8 +5403,10 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) {
scoped_ptr<SpdySessionDependencies> session_deps(
CreateSpdySessionDependencies(GetParam()));
session_deps->trusted_spdy_proxy = "123.45.67.89:8080";
- NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(),
+ NormalSpdyTransactionHelper helper(request,
+ DEFAULT_PRIORITY,
+ BoundNetLog(),
+ GetParam(),
session_deps.release());
helper.RunPreTestSetup();
helper.AddData(&data);
@@ -5797,8 +5447,7 @@ TEST_P(SpdyNetworkTransactionTest, RetryAfterRefused) {
scoped_ptr<SpdyFrame> req2(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true));
MockWrite writes[] = {
- CreateMockWrite(*req, 1),
- CreateMockWrite(*req2, 3),
+ CreateMockWrite(*req, 1), CreateMockWrite(*req2, 3),
};
scoped_ptr<SpdyFrame> refused(
@@ -5806,16 +5455,13 @@ TEST_P(SpdyNetworkTransactionTest, RetryAfterRefused) {
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(3, true));
MockRead reads[] = {
- CreateMockRead(*refused, 2),
- CreateMockRead(*resp, 4),
- CreateMockRead(*body, 5),
- MockRead(ASYNC, 0, 6) // EOF
+ CreateMockRead(*refused, 2), CreateMockRead(*resp, 4),
+ CreateMockRead(*body, 5), MockRead(ASYNC, 0, 6) // EOF
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
@@ -5824,21 +5470,17 @@ TEST_P(SpdyNetworkTransactionTest, RetryAfterRefused) {
// Start the transaction with basic parameters.
TestCompletionCallback callback;
- int rv = trans->Start(
- &CreateGetRequest(), callback.callback(), BoundNetLog());
+ int rv =
+ trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
EXPECT_EQ(OK, rv);
// Verify that we consumed all test data.
- EXPECT_TRUE(data.at_read_eof()) << "Read count: "
- << data.read_count()
- << " Read index: "
- << data.read_index();
- EXPECT_TRUE(data.at_write_eof()) << "Write count: "
- << data.write_count()
- << " Write index: "
- << data.write_index();
+ EXPECT_TRUE(data.at_read_eof()) << "Read count: " << data.read_count()
+ << " Read index: " << data.read_index();
+ EXPECT_TRUE(data.at_write_eof()) << "Write count: " << data.write_count()
+ << " Write index: " << data.write_index();
// Verify the SYN_REPLY.
HttpResponseInfo response = *trans->GetResponseInfo();
@@ -5859,9 +5501,8 @@ TEST_P(SpdyNetworkTransactionTest, OutOfOrderSynStream) {
scoped_ptr<SpdyFrame> req3(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 5, MEDIUM, true));
MockWrite writes[] = {
- CreateMockWrite(*req1, 0),
- CreateMockWrite(*req2, 3),
- CreateMockWrite(*req3, 4),
+ CreateMockWrite(*req1, 0), CreateMockWrite(*req2, 3),
+ CreateMockWrite(*req3, 4),
};
scoped_ptr<SpdyFrame> resp1(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
@@ -5871,19 +5512,16 @@ TEST_P(SpdyNetworkTransactionTest, OutOfOrderSynStream) {
scoped_ptr<SpdyFrame> resp3(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 5));
scoped_ptr<SpdyFrame> body3(spdy_util_.ConstructSpdyBodyFrame(5, true));
MockRead reads[] = {
- CreateMockRead(*resp1, 1),
- CreateMockRead(*body1, 2),
- CreateMockRead(*resp2, 5),
- CreateMockRead(*body2, 6),
- CreateMockRead(*resp3, 7),
- CreateMockRead(*body3, 8),
- MockRead(ASYNC, 0, 9) // EOF
- };
-
- DeterministicSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreateGetRequest(), LOWEST,
- BoundNetLog(), GetParam(), NULL);
+ CreateMockRead(*resp1, 1), CreateMockRead(*body1, 2),
+ CreateMockRead(*resp2, 5), CreateMockRead(*body2, 6),
+ CreateMockRead(*resp3, 7), CreateMockRead(*body3, 8),
+ MockRead(ASYNC, 0, 9) // EOF
+ };
+
+ DeterministicSocketData data(
+ reads, arraysize(reads), writes, arraysize(writes));
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), LOWEST, BoundNetLog(), GetParam(), NULL);
helper.SetDeterministic();
helper.RunPreTestSetup();
helper.AddDeterministicData(&data);
@@ -5960,21 +5598,17 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) {
return;
static int kFrameCount = 2;
- scoped_ptr<std::string> content(
- new std::string(kMaxSpdyFrameChunkSize, 'a'));
+ scoped_ptr<std::string> content(new std::string(kMaxSpdyFrameChunkSize, 'a'));
scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyPost(
kRequestUrl, 1, kMaxSpdyFrameChunkSize * kFrameCount, LOWEST, NULL, 0));
- scoped_ptr<SpdyFrame> body(
- spdy_util_.ConstructSpdyBodyFrame(
- 1, content->c_str(), content->size(), false));
- scoped_ptr<SpdyFrame> body_end(
- spdy_util_.ConstructSpdyBodyFrame(
- 1, content->c_str(), content->size(), true));
+ scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(
+ 1, content->c_str(), content->size(), false));
+ scoped_ptr<SpdyFrame> body_end(spdy_util_.ConstructSpdyBodyFrame(
+ 1, content->c_str(), content->size(), true));
MockWrite writes[] = {
- CreateMockWrite(*req, 0),
- CreateMockWrite(*body, 1),
- CreateMockWrite(*body_end, 2),
+ CreateMockWrite(*req, 0), CreateMockWrite(*body, 1),
+ CreateMockWrite(*body_end, 2),
};
static const int32 kDeltaWindowSize = 0xff;
@@ -5985,20 +5619,18 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) {
spdy_util_.ConstructSpdyWindowUpdate(2, kDeltaWindowSize));
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
MockRead reads[] = {
- CreateMockRead(*window_update_dummy, 3),
- CreateMockRead(*window_update_dummy, 4),
- CreateMockRead(*window_update_dummy, 5),
- CreateMockRead(*window_update, 6), // Four updates, therefore window
- CreateMockRead(*window_update, 7), // size should increase by
- CreateMockRead(*window_update, 8), // kDeltaWindowSize * 4
- CreateMockRead(*window_update, 9),
- CreateMockRead(*resp, 10),
- CreateMockRead(*body_end, 11),
- MockRead(ASYNC, 0, 0, 12) // EOF
+ CreateMockRead(*window_update_dummy, 3),
+ CreateMockRead(*window_update_dummy, 4),
+ CreateMockRead(*window_update_dummy, 5),
+ CreateMockRead(*window_update, 6), // Four updates, therefore window
+ CreateMockRead(*window_update, 7), // size should increase by
+ CreateMockRead(*window_update, 8), // kDeltaWindowSize * 4
+ CreateMockRead(*window_update, 9), CreateMockRead(*resp, 10),
+ CreateMockRead(*body_end, 11), MockRead(ASYNC, 0, 0, 12) // EOF
};
- DeterministicSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ DeterministicSocketData data(
+ reads, arraysize(reads), writes, arraysize(writes));
ScopedVector<UploadElementReader> element_readers;
for (int i = 0; i < kFrameCount; ++i) {
@@ -6013,8 +5645,8 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) {
request.url = GURL(kDefaultURL);
request.upload_data_stream = &upload_data_stream;
- NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.SetDeterministic();
helper.AddDeterministicData(&data);
helper.RunPreTestSetup();
@@ -6032,8 +5664,8 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) {
ASSERT_TRUE(stream != NULL);
ASSERT_TRUE(stream->stream() != NULL);
EXPECT_EQ(static_cast<int>(kSpdyStreamInitialWindowSize) +
- kDeltaWindowSize * kDeltaCount -
- kMaxSpdyFrameChunkSize * kFrameCount,
+ kDeltaWindowSize * kDeltaCount -
+ kMaxSpdyFrameChunkSize * kFrameCount,
stream->stream()->send_window_size());
data.RunFor(1);
@@ -6067,8 +5699,7 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) {
writes.push_back(CreateMockWrite(*window_update));
std::vector<MockRead> reads;
- scoped_ptr<SpdyFrame> resp(
- spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
+ scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
reads.push_back(CreateMockRead(*resp));
ScopedVector<SpdyFrame> body_frames;
@@ -6080,13 +5711,16 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) {
reads.push_back(CreateMockRead(*body_frames.back()));
remaining -= frame_size;
}
- reads.push_back(MockRead(ASYNC, ERR_IO_PENDING, 0)); // Yield.
+ reads.push_back(MockRead(ASYNC, ERR_IO_PENDING, 0)); // Yield.
- DelayedSocketData data(1, vector_as_array(&reads), reads.size(),
- vector_as_array(&writes), writes.size());
+ DelayedSocketData data(1,
+ vector_as_array(&reads),
+ reads.size(),
+ vector_as_array(&writes),
+ writes.size());
- NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.AddData(&data);
helper.RunPreTestSetup();
HttpNetworkTransaction* trans = helper.trans();
@@ -6098,8 +5732,7 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) {
rv = callback.WaitForResult();
EXPECT_EQ(OK, rv);
- SpdyHttpStream* stream =
- static_cast<SpdyHttpStream*>(trans->stream_.get());
+ SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get());
ASSERT_TRUE(stream != NULL);
ASSERT_TRUE(stream->stream() != NULL);
@@ -6136,34 +5769,30 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) {
// set content-length header correctly)
static int kFrameCount = 3;
- scoped_ptr<std::string> content(
- new std::string(kMaxSpdyFrameChunkSize, 'a'));
+ scoped_ptr<std::string> content(new std::string(kMaxSpdyFrameChunkSize, 'a'));
scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyPost(
kRequestUrl, 1, kMaxSpdyFrameChunkSize * kFrameCount, LOWEST, NULL, 0));
- scoped_ptr<SpdyFrame> body(
- spdy_util_.ConstructSpdyBodyFrame(
- 1, content->c_str(), content->size(), false));
+ scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(
+ 1, content->c_str(), content->size(), false));
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_FLOW_CONTROL_ERROR));
// We're not going to write a data frame with FIN, we'll receive a bad
// WINDOW_UPDATE while sending a request and will send a RST_STREAM frame.
MockWrite writes[] = {
- CreateMockWrite(*req, 0),
- CreateMockWrite(*body, 2),
- CreateMockWrite(*rst, 3),
+ CreateMockWrite(*req, 0), CreateMockWrite(*body, 2),
+ CreateMockWrite(*rst, 3),
};
static const int32 kDeltaWindowSize = 0x7fffffff; // cause an overflow
scoped_ptr<SpdyFrame> window_update(
spdy_util_.ConstructSpdyWindowUpdate(1, kDeltaWindowSize));
MockRead reads[] = {
- CreateMockRead(*window_update, 1),
- MockRead(ASYNC, 0, 4) // EOF
+ CreateMockRead(*window_update, 1), MockRead(ASYNC, 0, 4) // EOF
};
- DeterministicSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ DeterministicSocketData data(
+ reads, arraysize(reads), writes, arraysize(writes));
ScopedVector<UploadElementReader> element_readers;
for (int i = 0; i < kFrameCount; ++i) {
@@ -6178,8 +5807,8 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) {
request.url = GURL("http://www.google.com/");
request.upload_data_stream = &upload_data_stream;
- NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.SetDeterministic();
helper.RunPreTestSetup();
helper.AddDeterministicData(&data);
@@ -6228,18 +5857,20 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) {
std::string content(kMaxSpdyFrameChunkSize, 'a');
scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyPost(
- kRequestUrl, 1, kSpdyStreamInitialWindowSize + kUploadDataSize,
- LOWEST, NULL, 0));
+ kRequestUrl,
+ 1,
+ kSpdyStreamInitialWindowSize + kUploadDataSize,
+ LOWEST,
+ NULL,
+ 0));
// Full frames.
- scoped_ptr<SpdyFrame> body1(
- spdy_util_.ConstructSpdyBodyFrame(
- 1, content.c_str(), content.size(), false));
+ scoped_ptr<SpdyFrame> body1(spdy_util_.ConstructSpdyBodyFrame(
+ 1, content.c_str(), content.size(), false));
// Last frame to zero out the window size.
- scoped_ptr<SpdyFrame> body2(
- spdy_util_.ConstructSpdyBodyFrame(
- 1, content.c_str(), last_frame_size, false));
+ scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(
+ 1, content.c_str(), last_frame_size, false));
// Data frame to be sent once WINDOW_UPDATE frame is received.
scoped_ptr<SpdyFrame> body3(spdy_util_.ConstructSpdyBodyFrame(1, true));
@@ -6261,14 +5892,11 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) {
spdy_util_.ConstructSpdyWindowUpdate(1, kUploadDataSize));
scoped_ptr<SpdyFrame> reply(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
MockRead reads[] = {
- CreateMockRead(*session_window_update),
- CreateMockRead(*session_window_update),
- CreateMockRead(*window_update),
- CreateMockRead(*window_update),
- CreateMockRead(*reply),
- CreateMockRead(*body2),
- CreateMockRead(*body3),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*session_window_update),
+ CreateMockRead(*session_window_update), CreateMockRead(*window_update),
+ CreateMockRead(*window_update), CreateMockRead(*reply),
+ CreateMockRead(*body2), CreateMockRead(*body3),
+ MockRead(ASYNC, 0, 0) // EOF
};
// Skip the session window updates unless we're using SPDY/3.1 and
@@ -6278,8 +5906,8 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) {
// Force all writes to happen before any read, last write will not
// actually queue a frame, due to window size being 0.
- DelayedSocketData data(num_writes, reads + read_offset, num_reads,
- writes.get(), num_writes);
+ DelayedSocketData data(
+ num_writes, reads + read_offset, num_reads, writes.get(), num_writes);
ScopedVector<UploadElementReader> element_readers;
std::string upload_data_string(kSpdyStreamInitialWindowSize, 'a');
@@ -6292,8 +5920,8 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) {
request.method = "POST";
request.url = GURL("http://www.google.com/");
request.upload_data_stream = &upload_data_stream;
- NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.AddData(&data);
helper.RunPreTestSetup();
@@ -6317,7 +5945,7 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) {
// since we're send-stalled.
EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control());
- data.ForceNextRead(); // Read in WINDOW_UPDATE frame.
+ data.ForceNextRead(); // Read in WINDOW_UPDATE frame.
rv = callback.WaitForResult();
helper.VerifyDataConsumed();
}
@@ -6341,18 +5969,20 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlStallResumeAfterSettings) {
std::string content(kMaxSpdyFrameChunkSize, 'a');
scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyPost(
- kRequestUrl, 1, kSpdyStreamInitialWindowSize + kUploadDataSize,
- LOWEST, NULL, 0));
+ kRequestUrl,
+ 1,
+ kSpdyStreamInitialWindowSize + kUploadDataSize,
+ LOWEST,
+ NULL,
+ 0));
// Full frames.
- scoped_ptr<SpdyFrame> body1(
- spdy_util_.ConstructSpdyBodyFrame(
- 1, content.c_str(), content.size(), false));
+ scoped_ptr<SpdyFrame> body1(spdy_util_.ConstructSpdyBodyFrame(
+ 1, content.c_str(), content.size(), false));
// Last frame to zero out the window size.
- scoped_ptr<SpdyFrame> body2(
- spdy_util_.ConstructSpdyBodyFrame(
- 1, content.c_str(), last_frame_size, false));
+ scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(
+ 1, content.c_str(), last_frame_size, false));
// Data frame to be sent once SETTINGS frame is received.
scoped_ptr<SpdyFrame> body3(spdy_util_.ConstructSpdyBodyFrame(1, true));
@@ -6369,9 +5999,8 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlStallResumeAfterSettings) {
// Construct read frame for SETTINGS that gives enough space to upload the
// rest of the data.
SettingsMap settings;
- settings[SETTINGS_INITIAL_WINDOW_SIZE] =
- SettingsFlagsAndValue(
- SETTINGS_FLAG_NONE, kSpdyStreamInitialWindowSize * 2);
+ settings[SETTINGS_INITIAL_WINDOW_SIZE] = SettingsFlagsAndValue(
+ SETTINGS_FLAG_NONE, kSpdyStreamInitialWindowSize * 2);
scoped_ptr<SpdyFrame> settings_frame_large(
spdy_util_.ConstructSpdySettings(settings));
@@ -6392,8 +6021,10 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlStallResumeAfterSettings) {
// Force all writes to happen before any read, last write will not
// actually queue a frame, due to window size being 0.
- DeterministicSocketData data(vector_as_array(&reads), reads.size(),
- vector_as_array(&writes), writes.size());
+ DeterministicSocketData data(vector_as_array(&reads),
+ reads.size(),
+ vector_as_array(&writes),
+ writes.size());
ScopedVector<UploadElementReader> element_readers;
std::string upload_data_string(kSpdyStreamInitialWindowSize, 'a');
@@ -6406,8 +6037,8 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlStallResumeAfterSettings) {
request.method = "POST";
request.url = GURL("http://www.google.com/");
request.upload_data_stream = &upload_data_stream;
- NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.SetDeterministic();
helper.RunPreTestSetup();
helper.AddDeterministicData(&data);
@@ -6418,7 +6049,7 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlStallResumeAfterSettings) {
int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
- data.RunFor(num_writes - 1); // Write as much as we can.
+ data.RunFor(num_writes - 1); // Write as much as we can.
SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get());
ASSERT_TRUE(stream != NULL);
@@ -6433,7 +6064,7 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlStallResumeAfterSettings) {
// since we're send-stalled.
EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control());
- data.RunFor(6); // Read in SETTINGS frame to unstall.
+ data.RunFor(6); // Read in SETTINGS frame to unstall.
rv = callback.WaitForResult();
helper.VerifyDataConsumed();
// If stream is NULL, that means it was unstalled and closed.
@@ -6459,18 +6090,20 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlNegativeSendWindowSize) {
std::string content(kMaxSpdyFrameChunkSize, 'a');
scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyPost(
- kRequestUrl, 1, kSpdyStreamInitialWindowSize + kUploadDataSize,
- LOWEST, NULL, 0));
+ kRequestUrl,
+ 1,
+ kSpdyStreamInitialWindowSize + kUploadDataSize,
+ LOWEST,
+ NULL,
+ 0));
// Full frames.
- scoped_ptr<SpdyFrame> body1(
- spdy_util_.ConstructSpdyBodyFrame(
- 1, content.c_str(), content.size(), false));
+ scoped_ptr<SpdyFrame> body1(spdy_util_.ConstructSpdyBodyFrame(
+ 1, content.c_str(), content.size(), false));
// Last frame to zero out the window size.
- scoped_ptr<SpdyFrame> body2(
- spdy_util_.ConstructSpdyBodyFrame(
- 1, content.c_str(), last_frame_size, false));
+ scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(
+ 1, content.c_str(), last_frame_size, false));
// Data frame to be sent once SETTINGS frame is received.
scoped_ptr<SpdyFrame> body3(spdy_util_.ConstructSpdyBodyFrame(1, true));
@@ -6487,9 +6120,8 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlNegativeSendWindowSize) {
// Construct read frame for SETTINGS that makes the send_window_size
// negative.
SettingsMap new_settings;
- new_settings[SETTINGS_INITIAL_WINDOW_SIZE] =
- SettingsFlagsAndValue(
- SETTINGS_FLAG_NONE, kSpdyStreamInitialWindowSize / 2);
+ new_settings[SETTINGS_INITIAL_WINDOW_SIZE] = SettingsFlagsAndValue(
+ SETTINGS_FLAG_NONE, kSpdyStreamInitialWindowSize / 2);
scoped_ptr<SpdyFrame> settings_frame_small(
spdy_util_.ConstructSpdySettings(new_settings));
// Construct read frames for WINDOW_UPDATE that makes the send_window_size
@@ -6516,8 +6148,10 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlNegativeSendWindowSize) {
// Force all writes to happen before any read, last write will not
// actually queue a frame, due to window size being 0.
- DeterministicSocketData data(vector_as_array(&reads), reads.size(),
- vector_as_array(&writes), writes.size());
+ DeterministicSocketData data(vector_as_array(&reads),
+ reads.size(),
+ vector_as_array(&writes),
+ writes.size());
ScopedVector<UploadElementReader> element_readers;
std::string upload_data_string(kSpdyStreamInitialWindowSize, 'a');
@@ -6530,8 +6164,8 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlNegativeSendWindowSize) {
request.method = "POST";
request.url = GURL("http://www.google.com/");
request.upload_data_stream = &upload_data_stream;
- NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
- BoundNetLog(), GetParam(), NULL);
+ NormalSpdyTransactionHelper helper(
+ request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.SetDeterministic();
helper.RunPreTestSetup();
helper.AddDeterministicData(&data);
@@ -6542,7 +6176,7 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlNegativeSendWindowSize) {
int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
- data.RunFor(num_writes - 1); // Write as much as we can.
+ data.RunFor(num_writes - 1); // Write as much as we can.
SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get());
ASSERT_TRUE(stream != NULL);

Powered by Google App Engine
This is Rietveld 408576698