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

Side by Side Diff: net/spdy/spdy_network_transaction_spdy2_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 5545 matching lines...) Expand 10 before | Expand all | Expand 10 after
5556 << data->write_count() 5556 << data->write_count()
5557 << " Write index: " 5557 << " Write index: "
5558 << data->write_index(); 5558 << data->write_index();
5559 5559
5560 // Verify the SYN_REPLY. 5560 // Verify the SYN_REPLY.
5561 HttpResponseInfo response = *trans->GetResponseInfo(); 5561 HttpResponseInfo response = *trans->GetResponseInfo();
5562 EXPECT_TRUE(response.headers != NULL); 5562 EXPECT_TRUE(response.headers != NULL);
5563 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5563 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5564 } 5564 }
5565 5565
5566 TEST_P(SpdyNetworkTransactionSpdy2Test, OutOfOrderSynStream) {
5567 // This first request will start to establish the SpdySession.
5568 // Then we will start the second (MEDIUM priority) and then third
5569 // (HIGHEST priority) request in such a way that the third will actually
5570 // start before the second, causing the second to be re-numbered.
5571 scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5572 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 5, HIGHEST));
5573 scoped_ptr<SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 7, MEDIUM));
5574 MockWrite writes[] = {
5575 CreateMockWrite(*req1, 0),
5576 CreateMockWrite(*req2, 3),
5577 CreateMockWrite(*req3, 4),
5578 };
5579
5580 scoped_ptr<SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1));
5581 scoped_ptr<SpdyFrame> body1(ConstructSpdyBodyFrame(1, true));
5582 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 7));
5583 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(7, true));
5584 scoped_ptr<SpdyFrame> resp3(ConstructSpdyGetSynReply(NULL, 0, 5));
5585 scoped_ptr<SpdyFrame> body3(ConstructSpdyBodyFrame(5, true));
5586 MockRead reads[] = {
5587 CreateMockRead(*resp1, 1),
5588 CreateMockRead(*body1, 2),
5589 CreateMockRead(*resp2, 5),
5590 CreateMockRead(*body2, 6),
5591 CreateMockRead(*resp3, 7),
5592 CreateMockRead(*body3, 8),
5593 MockRead(ASYNC, 0, 9) // EOF
5594 };
5595
5596 scoped_refptr<DeterministicSocketData> data(
5597 new DeterministicSocketData(reads, arraysize(reads),
5598 writes, arraysize(writes)));
5599 NormalSpdyTransactionHelper helper(CreateGetRequest(),
5600 BoundNetLog(), GetParam(), NULL);
5601 helper.SetDeterministic();
5602 helper.RunPreTestSetup();
5603 helper.AddDeterministicData(data.get());
5604
5605 // Start the first transaction to set up the SpdySession
5606 HttpNetworkTransaction* trans = helper.trans();
5607 TestCompletionCallback callback;
5608 HttpRequestInfo info1 = CreateGetRequest();
5609 info1.priority = LOWEST;
5610 int rv = trans->Start(&info1, callback.callback(), BoundNetLog());
5611 EXPECT_EQ(ERR_IO_PENDING, rv);
5612
5613 // Run the message loop, but do not allow the write to complete.
5614 // This leaves the SpdySession with a write pending, which prevents
5615 // SpdySession from attempting subsequent writes until this write completes.
5616 MessageLoop::current()->RunAllPending();
5617
5618 // Now, start both new transactions
5619 HttpRequestInfo info2 = CreateGetRequest();
5620 info2.priority = MEDIUM;
5621 TestCompletionCallback callback2;
5622 scoped_ptr<HttpNetworkTransaction> trans2(
5623 new HttpNetworkTransaction(helper.session()));
5624 rv = trans2->Start(&info2, callback2.callback(), BoundNetLog());
5625 EXPECT_EQ(ERR_IO_PENDING, rv);
5626 MessageLoop::current()->RunAllPending();
5627
5628 HttpRequestInfo info3 = CreateGetRequest();
5629 info3.priority = HIGHEST;
5630 TestCompletionCallback callback3;
5631 scoped_ptr<HttpNetworkTransaction> trans3(
5632 new HttpNetworkTransaction(helper.session()));
5633 rv = trans3->Start(&info3, callback3.callback(), BoundNetLog());
5634 EXPECT_EQ(ERR_IO_PENDING, rv);
5635 MessageLoop::current()->RunAllPending();
5636
5637 // We now have two SYN_STREAM frames queued up which will be
5638 // dequeued only once the first write completes, which we
5639 // now allow to happen.
5640 data->RunFor(2);
5641 EXPECT_EQ(OK, callback.WaitForResult());
5642
5643 // And now we can allow everything else to run to completion.
5644 data->SetStop(10);
5645 data->Run();
5646 EXPECT_EQ(OK, callback2.WaitForResult());
5647 EXPECT_EQ(OK, callback3.WaitForResult());
5648
5649 helper.VerifyDataConsumed();
5650 }
5651
5566 } // namespace net 5652 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/spdy/spdy_network_transaction_spdy3_unittest.cc » ('j') | net/spdy/spdy_session.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698