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

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

Issue 9321003: net: Make UploadData::GetContentLength() asynchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years, 10 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 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 // Test that a simple POST works. 1682 // Test that a simple POST works.
1683 TEST_P(SpdyNetworkTransactionTest, EmptyPost) { 1683 TEST_P(SpdyNetworkTransactionTest, EmptyPost) {
1684 // Setup the request 1684 // Setup the request
1685 HttpRequestInfo request; 1685 HttpRequestInfo request;
1686 request.method = "POST"; 1686 request.method = "POST";
1687 request.url = GURL("http://www.google.com/"); 1687 request.url = GURL("http://www.google.com/");
1688 // Create an empty UploadData. 1688 // Create an empty UploadData.
1689 request.upload_data = new UploadData(); 1689 request.upload_data = new UploadData();
1690 1690
1691 // Http POST Content-Length is using UploadDataStream::size(). 1691 // Http POST Content-Length is using UploadDataStream::size().
1692 // It is the same as request.upload_data->GetContentLength(). 1692 // It is the same as request.upload_data->GetContentLengthSync().
1693 scoped_ptr<UploadDataStream> stream( 1693 scoped_ptr<UploadDataStream> stream(
1694 new UploadDataStream(request.upload_data)); 1694 new UploadDataStream(request.upload_data));
1695 ASSERT_EQ(OK, stream->Init()); 1695 ASSERT_EQ(OK, stream->Init());
1696 ASSERT_EQ(request.upload_data->GetContentLength(), stream->size()); 1696 ASSERT_EQ(request.upload_data->GetContentLengthSync(),
1697 stream->size());
1697 1698
1698 scoped_ptr<spdy::SpdyFrame> 1699 scoped_ptr<spdy::SpdyFrame>
1699 req(ConstructSpdyPost(request.upload_data->GetContentLength(), NULL, 0)); 1700 req(ConstructSpdyPost(
1701 request.upload_data->GetContentLengthSync(), NULL, 0));
1700 // Set the FIN bit since there will be no body. 1702 // Set the FIN bit since there will be no body.
1701 req->set_flags(spdy::CONTROL_FLAG_FIN); 1703 req->set_flags(spdy::CONTROL_FLAG_FIN);
1702 MockWrite writes[] = { 1704 MockWrite writes[] = {
1703 CreateMockWrite(*req), 1705 CreateMockWrite(*req),
1704 }; 1706 };
1705 1707
1706 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); 1708 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0));
1707 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 1709 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
1708 MockRead reads[] = { 1710 MockRead reads[] = {
1709 CreateMockRead(*resp), 1711 CreateMockRead(*resp),
(...skipping 19 matching lines...) Expand all
1729 static const char upload[] = { "hello!" }; 1731 static const char upload[] = { "hello!" };
1730 1732
1731 // Setup the request 1733 // Setup the request
1732 HttpRequestInfo request; 1734 HttpRequestInfo request;
1733 request.method = "POST"; 1735 request.method = "POST";
1734 request.url = GURL("http://www.google.com/"); 1736 request.url = GURL("http://www.google.com/");
1735 request.upload_data = new UploadData(); 1737 request.upload_data = new UploadData();
1736 request.upload_data->AppendBytes(upload, sizeof(upload)); 1738 request.upload_data->AppendBytes(upload, sizeof(upload));
1737 1739
1738 // Http POST Content-Length is using UploadDataStream::size(). 1740 // Http POST Content-Length is using UploadDataStream::size().
1739 // It is the same as request.upload_data->GetContentLength(). 1741 // It is the same as request.upload_data->GetContentLengthSync().
1740 scoped_ptr<UploadDataStream> stream( 1742 scoped_ptr<UploadDataStream> stream(
1741 new UploadDataStream(request.upload_data)); 1743 new UploadDataStream(request.upload_data));
1742 ASSERT_EQ(OK, stream->Init()); 1744 ASSERT_EQ(OK, stream->Init());
1743 ASSERT_EQ(request.upload_data->GetContentLength(), stream->size()); 1745 ASSERT_EQ(request.upload_data->GetContentLengthSync(),
1746 stream->size());
1744 scoped_ptr<spdy::SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0)); 1747 scoped_ptr<spdy::SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0));
1745 scoped_ptr<spdy::SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true)); 1748 scoped_ptr<spdy::SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true));
1746 MockRead reads[] = { 1749 MockRead reads[] = {
1747 CreateMockRead(*stream_reply, 2), 1750 CreateMockRead(*stream_reply, 2),
1748 CreateMockRead(*stream_body, 3), 1751 CreateMockRead(*stream_body, 3),
1749 MockRead(false, 0, 0) // EOF 1752 MockRead(false, 0, 0) // EOF
1750 }; 1753 };
1751 1754
1752 scoped_ptr<DelayedSocketData> data( 1755 scoped_ptr<DelayedSocketData> data(
1753 new DelayedSocketData(0, reads, arraysize(reads), NULL, 0)); 1756 new DelayedSocketData(0, reads, arraysize(reads), NULL, 0));
(...skipping 3947 matching lines...) Expand 10 before | Expand all | Expand 10 after
5701 << " Write index: " 5704 << " Write index: "
5702 << data->write_index(); 5705 << data->write_index();
5703 5706
5704 // Verify the SYN_REPLY. 5707 // Verify the SYN_REPLY.
5705 HttpResponseInfo response = *trans->GetResponseInfo(); 5708 HttpResponseInfo response = *trans->GetResponseInfo();
5706 EXPECT_TRUE(response.headers != NULL); 5709 EXPECT_TRUE(response.headers != NULL);
5707 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5710 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5708 } 5711 }
5709 5712
5710 } // namespace net 5713 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | webkit/tools/test_shell/simple_resource_loader_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698