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

Unified Diff: net/http/http_pipelined_network_transaction_unittest.cc

Issue 10095024: Refuse to pipeline frames, prefetches, and downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add unit test Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/http/http_stream_factory_impl_job.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_pipelined_network_transaction_unittest.cc
diff --git a/net/http/http_pipelined_network_transaction_unittest.cc b/net/http/http_pipelined_network_transaction_unittest.cc
index 27ca29569d3af06ffd42a4d894cbcad78b265315..872eb9fc11c62f63a404346194a0b1e95f5e52c4 100644
--- a/net/http/http_pipelined_network_transaction_unittest.cc
+++ b/net/http/http_pipelined_network_transaction_unittest.cc
@@ -113,11 +113,20 @@ class HttpPipelinedNetworkTransactionTest : public testing::Test {
data_vector_.push_back(data);
}
- HttpRequestInfo* GetRequestInfo(const char* filename) {
+ enum RequestInfoOptions {
+ REQUEST_DEFAULT,
+ REQUEST_MAIN_RESOURCE,
+ };
+
+ HttpRequestInfo* GetRequestInfo(
+ const char* filename, RequestInfoOptions options = REQUEST_DEFAULT) {
std::string url = StringPrintf("http://localhost/%s", filename);
HttpRequestInfo* request_info = new HttpRequestInfo;
request_info->url = GURL(url);
request_info->method = "GET";
+ if (options == REQUEST_MAIN_RESOURCE) {
+ request_info->load_flags = LOAD_MAIN_FRAME;
+ }
request_info_vector_.push_back(request_info);
return request_info;
}
@@ -176,32 +185,32 @@ class HttpPipelinedNetworkTransactionTest : public testing::Test {
ExpectResponse("two.html", two_transaction, SYNCHRONOUS);
}
- void CompleteFourRequests() {
+ void CompleteFourRequests(RequestInfoOptions options) {
scoped_ptr<HttpNetworkTransaction> one_transaction(
new HttpNetworkTransaction(session_.get()));
TestCompletionCallback one_callback;
EXPECT_EQ(ERR_IO_PENDING,
- one_transaction->Start(GetRequestInfo("one.html"),
+ one_transaction->Start(GetRequestInfo("one.html", options),
one_callback.callback(), BoundNetLog()));
EXPECT_EQ(OK, one_callback.WaitForResult());
HttpNetworkTransaction two_transaction(session_.get());
TestCompletionCallback two_callback;
EXPECT_EQ(ERR_IO_PENDING,
- two_transaction.Start(GetRequestInfo("two.html"),
+ two_transaction.Start(GetRequestInfo("two.html", options),
two_callback.callback(), BoundNetLog()));
HttpNetworkTransaction three_transaction(session_.get());
TestCompletionCallback three_callback;
EXPECT_EQ(ERR_IO_PENDING,
- three_transaction.Start(GetRequestInfo("three.html"),
+ three_transaction.Start(GetRequestInfo("three.html", options),
three_callback.callback(),
BoundNetLog()));
HttpNetworkTransaction four_transaction(session_.get());
TestCompletionCallback four_callback;
EXPECT_EQ(ERR_IO_PENDING,
- four_transaction.Start(GetRequestInfo("four.html"),
+ four_transaction.Start(GetRequestInfo("four.html", options),
four_callback.callback(), BoundNetLog()));
ExpectResponse("one.html", *one_transaction.get(), SYNCHRONOUS);
@@ -316,7 +325,50 @@ TEST_F(HttpPipelinedNetworkTransactionTest, ReusesOnSpaceAvailable) {
};
AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes));
- CompleteFourRequests();
+ CompleteFourRequests(REQUEST_DEFAULT);
+
+ ClientSocketPoolManager::set_max_sockets_per_group(
+ HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_sockets);
+}
+
+TEST_F(HttpPipelinedNetworkTransactionTest, WontPipelineMainResource) {
+ int old_max_sockets = ClientSocketPoolManager::max_sockets_per_group(
+ HttpNetworkSession::NORMAL_SOCKET_POOL);
+ ClientSocketPoolManager::set_max_sockets_per_group(
+ HttpNetworkSession::NORMAL_SOCKET_POOL, 1);
+ Initialize(false);
+
+ MockWrite writes[] = {
+ MockWrite(SYNCHRONOUS, 0, "GET /one.html HTTP/1.1\r\n"
+ "Host: localhost\r\n"
+ "Connection: keep-alive\r\n\r\n"),
+ MockWrite(SYNCHRONOUS, 4, "GET /two.html HTTP/1.1\r\n"
+ "Host: localhost\r\n"
+ "Connection: keep-alive\r\n\r\n"),
+ MockWrite(SYNCHRONOUS, 8, "GET /three.html HTTP/1.1\r\n"
+ "Host: localhost\r\n"
+ "Connection: keep-alive\r\n\r\n"),
+ MockWrite(SYNCHRONOUS, 12, "GET /four.html HTTP/1.1\r\n"
+ "Host: localhost\r\n"
+ "Connection: keep-alive\r\n\r\n"),
+ };
+ MockRead reads[] = {
+ MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n"),
+ MockRead(SYNCHRONOUS, 2, "Content-Length: 8\r\n\r\n"),
+ MockRead(SYNCHRONOUS, 3, "one.html"),
+ MockRead(SYNCHRONOUS, 5, "HTTP/1.1 200 OK\r\n"),
+ MockRead(SYNCHRONOUS, 6, "Content-Length: 8\r\n\r\n"),
+ MockRead(SYNCHRONOUS, 7, "two.html"),
+ MockRead(SYNCHRONOUS, 9, "HTTP/1.1 200 OK\r\n"),
+ MockRead(SYNCHRONOUS, 10, "Content-Length: 10\r\n\r\n"),
+ MockRead(SYNCHRONOUS, 11, "three.html"),
+ MockRead(SYNCHRONOUS, 13, "HTTP/1.1 200 OK\r\n"),
+ MockRead(SYNCHRONOUS, 14, "Content-Length: 9\r\n\r\n"),
+ MockRead(SYNCHRONOUS, 15, "four.html"),
+ };
+ AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes));
+
+ CompleteFourRequests(REQUEST_MAIN_RESOURCE);
ClientSocketPoolManager::set_max_sockets_per_group(
HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_sockets);
@@ -669,7 +721,7 @@ TEST_F(HttpPipelinedNetworkTransactionTest, PipelinesImmediatelyIfKnownGood) {
};
AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes));
- CompleteFourRequests();
+ CompleteFourRequests(REQUEST_DEFAULT);
HttpNetworkTransaction second_one_transaction(session_.get());
TestCompletionCallback second_one_callback;
« no previous file with comments | « no previous file | net/http/http_stream_factory_impl_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698