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

Side by Side Diff: net/spdy/spdy_network_transaction_spdy3_unittest.cc

Issue 10382107: Change the stream_id for streams which are serialized out of order. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add spdy2 version of the test. Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 6128 matching lines...) Expand 10 before | Expand all | Expand 10 after
6139 << data->write_count() 6139 << data->write_count()
6140 << " Write index: " 6140 << " Write index: "
6141 << data->write_index(); 6141 << data->write_index();
6142 6142
6143 // Verify the SYN_REPLY. 6143 // Verify the SYN_REPLY.
6144 HttpResponseInfo response = *trans->GetResponseInfo(); 6144 HttpResponseInfo response = *trans->GetResponseInfo();
6145 EXPECT_TRUE(response.headers != NULL); 6145 EXPECT_TRUE(response.headers != NULL);
6146 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 6146 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
6147 } 6147 }
6148 6148
6149 TEST_P(SpdyNetworkTransactionSpdy3Test, OutOfOrderSynStream) {
6150 // This first request will start to establish the SpdySession.
6151 // Then we will start the second (MEDIUM priority) and then third
6152 // (HIGHEST priority) request in such a way that the third will actually
6153 // start before the second, causing the second to be re-numbered.
6154 scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
6155 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 5, HIGHEST));
6156 scoped_ptr<SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 7, MEDIUM));
6157 MockWrite writes[] = {
6158 CreateMockWrite(*req1, 0),
6159 CreateMockWrite(*req2, 3),
6160 CreateMockWrite(*req3, 4),
6161 };
6162
6163 scoped_ptr<SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1));
6164 scoped_ptr<SpdyFrame> body1(ConstructSpdyBodyFrame(1, true));
6165 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 7));
6166 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(7, true));
6167 scoped_ptr<SpdyFrame> resp3(ConstructSpdyGetSynReply(NULL, 0, 5));
6168 scoped_ptr<SpdyFrame> body3(ConstructSpdyBodyFrame(5, true));
6169 MockRead reads[] = {
6170 CreateMockRead(*resp1, 1),
6171 CreateMockRead(*body1, 2),
6172 CreateMockRead(*resp2, 5),
6173 CreateMockRead(*body2, 6),
6174 CreateMockRead(*resp3, 7),
6175 CreateMockRead(*body3, 8),
6176 MockRead(ASYNC, 0, 9) // EOF
6177 };
6178
6179 scoped_refptr<DeterministicSocketData> data(
6180 new DeterministicSocketData(reads, arraysize(reads),
6181 writes, arraysize(writes)));
6182 NormalSpdyTransactionHelper helper(CreateGetRequest(),
6183 BoundNetLog(), GetParam(), NULL);
6184 helper.SetDeterministic();
6185 helper.RunPreTestSetup();
6186 helper.AddDeterministicData(data.get());
6187
6188 // Start the first transaction to set up the SpdySession
6189 HttpNetworkTransaction* trans = helper.trans();
6190 TestCompletionCallback callback;
6191 HttpRequestInfo info1 = CreateGetRequest();
6192 info1.priority = LOWEST;
6193 int rv = trans->Start(&info1, callback.callback(), BoundNetLog());
6194 EXPECT_EQ(ERR_IO_PENDING, rv);
6195
6196 // Run the message loop, but do not allow the write to complete.
6197 // This leaves the SpdySession with a write pending, which prevents
6198 // SpdySession from attempting subsequent writes until this write completes.
6199 MessageLoop::current()->RunAllPending();
6200
6201 // Now, start both new transactions
6202 HttpRequestInfo info2 = CreateGetRequest();
6203 info2.priority = MEDIUM;
6204 TestCompletionCallback callback2;
6205 scoped_ptr<HttpNetworkTransaction> trans2(
6206 new HttpNetworkTransaction(helper.session()));
6207 rv = trans2->Start(&info2, callback2.callback(), BoundNetLog());
6208 EXPECT_EQ(ERR_IO_PENDING, rv);
6209 MessageLoop::current()->RunAllPending();
6210
6211 HttpRequestInfo info3 = CreateGetRequest();
6212 info3.priority = HIGHEST;
6213 TestCompletionCallback callback3;
6214 scoped_ptr<HttpNetworkTransaction> trans3(
6215 new HttpNetworkTransaction(helper.session()));
6216 rv = trans3->Start(&info3, callback3.callback(), BoundNetLog());
6217 EXPECT_EQ(ERR_IO_PENDING, rv);
6218 MessageLoop::current()->RunAllPending();
6219
6220 // We now have two SYN_STREAM frames queued up which will be
6221 // dequeued only once the first write completes, which we
6222 // now allow to happen.
6223 data->RunFor(2);
6224 EXPECT_EQ(OK, callback.WaitForResult());
6225
6226 // And now we can allow everything else to run to completion.
6227 data->SetStop(10);
6228 data->Run();
6229 EXPECT_EQ(OK, callback2.WaitForResult());
6230 EXPECT_EQ(OK, callback3.WaitForResult());
6231
6232 helper.VerifyDataConsumed();
6233 }
6234
6149 } // namespace net 6235 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698