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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_unittest.cc

Issue 2262183002: [NoStatePrefetch] Do not send responses to renderer in prefetch mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefetchProto
Patch Set: remove WebDocument api Created 4 years, 3 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
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[3][0].type()); 1489 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[3][0].type());
1490 CheckRequestCompleteErrorCode(msgs[3][1], net::ERR_ABORTED); 1490 CheckRequestCompleteErrorCode(msgs[3][1], net::ERR_ABORTED);
1491 1491
1492 // However, request 4 should have actually gone to completion. (Only request 2 1492 // However, request 4 should have actually gone to completion. (Only request 2
1493 // was canceled.) 1493 // was canceled.)
1494 EXPECT_EQ(4, network_delegate()->completed_requests()); 1494 EXPECT_EQ(4, network_delegate()->completed_requests());
1495 EXPECT_EQ(1, network_delegate()->canceled_requests()); 1495 EXPECT_EQ(1, network_delegate()->canceled_requests());
1496 EXPECT_EQ(0, network_delegate()->error_count()); 1496 EXPECT_EQ(0, network_delegate()->error_count());
1497 } 1497 }
1498 1498
1499 TEST_P(ResourceDispatcherHostTest, DownloadToNetworkCache) {
1500 // Normal request.
1501 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_2());
1502
1503 // Cache-only request.
1504 ResourceRequest request_to_cache = CreateResourceRequest(
1505 "GET", RESOURCE_TYPE_IMAGE, net::URLRequestTestJob::test_url_3());
1506 request_to_cache.download_to_network_cache_only = true;
1507 ResourceHostMsg_RequestResource msg_to_cache(0, 2, request_to_cache);
1508 host_.OnMessageReceived(msg_to_cache, filter_.get());
1509
1510 KickOffRequest();
1511
1512 // The handler for the cache-only request should have been detached now.
1513 GlobalRequestID global_request_id(filter_->child_id(), 2);
1514 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(
1515 host_.GetURLRequest(global_request_id));
1516 ASSERT_TRUE(info->detachable_handler()->is_detached());
1517
1518 // Flush all the pending requests.
1519 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {
1520 }
1521 base::RunLoop().RunUntilIdle();
1522
1523 // Everything should be out now.
1524 EXPECT_EQ(0, host_.pending_requests());
1525
1526 ResourceIPCAccumulator::ClassifiedMessages msgs;
1527 accum_.GetClassifiedMessages(&msgs);
1528
1529 // There are two requests, so we should have gotten them classified as such.
1530 ASSERT_EQ(2U, msgs.size());
1531
1532 // The normal request succeeded.
1533 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_2());
1534
1535 // The cache-only request got canceled, as far as the renderer is concerned.
1536 ASSERT_EQ(1U, msgs[1].size());
1537 CheckRequestCompleteErrorCode(msgs[1][0], net::ERR_ABORTED);
1538
1539 // However, all requests should have actually gone to completion.
1540 EXPECT_EQ(2, network_delegate()->completed_requests());
1541 EXPECT_EQ(0, network_delegate()->canceled_requests());
1542 EXPECT_EQ(0, network_delegate()->error_count());
1543 }
1544
1499 // Shows that detachable requests will timeout if the request takes too long to 1545 // Shows that detachable requests will timeout if the request takes too long to
1500 // complete. 1546 // complete.
1501 TEST_P(ResourceDispatcherHostTest, DetachedResourceTimesOut) { 1547 TEST_P(ResourceDispatcherHostTest, DetachedResourceTimesOut) {
1502 MakeTestRequestWithResourceType(filter_.get(), 0, 1, 1548 MakeTestRequestWithResourceType(filter_.get(), 0, 1,
1503 net::URLRequestTestJob::test_url_2(), 1549 net::URLRequestTestJob::test_url_2(),
1504 RESOURCE_TYPE_PREFETCH); // detachable type 1550 RESOURCE_TYPE_PREFETCH); // detachable type
1505 GlobalRequestID global_request_id(filter_->child_id(), 1); 1551 GlobalRequestID global_request_id(filter_->child_id(), 1);
1506 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest( 1552 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(
1507 host_.GetURLRequest(global_request_id)); 1553 host_.GetURLRequest(global_request_id));
1508 ASSERT_TRUE(info->detachable_handler()); 1554 ASSERT_TRUE(info->detachable_handler());
(...skipping 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after
3826 return nullptr; 3872 return nullptr;
3827 } 3873 }
3828 3874
3829 INSTANTIATE_TEST_CASE_P( 3875 INSTANTIATE_TEST_CASE_P(
3830 ResourceDispatcherHostTests, 3876 ResourceDispatcherHostTests,
3831 ResourceDispatcherHostTest, 3877 ResourceDispatcherHostTest,
3832 testing::Values(TestConfig::kDefault, 3878 testing::Values(TestConfig::kDefault,
3833 TestConfig::kOptimizeIPCForSmallResourceEnabled)); 3879 TestConfig::kOptimizeIPCForSmallResourceEnabled));
3834 3880
3835 } // namespace content 3881 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.cc ('k') | content/child/request_extra_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698