summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorrch <rch@chromium.org>2015-05-04 12:52:06 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-04 19:53:03 +0000
commit73e1742f4729161d16f70cbdad9d4c1c1836be52 (patch)
tree9e3ea3460d3f2d587100304837c849e515fc2209 /net
parent62a759e582743bca13f27d1ce5db3dc2fe66fbb6 (diff)
downloadchromium_src-73e1742f4729161d16f70cbdad9d4c1c1836be52.zip
chromium_src-73e1742f4729161d16f70cbdad9d4c1c1836be52.tar.gz
chromium_src-73e1742f4729161d16f70cbdad9d4c1c1836be52.tar.bz2
Convert SpdyNetworkTransactionTest to SequencedSocketData.
Reduces runtime to 11 seconds from 59 seconds on my linux workstation. There are still a number of tests which have not been unconverted because they make use of "CompleteRead" semantics which I still need to implement in SequencedSocketData. BUG=332112 Review URL: https://codereview.chromium.org/1114213005 Cr-Commit-Position: refs/heads/master@{#328171}
Diffstat (limited to 'net')
-rw-r--r--net/spdy/spdy_network_transaction_unittest.cc1045
1 files changed, 479 insertions, 566 deletions
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc
index 3c2073c..28f4a18 100644
--- a/net/spdy/spdy_network_transaction_unittest.cc
+++ b/net/spdy/spdy_network_transaction_unittest.cc
@@ -268,14 +268,9 @@ class SpdyNetworkTransactionTest
// should end with an empty read, and that read needs to be processed to
// 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)->AllReadDataConsumed())
- << "Read count: " << (*it)->read_count()
- << " Read index: " << (*it)->read_index();
- EXPECT_TRUE((*it)->AllWriteDataConsumed())
- << "Write count: " << (*it)->write_count()
- << " Write index: " << (*it)->write_index();
+ for (const SocketDataProvider* provider : data_vector_) {
+ EXPECT_TRUE(provider->AllReadDataConsumed());
+ EXPECT_TRUE(provider->AllWriteDataConsumed());
}
}
@@ -283,18 +278,13 @@ class SpdyNetworkTransactionTest
// processed. In that case we want to explicitly ensure that the reads were
// not processed.
void VerifyDataNotConsumed() {
- for (DataVector::iterator it = data_vector_.begin();
- it != data_vector_.end(); ++it) {
- EXPECT_TRUE(!(*it)->AllReadDataConsumed())
- << "Read count: " << (*it)->read_count()
- << " Read index: " << (*it)->read_index();
- EXPECT_TRUE(!(*it)->AllWriteDataConsumed())
- << "Write count: " << (*it)->write_count()
- << " Write index: " << (*it)->write_index();
+ for (const SocketDataProvider* provider : data_vector_) {
+ EXPECT_FALSE(provider->AllReadDataConsumed());
+ EXPECT_FALSE(provider->AllWriteDataConsumed());
}
}
- void RunToCompletion(StaticSocketDataProvider* data) {
+ void RunToCompletion(SocketDataProvider* data) {
RunPreTestSetup();
AddData(data);
RunDefaultTest();
@@ -302,7 +292,7 @@ class SpdyNetworkTransactionTest
}
void RunToCompletionWithSSLData(
- StaticSocketDataProvider* data,
+ SocketDataProvider* data,
scoped_ptr<SSLSocketDataProvider> ssl_provider) {
RunPreTestSetup();
AddDataWithSSLSocketDataProvider(data, ssl_provider.Pass());
@@ -310,7 +300,7 @@ class SpdyNetworkTransactionTest
VerifyDataConsumed();
}
- void AddData(StaticSocketDataProvider* data) {
+ void AddData(SocketDataProvider* data) {
scoped_ptr<SSLSocketDataProvider> ssl_provider(
new SSLSocketDataProvider(ASYNC, OK));
ssl_provider->cert =
@@ -319,7 +309,7 @@ class SpdyNetworkTransactionTest
}
void AddDataWithSSLSocketDataProvider(
- StaticSocketDataProvider* data,
+ SocketDataProvider* data,
scoped_ptr<SSLSocketDataProvider> ssl_provider) {
DCHECK(!deterministic_);
data_vector_.push_back(data);
@@ -387,16 +377,16 @@ class SpdyNetworkTransactionTest
}
private:
- typedef std::vector<StaticSocketDataProvider*> DataVector;
+ typedef std::vector<SocketDataProvider*> DataVector;
typedef ScopedVector<SSLSocketDataProvider> SSLVector;
- typedef ScopedVector<StaticSocketDataProvider> AlternateVector;
+ typedef ScopedVector<SocketDataProvider> AlternateVector;
typedef ScopedVector<DeterministicSocketData> AlternateDeterministicVector;
HttpRequestInfo request_;
RequestPriority priority_;
scoped_ptr<SpdySessionDependencies> session_deps_;
scoped_refptr<HttpNetworkSession> session_;
TransactionHelperResult output_;
- scoped_ptr<StaticSocketDataProvider> first_transaction_;
+ scoped_ptr<SocketDataProvider> first_transaction_;
SSLVector ssl_vector_;
TestCompletionCallback callback_;
scoped_ptr<HttpNetworkTransaction> trans_;
@@ -563,7 +553,7 @@ class SpdyNetworkTransactionTest
// to skip over data destined for other transactions while we consume
// the data for |trans|.
int ReadResult(HttpNetworkTransaction* trans,
- StaticSocketDataProvider* data,
+ SocketDataProvider* data,
std::string* result) {
const int kSize = 3000;
@@ -573,12 +563,6 @@ class SpdyNetworkTransactionTest
while (true) {
int rv = trans->Read(buf.get(), kSize, callback.callback());
if (rv == ERR_IO_PENDING) {
- // Multiple transactions may be in the data set. Keep pulling off
- // reads until we complete our callback.
- while (!callback.have_result()) {
- data->CompleteRead();
- base::RunLoop().RunUntilIdle();
- }
rv = callback.WaitForResult();
} else if (rv <= 0) {
break;
@@ -606,7 +590,7 @@ class SpdyNetworkTransactionTest
EXPECT_EQ(0u, spdy_session->num_unclaimed_pushed_streams());
}
- void RunServerPushTest(OrderedSocketData* data,
+ void RunServerPushTest(SequencedSocketData* data,
HttpResponseInfo* response,
HttpResponseInfo* push_response,
const std::string& expected) {
@@ -747,18 +731,17 @@ 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, 0)};
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, 1),
+ CreateMockRead(*body, 2),
+ MockRead(ASYNC, 0, 3) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -774,7 +757,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, 0)};
SpdyPriority spdy_prio = 0;
EXPECT_TRUE(GetSpdyPriority(spdy_util_.spdy_version(), *req, &spdy_prio));
@@ -824,13 +807,13 @@ 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, 1),
+ CreateMockRead(*body, 2),
+ MockRead(ASYNC, 0, 3) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes,
+ arraysize(writes));
HttpRequestInfo http_req = CreateGetRequest();
NormalSpdyTransactionHelper helper(http_req, p, BoundNetLog(),
@@ -873,27 +856,26 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGets) {
scoped_ptr<SpdyFrame> fbody3(spdy_util_.ConstructSpdyBodyFrame(5, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*req2),
- CreateMockWrite(*req3),
+ CreateMockWrite(*req, 0),
+ CreateMockWrite(*req2, 3),
+ CreateMockWrite(*req3, 6),
};
MockRead reads[] = {
- CreateMockRead(*resp, 1),
- CreateMockRead(*body),
- CreateMockRead(*resp2, 4),
- CreateMockRead(*body2),
- CreateMockRead(*resp3, 7),
- CreateMockRead(*body3),
+ CreateMockRead(*resp, 1),
+ CreateMockRead(*body, 2),
+ CreateMockRead(*resp2, 4),
+ CreateMockRead(*body2, 5),
+ CreateMockRead(*resp3, 7),
+ CreateMockRead(*body3, 8),
- CreateMockRead(*fbody),
- CreateMockRead(*fbody2),
- CreateMockRead(*fbody3),
+ CreateMockRead(*fbody, 9),
+ CreateMockRead(*fbody2, 10),
+ CreateMockRead(*fbody3, 11),
- MockRead(ASYNC, 0, 0), // EOF
+ MockRead(ASYNC, 0, 12), // EOF
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- OrderedSocketData data_placeholder(NULL, 0, NULL, 0);
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ SequencedSocketData data_placeholder(NULL, 0, NULL, 0);
BoundNetLog log;
TransactionHelperResult out;
@@ -964,23 +946,21 @@ TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBinding) {
scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*req2),
+ CreateMockWrite(*req, 0), CreateMockWrite(*req2, 3),
};
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, 2),
+ CreateMockRead(*resp2, 4),
+ CreateMockRead(*body2, 5),
+ CreateMockRead(*fbody, 6),
+ CreateMockRead(*fbody2, 7),
+ MockRead(ASYNC, 0, 8), // EOF
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING);
- OrderedSocketData data_placeholder(NULL, 0, NULL, 0);
+ SequencedSocketData data_placeholder(NULL, 0, NULL, 0);
data_placeholder.set_connect_data(never_finishing_connect);
BoundNetLog log;
@@ -1051,24 +1031,23 @@ TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBindingFromPreconnect) {
scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*req2),
+ CreateMockWrite(*req, 0), CreateMockWrite(*req2, 3),
};
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, 2),
+ CreateMockRead(*resp2, 4),
+ CreateMockRead(*body2, 5),
+ CreateMockRead(*fbody, 6),
+ CreateMockRead(*fbody2, 7),
+ MockRead(ASYNC, 0, 8), // EOF
};
- OrderedSocketData preconnect_data(reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData preconnect_data(reads, arraysize(reads), writes,
+ arraysize(writes));
MockConnect never_finishing_connect(ASYNC, ERR_IO_PENDING);
- OrderedSocketData data_placeholder(NULL, 0, NULL, 0);
+ SequencedSocketData data_placeholder(NULL, 0, NULL, 0);
data_placeholder.set_connect_data(never_finishing_connect);
BoundNetLog log;
@@ -1170,29 +1149,28 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrent) {
scoped_ptr<SpdyFrame> settings_ack(spdy_util_.ConstructSpdySettingsAck());
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*settings_ack, 2),
- CreateMockWrite(*req2),
- CreateMockWrite(*req3),
+ CreateMockWrite(*req, 0),
+ CreateMockWrite(*settings_ack, 5),
+ CreateMockWrite(*req2, 6),
+ CreateMockWrite(*req3, 10),
};
MockRead reads[] = {
- CreateMockRead(*settings_frame, 1),
- CreateMockRead(*resp),
- CreateMockRead(*body),
- CreateMockRead(*fbody),
- CreateMockRead(*resp2, 8),
- CreateMockRead(*body2),
- CreateMockRead(*fbody2),
- CreateMockRead(*resp3, 13),
- CreateMockRead(*body3),
- CreateMockRead(*fbody3),
+ CreateMockRead(*settings_frame, 1),
+ CreateMockRead(*resp, 2),
+ CreateMockRead(*body, 3),
+ CreateMockRead(*fbody, 4),
+ CreateMockRead(*resp2, 7),
+ CreateMockRead(*body2, 8),
+ CreateMockRead(*fbody2, 9),
+ CreateMockRead(*resp3, 11),
+ CreateMockRead(*body3, 12),
+ CreateMockRead(*fbody3, 13),
- MockRead(ASYNC, 0, 0), // EOF
+ MockRead(ASYNC, 0, 14), // EOF
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
BoundNetLog log;
TransactionHelperResult out;
@@ -1229,7 +1207,6 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrent) {
ASSERT_EQ(out.rv, ERR_IO_PENDING);
out.rv = callback2.WaitForResult();
ASSERT_EQ(OK, out.rv);
- EXPECT_EQ(7U, data.read_index()); // i.e. the third trans was queued
out.rv = callback3.WaitForResult();
ASSERT_EQ(OK, out.rv);
@@ -1303,39 +1280,40 @@ TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) {
scoped_ptr<SpdyFrame> settings_frame(
spdy_util_.ConstructSpdySettings(settings));
scoped_ptr<SpdyFrame> settings_ack(spdy_util_.ConstructSpdySettingsAck());
-
- MockWrite writes[] = { CreateMockWrite(*req),
- CreateMockWrite(*settings_ack, 2),
- CreateMockWrite(*req2),
- CreateMockWrite(*req4),
- CreateMockWrite(*req3),
+ MockWrite writes[] = {
+ CreateMockWrite(*req, 0),
+ CreateMockWrite(*settings_ack, 5),
+ // By making these synchronous, it guarantees that they are not *started*
+ // before their sequence number, which in turn verifies that only a single
+ // request is in-flight at a time.
+ CreateMockWrite(*req2, 6, SYNCHRONOUS),
+ CreateMockWrite(*req4, 10, SYNCHRONOUS),
+ CreateMockWrite(*req3, 13, SYNCHRONOUS),
};
MockRead reads[] = {
- CreateMockRead(*settings_frame, 1),
- CreateMockRead(*resp),
- CreateMockRead(*body),
- CreateMockRead(*fbody),
- CreateMockRead(*resp2, 8),
- CreateMockRead(*body2),
- CreateMockRead(*fbody2),
- CreateMockRead(*resp4, 14),
- CreateMockRead(*fbody4),
- CreateMockRead(*resp3, 17),
- CreateMockRead(*body3),
- CreateMockRead(*fbody3),
-
- MockRead(ASYNC, 0, 0), // EOF
- };
-
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
-
+ CreateMockRead(*settings_frame, 1),
+ CreateMockRead(*resp, 2),
+ CreateMockRead(*body, 3),
+ CreateMockRead(*fbody, 4),
+ CreateMockRead(*resp2, 7),
+ CreateMockRead(*body2, 8),
+ CreateMockRead(*fbody2, 9),
+ CreateMockRead(*resp4, 11),
+ CreateMockRead(*fbody4, 12),
+ CreateMockRead(*resp3, 14),
+ CreateMockRead(*body3, 15),
+ CreateMockRead(*fbody3, 16),
+
+ MockRead(ASYNC, 0, 17), // EOF
+ };
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
BoundNetLog log;
TransactionHelperResult out;
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunPreTestSetup();
helper.AddData(&data);
+
scoped_ptr<HttpNetworkTransaction> trans1(
new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get()));
scoped_ptr<HttpNetworkTransaction> trans2(
@@ -1370,7 +1348,6 @@ TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) {
out.rv = callback2.WaitForResult();
ASSERT_EQ(OK, out.rv);
- EXPECT_EQ(data.read_index(), 7U); // i.e. the third & fourth trans queued
out.rv = callback3.WaitForResult();
ASSERT_EQ(OK, out.rv);
@@ -1417,7 +1394,7 @@ TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) {
}
// Similar to ThreeGetsMaxConcurrrent above, however, this test
-// deletes a session in the middle of the transaction to insure
+// deletes a session in the middle of the transaction to ensure
// that we properly remove pendingcreatestream objects from
// the spdy_session
TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) {
@@ -1443,23 +1420,22 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) {
scoped_ptr<SpdyFrame> settings_ack(spdy_util_.ConstructSpdySettingsAck());
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*settings_ack, 2),
- CreateMockWrite(*req2),
+ CreateMockWrite(*req, 0),
+ CreateMockWrite(*settings_ack, 5),
+ CreateMockWrite(*req2, 6),
};
MockRead reads[] = {
- CreateMockRead(*settings_frame, 1),
- CreateMockRead(*resp),
- CreateMockRead(*body),
- CreateMockRead(*fbody),
- CreateMockRead(*resp2, 8),
- CreateMockRead(*body2),
- CreateMockRead(*fbody2),
- MockRead(ASYNC, 0, 0), // EOF
+ CreateMockRead(*settings_frame, 1),
+ CreateMockRead(*resp, 2),
+ CreateMockRead(*body, 3),
+ CreateMockRead(*fbody, 4),
+ CreateMockRead(*resp2, 7),
+ CreateMockRead(*body2, 8),
+ CreateMockRead(*fbody2, 9),
+ MockRead(ASYNC, 0, 10), // EOF
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
BoundNetLog log;
TransactionHelperResult out;
@@ -1496,8 +1472,6 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) {
out.rv = callback2.WaitForResult();
ASSERT_EQ(OK, out.rv);
- EXPECT_EQ(8U, data.read_index());
-
const HttpResponseInfo* response1 = trans1->GetResponseInfo();
ASSERT_TRUE(response1 != NULL);
EXPECT_TRUE(response1->headers.get() != NULL);
@@ -1575,22 +1549,21 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentSocketClose) {
scoped_ptr<SpdyFrame> settings_ack(spdy_util_.ConstructSpdySettingsAck());
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*settings_ack, 2),
- CreateMockWrite(*req2),
+ CreateMockWrite(*req, 0),
+ CreateMockWrite(*settings_ack, 5),
+ CreateMockWrite(*req2, 6),
};
MockRead reads[] = {
- CreateMockRead(*settings_frame, 1),
- CreateMockRead(*resp),
- CreateMockRead(*body),
- CreateMockRead(*fin_body),
- CreateMockRead(*resp2, 8),
- MockRead(ASYNC, ERR_CONNECTION_RESET, 0), // Abort!
+ CreateMockRead(*settings_frame, 1),
+ CreateMockRead(*resp, 2),
+ CreateMockRead(*body, 3),
+ CreateMockRead(*fin_body, 4),
+ CreateMockRead(*resp2, 7),
+ MockRead(ASYNC, ERR_CONNECTION_RESET, 8), // Abort!
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
- OrderedSocketData data_placeholder(NULL, 0, NULL, 0);
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ SequencedSocketData data_placeholder(NULL, 0, NULL, 0);
BoundNetLog log;
TransactionHelperResult out;
@@ -1628,8 +1601,6 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentSocketClose) {
out.rv = callback3.WaitForResult();
ASSERT_EQ(ERR_ABORTED, out.rv);
- EXPECT_EQ(6U, data.read_index());
-
const HttpResponseInfo* response1 = trans1.GetResponseInfo();
ASSERT_TRUE(response1 != NULL);
EXPECT_TRUE(response1->headers.get() != NULL);
@@ -1661,19 +1632,18 @@ TEST_P(SpdyNetworkTransactionTest, Put) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdySyn(1, *put_headers, LOWEST, false, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
+ CreateMockWrite(*req, 0),
};
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, 1),
+ CreateMockRead(*body, 2),
+ MockRead(ASYNC, 0, 3) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -1695,19 +1665,18 @@ TEST_P(SpdyNetworkTransactionTest, Head) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdySyn(1, *head_headers, LOWEST, false, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
+ CreateMockWrite(*req, 0),
};
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, 1),
+ CreateMockRead(*body, 2),
+ MockRead(ASYNC, 0, 3) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -1723,19 +1692,17 @@ TEST_P(SpdyNetworkTransactionTest, Post) {
GetDefaultUrl(), 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, 0), CreateMockWrite(*body, 1), // 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, 2),
+ CreateMockRead(*body, 3),
+ MockRead(ASYNC, 0, 4) // EOF
};
- DelayedSocketData data(2, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreatePostRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -1751,19 +1718,17 @@ TEST_P(SpdyNetworkTransactionTest, FilePost) {
GetDefaultUrl(), 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, 0), CreateMockWrite(*body, 1), // 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, 2),
+ CreateMockRead(*body, 3),
+ MockRead(ASYNC, 0, 4) // EOF
};
- DelayedSocketData data(2, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateFilePostRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -1776,13 +1741,13 @@ 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, 1) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateUnreadableFilePostRequest(),
DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
@@ -1801,19 +1766,17 @@ TEST_P(SpdyNetworkTransactionTest, ComplexPost) {
GetDefaultUrl(), 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, 0), CreateMockWrite(*body, 1), // 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, 2),
+ CreateMockRead(*body, 3),
+ MockRead(ASYNC, 0, 4) // EOF
};
- DelayedSocketData data(2, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateComplexPostRequest(),
DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
@@ -1829,19 +1792,17 @@ 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, 0), CreateMockWrite(*body, 1),
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp, 2),
+ CreateMockRead(*body, 3),
+ MockRead(ASYNC, 0, 4) // EOF
};
- DelayedSocketData data(2, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(),
DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
@@ -1866,23 +1827,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, 0),
+ CreateMockWrite(*chunk1, 1),
+ CreateMockWrite(*chunk2, 2),
+ CreateMockWrite(*chunk3, 3),
};
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, 4),
+ CreateMockRead(*chunk1, 5),
+ CreateMockRead(*chunk2, 6),
+ CreateMockRead(*chunk3, 7),
+ MockRead(ASYNC, 0, 8) // EOF
};
- DelayedSocketData data(4, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(),
DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
@@ -1930,19 +1890,18 @@ TEST_P(SpdyNetworkTransactionTest, NullPost) {
spdy_util_.ConstructSpdySyn(1, *req_block, LOWEST, false, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
+ CreateMockWrite(*req, 0),
};
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, 1),
+ CreateMockRead(*body, 2),
+ MockRead(ASYNC, 0, 3) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
@@ -1974,18 +1933,18 @@ TEST_P(SpdyNetworkTransactionTest, EmptyPost) {
spdy_util_.ConstructSpdySyn(1, *req_block, LOWEST, false, true));
MockWrite writes[] = {
- CreateMockWrite(*req),
+ CreateMockWrite(*req, 0),
};
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, 1),
+ CreateMockRead(*body, 2),
+ MockRead(ASYNC, 0, 3) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
@@ -2088,11 +2047,17 @@ 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, 1), MockRead(ASYNC, 0, 3) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads), NULL, 0);
+ 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));
+ MockWrite writes[] = {
+ CreateMockWrite(*req, 0), CreateMockWrite(*rst, 2),
+ };
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -2108,21 +2073,19 @@ TEST_P(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) {
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*rst),
+ CreateMockWrite(*req, 0), CreateMockWrite(*rst, 4),
};
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, 1),
+ CreateMockRead(*resp, 2),
+ CreateMockRead(*body, 3),
+ MockRead(ASYNC, 0, 5) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
@@ -2155,8 +2118,7 @@ TEST_P(SpdyNetworkTransactionTest, ResetReplyWithTransferEncoding) {
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*rst),
+ CreateMockWrite(*req, 0), CreateMockWrite(*rst, 2),
};
const char* const headers[] = {
@@ -2167,13 +2129,12 @@ TEST_P(SpdyNetworkTransactionTest, ResetReplyWithTransferEncoding) {
scoped_ptr<SpdyFrame> body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp, 1),
+ CreateMockRead(*body, 3),
+ MockRead(ASYNC, 0, 4) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -2191,8 +2152,7 @@ TEST_P(SpdyNetworkTransactionTest, ResetPushWithTransferEncoding) {
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*rst),
+ CreateMockWrite(*req, 0), CreateMockWrite(*rst, 4),
};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
@@ -2204,14 +2164,13 @@ TEST_P(SpdyNetworkTransactionTest, ResetPushWithTransferEncoding) {
GetDefaultUrlWithPath("/1").c_str()));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*push),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp, 1),
+ CreateMockRead(*push, 2),
+ CreateMockRead(*body, 3),
+ MockRead(ASYNC, 0, 5) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -2312,8 +2271,8 @@ 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, 0)};
// 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
@@ -2334,14 +2293,13 @@ TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) {
MockRead(ASYNC, 0, 0, 6), // EOF
};
MockRead reads2[] = {
- CreateMockRead(*resp, 2),
- MockRead(ASYNC, 0, 0, 3), // EOF
+ CreateMockRead(*resp, 1), MockRead(ASYNC, 0, 0, 2), // EOF
};
OrderedSocketData data(reads, arraysize(reads),
writes, arraysize(writes));
- DelayedSocketData data2(1, reads2, arraysize(reads2),
- writes2, arraysize(writes2));
+ SequencedSocketData data2(reads2, arraysize(reads2), writes2,
+ arraysize(writes2));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
@@ -2454,10 +2412,9 @@ TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectGetRequest) {
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));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ SequencedSocketData data2(reads2, arraysize(reads2), writes2,
+ arraysize(writes2));
// TODO(erikchen): Make test support SPDYSSL, SPDYNPN
TestDelegate d;
@@ -2537,10 +2494,9 @@ TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectServerPush) {
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));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ SequencedSocketData data2(reads2, arraysize(reads2), writes2,
+ arraysize(writes2));
// TODO(erikchen): Make test support SPDYSSL, SPDYNPN
TestDelegate d;
@@ -2577,8 +2533,6 @@ TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectServerPush) {
std::string contents2("hello!");
EXPECT_EQ(contents2, d2.data_received());
}
- data.CompleteRead();
- data2.CompleteRead();
EXPECT_TRUE(data.AllReadDataConsumed());
EXPECT_TRUE(data.AllWriteDataConsumed());
EXPECT_TRUE(data2.AllReadDataConsumed());
@@ -2591,7 +2545,7 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame) {
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
+ CreateMockWrite(*stream1_syn, 0),
};
scoped_ptr<SpdyFrame>
@@ -2603,18 +2557,17 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame) {
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, 1),
+ CreateMockRead(*stream2_syn, 2),
+ CreateMockRead(*stream1_body, 3, SYNCHRONOUS),
+ CreateMockRead(*stream2_body, 4),
+ MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5), // Force a pause
};
HttpResponseInfo response;
HttpResponseInfo response2;
std::string expected_push_result("pushed");
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
RunServerPushTest(&data,
&response,
&response2,
@@ -2635,7 +2588,7 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushBeforeSynReply) {
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
+ CreateMockWrite(*stream1_syn, 0),
};
scoped_ptr<SpdyFrame>
@@ -2647,18 +2600,17 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushBeforeSynReply) {
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, 1),
+ CreateMockRead(*stream1_reply, 2),
+ CreateMockRead(*stream1_body, 3, SYNCHRONOUS),
+ CreateMockRead(*stream2_body, 4),
+ MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5), // Force a pause
};
HttpResponseInfo response;
HttpResponseInfo response2;
std::string expected_push_result("pushed");
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
RunServerPushTest(&data,
&response,
&response2,
@@ -2676,7 +2628,9 @@ 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, 0),
+ };
scoped_ptr<SpdyFrame>
stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
@@ -2689,18 +2643,17 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame2) {
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, 1),
+ CreateMockRead(*stream2_syn, 2),
+ CreateMockRead(*stream2_body, 3),
+ CreateMockRead(*stream1_body, 4, SYNCHRONOUS),
+ MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5), // Force a pause
};
HttpResponseInfo response;
HttpResponseInfo response2;
std::string expected_push_result("pushed");
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
RunServerPushTest(&data,
&response,
&response2,
@@ -2721,7 +2674,7 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushServerAborted) {
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
+ CreateMockWrite(*stream1_syn, 0),
};
scoped_ptr<SpdyFrame>
@@ -2731,15 +2684,14 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushServerAborted) {
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, 1),
+ CreateMockRead(*stream2_syn, 2),
+ CreateMockRead(*stream2_rst, 3),
+ CreateMockRead(*stream1_body, 4, SYNCHRONOUS),
+ MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5), // Force a pause
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
@@ -2757,12 +2709,8 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushServerAborted) {
EXPECT_EQ(OK, rv);
// Verify that we consumed all test data.
- EXPECT_TRUE(data.AllReadDataConsumed())
- << "Read count: " << data.read_count()
- << " Read index: " << data.read_index();
- EXPECT_TRUE(data.AllWriteDataConsumed())
- << "Write count: " << data.write_count()
- << " Write index: " << data.write_index();
+ EXPECT_TRUE(data.AllReadDataConsumed());
+ EXPECT_TRUE(data.AllWriteDataConsumed());
// Verify the SYN_REPLY.
HttpResponseInfo response = *trans->GetResponseInfo();
@@ -2780,8 +2728,7 @@ 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, 0), CreateMockWrite(*stream3_rst, 4),
};
scoped_ptr<SpdyFrame>
@@ -2795,19 +2742,18 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushDuplicate) {
scoped_ptr<SpdyFrame> stream3_syn(spdy_util_.ConstructSpdyPush(
NULL, 0, 4, 1, GetDefaultUrlWithPath("/foo.dat").c_str()));
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, 1),
+ CreateMockRead(*stream2_syn, 2),
+ CreateMockRead(*stream3_syn, 3),
+ CreateMockRead(*stream1_body, 5),
+ CreateMockRead(*stream2_body, 6),
+ MockRead(SYNCHRONOUS, 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));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
RunServerPushTest(&data,
&response,
&response2,
@@ -2828,7 +2774,7 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrame) {
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
+ CreateMockWrite(*stream1_syn, 0),
};
scoped_ptr<SpdyFrame>
@@ -2851,21 +2797,20 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrame) {
new SpdyFrame(stream2_body_base->data() + 3 * kChunkSize,
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, 1),
+ CreateMockRead(*stream2_syn, 2),
+ CreateMockRead(*stream2_body1, 3),
+ CreateMockRead(*stream2_body2, 4),
+ CreateMockRead(*stream2_body3, 5),
+ CreateMockRead(*stream2_body4, 6),
+ CreateMockRead(*stream1_body, 7, SYNCHRONOUS),
+ MockRead(SYNCHRONOUS, ERR_IO_PENDING, 8), // 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));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
RunServerPushTest(&data, &response, &response2, kPushedData);
// Verify the SYN_REPLY.
@@ -2883,7 +2828,7 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrameInterrupted) {
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
+ CreateMockWrite(*stream1_syn, 0),
};
scoped_ptr<SpdyFrame>
@@ -2906,21 +2851,19 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrameInterrupted) {
new SpdyFrame(stream2_body_base->data() + 3 * kChunkSize,
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, 1),
+ CreateMockRead(*stream2_syn, 2),
+ CreateMockRead(*stream2_body1, 3),
+ CreateMockRead(*stream2_body2, 4),
+ CreateMockRead(*stream2_body3, 5),
+ CreateMockRead(*stream2_body4, 6),
+ CreateMockRead(*stream1_body.get(), 7, SYNCHRONOUS),
+ MockRead(SYNCHRONOUS, ERR_IO_PENDING, 8) // Force a pause.
};
HttpResponseInfo response;
HttpResponseInfo response2;
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
RunServerPushTest(&data, &response, &response2, kPushedData);
// Verify the SYN_REPLY.
@@ -2946,8 +2889,7 @@ 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, 0), CreateMockWrite(*stream2_rst, 3),
};
scoped_ptr<SpdyFrame>
@@ -2955,14 +2897,13 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID0) {
scoped_ptr<SpdyFrame> stream2_syn(spdy_util_.ConstructSpdyPush(
NULL, 0, 2, 0, GetDefaultUrlWithPath("/foo.dat").c_str()));
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, 1),
+ CreateMockRead(*stream2_syn, 2),
+ CreateMockRead(*stream1_body, 4),
+ MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5) // Force a pause
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
@@ -2980,12 +2921,8 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID0) {
EXPECT_EQ(OK, rv);
// Verify that we consumed all test data.
- EXPECT_TRUE(data.AllReadDataConsumed())
- << "Read count: " << data.read_count()
- << " Read index: " << data.read_index();
- EXPECT_TRUE(data.AllWriteDataConsumed())
- << "Write count: " << data.write_count()
- << " Write index: " << data.write_index();
+ EXPECT_TRUE(data.AllReadDataConsumed());
+ EXPECT_TRUE(data.AllWriteDataConsumed());
// Verify the SYN_REPLY.
HttpResponseInfo response = *trans->GetResponseInfo();
@@ -3001,8 +2938,7 @@ 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, 0), CreateMockWrite(*stream2_rst, 3),
};
scoped_ptr<SpdyFrame>
@@ -3010,14 +2946,13 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) {
scoped_ptr<SpdyFrame> stream2_syn(spdy_util_.ConstructSpdyPush(
NULL, 0, 2, 9, GetDefaultUrlWithPath("/foo.dat").c_str()));
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, 1),
+ CreateMockRead(*stream2_syn, 2),
+ CreateMockRead(*stream1_body, 4),
+ MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5), // Force a pause
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
@@ -3035,12 +2970,8 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) {
EXPECT_EQ(OK, rv);
// Verify that we consumed all test data.
- EXPECT_TRUE(data.AllReadDataConsumed())
- << "Read count: " << data.read_count()
- << " Read index: " << data.read_index();
- EXPECT_TRUE(data.AllWriteDataConsumed())
- << "Write count: " << data.write_count()
- << " Write index: " << data.write_index();
+ EXPECT_TRUE(data.AllReadDataConsumed());
+ EXPECT_TRUE(data.AllWriteDataConsumed());
// Verify the SYN_REPLY.
HttpResponseInfo response = *trans->GetResponseInfo();
@@ -3056,8 +2987,7 @@ 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, 0), CreateMockWrite(*stream2_rst, 3),
};
scoped_ptr<SpdyFrame>
@@ -3069,14 +2999,13 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) {
scoped_ptr<SpdyFrame> stream2_syn(spdy_util_.ConstructInitialSpdyPushFrame(
incomplete_headers.Pass(), 2, 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, 1),
+ CreateMockRead(*stream2_syn, 2),
+ CreateMockRead(*stream1_body, 4),
+ MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5) // Force a pause
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
@@ -3092,13 +3021,10 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) {
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
EXPECT_EQ(OK, rv);
+
// Verify that we consumed all test data.
- EXPECT_TRUE(data.AllReadDataConsumed())
- << "Read count: " << data.read_count()
- << " Read index: " << data.read_index();
- EXPECT_TRUE(data.AllWriteDataConsumed())
- << "Write count: " << data.write_count()
- << " Write index: " << data.write_index();
+ EXPECT_TRUE(data.AllReadDataConsumed());
+ EXPECT_TRUE(data.AllWriteDataConsumed());
// Verify the SYN_REPLY.
HttpResponseInfo response = *trans->GetResponseInfo();
@@ -3156,7 +3082,7 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) {
for (size_t i = 0; i < arraysize(test_cases); ++i) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req, 0)};
scoped_ptr<SpdyFrame> resp(
spdy_util_.ConstructSpdyGetSynReply(test_cases[i].extra_headers,
@@ -3164,13 +3090,13 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) {
1));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp, 1),
+ CreateMockRead(*body, 2),
+ MockRead(ASYNC, 0, 3) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes,
+ arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -3274,7 +3200,7 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) {
false, 1, LOWEST, true));
MockWrite writes[] = {
- CreateMockWrite(*frame_req),
+ CreateMockWrite(*frame_req, 0),
};
// Construct the reply.
@@ -3287,9 +3213,9 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) {
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
MockRead reads[] = {
- CreateMockRead(*frame_reply),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*frame_reply, 1),
+ CreateMockRead(*body, 2),
+ MockRead(ASYNC, 0, 3) // EOF
};
// Attach the headers to the request.
@@ -3302,8 +3228,8 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) {
request.extra_headers.SetHeader(header_key, header_value);
}
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes,
+ arraysize(writes));
NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -3376,8 +3302,7 @@ TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) {
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*rst),
+ CreateMockWrite(*req, 0), CreateMockWrite(*rst, 2),
};
// Construct the reply.
@@ -3386,12 +3311,11 @@ TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) {
test_cases[i].headers, test_cases[i].num_headers, &reply_headers);
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyReply(1, reply_headers));
MockRead reads[] = {
- CreateMockRead(*resp),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp, 1), MockRead(ASYNC, 0, 3) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes,
+ arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -3432,19 +3356,18 @@ TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionError) {
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*req),
- CreateMockWrite(*rst),
+ CreateMockWrite(*req, 0), CreateMockWrite(*rst, 3),
};
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, 1),
+ CreateMockRead(*body, 2),
+ MockRead(ASYNC, 0, 4) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes,
+ arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -3473,16 +3396,15 @@ TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionErrorSpdy4) {
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
scoped_ptr<SpdyFrame> goaway(spdy_util_.ConstructSpdyGoAway(
0, GOAWAY_COMPRESSION_ERROR, "Framer error: 5 (DECOMPRESS_FAILURE)."));
- MockWrite writes[] = {CreateMockWrite(*req), CreateMockWrite(*goaway)};
+ MockWrite writes[] = {CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 2)};
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, 1),
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -3499,14 +3421,14 @@ TEST_P(SpdyNetworkTransactionTest, GoAwayOnDecompressionFailure) {
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
scoped_ptr<SpdyFrame> goaway(spdy_util_.ConstructSpdyGoAway(
0, GOAWAY_COMPRESSION_ERROR, "Framer error: 5 (DECOMPRESS_FAILURE)."));
- MockWrite writes[] = {CreateMockWrite(*req), CreateMockWrite(*goaway)};
+ MockWrite writes[] = {CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 2)};
// Read HEADERS with corrupted payload.
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
memset(resp->data() + 12, 0xff, resp->size() - 12);
- MockRead reads[] = {CreateMockRead(*resp)};
+ MockRead reads[] = {CreateMockRead(*resp, 1)};
- DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(
CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -3519,7 +3441,7 @@ TEST_P(SpdyNetworkTransactionTest, GoAwayOnFrameSizeError) {
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
scoped_ptr<SpdyFrame> goaway(spdy_util_.ConstructSpdyGoAway(
0, GOAWAY_PROTOCOL_ERROR, "Framer error: 1 (INVALID_CONTROL_FRAME)."));
- MockWrite writes[] = {CreateMockWrite(*req), CreateMockWrite(*goaway)};
+ MockWrite writes[] = {CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 2)};
// Read WINDOW_UPDATE with incorrectly-sized payload.
// TODO(jgraettinger): SpdyFramer signals this as an INVALID_CONTROL_FRAME,
@@ -3529,9 +3451,9 @@ TEST_P(SpdyNetworkTransactionTest, GoAwayOnFrameSizeError) {
test::SetFrameLength(bad_window_update.get(),
bad_window_update->size() - 1,
spdy_util_.spdy_version());
- MockRead reads[] = {CreateMockRead(*bad_window_update)};
+ MockRead reads[] = {CreateMockRead(*bad_window_update, 1)};
- DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(
CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -3580,17 +3502,19 @@ TEST_P(SpdyNetworkTransactionTest, PartialWrite) {
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
const int kChunks = 5;
scoped_ptr<MockWrite[]> writes(ChopWriteFrame(*req.get(), kChunks));
+ for (int i = 0; i < kChunks; ++i) {
+ writes[i].sequence_number = i;
+ }
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, kChunks),
+ CreateMockRead(*body, kChunks + 1),
+ MockRead(ASYNC, 0, kChunks + 2) // EOF
};
- DelayedSocketData data(kChunks, reads, arraysize(reads),
- writes.get(), kChunks);
+ SequencedSocketData data(reads, arraysize(reads), writes.get(), kChunks);
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -3611,16 +3535,16 @@ TEST_P(SpdyNetworkTransactionTest, DecompressFailureOnSynReply) {
spdy_util_.ConstructSpdyGet(NULL, 0, true, 1, LOWEST, true));
scoped_ptr<SpdyFrame> goaway(spdy_util_.ConstructSpdyGoAway(
0, GOAWAY_COMPRESSION_ERROR, "Framer error: 5 (DECOMPRESS_FAILURE)."));
- MockWrite writes[] = {CreateMockWrite(*compressed), CreateMockWrite(*goaway)};
+ MockWrite writes[] = {CreateMockWrite(*compressed, 0),
+ CreateMockWrite(*goaway, 2)};
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, 1),
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
SpdySessionDependencies* session_deps =
CreateSpdySessionDependencies(GetParam());
session_deps->enable_compression = true;
@@ -3639,20 +3563,19 @@ TEST_P(SpdyNetworkTransactionTest, NetLog) {
};
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(kExtraHeaders, 1, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req, 0)};
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, 1),
+ CreateMockRead(*body, 2),
+ MockRead(ASYNC, 0, 3) // EOF
};
BoundTestNetLog log;
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequestWithUserAgent(),
DEFAULT_PRIORITY,
log.bound(), GetParam(), NULL);
@@ -3731,7 +3654,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, 0)};
// 2 data frames in a single read.
scoped_ptr<SpdyFrame> data_frame_1(
@@ -3920,7 +3843,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, 0)};
// 5 data frames in a single read.
scoped_ptr<SpdyFrame> reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
@@ -3936,12 +3859,11 @@ TEST_P(SpdyNetworkTransactionTest, BufferedAll) {
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, 1),
+ MockRead(ASYNC, 0, 2) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
@@ -4194,7 +4116,7 @@ TEST_P(SpdyNetworkTransactionTest, SettingsSaved) {
// Construct the request.
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = { CreateMockWrite(*req) };
+ MockWrite writes[] = {CreateMockWrite(*req, 0)};
// Construct the reply.
scoped_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock());
@@ -4227,14 +4149,13 @@ 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, 1),
+ CreateMockRead(*body, 2),
+ CreateMockRead(*settings_frame, 3),
+ MockRead(ASYNC, 0, 4) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
helper.AddData(&data);
helper.RunDefaultTest();
helper.VerifyDataConsumed();
@@ -4405,15 +4326,14 @@ 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, 0)};
scoped_ptr<SpdyFrame> go_away(spdy_util_.ConstructSpdyGoAway());
MockRead reads[] = {
- CreateMockRead(*go_away),
+ CreateMockRead(*go_away, 1),
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.AddData(&data);
@@ -4425,16 +4345,14 @@ 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, 0)};
scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
MockRead reads[] = {
- CreateMockRead(*resp),
- MockRead(SYNCHRONOUS, 0, 0) // EOF
+ CreateMockRead(*resp, 1), MockRead(SYNCHRONOUS, 0, 2) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
BoundNetLog log;
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
log, GetParam(), NULL);
@@ -4472,9 +4390,9 @@ TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredError) {
scoped_ptr<SpdyFrame> go_away(spdy_util_.ConstructSpdyGoAway(
0, GOAWAY_HTTP_1_1_REQUIRED, "Try again using HTTP/1.1 please."));
MockRead reads[] = {
- CreateMockRead(*go_away),
+ CreateMockRead(*go_away, 0),
};
- DelayedSocketData data(0, reads, arraysize(reads), nullptr, 0);
+ SequencedSocketData data(reads, arraysize(reads), nullptr, 0);
helper.RunToCompletion(&data);
TransactionHelperResult out = helper.output();
@@ -4508,12 +4426,12 @@ TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredRetry) {
scoped_ptr<SpdyHeaderBlock> headers(spdy_util_.ConstructGetHeaderBlock(url));
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdySyn(1, *headers, LOWEST, false, true));
- MockWrite writes0[] = {CreateMockWrite(*req)};
+ MockWrite writes0[] = {CreateMockWrite(*req, 0)};
scoped_ptr<SpdyFrame> go_away(spdy_util_.ConstructSpdyGoAway(
0, GOAWAY_HTTP_1_1_REQUIRED, "Try again using HTTP/1.1 please."));
- MockRead reads0[] = {CreateMockRead(*go_away)};
- DelayedSocketData data0(1, reads0, arraysize(reads0), writes0,
- arraysize(writes0));
+ MockRead reads0[] = {CreateMockRead(*go_away, 1)};
+ SequencedSocketData data0(reads0, arraysize(reads0), writes0,
+ arraysize(writes0));
scoped_ptr<SSLSocketDataProvider> ssl_provider0(
new SSLSocketDataProvider(ASYNC, OK));
@@ -4527,16 +4445,16 @@ TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredRetry) {
helper.AddDataWithSSLSocketDataProvider(&data0, ssl_provider0.Pass());
// Second socket: falling back to HTTP/1.1.
- MockWrite writes1[] = {MockWrite(
- "GET / HTTP/1.1\r\n"
- "Host: www.example.org\r\n"
- "Connection: keep-alive\r\n\r\n")};
- MockRead reads1[] = {MockRead(
- "HTTP/1.1 200 OK\r\n"
- "Content-Length: 5\r\n\r\n"
- "hello")};
- DelayedSocketData data1(1, reads1, arraysize(reads1), writes1,
- arraysize(writes1));
+ MockWrite writes1[] = {MockWrite(ASYNC, 0,
+ "GET / HTTP/1.1\r\n"
+ "Host: www.example.org\r\n"
+ "Connection: keep-alive\r\n\r\n")};
+ MockRead reads1[] = {MockRead(ASYNC, 1,
+ "HTTP/1.1 200 OK\r\n"
+ "Content-Length: 5\r\n\r\n"
+ "hello")};
+ SequencedSocketData data1(reads1, arraysize(reads1), writes1,
+ arraysize(writes1));
scoped_ptr<SSLSocketDataProvider> ssl_provider1(
new SSLSocketDataProvider(ASYNC, OK));
@@ -4599,12 +4517,12 @@ TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredProxyRetry) {
// First socket: HTTP/2 CONNECT rejected with HTTP_1_1_REQUIRED.
scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyConnect(
nullptr, 0, 1, LOWEST, HostPortPair("www.example.org", 443)));
- MockWrite writes0[] = {CreateMockWrite(*req)};
+ MockWrite writes0[] = {CreateMockWrite(*req, 0)};
scoped_ptr<SpdyFrame> go_away(spdy_util_.ConstructSpdyGoAway(
0, GOAWAY_HTTP_1_1_REQUIRED, "Try again using HTTP/1.1 please."));
- MockRead reads0[] = {CreateMockRead(*go_away)};
- DelayedSocketData data0(1, reads0, arraysize(reads0), writes0,
- arraysize(writes0));
+ MockRead reads0[] = {CreateMockRead(*go_away, 1)};
+ SequencedSocketData data0(reads0, arraysize(reads0), writes0,
+ arraysize(writes0));
scoped_ptr<SSLSocketDataProvider> ssl_provider0(
new SSLSocketDataProvider(ASYNC, OK));
@@ -4619,25 +4537,25 @@ TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredProxyRetry) {
// Second socket: retry using HTTP/1.1.
MockWrite writes1[] = {
- MockWrite(ASYNC, 1,
+ MockWrite(ASYNC, 0,
"CONNECT www.example.org:443 HTTP/1.1\r\n"
"Host: www.example.org\r\n"
"Proxy-Connection: keep-alive\r\n\r\n"),
- MockWrite(ASYNC, 3,
+ MockWrite(ASYNC, 2,
"GET / HTTP/1.1\r\n"
"Host: www.example.org\r\n"
"Connection: keep-alive\r\n\r\n"),
};
MockRead reads1[] = {
- MockRead(ASYNC, 2, "HTTP/1.1 200 OK\r\n\r\n"),
- MockRead(ASYNC, 4,
+ MockRead(ASYNC, 1, "HTTP/1.1 200 OK\r\n\r\n"),
+ MockRead(ASYNC, 3,
"HTTP/1.1 200 OK\r\n"
"Content-Length: 5\r\n\r\n"
"hello"),
};
- DelayedSocketData data1(1, reads1, arraysize(reads1), writes1,
- arraysize(writes1));
+ SequencedSocketData data1(reads1, arraysize(reads1), writes1,
+ arraysize(writes1));
scoped_ptr<SSLSocketDataProvider> ssl_provider1(
new SSLSocketDataProvider(ASYNC, OK));
@@ -4711,7 +4629,7 @@ TEST_P(SpdyNetworkTransactionTest, ProxyConnect) {
CreateMockRead(*body.get(), 4),
MockRead(ASYNC, 0, 0, 5),
};
- scoped_ptr<OrderedSocketData> data(new OrderedSocketData(
+ scoped_ptr<SequencedSocketData> data(new SequencedSocketData(
reads, arraysize(reads), writes, arraysize(writes)));
helper.AddData(data.get());
@@ -4761,19 +4679,17 @@ TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
MockWrite writes[] = {
- CreateMockWrite(*req, 1),
+ CreateMockWrite(*req, 0),
};
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, 1),
+ CreateMockRead(*body, 2),
+ MockRead(SYNCHRONOUS, ERR_IO_PENDING, 3), // Force a pause
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
helper.AddData(&data);
HttpNetworkTransaction* trans = helper.trans();
@@ -4828,7 +4744,7 @@ TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) {
MockRead(ASYNC, 0, 5) // EOF
};
- scoped_ptr<OrderedSocketData> data_proxy(new OrderedSocketData(
+ scoped_ptr<SequencedSocketData> data_proxy(new SequencedSocketData(
reads2, arraysize(reads2), writes2, arraysize(writes2)));
// Create another request to www.example.org, but this time through a proxy.
@@ -4868,7 +4784,6 @@ TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) {
ASSERT_EQ(OK, ReadTransaction(trans_proxy, &response_data));
EXPECT_EQ("hello!", response_data);
- data.CompleteRead();
helper_proxy.VerifyDataConsumed();
}
@@ -4880,16 +4795,16 @@ 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, 0),
+ CreateMockRead(*body, 1),
+ MockRead(ASYNC, ERR_IO_PENDING, 2),
+ MockRead(ASYNC, ERR_CONNECTION_RESET, 3),
};
MockRead reads2[] = {
- CreateMockRead(*resp),
- CreateMockRead(*body),
- MockRead(ASYNC, 0, 0) // EOF
+ CreateMockRead(*resp, 0),
+ CreateMockRead(*body, 1),
+ MockRead(ASYNC, 0, 2) // EOF
};
// This test has a couple of variants.
@@ -4958,18 +4873,18 @@ TEST_P(SpdyNetworkTransactionTest, SpdyOnOffToggle) {
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, 0)};
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, 1),
+ CreateMockRead(*body, 2),
+ MockRead(ASYNC, 0, 3) // EOF
};
- DelayedSocketData data(1, spdy_reads, arraysize(spdy_reads),
- spdy_writes, arraysize(spdy_writes));
+ SequencedSocketData data(spdy_reads, arraysize(spdy_reads), spdy_writes,
+ arraysize(spdy_writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -4979,12 +4894,20 @@ TEST_P(SpdyNetworkTransactionTest, SpdyOnOffToggle) {
EXPECT_EQ("hello!", out.response_data);
HttpStreamFactory::set_spdy_enabled(false);
+ MockWrite http_writes[] = {
+ MockWrite(SYNCHRONOUS, 0,
+ "GET / HTTP/1.1\r\n"
+ "Host: www.example.org\r\n"
+ "Connection: keep-alive\r\n\r\n"),
+ };
+
MockRead http_reads[] = {
- MockRead("HTTP/1.1 200 OK\r\n\r\n"),
- MockRead("hello from http"),
- MockRead(SYNCHRONOUS, OK),
+ MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n\r\n"),
+ MockRead(SYNCHRONOUS, 2, "hello from http"),
+ MockRead(SYNCHRONOUS, OK, 3),
};
- DelayedSocketData data2(1, http_reads, arraysize(http_reads), NULL, 0);
+ SequencedSocketData data2(http_reads, arraysize(http_reads), http_writes,
+ arraysize(http_writes));
NormalSpdyTransactionHelper helper2(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper2.SetSpdyDisabled();
@@ -5013,8 +4936,7 @@ TEST_P(SpdyNetworkTransactionTest, SpdyBasicAuth) {
arraysize(kExtraAuthorizationHeaders) / 2,
false, 3, LOWEST, true));
MockWrite spdy_writes[] = {
- CreateMockWrite(*req_get, 1),
- CreateMockWrite(*req_get_authorization, 4),
+ CreateMockWrite(*req_get, 0), CreateMockWrite(*req_get_authorization, 3),
};
// The first response is a 401 authentication challenge, and the second
@@ -5036,15 +4958,15 @@ 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, 1),
+ CreateMockRead(*body_authentication, 2),
+ CreateMockRead(*resp_data, 4),
+ CreateMockRead(*body_data, 5),
+ MockRead(ASYNC, 0, 6),
};
- OrderedSocketData data(spdy_reads, arraysize(spdy_reads),
- spdy_writes, arraysize(spdy_writes));
+ SequencedSocketData data(spdy_reads, arraysize(spdy_reads), spdy_writes,
+ arraysize(spdy_writes));
HttpRequestInfo request(CreateGetRequest());
BoundNetLog net_log;
NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY,
@@ -5095,7 +5017,7 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushWithHeaders) {
scoped_ptr<SpdyFrame> stream1_body(
spdy_util_.ConstructSpdyBodyFrame(1, true));
MockWrite writes[] = {
- CreateMockWrite(*stream1_syn, 1),
+ CreateMockWrite(*stream1_syn, 0),
};
scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock());
@@ -5124,19 +5046,18 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushWithHeaders) {
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, 1),
+ CreateMockRead(*stream2_syn, 2),
+ CreateMockRead(*stream2_headers, 3),
+ CreateMockRead(*stream1_body, 4, SYNCHRONOUS),
+ CreateMockRead(*stream2_body, 5),
+ MockRead(SYNCHRONOUS, 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));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
RunServerPushTest(&data,
&response,
&response2,
@@ -5523,7 +5444,7 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) {
scoped_ptr<SpdyFrame> rst(
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
- CreateMockWrite(*req), CreateMockWrite(*rst),
+ CreateMockWrite(*req, 0), CreateMockWrite(*rst, 4),
};
scoped_ptr<SpdyFrame> stream1_reply(
@@ -5542,14 +5463,13 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) {
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, 1),
+ CreateMockRead(*stream1_headers, 2),
+ CreateMockRead(*stream1_body, 3),
+ MockRead(ASYNC, 0, 5) // EOF
};
- DelayedSocketData data(1, reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -5563,8 +5483,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, 0), CreateMockWrite(*rst, 4),
};
scoped_ptr<SpdyFrame> stream1_reply(
@@ -5585,11 +5504,11 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyWithLateHeaders) {
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, 1),
+ CreateMockRead(*stream1_body, 2),
+ CreateMockRead(*stream1_headers, 3),
+ CreateMockRead(*stream1_body2, 5),
+ MockRead(ASYNC, 0, 6) // EOF
};
DelayedSocketData data(1, reads, arraysize(reads),
@@ -5641,8 +5560,7 @@ 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, 0), CreateMockWrite(*push_rst, 3),
};
scoped_ptr<SpdyFrame>
@@ -5661,16 +5579,16 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) {
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, 1),
+ CreateMockRead(*stream2_syn, 2),
+ CreateMockRead(*stream1_body, 4),
+ CreateMockRead(*stream2_body, 5),
+ MockRead(SYNCHRONOUS, ERR_IO_PENDING, 6), // Force a pause
};
HttpResponseInfo response;
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes,
+ arraysize(writes));
HttpRequestInfo request;
request.method = "GET";
@@ -5724,8 +5642,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, 0), CreateMockWrite(*req2, 2),
};
scoped_ptr<SpdyFrame> refused(
@@ -5733,14 +5650,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, 1),
+ CreateMockRead(*resp, 3),
+ CreateMockRead(*body, 4),
+ MockRead(ASYNC, 0, 5) // EOF
};
- OrderedSocketData data(reads, arraysize(reads),
- writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
@@ -5758,12 +5674,8 @@ TEST_P(SpdyNetworkTransactionTest, RetryAfterRefused) {
EXPECT_EQ(OK, rv);
// Verify that we consumed all test data.
- EXPECT_TRUE(data.AllReadDataConsumed())
- << "Read count: " << data.read_count()
- << " Read index: " << data.read_index();
- EXPECT_TRUE(data.AllWriteDataConsumed())
- << "Write count: " << data.write_count()
- << " Write index: " << data.write_index();
+ EXPECT_TRUE(data.AllReadDataConsumed());
+ EXPECT_TRUE(data.AllWriteDataConsumed());
// Verify the SYN_REPLY.
HttpResponseInfo response = *trans->GetResponseInfo();
@@ -6546,7 +6458,7 @@ TEST_P(SpdyNetworkTransactionTest, GoAwayOnOddPushStreamId) {
CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 2),
};
- DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(
CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -6580,7 +6492,7 @@ TEST_P(SpdyNetworkTransactionTest,
CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 3),
};
- DelayedSocketData data(1, reads, arraysize(reads), writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
NormalSpdyTransactionHelper helper(
CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL);
helper.RunToCompletion(&data);
@@ -6595,17 +6507,18 @@ class SpdyNetworkTransactionNoTLSUsageCheckTest
// Construct the request.
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
- MockWrite writes[] = {CreateMockWrite(*req)};
+ MockWrite writes[] = {CreateMockWrite(*req, 0)};
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, 1),
+ CreateMockRead(*body, 2),
+ MockRead(ASYNC, 0, 3) // EOF
};
- DelayedSocketData data(
- 1, reads, arraysize(reads), writes, arraysize(writes));
+ SequencedSocketData data(reads, arraysize(reads), writes,
+ arraysize(writes));
HttpRequestInfo request;
request.method = "GET";
request.url = GURL("https://www.example.org/");
@@ -6657,7 +6570,7 @@ class SpdyNetworkTransactionTLSUsageCheckTest
spdy_util_.ConstructSpdyGoAway(0, GOAWAY_INADEQUATE_SECURITY, ""));
MockWrite writes[] = {CreateMockWrite(*goaway)};
- DelayedSocketData data(1, NULL, 0, writes, arraysize(writes));
+ StaticSocketDataProvider data(NULL, 0, writes, arraysize(writes));
HttpRequestInfo request;
request.method = "GET";
request.url = GURL("https://www.example.org/");