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

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

Issue 10815074: Instead of enqueueing SPDY frames, enqueue SPDY streams that are ready to produce data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove logging and cleanup Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_network_transaction_spdy2_unittest.cc ('k') | net/spdy/spdy_session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 // Http POST Content-Length is using UploadDataStream::size(). 1708 // Http POST Content-Length is using UploadDataStream::size().
1709 // It is the same as request.upload_data->GetContentLengthSync(). 1709 // It is the same as request.upload_data->GetContentLengthSync().
1710 scoped_ptr<UploadDataStream> stream( 1710 scoped_ptr<UploadDataStream> stream(
1711 new UploadDataStream(request.upload_data)); 1711 new UploadDataStream(request.upload_data));
1712 ASSERT_EQ(OK, stream->Init()); 1712 ASSERT_EQ(OK, stream->Init());
1713 ASSERT_EQ(request.upload_data->GetContentLengthSync(), 1713 ASSERT_EQ(request.upload_data->GetContentLengthSync(),
1714 stream->size()); 1714 stream->size());
1715 scoped_ptr<SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0)); 1715 scoped_ptr<SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0));
1716 scoped_ptr<SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true)); 1716 scoped_ptr<SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true));
1717 MockRead reads[] = { 1717 MockRead reads[] = {
1718 CreateMockRead(*stream_reply, 2), 1718 CreateMockRead(*stream_reply, 1),
1719 CreateMockRead(*stream_body, 3), 1719 MockRead(ASYNC, 0, 3) // EOF
1720 MockRead(SYNCHRONOUS, 0, 0) // EOF
1721 }; 1720 };
1722 1721
1723 DelayedSocketData data(0, reads, arraysize(reads), NULL, 0); 1722 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0));
1724 NormalSpdyTransactionHelper helper(request, 1723 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
1724 MockRead writes[] = {
1725 CreateMockWrite(*req, 0),
1726 CreateMockWrite(*body, 2),
1727 };
1728
1729 DeterministicSocketData data(reads, arraysize(reads),
1730 writes, arraysize(writes));
1731 NormalSpdyTransactionHelper helper(CreatePostRequest(),
1725 BoundNetLog(), GetParam(), NULL); 1732 BoundNetLog(), GetParam(), NULL);
1733 helper.SetDeterministic();
1726 helper.RunPreTestSetup(); 1734 helper.RunPreTestSetup();
1727 helper.AddData(&data); 1735 helper.AddDeterministicData(&data);
1728 helper.RunDefaultTest(); 1736 HttpNetworkTransaction* trans = helper.trans();
1729 helper.VerifyDataConsumed();
1730 1737
1731 TransactionHelperResult out = helper.output(); 1738 TestCompletionCallback callback;
1732 EXPECT_EQ(ERR_SYN_REPLY_NOT_RECEIVED, out.rv); 1739 int rv = trans->Start(
1740 &CreatePostRequest(), callback.callback(), BoundNetLog());
1741 EXPECT_EQ(ERR_IO_PENDING, rv);
1742
1743 data.RunFor(2);
1744 rv = callback.WaitForResult();
1745 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv);
1746 data.RunFor(1);
1733 } 1747 }
1734 1748
1735 // The client upon cancellation tries to send a RST_STREAM frame. The mock 1749 // The client upon cancellation tries to send a RST_STREAM frame. The mock
1736 // socket causes the TCP write to return zero. This test checks that the client 1750 // socket causes the TCP write to return zero. This test checks that the client
1737 // tries to queue up the RST_STREAM frame again. 1751 // tries to queue up the RST_STREAM frame again.
1738 TEST_P(SpdyNetworkTransactionSpdy3Test, SocketWriteReturnsZero) { 1752 TEST_P(SpdyNetworkTransactionSpdy3Test, SocketWriteReturnsZero) {
1739 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 1753 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
1740 scoped_ptr<SpdyFrame> rst( 1754 scoped_ptr<SpdyFrame> rst(
1741 ConstructSpdyRstStream(1, CANCEL)); 1755 ConstructSpdyRstStream(1, CANCEL));
1742 MockWrite writes[] = { 1756 MockWrite writes[] = {
(...skipping 4266 matching lines...) Expand 10 before | Expand all | Expand 10 after
6009 // Verify the SYN_REPLY. 6023 // Verify the SYN_REPLY.
6010 HttpResponseInfo response = *trans->GetResponseInfo(); 6024 HttpResponseInfo response = *trans->GetResponseInfo();
6011 EXPECT_TRUE(response.headers != NULL); 6025 EXPECT_TRUE(response.headers != NULL);
6012 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 6026 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
6013 } 6027 }
6014 6028
6015 TEST_P(SpdyNetworkTransactionSpdy3Test, OutOfOrderSynStream) { 6029 TEST_P(SpdyNetworkTransactionSpdy3Test, OutOfOrderSynStream) {
6016 // This first request will start to establish the SpdySession. 6030 // This first request will start to establish the SpdySession.
6017 // Then we will start the second (MEDIUM priority) and then third 6031 // Then we will start the second (MEDIUM priority) and then third
6018 // (HIGHEST priority) request in such a way that the third will actually 6032 // (HIGHEST priority) request in such a way that the third will actually
6019 // start before the second, causing the second to be re-numbered. 6033 // start before the second, causing the second to be numbered differently
6034 // than they order they were created.
6020 scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 6035 scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
6021 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, MEDIUM)); 6036 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, HIGHEST));
6022 scoped_ptr<SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 5, HIGHEST)); 6037 scoped_ptr<SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 5, MEDIUM));
6023 MockWrite writes[] = { 6038 MockWrite writes[] = {
6024 CreateMockWrite(*req1, 0), 6039 CreateMockWrite(*req1, 0),
6025 CreateMockWrite(*req2, 3), 6040 CreateMockWrite(*req2, 3),
6026 CreateMockWrite(*req3, 4), 6041 CreateMockWrite(*req3, 4),
6027 }; 6042 };
6028 6043
6029 scoped_ptr<SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1)); 6044 scoped_ptr<SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1));
6030 scoped_ptr<SpdyFrame> body1(ConstructSpdyBodyFrame(1, true)); 6045 scoped_ptr<SpdyFrame> body1(ConstructSpdyBodyFrame(1, true));
6031 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); 6046 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3));
6032 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(3, true)); 6047 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(3, true));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
6091 // And now we can allow everything else to run to completion. 6106 // And now we can allow everything else to run to completion.
6092 data.SetStop(10); 6107 data.SetStop(10);
6093 data.Run(); 6108 data.Run();
6094 EXPECT_EQ(OK, callback2.WaitForResult()); 6109 EXPECT_EQ(OK, callback2.WaitForResult());
6095 EXPECT_EQ(OK, callback3.WaitForResult()); 6110 EXPECT_EQ(OK, callback3.WaitForResult());
6096 6111
6097 helper.VerifyDataConsumed(); 6112 helper.VerifyDataConsumed();
6098 } 6113 }
6099 6114
6100 } // namespace net 6115 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_network_transaction_spdy2_unittest.cc ('k') | net/spdy/spdy_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698