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

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

Issue 2762953004: Remove inline small resource transfer experiment (Closed)
Patch Set: Created 3 years, 9 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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/memory/shared_memory.h" 17 #include "base/memory/shared_memory.h"
18 #include "base/pickle.h" 18 #include "base/pickle.h"
19 #include "base/run_loop.h" 19 #include "base/run_loop.h"
20 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
21 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_split.h" 22 #include "base/strings/string_split.h"
23 #include "base/test/scoped_feature_list.h"
24 #include "base/threading/thread_task_runner_handle.h" 23 #include "base/threading/thread_task_runner_handle.h"
25 #include "content/browser/browser_thread_impl.h" 24 #include "content/browser/browser_thread_impl.h"
26 #include "content/browser/child_process_security_policy_impl.h" 25 #include "content/browser/child_process_security_policy_impl.h"
27 #include "content/browser/download/download_manager_impl.h" 26 #include "content/browser/download/download_manager_impl.h"
28 #include "content/browser/download/download_resource_handler.h" 27 #include "content/browser/download/download_resource_handler.h"
29 #include "content/browser/frame_host/navigation_request_info.h" 28 #include "content/browser/frame_host/navigation_request_info.h"
30 #include "content/browser/loader/detachable_resource_handler.h" 29 #include "content/browser/loader/detachable_resource_handler.h"
31 #include "content/browser/loader/downloaded_temp_file_impl.h" 30 #include "content/browser/loader/downloaded_temp_file_impl.h"
32 #include "content/browser/loader/navigation_resource_throttle.h" 31 #include "content/browser/loader/navigation_resource_throttle.h"
33 #include "content/browser/loader/navigation_url_loader.h" 32 #include "content/browser/loader/navigation_url_loader.h"
(...skipping 12 matching lines...) Expand all
46 #include "content/public/browser/render_process_host.h" 45 #include "content/public/browser/render_process_host.h"
47 #include "content/public/browser/render_view_host.h" 46 #include "content/public/browser/render_view_host.h"
48 #include "content/public/browser/resource_context.h" 47 #include "content/public/browser/resource_context.h"
49 #include "content/public/browser/resource_dispatcher_host_delegate.h" 48 #include "content/public/browser/resource_dispatcher_host_delegate.h"
50 #include "content/public/browser/resource_request_info.h" 49 #include "content/public/browser/resource_request_info.h"
51 #include "content/public/browser/resource_throttle.h" 50 #include "content/public/browser/resource_throttle.h"
52 #include "content/public/browser/web_contents.h" 51 #include "content/public/browser/web_contents.h"
53 #include "content/public/browser/web_contents_observer.h" 52 #include "content/public/browser/web_contents_observer.h"
54 #include "content/public/common/browser_side_navigation_policy.h" 53 #include "content/public/common/browser_side_navigation_policy.h"
55 #include "content/public/common/child_process_host.h" 54 #include "content/public/common/child_process_host.h"
56 #include "content/public/common/content_features.h"
57 #include "content/public/common/process_type.h" 55 #include "content/public/common/process_type.h"
58 #include "content/public/common/resource_response.h" 56 #include "content/public/common/resource_response.h"
59 #include "content/public/test/test_browser_context.h" 57 #include "content/public/test/test_browser_context.h"
60 #include "content/public/test/test_browser_thread_bundle.h" 58 #include "content/public/test/test_browser_thread_bundle.h"
61 #include "content/public/test/test_renderer_host.h" 59 #include "content/public/test/test_renderer_host.h"
62 #include "content/test/test_content_browser_client.h" 60 #include "content/test/test_content_browser_client.h"
63 #include "content/test/test_navigation_url_loader_delegate.h" 61 #include "content/test/test_navigation_url_loader_delegate.h"
64 #include "net/base/chunked_upload_data_stream.h" 62 #include "net/base/chunked_upload_data_stream.h"
65 #include "net/base/elements_upload_data_stream.h" 63 #include "net/base/elements_upload_data_stream.h"
66 #include "net/base/load_flags.h" 64 #include "net/base/load_flags.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } // namespace 134 } // namespace
137 135
138 static int RequestIDForMessage(const IPC::Message& msg) { 136 static int RequestIDForMessage(const IPC::Message& msg) {
139 int request_id = -1; 137 int request_id = -1;
140 switch (msg.type()) { 138 switch (msg.type()) {
141 case ResourceMsg_UploadProgress::ID: 139 case ResourceMsg_UploadProgress::ID:
142 case ResourceMsg_ReceivedResponse::ID: 140 case ResourceMsg_ReceivedResponse::ID:
143 case ResourceMsg_ReceivedRedirect::ID: 141 case ResourceMsg_ReceivedRedirect::ID:
144 case ResourceMsg_SetDataBuffer::ID: 142 case ResourceMsg_SetDataBuffer::ID:
145 case ResourceMsg_DataReceived::ID: 143 case ResourceMsg_DataReceived::ID:
146 case ResourceMsg_InlinedDataChunkReceived::ID:
147 case ResourceMsg_DataDownloaded::ID: 144 case ResourceMsg_DataDownloaded::ID:
148 case ResourceMsg_RequestComplete::ID: { 145 case ResourceMsg_RequestComplete::ID: {
149 bool result = base::PickleIterator(msg).ReadInt(&request_id); 146 bool result = base::PickleIterator(msg).ReadInt(&request_id);
150 DCHECK(result); 147 DCHECK(result);
151 break; 148 break;
152 } 149 }
153 } 150 }
154 return request_id; 151 return request_id;
155 } 152 }
156 153
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 819
823 int resource_request_redirect_count() { 820 int resource_request_redirect_count() {
824 return resource_request_redirect_count_; 821 return resource_request_redirect_count_;
825 } 822 }
826 823
827 private: 824 private:
828 int resource_request_redirect_count_; 825 int resource_request_redirect_count_;
829 int resource_response_start_count_; 826 int resource_response_start_count_;
830 }; 827 };
831 828
832 enum class TestConfig {
833 kDefault,
834 kOptimizeIPCForSmallResourceEnabled,
835 };
836
837 void CheckRequestCompleteErrorCode(const IPC::Message& message, 829 void CheckRequestCompleteErrorCode(const IPC::Message& message,
838 int expected_error_code) { 830 int expected_error_code) {
839 // Verify the expected error code was received. 831 // Verify the expected error code was received.
840 int request_id; 832 int request_id;
841 int error_code; 833 int error_code;
842 834
843 ASSERT_EQ(ResourceMsg_RequestComplete::ID, message.type()); 835 ASSERT_EQ(ResourceMsg_RequestComplete::ID, message.type());
844 836
845 base::PickleIterator iter(message); 837 base::PickleIterator iter(message);
846 ASSERT_TRUE(IPC::ReadParam(&message, &iter, &request_id)); 838 ASSERT_TRUE(IPC::ReadParam(&message, &iter, &request_id));
847 ASSERT_TRUE(IPC::ReadParam(&message, &iter, &error_code)); 839 ASSERT_TRUE(IPC::ReadParam(&message, &iter, &error_code));
848 ASSERT_EQ(expected_error_code, error_code); 840 ASSERT_EQ(expected_error_code, error_code);
849 } 841 }
850 842
851 class ResourceDispatcherHostTest : public testing::TestWithParam<TestConfig>, 843 class ResourceDispatcherHostTest : public testing::Test, public IPC::Sender {
852 public IPC::Sender {
853 public: 844 public:
854 typedef ResourceDispatcherHostImpl::LoadInfo LoadInfo; 845 typedef ResourceDispatcherHostImpl::LoadInfo LoadInfo;
855 typedef ResourceDispatcherHostImpl::LoadInfoList LoadInfoList; 846 typedef ResourceDispatcherHostImpl::LoadInfoList LoadInfoList;
856 typedef ResourceDispatcherHostImpl::LoadInfoMap LoadInfoMap; 847 typedef ResourceDispatcherHostImpl::LoadInfoMap LoadInfoMap;
857 848
858 ResourceDispatcherHostTest() 849 ResourceDispatcherHostTest()
859 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), 850 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
860 host_(base::Bind(&DownloadResourceHandler::Create)), 851 host_(base::Bind(&DownloadResourceHandler::Create)),
861 use_test_ssl_certificate_(false), 852 use_test_ssl_certificate_(false),
862 send_data_received_acks_(false), 853 send_data_received_acks_(false),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 scoped_refptr<SiteInstance> site_instance = 898 scoped_refptr<SiteInstance> site_instance =
908 SiteInstance::Create(browser_context_.get()); 899 SiteInstance::Create(browser_context_.get());
909 web_contents_.reset( 900 web_contents_.reset(
910 WebContents::Create(WebContents::CreateParams(browser_context_.get()))); 901 WebContents::Create(WebContents::CreateParams(browser_context_.get())));
911 web_contents_observer_.reset( 902 web_contents_observer_.reset(
912 new TestWebContentsObserver(web_contents_.get())); 903 new TestWebContentsObserver(web_contents_.get()));
913 web_contents_filter_ = new TestFilterSpecifyingChild( 904 web_contents_filter_ = new TestFilterSpecifyingChild(
914 browser_context_->GetResourceContext(), 905 browser_context_->GetResourceContext(),
915 web_contents_->GetRenderProcessHost()->GetID()); 906 web_contents_->GetRenderProcessHost()->GetID());
916 child_ids_.insert(web_contents_->GetRenderProcessHost()->GetID()); 907 child_ids_.insert(web_contents_->GetRenderProcessHost()->GetID());
917
918 switch (GetParam()) {
919 case TestConfig::kDefault:
920 break;
921 case TestConfig::kOptimizeIPCForSmallResourceEnabled: {
922 scoped_feature_list_.InitAndEnableFeature(
923 features::kOptimizeLoadingIPCForSmallResources);
924 ASSERT_TRUE(base::FeatureList::IsEnabled(
925 features::kOptimizeLoadingIPCForSmallResources));
926 break;
927 }
928 }
929 } 908 }
930 909
931 void TearDown() override { 910 void TearDown() override {
932 web_contents_filter_->OnChannelClosing(); 911 web_contents_filter_->OnChannelClosing();
933 web_contents_observer_.reset(); 912 web_contents_observer_.reset();
934 web_contents_.reset(); 913 web_contents_.reset();
935 914
936 EXPECT_TRUE(URLRequestTestDelayedStartJob::DelayedStartQueueEmpty()); 915 EXPECT_TRUE(URLRequestTestDelayedStartJob::DelayedStartQueueEmpty());
937 URLRequestTestDelayedStartJob::ClearQueue(); 916 URLRequestTestDelayedStartJob::ClearQueue();
938 917
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 ResourceIPCAccumulator accum_; 1127 ResourceIPCAccumulator accum_;
1149 std::string response_headers_; 1128 std::string response_headers_;
1150 std::string response_data_; 1129 std::string response_data_;
1151 bool use_test_ssl_certificate_; 1130 bool use_test_ssl_certificate_;
1152 std::string scheme_; 1131 std::string scheme_;
1153 bool send_data_received_acks_; 1132 bool send_data_received_acks_;
1154 std::set<int> child_ids_; 1133 std::set<int> child_ids_;
1155 std::unique_ptr<base::RunLoop> wait_for_request_complete_loop_; 1134 std::unique_ptr<base::RunLoop> wait_for_request_complete_loop_;
1156 RenderViewHostTestEnabler render_view_host_test_enabler_; 1135 RenderViewHostTestEnabler render_view_host_test_enabler_;
1157 bool auto_advance_; 1136 bool auto_advance_;
1158 base::test::ScopedFeatureList scoped_feature_list_;
1159 }; 1137 };
1160 1138
1161 void ResourceDispatcherHostTest::MakeTestRequest(int render_view_id, 1139 void ResourceDispatcherHostTest::MakeTestRequest(int render_view_id,
1162 int request_id, 1140 int request_id,
1163 const GURL& url) { 1141 const GURL& url) {
1164 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 1142 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
1165 url, RESOURCE_TYPE_SUB_RESOURCE); 1143 url, RESOURCE_TYPE_SUB_RESOURCE);
1166 } 1144 }
1167 1145
1168 void ResourceDispatcherHostTest::MakeTestRequestWithRenderFrame( 1146 void ResourceDispatcherHostTest::MakeTestRequestWithRenderFrame(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 void ResourceDispatcherHostTest::CompleteStartRequest( 1235 void ResourceDispatcherHostTest::CompleteStartRequest(
1258 ResourceMessageFilter* filter, 1236 ResourceMessageFilter* filter,
1259 int request_id) { 1237 int request_id) {
1260 GlobalRequestID gid(filter->child_id(), request_id); 1238 GlobalRequestID gid(filter->child_id(), request_id);
1261 net::URLRequest* req = host_.GetURLRequest(gid); 1239 net::URLRequest* req = host_.GetURLRequest(gid);
1262 EXPECT_TRUE(req); 1240 EXPECT_TRUE(req);
1263 if (req) 1241 if (req)
1264 URLRequestTestDelayedStartJob::CompleteStart(req); 1242 URLRequestTestDelayedStartJob::CompleteStart(req);
1265 } 1243 }
1266 1244
1267 testing::AssertionResult ExtractInlinedChunkData(
1268 const IPC::Message& message,
1269 std::string* leading_chunk_data) {
1270 base::PickleIterator iter(message);
1271 int request_id;
1272 if (!IPC::ReadParam(&message, &iter, &request_id))
1273 return testing::AssertionFailure() << "Could not read request_id";
1274
1275 std::vector<char> data;
1276 if (!IPC::ReadParam(&message, &iter, &data))
1277 return testing::AssertionFailure() << "Could not read data";
1278 leading_chunk_data->assign(data.begin(), data.end());
1279
1280 return testing::AssertionSuccess();
1281 }
1282
1283 testing::AssertionResult ExtractDataOffsetAndLength(const IPC::Message& message, 1245 testing::AssertionResult ExtractDataOffsetAndLength(const IPC::Message& message,
1284 int* data_offset, 1246 int* data_offset,
1285 int* data_length) { 1247 int* data_length) {
1286 base::PickleIterator iter(message); 1248 base::PickleIterator iter(message);
1287 int request_id; 1249 int request_id;
1288 if (!IPC::ReadParam(&message, &iter, &request_id)) 1250 if (!IPC::ReadParam(&message, &iter, &request_id))
1289 return testing::AssertionFailure() << "Could not read request_id"; 1251 return testing::AssertionFailure() << "Could not read request_id";
1290 if (!IPC::ReadParam(&message, &iter, data_offset)) 1252 if (!IPC::ReadParam(&message, &iter, data_offset))
1291 return testing::AssertionFailure() << "Could not read data_offset"; 1253 return testing::AssertionFailure() << "Could not read data_offset";
1292 if (!IPC::ReadParam(&message, &iter, data_length)) 1254 if (!IPC::ReadParam(&message, &iter, data_length))
1293 return testing::AssertionFailure() << "Could not read data_length"; 1255 return testing::AssertionFailure() << "Could not read data_length";
1294 return testing::AssertionSuccess(); 1256 return testing::AssertionSuccess();
1295 } 1257 }
1296 1258
1297 void CheckSuccessfulRequestWithErrorCodeForInlinedCase(
1298 const std::vector<IPC::Message>& messages,
1299 const std::string& reference_data,
1300 int expected_error) {
1301 // A successful request on the inlined case will have received 3 messages:
1302 // ReceivedResponse (indicates headers received)
1303 // InlinedDataChunkReceived (contains the content)
1304 // RequestComplete (request is done)
1305
1306 ASSERT_EQ(3U, messages.size());
1307
1308 // The first messages should be received response
1309 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, messages[0].type());
1310 ASSERT_EQ(ResourceMsg_InlinedDataChunkReceived::ID, messages[1].type());
1311
1312 std::string leading_chunk_data;
1313 ASSERT_TRUE(ExtractInlinedChunkData(messages[1], &leading_chunk_data));
1314 ASSERT_EQ(reference_data, leading_chunk_data);
1315 CheckRequestCompleteErrorCode(messages[2], expected_error);
1316 }
1317
1318 void CheckSuccessfulRequestWithErrorCode( 1259 void CheckSuccessfulRequestWithErrorCode(
1319 const std::vector<IPC::Message>& messages, 1260 const std::vector<IPC::Message>& messages,
1320 const std::string& reference_data, 1261 const std::string& reference_data,
1321 int expected_error) { 1262 int expected_error) {
1322 ASSERT_LT(2U, messages.size()); 1263 ASSERT_LT(2U, messages.size());
1323 if (base::FeatureList::IsEnabled(
1324 features::kOptimizeLoadingIPCForSmallResources) &&
1325 messages[1].type() == ResourceMsg_InlinedDataChunkReceived::ID) {
1326 CheckSuccessfulRequestWithErrorCodeForInlinedCase(
1327 messages, reference_data, expected_error);
1328 return;
1329 }
1330 1264
1331 // A successful request will have received 4 messages: 1265 // A successful request will have received 4 messages:
1332 // ReceivedResponse (indicates headers received) 1266 // ReceivedResponse (indicates headers received)
1333 // SetDataBuffer (contains shared memory handle) 1267 // SetDataBuffer (contains shared memory handle)
1334 // DataReceived (data offset and length into shared memory) 1268 // DataReceived (data offset and length into shared memory)
1335 // RequestComplete (request is done) 1269 // RequestComplete (request is done)
1336 // 1270 //
1337 // This function verifies that we received 4 messages and that they are 1271 // This function verifies that we received 4 messages and that they are
1338 // appropriate. It allows for an error code other than net::OK if the request 1272 // appropriate. It allows for an error code other than net::OK if the request
1339 // should successfully receive data and then abort, e.g., on cancel. 1273 // should successfully receive data and then abort, e.g., on cancel.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 size_t failure_index = messages.size() - 1; 1330 size_t failure_index = messages.size() - 1;
1397 1331
1398 if (messages.size() == 2) { 1332 if (messages.size() == 2) {
1399 EXPECT_EQ(ResourceMsg_ReceivedResponse::ID, messages[0].type()); 1333 EXPECT_EQ(ResourceMsg_ReceivedResponse::ID, messages[0].type());
1400 } 1334 }
1401 1335
1402 CheckRequestCompleteErrorCode(messages[failure_index], expected_error); 1336 CheckRequestCompleteErrorCode(messages[failure_index], expected_error);
1403 } 1337 }
1404 1338
1405 // Tests whether many messages get dispatched properly. 1339 // Tests whether many messages get dispatched properly.
1406 TEST_P(ResourceDispatcherHostTest, TestMany) { 1340 TEST_F(ResourceDispatcherHostTest, TestMany) {
1407 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); 1341 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1());
1408 MakeTestRequest(0, 2, net::URLRequestTestJob::test_url_2()); 1342 MakeTestRequest(0, 2, net::URLRequestTestJob::test_url_2());
1409 MakeTestRequest(0, 3, net::URLRequestTestJob::test_url_3()); 1343 MakeTestRequest(0, 3, net::URLRequestTestJob::test_url_3());
1410 MakeTestRequestWithResourceType(filter_.get(), 0, 4, 1344 MakeTestRequestWithResourceType(filter_.get(), 0, 4,
1411 net::URLRequestTestJob::test_url_4(), 1345 net::URLRequestTestJob::test_url_4(),
1412 RESOURCE_TYPE_PREFETCH); // detachable type 1346 RESOURCE_TYPE_PREFETCH); // detachable type
1413 MakeTestRequest(0, 5, net::URLRequestTestJob::test_url_redirect_to_url_2()); 1347 MakeTestRequest(0, 5, net::URLRequestTestJob::test_url_redirect_to_url_2());
1414 1348
1415 // Finish the redirection 1349 // Finish the redirection
1416 ResourceHostMsg_FollowRedirect redirect_msg(5); 1350 ResourceHostMsg_FollowRedirect redirect_msg(5);
(...skipping 12 matching lines...) Expand all
1429 1363
1430 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1()); 1364 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1());
1431 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_2()); 1365 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_2());
1432 CheckSuccessfulRequest(msgs[2], net::URLRequestTestJob::test_data_3()); 1366 CheckSuccessfulRequest(msgs[2], net::URLRequestTestJob::test_data_3());
1433 CheckSuccessfulRequest(msgs[3], net::URLRequestTestJob::test_data_4()); 1367 CheckSuccessfulRequest(msgs[3], net::URLRequestTestJob::test_data_4());
1434 CheckSuccessfulRedirect(msgs[4], net::URLRequestTestJob::test_data_2()); 1368 CheckSuccessfulRedirect(msgs[4], net::URLRequestTestJob::test_data_2());
1435 } 1369 }
1436 1370
1437 // Tests whether messages get canceled properly. We issue four requests, 1371 // Tests whether messages get canceled properly. We issue four requests,
1438 // cancel two of them, and make sure that each sent the proper notifications. 1372 // cancel two of them, and make sure that each sent the proper notifications.
1439 TEST_P(ResourceDispatcherHostTest, Cancel) { 1373 TEST_F(ResourceDispatcherHostTest, Cancel) {
1440 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); 1374 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1());
1441 MakeTestRequest(0, 2, net::URLRequestTestJob::test_url_2()); 1375 MakeTestRequest(0, 2, net::URLRequestTestJob::test_url_2());
1442 MakeTestRequest(0, 3, net::URLRequestTestJob::test_url_3()); 1376 MakeTestRequest(0, 3, net::URLRequestTestJob::test_url_3());
1443 1377
1444 MakeTestRequestWithResourceType(filter_.get(), 0, 4, 1378 MakeTestRequestWithResourceType(filter_.get(), 0, 4,
1445 net::URLRequestTestJob::test_url_4(), 1379 net::URLRequestTestJob::test_url_4(),
1446 RESOURCE_TYPE_PREFETCH); // detachable type 1380 RESOURCE_TYPE_PREFETCH); // detachable type
1447 1381
1448 CancelRequest(2); 1382 CancelRequest(2);
1449 1383
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[3][0].type()); 1416 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[3][0].type());
1483 CheckRequestCompleteErrorCode(msgs[3][1], net::ERR_ABORTED); 1417 CheckRequestCompleteErrorCode(msgs[3][1], net::ERR_ABORTED);
1484 1418
1485 // However, request 4 should have actually gone to completion. (Only request 2 1419 // However, request 4 should have actually gone to completion. (Only request 2
1486 // was canceled.) 1420 // was canceled.)
1487 EXPECT_EQ(4, network_delegate()->completed_requests()); 1421 EXPECT_EQ(4, network_delegate()->completed_requests());
1488 EXPECT_EQ(1, network_delegate()->canceled_requests()); 1422 EXPECT_EQ(1, network_delegate()->canceled_requests());
1489 EXPECT_EQ(0, network_delegate()->error_count()); 1423 EXPECT_EQ(0, network_delegate()->error_count());
1490 } 1424 }
1491 1425
1492 TEST_P(ResourceDispatcherHostTest, DownloadToNetworkCache) { 1426 TEST_F(ResourceDispatcherHostTest, DownloadToNetworkCache) {
1493 // Normal request. 1427 // Normal request.
1494 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_2()); 1428 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_2());
1495 1429
1496 // Cache-only request. 1430 // Cache-only request.
1497 ResourceRequest request_to_cache = CreateResourceRequest( 1431 ResourceRequest request_to_cache = CreateResourceRequest(
1498 "GET", RESOURCE_TYPE_IMAGE, net::URLRequestTestJob::test_url_3()); 1432 "GET", RESOURCE_TYPE_IMAGE, net::URLRequestTestJob::test_url_3());
1499 request_to_cache.download_to_network_cache_only = true; 1433 request_to_cache.download_to_network_cache_only = true;
1500 ResourceHostMsg_RequestResource msg_to_cache(0, 2, request_to_cache); 1434 ResourceHostMsg_RequestResource msg_to_cache(0, 2, request_to_cache);
1501 OnMessageReceived(msg_to_cache, filter_.get()); 1435 OnMessageReceived(msg_to_cache, filter_.get());
1502 1436
(...skipping 27 matching lines...) Expand all
1530 CheckRequestCompleteErrorCode(msgs[1][0], net::ERR_ABORTED); 1464 CheckRequestCompleteErrorCode(msgs[1][0], net::ERR_ABORTED);
1531 1465
1532 // However, all requests should have actually gone to completion. 1466 // However, all requests should have actually gone to completion.
1533 EXPECT_EQ(2, network_delegate()->completed_requests()); 1467 EXPECT_EQ(2, network_delegate()->completed_requests());
1534 EXPECT_EQ(0, network_delegate()->canceled_requests()); 1468 EXPECT_EQ(0, network_delegate()->canceled_requests());
1535 EXPECT_EQ(0, network_delegate()->error_count()); 1469 EXPECT_EQ(0, network_delegate()->error_count());
1536 } 1470 }
1537 1471
1538 // Shows that detachable requests will timeout if the request takes too long to 1472 // Shows that detachable requests will timeout if the request takes too long to
1539 // complete. 1473 // complete.
1540 TEST_P(ResourceDispatcherHostTest, DetachedResourceTimesOut) { 1474 TEST_F(ResourceDispatcherHostTest, DetachedResourceTimesOut) {
1541 MakeTestRequestWithResourceType(filter_.get(), 0, 1, 1475 MakeTestRequestWithResourceType(filter_.get(), 0, 1,
1542 net::URLRequestTestJob::test_url_2(), 1476 net::URLRequestTestJob::test_url_2(),
1543 RESOURCE_TYPE_PREFETCH); // detachable type 1477 RESOURCE_TYPE_PREFETCH); // detachable type
1544 GlobalRequestID global_request_id(filter_->child_id(), 1); 1478 GlobalRequestID global_request_id(filter_->child_id(), 1);
1545 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest( 1479 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(
1546 host_.GetURLRequest(global_request_id)); 1480 host_.GetURLRequest(global_request_id));
1547 ASSERT_TRUE(info->detachable_handler()); 1481 ASSERT_TRUE(info->detachable_handler());
1548 info->detachable_handler()->set_cancel_delay( 1482 info->detachable_handler()->set_cancel_delay(
1549 base::TimeDelta::FromMilliseconds(200)); 1483 base::TimeDelta::FromMilliseconds(200));
1550 base::RunLoop().RunUntilIdle(); 1484 base::RunLoop().RunUntilIdle();
(...skipping 19 matching lines...) Expand all
1570 base::MessageLoop::current(), &base::MessageLoop::QuitWhenIdle); 1504 base::MessageLoop::current(), &base::MessageLoop::QuitWhenIdle);
1571 base::RunLoop().Run(); 1505 base::RunLoop().Run();
1572 1506
1573 // The prefetch should be cancelled by now. 1507 // The prefetch should be cancelled by now.
1574 EXPECT_EQ(0, host_.pending_requests()); 1508 EXPECT_EQ(0, host_.pending_requests());
1575 EXPECT_EQ(1, network_delegate()->completed_requests()); 1509 EXPECT_EQ(1, network_delegate()->completed_requests());
1576 EXPECT_EQ(1, network_delegate()->canceled_requests()); 1510 EXPECT_EQ(1, network_delegate()->canceled_requests());
1577 EXPECT_EQ(0, network_delegate()->error_count()); 1511 EXPECT_EQ(0, network_delegate()->error_count());
1578 } 1512 }
1579 1513
1580 TEST_P(ResourceDispatcherHostTest, SyncLoadSuccess) { 1514 TEST_F(ResourceDispatcherHostTest, SyncLoadSuccess) {
1581 ResourceRequest request = CreateResourceRequest( 1515 ResourceRequest request = CreateResourceRequest(
1582 "GET", RESOURCE_TYPE_XHR, net::URLRequestTestJob::test_url_1()); 1516 "GET", RESOURCE_TYPE_XHR, net::URLRequestTestJob::test_url_1());
1583 request.priority = net::MAXIMUM_PRIORITY; 1517 request.priority = net::MAXIMUM_PRIORITY;
1584 1518
1585 // Successful sync load. 1519 // Successful sync load.
1586 std::tuple<SyncLoadResult> result; 1520 std::tuple<SyncLoadResult> result;
1587 ResourceHostMsg_SyncLoad sync_load_msg(0, 1, request, &std::get<0>(result)); 1521 ResourceHostMsg_SyncLoad sync_load_msg(0, 1, request, &std::get<0>(result));
1588 OnMessageReceived(sync_load_msg, filter_.get()); 1522 OnMessageReceived(sync_load_msg, filter_.get());
1589 base::RunLoop().RunUntilIdle(); 1523 base::RunLoop().RunUntilIdle();
1590 1524
1591 const IPC::Message* reply = accum_.GetReply(sync_load_msg); 1525 const IPC::Message* reply = accum_.GetReply(sync_load_msg);
1592 ASSERT_TRUE(reply); 1526 ASSERT_TRUE(reply);
1593 1527
1594 ASSERT_TRUE(ResourceHostMsg_SyncLoad::ReadReplyParam(reply, &result)); 1528 ASSERT_TRUE(ResourceHostMsg_SyncLoad::ReadReplyParam(reply, &result));
1595 EXPECT_EQ(net::OK, std::get<0>(result).error_code); 1529 EXPECT_EQ(net::OK, std::get<0>(result).error_code);
1596 } 1530 }
1597 1531
1598 TEST_P(ResourceDispatcherHostTest, SyncLoadError) { 1532 TEST_F(ResourceDispatcherHostTest, SyncLoadError) {
1599 ResourceRequest request = CreateResourceRequest( 1533 ResourceRequest request = CreateResourceRequest(
1600 "GET", RESOURCE_TYPE_XHR, net::URLRequestTestJob::test_url_error()); 1534 "GET", RESOURCE_TYPE_XHR, net::URLRequestTestJob::test_url_error());
1601 request.priority = net::MAXIMUM_PRIORITY; 1535 request.priority = net::MAXIMUM_PRIORITY;
1602 1536
1603 // Failued sync load. 1537 // Failued sync load.
1604 std::tuple<SyncLoadResult> result; 1538 std::tuple<SyncLoadResult> result;
1605 ResourceHostMsg_SyncLoad sync_load_msg(0, 1, request, &std::get<0>(result)); 1539 ResourceHostMsg_SyncLoad sync_load_msg(0, 1, request, &std::get<0>(result));
1606 OnMessageReceived(sync_load_msg, filter_.get()); 1540 OnMessageReceived(sync_load_msg, filter_.get());
1607 base::RunLoop().RunUntilIdle(); 1541 base::RunLoop().RunUntilIdle();
1608 1542
1609 const IPC::Message* reply = accum_.GetReply(sync_load_msg); 1543 const IPC::Message* reply = accum_.GetReply(sync_load_msg);
1610 ASSERT_TRUE(reply); 1544 ASSERT_TRUE(reply);
1611 1545
1612 ASSERT_TRUE(ResourceHostMsg_SyncLoad::ReadReplyParam(reply, &result)); 1546 ASSERT_TRUE(ResourceHostMsg_SyncLoad::ReadReplyParam(reply, &result));
1613 EXPECT_EQ(net::ERR_INVALID_URL, std::get<0>(result).error_code); 1547 EXPECT_EQ(net::ERR_INVALID_URL, std::get<0>(result).error_code);
1614 } 1548 }
1615 1549
1616 TEST_P(ResourceDispatcherHostTest, SyncLoadCancel) { 1550 TEST_F(ResourceDispatcherHostTest, SyncLoadCancel) {
1617 ResourceRequest request = CreateResourceRequest( 1551 ResourceRequest request = CreateResourceRequest(
1618 "GET", RESOURCE_TYPE_XHR, net::URLRequestTestJob::test_url_1()); 1552 "GET", RESOURCE_TYPE_XHR, net::URLRequestTestJob::test_url_1());
1619 request.priority = net::MAXIMUM_PRIORITY; 1553 request.priority = net::MAXIMUM_PRIORITY;
1620 1554
1621 // Cancelled sync load. 1555 // Cancelled sync load.
1622 SyncLoadResult result; 1556 SyncLoadResult result;
1623 ResourceHostMsg_SyncLoad sync_load_msg(0, 1, request, &result); 1557 ResourceHostMsg_SyncLoad sync_load_msg(0, 1, request, &result);
1624 1558
1625 OnMessageReceived(sync_load_msg, filter_.get()); 1559 OnMessageReceived(sync_load_msg, filter_.get());
1626 host_.CancelRequestsForProcess(filter_->child_id()); 1560 host_.CancelRequestsForProcess(filter_->child_id());
1627 base::RunLoop().RunUntilIdle(); 1561 base::RunLoop().RunUntilIdle();
1628 1562
1629 const IPC::Message* reply = accum_.GetReply(sync_load_msg); 1563 const IPC::Message* reply = accum_.GetReply(sync_load_msg);
1630 ASSERT_TRUE(reply); 1564 ASSERT_TRUE(reply);
1631 ASSERT_TRUE(reply->is_reply_error()); 1565 ASSERT_TRUE(reply->is_reply_error());
1632 } 1566 }
1633 1567
1634 // If the filter has disappeared then detachable resources should continue to 1568 // If the filter has disappeared then detachable resources should continue to
1635 // load. 1569 // load.
1636 TEST_P(ResourceDispatcherHostTest, DeletedFilterDetached) { 1570 TEST_F(ResourceDispatcherHostTest, DeletedFilterDetached) {
1637 // test_url_1's data is available synchronously, so use 2 and 3. 1571 // test_url_1's data is available synchronously, so use 2 and 3.
1638 ResourceRequest request_prefetch = CreateResourceRequest( 1572 ResourceRequest request_prefetch = CreateResourceRequest(
1639 "GET", RESOURCE_TYPE_PREFETCH, net::URLRequestTestJob::test_url_2()); 1573 "GET", RESOURCE_TYPE_PREFETCH, net::URLRequestTestJob::test_url_2());
1640 ResourceRequest request_ping = CreateResourceRequest( 1574 ResourceRequest request_ping = CreateResourceRequest(
1641 "GET", RESOURCE_TYPE_PING, net::URLRequestTestJob::test_url_3()); 1575 "GET", RESOURCE_TYPE_PING, net::URLRequestTestJob::test_url_3());
1642 1576
1643 ResourceHostMsg_RequestResource msg_prefetch(0, 1, request_prefetch); 1577 ResourceHostMsg_RequestResource msg_prefetch(0, 1, request_prefetch);
1644 OnMessageReceived(msg_prefetch, filter_.get()); 1578 OnMessageReceived(msg_prefetch, filter_.get());
1645 ResourceHostMsg_RequestResource msg_ping(0, 2, request_ping); 1579 ResourceHostMsg_RequestResource msg_ping(0, 2, request_ping);
1646 OnMessageReceived(msg_ping, filter_.get()); 1580 OnMessageReceived(msg_ping, filter_.get());
(...skipping 29 matching lines...) Expand all
1676 base::RunLoop().RunUntilIdle(); 1610 base::RunLoop().RunUntilIdle();
1677 1611
1678 EXPECT_EQ(0, host_.pending_requests()); 1612 EXPECT_EQ(0, host_.pending_requests());
1679 EXPECT_EQ(2, network_delegate()->completed_requests()); 1613 EXPECT_EQ(2, network_delegate()->completed_requests());
1680 EXPECT_EQ(0, network_delegate()->canceled_requests()); 1614 EXPECT_EQ(0, network_delegate()->canceled_requests());
1681 EXPECT_EQ(0, network_delegate()->error_count()); 1615 EXPECT_EQ(0, network_delegate()->error_count());
1682 } 1616 }
1683 1617
1684 // If the filter has disappeared (original process dies) then detachable 1618 // If the filter has disappeared (original process dies) then detachable
1685 // resources should continue to load, even when redirected. 1619 // resources should continue to load, even when redirected.
1686 TEST_P(ResourceDispatcherHostTest, DeletedFilterDetachedRedirect) { 1620 TEST_F(ResourceDispatcherHostTest, DeletedFilterDetachedRedirect) {
1687 ResourceRequest request = CreateResourceRequest( 1621 ResourceRequest request = CreateResourceRequest(
1688 "GET", RESOURCE_TYPE_PREFETCH, 1622 "GET", RESOURCE_TYPE_PREFETCH,
1689 net::URLRequestTestJob::test_url_redirect_to_url_2()); 1623 net::URLRequestTestJob::test_url_redirect_to_url_2());
1690 1624
1691 ResourceHostMsg_RequestResource msg(0, 1, request); 1625 ResourceHostMsg_RequestResource msg(0, 1, request);
1692 OnMessageReceived(msg, filter_.get()); 1626 OnMessageReceived(msg, filter_.get());
1693 1627
1694 // Remove the filter before processing the request by simulating channel 1628 // Remove the filter before processing the request by simulating channel
1695 // closure. 1629 // closure.
1696 GlobalRequestID global_request_id(filter_->child_id(), 1); 1630 GlobalRequestID global_request_id(filter_->child_id(), 1);
(...skipping 25 matching lines...) Expand all
1722 // Finish up the request. 1656 // Finish up the request.
1723 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 1657 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
1724 base::RunLoop().RunUntilIdle(); 1658 base::RunLoop().RunUntilIdle();
1725 1659
1726 EXPECT_EQ(0, host_.pending_requests()); 1660 EXPECT_EQ(0, host_.pending_requests());
1727 EXPECT_EQ(1, network_delegate()->completed_requests()); 1661 EXPECT_EQ(1, network_delegate()->completed_requests());
1728 EXPECT_EQ(0, network_delegate()->canceled_requests()); 1662 EXPECT_EQ(0, network_delegate()->canceled_requests());
1729 EXPECT_EQ(0, network_delegate()->error_count()); 1663 EXPECT_EQ(0, network_delegate()->error_count());
1730 } 1664 }
1731 1665
1732 TEST_P(ResourceDispatcherHostTest, CancelWhileStartIsDeferred) { 1666 TEST_F(ResourceDispatcherHostTest, CancelWhileStartIsDeferred) {
1733 bool was_deleted = false; 1667 bool was_deleted = false;
1734 1668
1735 // Arrange to have requests deferred before starting. 1669 // Arrange to have requests deferred before starting.
1736 TestResourceDispatcherHostDelegate delegate; 1670 TestResourceDispatcherHostDelegate delegate;
1737 delegate.set_flags(DEFER_STARTING_REQUEST); 1671 delegate.set_flags(DEFER_STARTING_REQUEST);
1738 delegate.set_url_request_user_data(new TestUserData(&was_deleted)); 1672 delegate.set_url_request_user_data(new TestUserData(&was_deleted));
1739 host_.SetDelegate(&delegate); 1673 host_.SetDelegate(&delegate);
1740 1674
1741 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); 1675 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1());
1742 // We cancel from the renderer because all non-renderer cancels delete 1676 // We cancel from the renderer because all non-renderer cancels delete
1743 // the request synchronously. 1677 // the request synchronously.
1744 RendererCancelRequest(1); 1678 RendererCancelRequest(1);
1745 1679
1746 // Our TestResourceThrottle should not have been deleted yet. This is to 1680 // Our TestResourceThrottle should not have been deleted yet. This is to
1747 // ensure that destruction of the URLRequest happens asynchronously to 1681 // ensure that destruction of the URLRequest happens asynchronously to
1748 // calling CancelRequest. 1682 // calling CancelRequest.
1749 EXPECT_FALSE(was_deleted); 1683 EXPECT_FALSE(was_deleted);
1750 1684
1751 base::RunLoop().RunUntilIdle(); 1685 base::RunLoop().RunUntilIdle();
1752 1686
1753 EXPECT_TRUE(was_deleted); 1687 EXPECT_TRUE(was_deleted);
1754 } 1688 }
1755 1689
1756 TEST_P(ResourceDispatcherHostTest, DetachWhileStartIsDeferred) { 1690 TEST_F(ResourceDispatcherHostTest, DetachWhileStartIsDeferred) {
1757 bool was_deleted = false; 1691 bool was_deleted = false;
1758 1692
1759 // Arrange to have requests deferred before starting. 1693 // Arrange to have requests deferred before starting.
1760 TestResourceDispatcherHostDelegate delegate; 1694 TestResourceDispatcherHostDelegate delegate;
1761 delegate.set_flags(DEFER_STARTING_REQUEST); 1695 delegate.set_flags(DEFER_STARTING_REQUEST);
1762 delegate.set_url_request_user_data(new TestUserData(&was_deleted)); 1696 delegate.set_url_request_user_data(new TestUserData(&was_deleted));
1763 host_.SetDelegate(&delegate); 1697 host_.SetDelegate(&delegate);
1764 1698
1765 MakeTestRequestWithResourceType(filter_.get(), 0, 1, 1699 MakeTestRequestWithResourceType(filter_.get(), 0, 1,
1766 net::URLRequestTestJob::test_url_1(), 1700 net::URLRequestTestJob::test_url_1(),
(...skipping 21 matching lines...) Expand all
1788 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 1722 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
1789 base::RunLoop().RunUntilIdle(); 1723 base::RunLoop().RunUntilIdle();
1790 EXPECT_TRUE(was_deleted); 1724 EXPECT_TRUE(was_deleted);
1791 EXPECT_EQ(1, network_delegate()->completed_requests()); 1725 EXPECT_EQ(1, network_delegate()->completed_requests());
1792 EXPECT_EQ(0, network_delegate()->canceled_requests()); 1726 EXPECT_EQ(0, network_delegate()->canceled_requests());
1793 EXPECT_EQ(0, network_delegate()->error_count()); 1727 EXPECT_EQ(0, network_delegate()->error_count());
1794 } 1728 }
1795 1729
1796 // Tests if cancel is called in ResourceThrottle::WillStartRequest, then the 1730 // Tests if cancel is called in ResourceThrottle::WillStartRequest, then the
1797 // URLRequest will not be started. 1731 // URLRequest will not be started.
1798 TEST_P(ResourceDispatcherHostTest, CancelInResourceThrottleWillStartRequest) { 1732 TEST_F(ResourceDispatcherHostTest, CancelInResourceThrottleWillStartRequest) {
1799 TestResourceDispatcherHostDelegate delegate; 1733 TestResourceDispatcherHostDelegate delegate;
1800 delegate.set_flags(CANCEL_BEFORE_START); 1734 delegate.set_flags(CANCEL_BEFORE_START);
1801 host_.SetDelegate(&delegate); 1735 host_.SetDelegate(&delegate);
1802 1736
1803 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); 1737 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1());
1804 1738
1805 // flush all the pending requests 1739 // flush all the pending requests
1806 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 1740 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
1807 base::RunLoop().RunUntilIdle(); 1741 base::RunLoop().RunUntilIdle();
1808 1742
1809 ResourceIPCAccumulator::ClassifiedMessages msgs; 1743 ResourceIPCAccumulator::ClassifiedMessages msgs;
1810 accum_.GetClassifiedMessages(&msgs); 1744 accum_.GetClassifiedMessages(&msgs);
1811 1745
1812 // Check that request got canceled. 1746 // Check that request got canceled.
1813 ASSERT_EQ(1U, msgs[0].size()); 1747 ASSERT_EQ(1U, msgs[0].size());
1814 CheckRequestCompleteErrorCode(msgs[0][0], net::ERR_ABORTED); 1748 CheckRequestCompleteErrorCode(msgs[0][0], net::ERR_ABORTED);
1815 1749
1816 // Make sure URLRequest is never started. 1750 // Make sure URLRequest is never started.
1817 EXPECT_EQ(0, job_factory_->url_request_jobs_created_count()); 1751 EXPECT_EQ(0, job_factory_->url_request_jobs_created_count());
1818 } 1752 }
1819 1753
1820 TEST_P(ResourceDispatcherHostTest, PausedStartError) { 1754 TEST_F(ResourceDispatcherHostTest, PausedStartError) {
1821 // Arrange to have requests deferred before processing response headers. 1755 // Arrange to have requests deferred before processing response headers.
1822 TestResourceDispatcherHostDelegate delegate; 1756 TestResourceDispatcherHostDelegate delegate;
1823 delegate.set_flags(DEFER_PROCESSING_RESPONSE); 1757 delegate.set_flags(DEFER_PROCESSING_RESPONSE);
1824 host_.SetDelegate(&delegate); 1758 host_.SetDelegate(&delegate);
1825 1759
1826 job_factory_->SetDelayedStartJobGeneration(true); 1760 job_factory_->SetDelayedStartJobGeneration(true);
1827 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_error()); 1761 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_error());
1828 CompleteStartRequest(1); 1762 CompleteStartRequest(1);
1829 1763
1830 // flush all the pending requests 1764 // flush all the pending requests
1831 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 1765 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
1832 base::RunLoop().RunUntilIdle(); 1766 base::RunLoop().RunUntilIdle();
1833 1767
1834 EXPECT_EQ(0, host_.pending_requests()); 1768 EXPECT_EQ(0, host_.pending_requests());
1835 } 1769 }
1836 1770
1837 TEST_P(ResourceDispatcherHostTest, ThrottleAndResumeTwice) { 1771 TEST_F(ResourceDispatcherHostTest, ThrottleAndResumeTwice) {
1838 // Arrange to have requests deferred before starting. 1772 // Arrange to have requests deferred before starting.
1839 TestResourceDispatcherHostDelegate delegate; 1773 TestResourceDispatcherHostDelegate delegate;
1840 delegate.set_flags(DEFER_STARTING_REQUEST); 1774 delegate.set_flags(DEFER_STARTING_REQUEST);
1841 delegate.set_create_two_throttles(true); 1775 delegate.set_create_two_throttles(true);
1842 host_.SetDelegate(&delegate); 1776 host_.SetDelegate(&delegate);
1843 1777
1844 // Make sure the first throttle blocked the request, and then resume. 1778 // Make sure the first throttle blocked the request, and then resume.
1845 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); 1779 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1());
1846 GenericResourceThrottle* first_throttle = 1780 GenericResourceThrottle* first_throttle =
1847 GenericResourceThrottle::active_throttle(); 1781 GenericResourceThrottle::active_throttle();
(...skipping 17 matching lines...) Expand all
1865 1799
1866 // Make sure the request completed successfully. 1800 // Make sure the request completed successfully.
1867 ResourceIPCAccumulator::ClassifiedMessages msgs; 1801 ResourceIPCAccumulator::ClassifiedMessages msgs;
1868 accum_.GetClassifiedMessages(&msgs); 1802 accum_.GetClassifiedMessages(&msgs);
1869 ASSERT_EQ(1U, msgs.size()); 1803 ASSERT_EQ(1U, msgs.size());
1870 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1()); 1804 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1());
1871 } 1805 }
1872 1806
1873 1807
1874 // Tests that the delegate can cancel a request and provide a error code. 1808 // Tests that the delegate can cancel a request and provide a error code.
1875 TEST_P(ResourceDispatcherHostTest, CancelInDelegate) { 1809 TEST_F(ResourceDispatcherHostTest, CancelInDelegate) {
1876 TestResourceDispatcherHostDelegate delegate; 1810 TestResourceDispatcherHostDelegate delegate;
1877 delegate.set_flags(CANCEL_BEFORE_START); 1811 delegate.set_flags(CANCEL_BEFORE_START);
1878 delegate.set_error_code_for_cancellation(net::ERR_ACCESS_DENIED); 1812 delegate.set_error_code_for_cancellation(net::ERR_ACCESS_DENIED);
1879 host_.SetDelegate(&delegate); 1813 host_.SetDelegate(&delegate);
1880 1814
1881 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); 1815 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1());
1882 // The request will get cancelled by the throttle. 1816 // The request will get cancelled by the throttle.
1883 1817
1884 // flush all the pending requests 1818 // flush all the pending requests
1885 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 1819 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
1886 base::RunLoop().RunUntilIdle(); 1820 base::RunLoop().RunUntilIdle();
1887 1821
1888 ResourceIPCAccumulator::ClassifiedMessages msgs; 1822 ResourceIPCAccumulator::ClassifiedMessages msgs;
1889 accum_.GetClassifiedMessages(&msgs); 1823 accum_.GetClassifiedMessages(&msgs);
1890 1824
1891 // Check the cancellation 1825 // Check the cancellation
1892 ASSERT_EQ(1U, msgs.size()); 1826 ASSERT_EQ(1U, msgs.size());
1893 ASSERT_EQ(1U, msgs[0].size()); 1827 ASSERT_EQ(1U, msgs[0].size());
1894 1828
1895 CheckRequestCompleteErrorCode(msgs[0][0], net::ERR_ACCESS_DENIED); 1829 CheckRequestCompleteErrorCode(msgs[0][0], net::ERR_ACCESS_DENIED);
1896 } 1830 }
1897 1831
1898 // Tests CancelRequestsForProcess 1832 // Tests CancelRequestsForProcess
1899 TEST_P(ResourceDispatcherHostTest, TestProcessCancel) { 1833 TEST_F(ResourceDispatcherHostTest, TestProcessCancel) {
1900 scoped_refptr<TestFilter> test_filter = new TestFilter( 1834 scoped_refptr<TestFilter> test_filter = new TestFilter(
1901 browser_context_->GetResourceContext()); 1835 browser_context_->GetResourceContext());
1902 child_ids_.insert(test_filter->child_id()); 1836 child_ids_.insert(test_filter->child_id());
1903 1837
1904 // request 1 goes to the test delegate 1838 // request 1 goes to the test delegate
1905 MakeTestRequestWithResourceType(test_filter.get(), 0, 1, 1839 MakeTestRequestWithResourceType(test_filter.get(), 0, 1,
1906 net::URLRequestTestJob::test_url_1(), 1840 net::URLRequestTestJob::test_url_1(),
1907 RESOURCE_TYPE_SUB_RESOURCE); 1841 RESOURCE_TYPE_SUB_RESOURCE);
1908 1842
1909 // request 2 goes to us 1843 // request 2 goes to us
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 // But it completed anyway. For the network stack, no requests were canceled. 1902 // But it completed anyway. For the network stack, no requests were canceled.
1969 EXPECT_EQ(4, network_delegate()->completed_requests()); 1903 EXPECT_EQ(4, network_delegate()->completed_requests());
1970 EXPECT_EQ(0, network_delegate()->canceled_requests()); 1904 EXPECT_EQ(0, network_delegate()->canceled_requests());
1971 EXPECT_EQ(0, network_delegate()->error_count()); 1905 EXPECT_EQ(0, network_delegate()->error_count());
1972 1906
1973 test_filter->OnChannelClosing(); 1907 test_filter->OnChannelClosing();
1974 } 1908 }
1975 1909
1976 // Tests whether the correct requests get canceled when a RenderViewHost is 1910 // Tests whether the correct requests get canceled when a RenderViewHost is
1977 // deleted. 1911 // deleted.
1978 TEST_P(ResourceDispatcherHostTest, CancelRequestsOnRenderFrameDeleted) { 1912 TEST_F(ResourceDispatcherHostTest, CancelRequestsOnRenderFrameDeleted) {
1979 // Requests all hang once started. This prevents requests from being 1913 // Requests all hang once started. This prevents requests from being
1980 // destroyed due to completion. 1914 // destroyed due to completion.
1981 job_factory_->SetHangAfterStartJobGeneration(true); 1915 job_factory_->SetHangAfterStartJobGeneration(true);
1982 HandleScheme("http"); 1916 HandleScheme("http");
1983 1917
1984 TestResourceDispatcherHostDelegate delegate; 1918 TestResourceDispatcherHostDelegate delegate;
1985 host_.SetDelegate(&delegate); 1919 host_.SetDelegate(&delegate);
1986 host_.OnRenderViewHostCreated(filter_->child_id(), 0); 1920 host_.OnRenderViewHostCreated(filter_->child_id(), 0);
1987 1921
1988 // One RenderView issues a high priority request and a low priority one. Both 1922 // One RenderView issues a high priority request and a low priority one. Both
(...skipping 29 matching lines...) Expand all
2018 EXPECT_EQ(3, network_delegate_.created_requests()); 1952 EXPECT_EQ(3, network_delegate_.created_requests());
2019 EXPECT_EQ(4, network_delegate_.canceled_requests()); 1953 EXPECT_EQ(4, network_delegate_.canceled_requests());
2020 1954
2021 // No messages should have been sent, since none of the jobs made any 1955 // No messages should have been sent, since none of the jobs made any
2022 // progress. 1956 // progress.
2023 ResourceIPCAccumulator::ClassifiedMessages msgs; 1957 ResourceIPCAccumulator::ClassifiedMessages msgs;
2024 accum_.GetClassifiedMessages(&msgs); 1958 accum_.GetClassifiedMessages(&msgs);
2025 EXPECT_EQ(0U, msgs.size()); 1959 EXPECT_EQ(0U, msgs.size());
2026 } 1960 }
2027 1961
2028 TEST_P(ResourceDispatcherHostTest, TestProcessCancelDetachedTimesOut) { 1962 TEST_F(ResourceDispatcherHostTest, TestProcessCancelDetachedTimesOut) {
2029 MakeTestRequestWithResourceType(filter_.get(), 0, 1, 1963 MakeTestRequestWithResourceType(filter_.get(), 0, 1,
2030 net::URLRequestTestJob::test_url_4(), 1964 net::URLRequestTestJob::test_url_4(),
2031 RESOURCE_TYPE_PREFETCH); // detachable type 1965 RESOURCE_TYPE_PREFETCH); // detachable type
2032 GlobalRequestID global_request_id(filter_->child_id(), 1); 1966 GlobalRequestID global_request_id(filter_->child_id(), 1);
2033 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest( 1967 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(
2034 host_.GetURLRequest(global_request_id)); 1968 host_.GetURLRequest(global_request_id));
2035 ASSERT_TRUE(info->detachable_handler()); 1969 ASSERT_TRUE(info->detachable_handler());
2036 info->detachable_handler()->set_cancel_delay( 1970 info->detachable_handler()->set_cancel_delay(
2037 base::TimeDelta::FromMilliseconds(200)); 1971 base::TimeDelta::FromMilliseconds(200));
2038 base::RunLoop().RunUntilIdle(); 1972 base::RunLoop().RunUntilIdle();
(...skipping 25 matching lines...) Expand all
2064 ASSERT_EQ(2U, msgs[0].size()); 1998 ASSERT_EQ(2U, msgs[0].size());
2065 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[0][0].type()); 1999 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[0][0].type());
2066 CheckRequestCompleteErrorCode(msgs[0][1], net::ERR_ABORTED); 2000 CheckRequestCompleteErrorCode(msgs[0][1], net::ERR_ABORTED);
2067 // And not run to completion. 2001 // And not run to completion.
2068 EXPECT_EQ(1, network_delegate()->completed_requests()); 2002 EXPECT_EQ(1, network_delegate()->completed_requests());
2069 EXPECT_EQ(1, network_delegate()->canceled_requests()); 2003 EXPECT_EQ(1, network_delegate()->canceled_requests());
2070 EXPECT_EQ(0, network_delegate()->error_count()); 2004 EXPECT_EQ(0, network_delegate()->error_count());
2071 } 2005 }
2072 2006
2073 // Tests blocking and resuming requests. 2007 // Tests blocking and resuming requests.
2074 TEST_P(ResourceDispatcherHostTest, TestBlockingResumingRequests) { 2008 TEST_F(ResourceDispatcherHostTest, TestBlockingResumingRequests) {
2075 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 11)); 2009 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 11));
2076 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 12)); 2010 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 12));
2077 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 13)); 2011 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 13));
2078 2012
2079 MakeTestRequestWithRenderFrame(0, 10, 1, net::URLRequestTestJob::test_url_1(), 2013 MakeTestRequestWithRenderFrame(0, 10, 1, net::URLRequestTestJob::test_url_1(),
2080 RESOURCE_TYPE_SUB_RESOURCE); 2014 RESOURCE_TYPE_SUB_RESOURCE);
2081 MakeTestRequestWithRenderFrame(1, 11, 2, net::URLRequestTestJob::test_url_2(), 2015 MakeTestRequestWithRenderFrame(1, 11, 2, net::URLRequestTestJob::test_url_2(),
2082 RESOURCE_TYPE_SUB_RESOURCE); 2016 RESOURCE_TYPE_SUB_RESOURCE);
2083 MakeTestRequestWithRenderFrame(0, 10, 3, net::URLRequestTestJob::test_url_3(), 2017 MakeTestRequestWithRenderFrame(0, 10, 3, net::URLRequestTestJob::test_url_3(),
2084 RESOURCE_TYPE_SUB_RESOURCE); 2018 RESOURCE_TYPE_SUB_RESOURCE);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2066 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2133 2067
2134 msgs.clear(); 2068 msgs.clear();
2135 accum_.GetClassifiedMessages(&msgs); 2069 accum_.GetClassifiedMessages(&msgs);
2136 ASSERT_EQ(2U, msgs.size()); 2070 ASSERT_EQ(2U, msgs.size());
2137 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_2()); 2071 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_2());
2138 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3()); 2072 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3());
2139 } 2073 }
2140 2074
2141 // Tests blocking and canceling requests. 2075 // Tests blocking and canceling requests.
2142 TEST_P(ResourceDispatcherHostTest, TestBlockingCancelingRequests) { 2076 TEST_F(ResourceDispatcherHostTest, TestBlockingCancelingRequests) {
2143 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 11)); 2077 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 11));
2144 2078
2145 MakeTestRequestWithRenderFrame(0, 10, 1, net::URLRequestTestJob::test_url_1(), 2079 MakeTestRequestWithRenderFrame(0, 10, 1, net::URLRequestTestJob::test_url_1(),
2146 RESOURCE_TYPE_SUB_RESOURCE); 2080 RESOURCE_TYPE_SUB_RESOURCE);
2147 MakeTestRequestWithRenderFrame(1, 11, 2, net::URLRequestTestJob::test_url_2(), 2081 MakeTestRequestWithRenderFrame(1, 11, 2, net::URLRequestTestJob::test_url_2(),
2148 RESOURCE_TYPE_SUB_RESOURCE); 2082 RESOURCE_TYPE_SUB_RESOURCE);
2149 MakeTestRequestWithRenderFrame(0, 10, 3, net::URLRequestTestJob::test_url_3(), 2083 MakeTestRequestWithRenderFrame(0, 10, 3, net::URLRequestTestJob::test_url_3(),
2150 RESOURCE_TYPE_SUB_RESOURCE); 2084 RESOURCE_TYPE_SUB_RESOURCE);
2151 MakeTestRequestWithRenderFrame(1, 11, 4, net::URLRequestTestJob::test_url_1(), 2085 MakeTestRequestWithRenderFrame(1, 11, 4, net::URLRequestTestJob::test_url_1(),
2152 RESOURCE_TYPE_SUB_RESOURCE); 2086 RESOURCE_TYPE_SUB_RESOURCE);
(...skipping 20 matching lines...) Expand all
2173 GlobalFrameRoutingId(filter_->child_id(), 11)); 2107 GlobalFrameRoutingId(filter_->child_id(), 11));
2174 KickOffRequest(); 2108 KickOffRequest();
2175 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2109 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2176 2110
2177 msgs.clear(); 2111 msgs.clear();
2178 accum_.GetClassifiedMessages(&msgs); 2112 accum_.GetClassifiedMessages(&msgs);
2179 ASSERT_EQ(0U, msgs.size()); 2113 ASSERT_EQ(0U, msgs.size());
2180 } 2114 }
2181 2115
2182 // Tests that blocked requests are canceled if their associated process dies. 2116 // Tests that blocked requests are canceled if their associated process dies.
2183 TEST_P(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) { 2117 TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) {
2184 // This second filter is used to emulate a second process. 2118 // This second filter is used to emulate a second process.
2185 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 2119 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
2186 2120
2187 host_.BlockRequestsForRoute( 2121 host_.BlockRequestsForRoute(
2188 GlobalFrameRoutingId(second_filter->child_id(), 0)); 2122 GlobalFrameRoutingId(second_filter->child_id(), 0));
2189 2123
2190 MakeTestRequestWithResourceType(filter_.get(), 0, 1, 2124 MakeTestRequestWithResourceType(filter_.get(), 0, 1,
2191 net::URLRequestTestJob::test_url_1(), 2125 net::URLRequestTestJob::test_url_1(),
2192 RESOURCE_TYPE_SUB_RESOURCE); 2126 RESOURCE_TYPE_SUB_RESOURCE);
2193 MakeTestRequestWithResourceType(second_filter.get(), 0, 2, 2127 MakeTestRequestWithResourceType(second_filter.get(), 0, 2,
(...skipping 27 matching lines...) Expand all
2221 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3()); 2155 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3());
2222 2156
2223 EXPECT_TRUE(host_.blocked_loaders_map_.empty()); 2157 EXPECT_TRUE(host_.blocked_loaders_map_.empty());
2224 second_filter->OnChannelClosing(); 2158 second_filter->OnChannelClosing();
2225 } 2159 }
2226 2160
2227 // Tests that blocked requests don't leak when the ResourceDispatcherHost goes 2161 // Tests that blocked requests don't leak when the ResourceDispatcherHost goes
2228 // away. Note that we rely on Purify for finding the leaks if any. 2162 // away. Note that we rely on Purify for finding the leaks if any.
2229 // If this test turns the Purify bot red, check the ResourceDispatcherHost 2163 // If this test turns the Purify bot red, check the ResourceDispatcherHost
2230 // destructor to make sure the blocked requests are deleted. 2164 // destructor to make sure the blocked requests are deleted.
2231 TEST_P(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) { 2165 TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) {
2232 // This second filter is used to emulate a second process. 2166 // This second filter is used to emulate a second process.
2233 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 2167 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
2234 2168
2235 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 1)); 2169 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 1));
2236 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 2)); 2170 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 2));
2237 host_.BlockRequestsForRoute( 2171 host_.BlockRequestsForRoute(
2238 GlobalFrameRoutingId(second_filter->child_id(), 1)); 2172 GlobalFrameRoutingId(second_filter->child_id(), 1));
2239 2173
2240 MakeTestRequestWithResourceType(filter_.get(), 0, 1, 2174 MakeTestRequestWithResourceType(filter_.get(), 0, 1,
2241 net::URLRequestTestJob::test_url_1(), 2175 net::URLRequestTestJob::test_url_1(),
(...skipping 23 matching lines...) Expand all
2265 host_.CancelRequestsForProcess(filter_->child_id()); 2199 host_.CancelRequestsForProcess(filter_->child_id());
2266 host_.CancelRequestsForProcess(second_filter->child_id()); 2200 host_.CancelRequestsForProcess(second_filter->child_id());
2267 2201
2268 // Flush all the pending requests. 2202 // Flush all the pending requests.
2269 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2203 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2270 2204
2271 second_filter->OnChannelClosing(); 2205 second_filter->OnChannelClosing();
2272 } 2206 }
2273 2207
2274 // Test the private helper method "CalculateApproximateMemoryCost()". 2208 // Test the private helper method "CalculateApproximateMemoryCost()".
2275 TEST_P(ResourceDispatcherHostTest, CalculateApproximateMemoryCost) { 2209 TEST_F(ResourceDispatcherHostTest, CalculateApproximateMemoryCost) {
2276 net::URLRequestContext context; 2210 net::URLRequestContext context;
2277 std::unique_ptr<net::URLRequest> req(context.CreateRequest( 2211 std::unique_ptr<net::URLRequest> req(context.CreateRequest(
2278 GURL("http://www.google.com"), net::DEFAULT_PRIORITY, NULL)); 2212 GURL("http://www.google.com"), net::DEFAULT_PRIORITY, NULL));
2279 EXPECT_EQ(4425, ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( 2213 EXPECT_EQ(4425, ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(
2280 req.get())); 2214 req.get()));
2281 2215
2282 // Add 9 bytes of referrer. 2216 // Add 9 bytes of referrer.
2283 req->SetReferrer("123456789"); 2217 req->SetReferrer("123456789");
2284 EXPECT_EQ(4434, ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( 2218 EXPECT_EQ(4434, ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(
2285 req.get())); 2219 req.get()));
2286 2220
2287 // Add 33 bytes of upload content. 2221 // Add 33 bytes of upload content.
2288 std::string upload_content; 2222 std::string upload_content;
2289 upload_content.resize(33); 2223 upload_content.resize(33);
2290 std::fill(upload_content.begin(), upload_content.end(), 'x'); 2224 std::fill(upload_content.begin(), upload_content.end(), 'x');
2291 std::unique_ptr<net::UploadElementReader> reader( 2225 std::unique_ptr<net::UploadElementReader> reader(
2292 new net::UploadBytesElementReader(upload_content.data(), 2226 new net::UploadBytesElementReader(upload_content.data(),
2293 upload_content.size())); 2227 upload_content.size()));
2294 req->set_upload( 2228 req->set_upload(
2295 net::ElementsUploadDataStream::CreateWithReader(std::move(reader), 0)); 2229 net::ElementsUploadDataStream::CreateWithReader(std::move(reader), 0));
2296 2230
2297 // Since the upload throttling is disabled, this has no effect on the cost. 2231 // Since the upload throttling is disabled, this has no effect on the cost.
2298 EXPECT_EQ(4434, ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( 2232 EXPECT_EQ(4434, ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(
2299 req.get())); 2233 req.get()));
2300 } 2234 }
2301 2235
2302 // Test that too much memory for outstanding requests for a particular 2236 // Test that too much memory for outstanding requests for a particular
2303 // render_process_host_id causes requests to fail. 2237 // render_process_host_id causes requests to fail.
2304 TEST_P(ResourceDispatcherHostTest, TooMuchOutstandingRequestsMemory) { 2238 TEST_F(ResourceDispatcherHostTest, TooMuchOutstandingRequestsMemory) {
2305 // Expected cost of each request as measured by 2239 // Expected cost of each request as measured by
2306 // ResourceDispatcherHost::CalculateApproximateMemoryCost(). 2240 // ResourceDispatcherHost::CalculateApproximateMemoryCost().
2307 int kMemoryCostOfTest2Req = 2241 int kMemoryCostOfTest2Req =
2308 ResourceDispatcherHostImpl::kAvgBytesPerOutstandingRequest + 2242 ResourceDispatcherHostImpl::kAvgBytesPerOutstandingRequest +
2309 net::URLRequestTestJob::test_url_2().spec().size() + sizeof("GET") - 1; 2243 net::URLRequestTestJob::test_url_2().spec().size() + sizeof("GET") - 1;
2310 2244
2311 // Tighten the bound on the ResourceDispatcherHost, to speed things up. 2245 // Tighten the bound on the ResourceDispatcherHost, to speed things up.
2312 int kMaxCostPerProcess = 440000; 2246 int kMaxCostPerProcess = 440000;
2313 host_.set_max_outstanding_requests_cost_per_process(kMaxCostPerProcess); 2247 host_.set_max_outstanding_requests_cost_per_process(kMaxCostPerProcess);
2314 2248
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 net::URLRequestTestJob::test_data_2()); 2306 net::URLRequestTestJob::test_data_2());
2373 CheckSuccessfulRequest(msgs[kMaxRequests + 3], 2307 CheckSuccessfulRequest(msgs[kMaxRequests + 3],
2374 net::URLRequestTestJob::test_data_2()); 2308 net::URLRequestTestJob::test_data_2());
2375 2309
2376 second_filter->OnChannelClosing(); 2310 second_filter->OnChannelClosing();
2377 } 2311 }
2378 2312
2379 // Test that when too many requests are outstanding for a particular 2313 // Test that when too many requests are outstanding for a particular
2380 // render_process_host_id, any subsequent request from it fails. Also verify 2314 // render_process_host_id, any subsequent request from it fails. Also verify
2381 // that the global limit is honored. 2315 // that the global limit is honored.
2382 TEST_P(ResourceDispatcherHostTest, TooManyOutstandingRequests) { 2316 TEST_F(ResourceDispatcherHostTest, TooManyOutstandingRequests) {
2383 // Tighten the bound on the ResourceDispatcherHost, to speed things up. 2317 // Tighten the bound on the ResourceDispatcherHost, to speed things up.
2384 const size_t kMaxRequestsPerProcess = 2; 2318 const size_t kMaxRequestsPerProcess = 2;
2385 host_.set_max_num_in_flight_requests_per_process(kMaxRequestsPerProcess); 2319 host_.set_max_num_in_flight_requests_per_process(kMaxRequestsPerProcess);
2386 const size_t kMaxRequests = 3; 2320 const size_t kMaxRequests = 3;
2387 host_.set_max_num_in_flight_requests(kMaxRequests); 2321 host_.set_max_num_in_flight_requests(kMaxRequests);
2388 2322
2389 // Needed to emulate additional processes. 2323 // Needed to emulate additional processes.
2390 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 2324 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
2391 scoped_refptr<ForwardingFilter> third_filter = MakeForwardingFilter(); 2325 scoped_refptr<ForwardingFilter> third_filter = MakeForwardingFilter();
2392 2326
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2438 net::URLRequestTestJob::test_data_2()); 2372 net::URLRequestTestJob::test_data_2());
2439 CheckFailedRequest(msgs[kMaxRequestsPerProcess + 2], 2373 CheckFailedRequest(msgs[kMaxRequestsPerProcess + 2],
2440 net::URLRequestTestJob::test_data_2(), 2374 net::URLRequestTestJob::test_data_2(),
2441 net::ERR_INSUFFICIENT_RESOURCES); 2375 net::ERR_INSUFFICIENT_RESOURCES);
2442 2376
2443 second_filter->OnChannelClosing(); 2377 second_filter->OnChannelClosing();
2444 third_filter->OnChannelClosing(); 2378 third_filter->OnChannelClosing();
2445 } 2379 }
2446 2380
2447 // Tests that we sniff the mime type for a simple request. 2381 // Tests that we sniff the mime type for a simple request.
2448 TEST_P(ResourceDispatcherHostTest, MimeSniffed) { 2382 TEST_F(ResourceDispatcherHostTest, MimeSniffed) {
2449 std::string raw_headers("HTTP/1.1 200 OK\n\n"); 2383 std::string raw_headers("HTTP/1.1 200 OK\n\n");
2450 std::string response_data("<html><title>Test One</title></html>"); 2384 std::string response_data("<html><title>Test One</title></html>");
2451 SetResponse(raw_headers, response_data); 2385 SetResponse(raw_headers, response_data);
2452 2386
2453 HandleScheme("http"); 2387 HandleScheme("http");
2454 MakeTestRequest(0, 1, GURL("http:bla")); 2388 MakeTestRequest(0, 1, GURL("http:bla"));
2455 2389
2456 // Flush all pending requests. 2390 // Flush all pending requests.
2457 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2391 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2458 2392
2459 // Sorts out all the messages we saw by request. 2393 // Sorts out all the messages we saw by request.
2460 ResourceIPCAccumulator::ClassifiedMessages msgs; 2394 ResourceIPCAccumulator::ClassifiedMessages msgs;
2461 accum_.GetClassifiedMessages(&msgs); 2395 accum_.GetClassifiedMessages(&msgs);
2462 ASSERT_EQ(1U, msgs.size()); 2396 ASSERT_EQ(1U, msgs.size());
2463 2397
2464 ResourceResponseHead response_head; 2398 ResourceResponseHead response_head;
2465 GetResponseHead(msgs[0], &response_head); 2399 GetResponseHead(msgs[0], &response_head);
2466 ASSERT_EQ("text/html", response_head.mime_type); 2400 ASSERT_EQ("text/html", response_head.mime_type);
2467 } 2401 }
2468 2402
2469 // Tests that we don't sniff the mime type when the server provides one. 2403 // Tests that we don't sniff the mime type when the server provides one.
2470 TEST_P(ResourceDispatcherHostTest, MimeNotSniffed) { 2404 TEST_F(ResourceDispatcherHostTest, MimeNotSniffed) {
2471 std::string raw_headers("HTTP/1.1 200 OK\n" 2405 std::string raw_headers("HTTP/1.1 200 OK\n"
2472 "Content-type: image/jpeg\n\n"); 2406 "Content-type: image/jpeg\n\n");
2473 std::string response_data("<html><title>Test One</title></html>"); 2407 std::string response_data("<html><title>Test One</title></html>");
2474 SetResponse(raw_headers, response_data); 2408 SetResponse(raw_headers, response_data);
2475 2409
2476 HandleScheme("http"); 2410 HandleScheme("http");
2477 MakeTestRequest(0, 1, GURL("http:bla")); 2411 MakeTestRequest(0, 1, GURL("http:bla"));
2478 2412
2479 // Flush all pending requests. 2413 // Flush all pending requests.
2480 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2414 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2481 2415
2482 // Sorts out all the messages we saw by request. 2416 // Sorts out all the messages we saw by request.
2483 ResourceIPCAccumulator::ClassifiedMessages msgs; 2417 ResourceIPCAccumulator::ClassifiedMessages msgs;
2484 accum_.GetClassifiedMessages(&msgs); 2418 accum_.GetClassifiedMessages(&msgs);
2485 ASSERT_EQ(1U, msgs.size()); 2419 ASSERT_EQ(1U, msgs.size());
2486 2420
2487 ResourceResponseHead response_head; 2421 ResourceResponseHead response_head;
2488 GetResponseHead(msgs[0], &response_head); 2422 GetResponseHead(msgs[0], &response_head);
2489 ASSERT_EQ("image/jpeg", response_head.mime_type); 2423 ASSERT_EQ("image/jpeg", response_head.mime_type);
2490 } 2424 }
2491 2425
2492 // Tests that we don't sniff the mime type when there is no message body. 2426 // Tests that we don't sniff the mime type when there is no message body.
2493 TEST_P(ResourceDispatcherHostTest, MimeNotSniffed2) { 2427 TEST_F(ResourceDispatcherHostTest, MimeNotSniffed2) {
2494 SetResponse("HTTP/1.1 304 Not Modified\n\n"); 2428 SetResponse("HTTP/1.1 304 Not Modified\n\n");
2495 2429
2496 HandleScheme("http"); 2430 HandleScheme("http");
2497 MakeTestRequest(0, 1, GURL("http:bla")); 2431 MakeTestRequest(0, 1, GURL("http:bla"));
2498 2432
2499 // Flush all pending requests. 2433 // Flush all pending requests.
2500 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2434 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2501 2435
2502 // Sorts out all the messages we saw by request. 2436 // Sorts out all the messages we saw by request.
2503 ResourceIPCAccumulator::ClassifiedMessages msgs; 2437 ResourceIPCAccumulator::ClassifiedMessages msgs;
2504 accum_.GetClassifiedMessages(&msgs); 2438 accum_.GetClassifiedMessages(&msgs);
2505 ASSERT_EQ(1U, msgs.size()); 2439 ASSERT_EQ(1U, msgs.size());
2506 2440
2507 ResourceResponseHead response_head; 2441 ResourceResponseHead response_head;
2508 GetResponseHead(msgs[0], &response_head); 2442 GetResponseHead(msgs[0], &response_head);
2509 ASSERT_EQ("", response_head.mime_type); 2443 ASSERT_EQ("", response_head.mime_type);
2510 } 2444 }
2511 2445
2512 TEST_P(ResourceDispatcherHostTest, MimeSniff204) { 2446 TEST_F(ResourceDispatcherHostTest, MimeSniff204) {
2513 SetResponse("HTTP/1.1 204 No Content\n\n"); 2447 SetResponse("HTTP/1.1 204 No Content\n\n");
2514 2448
2515 HandleScheme("http"); 2449 HandleScheme("http");
2516 MakeTestRequest(0, 1, GURL("http:bla")); 2450 MakeTestRequest(0, 1, GURL("http:bla"));
2517 2451
2518 // Flush all pending requests. 2452 // Flush all pending requests.
2519 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2453 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2520 2454
2521 // Sorts out all the messages we saw by request. 2455 // Sorts out all the messages we saw by request.
2522 ResourceIPCAccumulator::ClassifiedMessages msgs; 2456 ResourceIPCAccumulator::ClassifiedMessages msgs;
2523 accum_.GetClassifiedMessages(&msgs); 2457 accum_.GetClassifiedMessages(&msgs);
2524 ASSERT_EQ(1U, msgs.size()); 2458 ASSERT_EQ(1U, msgs.size());
2525 2459
2526 ResourceResponseHead response_head; 2460 ResourceResponseHead response_head;
2527 GetResponseHead(msgs[0], &response_head); 2461 GetResponseHead(msgs[0], &response_head);
2528 ASSERT_EQ("text/plain", response_head.mime_type); 2462 ASSERT_EQ("text/plain", response_head.mime_type);
2529 } 2463 }
2530 2464
2531 TEST_P(ResourceDispatcherHostTest, MimeSniffEmpty) { 2465 TEST_F(ResourceDispatcherHostTest, MimeSniffEmpty) {
2532 SetResponse("HTTP/1.1 200 OK\n\n"); 2466 SetResponse("HTTP/1.1 200 OK\n\n");
2533 2467
2534 HandleScheme("http"); 2468 HandleScheme("http");
2535 MakeTestRequest(0, 1, GURL("http:bla")); 2469 MakeTestRequest(0, 1, GURL("http:bla"));
2536 2470
2537 // Flush all pending requests. 2471 // Flush all pending requests.
2538 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2472 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2539 2473
2540 // Sorts out all the messages we saw by request. 2474 // Sorts out all the messages we saw by request.
2541 ResourceIPCAccumulator::ClassifiedMessages msgs; 2475 ResourceIPCAccumulator::ClassifiedMessages msgs;
2542 accum_.GetClassifiedMessages(&msgs); 2476 accum_.GetClassifiedMessages(&msgs);
2543 ASSERT_EQ(1U, msgs.size()); 2477 ASSERT_EQ(1U, msgs.size());
2544 2478
2545 ResourceResponseHead response_head; 2479 ResourceResponseHead response_head;
2546 GetResponseHead(msgs[0], &response_head); 2480 GetResponseHead(msgs[0], &response_head);
2547 ASSERT_EQ("text/plain", response_head.mime_type); 2481 ASSERT_EQ("text/plain", response_head.mime_type);
2548 } 2482 }
2549 2483
2550 // Tests for crbug.com/31266 (Non-2xx + application/octet-stream). 2484 // Tests for crbug.com/31266 (Non-2xx + application/octet-stream).
2551 TEST_P(ResourceDispatcherHostTest, ForbiddenDownload) { 2485 TEST_F(ResourceDispatcherHostTest, ForbiddenDownload) {
2552 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 2486 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
2553 std::string raw_headers("HTTP/1.1 403 Forbidden\n" 2487 std::string raw_headers("HTTP/1.1 403 Forbidden\n"
2554 "Content-disposition: attachment; filename=blah\n" 2488 "Content-disposition: attachment; filename=blah\n"
2555 "Content-type: application/octet-stream\n\n"); 2489 "Content-type: application/octet-stream\n\n");
2556 std::string response_data("<html><title>Test One</title></html>"); 2490 std::string response_data("<html><title>Test One</title></html>");
2557 SetResponse(raw_headers, response_data); 2491 SetResponse(raw_headers, response_data);
2558 2492
2559 HandleScheme("http"); 2493 HandleScheme("http");
2560 2494
2561 int expected_error_code = net::ERR_INVALID_RESPONSE; 2495 int expected_error_code = net::ERR_INVALID_RESPONSE;
2562 GURL forbidden_download_url = GURL("http:bla"); 2496 GURL forbidden_download_url = GURL("http:bla");
2563 2497
2564 CompleteFailingMainResourceRequest(forbidden_download_url, 2498 CompleteFailingMainResourceRequest(forbidden_download_url,
2565 expected_error_code); 2499 expected_error_code);
2566 } 2500 }
2567 2501
2568 // Test for http://crbug.com/76202 . We don't want to destroy a 2502 // Test for http://crbug.com/76202 . We don't want to destroy a
2569 // download request prematurely when processing a cancellation from 2503 // download request prematurely when processing a cancellation from
2570 // the renderer. 2504 // the renderer.
2571 TEST_P(ResourceDispatcherHostTest, IgnoreCancelForDownloads) { 2505 TEST_F(ResourceDispatcherHostTest, IgnoreCancelForDownloads) {
2572 // PlzNavigate: A request that ends up being a download is a main resource 2506 // PlzNavigate: A request that ends up being a download is a main resource
2573 // request. Hence, it has been initiated by the browser and is not associated 2507 // request. Hence, it has been initiated by the browser and is not associated
2574 // with a renderer. Therefore, it cannot be canceled by a renderer IPC. 2508 // with a renderer. Therefore, it cannot be canceled by a renderer IPC.
2575 if (IsBrowserSideNavigationEnabled()) { 2509 if (IsBrowserSideNavigationEnabled()) {
2576 SUCCEED() << "Not applicable with --enable-browser-side-navigation."; 2510 SUCCEED() << "Not applicable with --enable-browser-side-navigation.";
2577 return; 2511 return;
2578 } 2512 }
2579 2513
2580 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 2514 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
2581 2515
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2613 2547
2614 // Since the request had already started processing as a download, 2548 // Since the request had already started processing as a download,
2615 // the cancellation above should have been ignored and the request 2549 // the cancellation above should have been ignored and the request
2616 // should still be alive. 2550 // should still be alive.
2617 EXPECT_EQ(1, host_.pending_requests()); 2551 EXPECT_EQ(1, host_.pending_requests());
2618 2552
2619 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2553 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2620 base::RunLoop().RunUntilIdle(); 2554 base::RunLoop().RunUntilIdle();
2621 } 2555 }
2622 2556
2623 TEST_P(ResourceDispatcherHostTest, CancelRequestsForContext) { 2557 TEST_F(ResourceDispatcherHostTest, CancelRequestsForContext) {
2624 EXPECT_EQ(0, host_.pending_requests()); 2558 EXPECT_EQ(0, host_.pending_requests());
2625 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 2559 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
2626 2560
2627 int render_view_id = 0; 2561 int render_view_id = 0;
2628 int request_id = 1; 2562 int request_id = 1;
2629 2563
2630 std::string raw_headers("HTTP\n" 2564 std::string raw_headers("HTTP\n"
2631 "Content-disposition: attachment; filename=foo\n\n"); 2565 "Content-disposition: attachment; filename=foo\n\n");
2632 std::string response_data("01234567890123456789\x01foobar"); 2566 std::string response_data("01234567890123456789\x01foobar");
2633 // Get past sniffing metrics. 2567 // Get past sniffing metrics.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2704 // Cancelling by context should work. 2638 // Cancelling by context should work.
2705 host_.CancelRequestsForContext(filter_->resource_context()); 2639 host_.CancelRequestsForContext(filter_->resource_context());
2706 EXPECT_EQ(0, host_.pending_requests()); 2640 EXPECT_EQ(0, host_.pending_requests());
2707 2641
2708 while (net::URLRequestTestJob::ProcessOnePendingMessage()) { 2642 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {
2709 } 2643 }
2710 base::RunLoop().RunUntilIdle(); 2644 base::RunLoop().RunUntilIdle();
2711 } 2645 }
2712 } 2646 }
2713 2647
2714 TEST_P(ResourceDispatcherHostTest, CancelRequestsForContextDetached) { 2648 TEST_F(ResourceDispatcherHostTest, CancelRequestsForContextDetached) {
2715 EXPECT_EQ(0, host_.pending_requests()); 2649 EXPECT_EQ(0, host_.pending_requests());
2716 2650
2717 int render_view_id = 0; 2651 int render_view_id = 0;
2718 int request_id = 1; 2652 int request_id = 1;
2719 2653
2720 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 2654 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
2721 net::URLRequestTestJob::test_url_4(), 2655 net::URLRequestTestJob::test_url_4(),
2722 RESOURCE_TYPE_PREFETCH); // detachable type 2656 RESOURCE_TYPE_PREFETCH); // detachable type
2723 2657
2724 // Simulate a cancel coming from the renderer. 2658 // Simulate a cancel coming from the renderer.
2725 RendererCancelRequest(request_id); 2659 RendererCancelRequest(request_id);
2726 2660
2727 // Since the request had already started processing as detachable, 2661 // Since the request had already started processing as detachable,
2728 // the cancellation above should have been ignored and the request 2662 // the cancellation above should have been ignored and the request
2729 // should have been detached. 2663 // should have been detached.
2730 EXPECT_EQ(1, host_.pending_requests()); 2664 EXPECT_EQ(1, host_.pending_requests());
2731 2665
2732 // Cancelling by other methods should also leave it detached. 2666 // Cancelling by other methods should also leave it detached.
2733 host_.CancelRequestsForProcess(render_view_id); 2667 host_.CancelRequestsForProcess(render_view_id);
2734 EXPECT_EQ(1, host_.pending_requests()); 2668 EXPECT_EQ(1, host_.pending_requests());
2735 2669
2736 // Cancelling by context should work. 2670 // Cancelling by context should work.
2737 host_.CancelRequestsForContext(filter_->resource_context()); 2671 host_.CancelRequestsForContext(filter_->resource_context());
2738 EXPECT_EQ(0, host_.pending_requests()); 2672 EXPECT_EQ(0, host_.pending_requests());
2739 } 2673 }
2740 2674
2741 // Test the cancelling of requests that are being transferred to a new renderer 2675 // Test the cancelling of requests that are being transferred to a new renderer
2742 // due to a redirection. 2676 // due to a redirection.
2743 TEST_P(ResourceDispatcherHostTest, CancelRequestsForContextTransferred) { 2677 TEST_F(ResourceDispatcherHostTest, CancelRequestsForContextTransferred) {
2744 // PlzNavigate: there are no transferred requests in PlzNavigate. 2678 // PlzNavigate: there are no transferred requests in PlzNavigate.
2745 if (IsBrowserSideNavigationEnabled()) 2679 if (IsBrowserSideNavigationEnabled())
2746 return; 2680 return;
2747 2681
2748 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 2682 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
2749 2683
2750 EXPECT_EQ(0, host_.pending_requests()); 2684 EXPECT_EQ(0, host_.pending_requests());
2751 2685
2752 int request_id = 1; 2686 int request_id = 1;
2753 2687
(...skipping 25 matching lines...) Expand all
2779 web_contents_->GetRenderViewHost()->GetRoutingID()); 2713 web_contents_->GetRenderViewHost()->GetRoutingID());
2780 EXPECT_EQ(1, host_.pending_requests()); 2714 EXPECT_EQ(1, host_.pending_requests());
2781 2715
2782 // Cancelling by context should work. 2716 // Cancelling by context should work.
2783 host_.CancelRequestsForContext(web_contents_filter_->resource_context()); 2717 host_.CancelRequestsForContext(web_contents_filter_->resource_context());
2784 EXPECT_EQ(0, host_.pending_requests()); 2718 EXPECT_EQ(0, host_.pending_requests());
2785 } 2719 }
2786 2720
2787 // Test transferred navigations with text/html, which doesn't trigger any 2721 // Test transferred navigations with text/html, which doesn't trigger any
2788 // content sniffing. 2722 // content sniffing.
2789 TEST_P(ResourceDispatcherHostTest, TransferNavigationHtml) { 2723 TEST_F(ResourceDispatcherHostTest, TransferNavigationHtml) {
2790 if (IsBrowserSideNavigationEnabled()) { 2724 if (IsBrowserSideNavigationEnabled()) {
2791 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 2725 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2792 return; 2726 return;
2793 } 2727 }
2794 2728
2795 EXPECT_EQ(0, host_.pending_requests()); 2729 EXPECT_EQ(0, host_.pending_requests());
2796 2730
2797 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 2731 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
2798 NavigationResourceThrottle::set_force_transfer_for_testing(true); 2732 NavigationResourceThrottle::set_force_transfer_for_testing(true);
2799 2733
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2846 2780
2847 ASSERT_EQ(2U, msgs.size()); 2781 ASSERT_EQ(2U, msgs.size());
2848 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 2782 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
2849 CheckSuccessfulRequest(msgs[1], kResponseBody); 2783 CheckSuccessfulRequest(msgs[1], kResponseBody);
2850 2784
2851 second_filter->OnChannelClosing(); 2785 second_filter->OnChannelClosing();
2852 } 2786 }
2853 2787
2854 // Test transferring two navigations with text/html, to ensure the resource 2788 // Test transferring two navigations with text/html, to ensure the resource
2855 // accounting works. 2789 // accounting works.
2856 TEST_P(ResourceDispatcherHostTest, TransferTwoNavigationsHtml) { 2790 TEST_F(ResourceDispatcherHostTest, TransferTwoNavigationsHtml) {
2857 if (IsBrowserSideNavigationEnabled()) { 2791 if (IsBrowserSideNavigationEnabled()) {
2858 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 2792 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2859 return; 2793 return;
2860 } 2794 }
2861 2795
2862 NavigationResourceThrottle::set_force_transfer_for_testing(true); 2796 NavigationResourceThrottle::set_force_transfer_for_testing(true);
2863 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 2797 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
2864 2798
2865 EXPECT_EQ(0, host_.pending_requests()); 2799 EXPECT_EQ(0, host_.pending_requests());
2866 2800
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2927 2861
2928 ASSERT_EQ(2U, msgs.size()); 2862 ASSERT_EQ(2U, msgs.size());
2929 CheckSuccessfulRequest(msgs[0], kResponseBody); 2863 CheckSuccessfulRequest(msgs[0], kResponseBody);
2930 2864
2931 second_filter->OnChannelClosing(); 2865 second_filter->OnChannelClosing();
2932 } 2866 }
2933 2867
2934 // Test transferred navigations with text/plain, which causes 2868 // Test transferred navigations with text/plain, which causes
2935 // MimeTypeResourceHandler to buffer the response to sniff the content before 2869 // MimeTypeResourceHandler to buffer the response to sniff the content before
2936 // the transfer occurs. 2870 // the transfer occurs.
2937 TEST_P(ResourceDispatcherHostTest, TransferNavigationText) { 2871 TEST_F(ResourceDispatcherHostTest, TransferNavigationText) {
2938 if (IsBrowserSideNavigationEnabled()) { 2872 if (IsBrowserSideNavigationEnabled()) {
2939 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 2873 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2940 return; 2874 return;
2941 } 2875 }
2942 2876
2943 NavigationResourceThrottle::set_force_transfer_for_testing(true); 2877 NavigationResourceThrottle::set_force_transfer_for_testing(true);
2944 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 2878 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
2945 2879
2946 EXPECT_EQ(0, host_.pending_requests()); 2880 EXPECT_EQ(0, host_.pending_requests());
2947 2881
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2995 ResourceIPCAccumulator::ClassifiedMessages msgs; 2929 ResourceIPCAccumulator::ClassifiedMessages msgs;
2996 accum_.GetClassifiedMessages(&msgs); 2930 accum_.GetClassifiedMessages(&msgs);
2997 2931
2998 ASSERT_EQ(2U, msgs.size()); 2932 ASSERT_EQ(2U, msgs.size());
2999 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 2933 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
3000 CheckSuccessfulRequest(msgs[1], kResponseBody); 2934 CheckSuccessfulRequest(msgs[1], kResponseBody);
3001 2935
3002 second_filter->OnChannelClosing(); 2936 second_filter->OnChannelClosing();
3003 } 2937 }
3004 2938
3005 TEST_P(ResourceDispatcherHostTest, TransferNavigationWithProcessCrash) { 2939 TEST_F(ResourceDispatcherHostTest, TransferNavigationWithProcessCrash) {
3006 if (IsBrowserSideNavigationEnabled()) { 2940 if (IsBrowserSideNavigationEnabled()) {
3007 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 2941 SUCCEED() << "Test is not applicable with browser side navigation enabled";
3008 return; 2942 return;
3009 } 2943 }
3010 2944
3011 NavigationResourceThrottle::set_force_transfer_for_testing(true); 2945 NavigationResourceThrottle::set_force_transfer_for_testing(true);
3012 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 2946 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
3013 2947
3014 EXPECT_EQ(0, host_.pending_requests()); 2948 EXPECT_EQ(0, host_.pending_requests());
3015 2949
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3079 ResourceIPCAccumulator::ClassifiedMessages msgs; 3013 ResourceIPCAccumulator::ClassifiedMessages msgs;
3080 accum_.GetClassifiedMessages(&msgs); 3014 accum_.GetClassifiedMessages(&msgs);
3081 3015
3082 ASSERT_EQ(2U, msgs.size()); 3016 ASSERT_EQ(2U, msgs.size());
3083 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 3017 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
3084 CheckSuccessfulRequest(msgs[1], kResponseBody); 3018 CheckSuccessfulRequest(msgs[1], kResponseBody);
3085 3019
3086 second_filter->OnChannelClosing(); 3020 second_filter->OnChannelClosing();
3087 } 3021 }
3088 3022
3089 TEST_P(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) { 3023 TEST_F(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) {
3090 if (IsBrowserSideNavigationEnabled()) { 3024 if (IsBrowserSideNavigationEnabled()) {
3091 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 3025 SUCCEED() << "Test is not applicable with browser side navigation enabled";
3092 return; 3026 return;
3093 } 3027 }
3094 3028
3095 NavigationResourceThrottle::set_force_transfer_for_testing(true); 3029 NavigationResourceThrottle::set_force_transfer_for_testing(true);
3096 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 3030 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
3097 3031
3098 EXPECT_EQ(0, host_.pending_requests()); 3032 EXPECT_EQ(0, host_.pending_requests());
3099 3033
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
3167 ResourceIPCAccumulator::ClassifiedMessages msgs; 3101 ResourceIPCAccumulator::ClassifiedMessages msgs;
3168 accum_.GetClassifiedMessages(&msgs); 3102 accum_.GetClassifiedMessages(&msgs);
3169 3103
3170 ASSERT_EQ(2U, msgs.size()); 3104 ASSERT_EQ(2U, msgs.size());
3171 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 3105 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
3172 CheckSuccessfulRequest(msgs[1], kResponseBody); 3106 CheckSuccessfulRequest(msgs[1], kResponseBody);
3173 3107
3174 second_filter->OnChannelClosing(); 3108 second_filter->OnChannelClosing();
3175 } 3109 }
3176 3110
3177 TEST_P(ResourceDispatcherHostTest, UnknownURLScheme) { 3111 TEST_F(ResourceDispatcherHostTest, UnknownURLScheme) {
3178 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 3112 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
3179 EXPECT_EQ(0, host_.pending_requests()); 3113 EXPECT_EQ(0, host_.pending_requests());
3180 3114
3181 HandleScheme("http"); 3115 HandleScheme("http");
3182 3116
3183 const GURL invalid_sheme_url = GURL("foo://bar"); 3117 const GURL invalid_sheme_url = GURL("foo://bar");
3184 const int expected_error_code = net::ERR_UNKNOWN_URL_SCHEME; 3118 const int expected_error_code = net::ERR_UNKNOWN_URL_SCHEME;
3185 3119
3186 CompleteFailingMainResourceRequest(invalid_sheme_url, expected_error_code); 3120 CompleteFailingMainResourceRequest(invalid_sheme_url, expected_error_code);
3187 } 3121 }
3188 3122
3189 TEST_P(ResourceDispatcherHostTest, DataReceivedACKs) { 3123 TEST_F(ResourceDispatcherHostTest, DataReceivedACKs) {
3190 EXPECT_EQ(0, host_.pending_requests()); 3124 EXPECT_EQ(0, host_.pending_requests());
3191 3125
3192 SendDataReceivedACKs(true); 3126 SendDataReceivedACKs(true);
3193 3127
3194 HandleScheme("big-job"); 3128 HandleScheme("big-job");
3195 MakeTestRequest(0, 1, GURL("big-job:0123456789,1000000")); 3129 MakeTestRequest(0, 1, GURL("big-job:0123456789,1000000"));
3196 3130
3197 base::RunLoop().RunUntilIdle(); 3131 base::RunLoop().RunUntilIdle();
3198 3132
3199 // Sort all the messages we saw by request. 3133 // Sort all the messages we saw by request.
3200 ResourceIPCAccumulator::ClassifiedMessages msgs; 3134 ResourceIPCAccumulator::ClassifiedMessages msgs;
3201 accum_.GetClassifiedMessages(&msgs); 3135 accum_.GetClassifiedMessages(&msgs);
3202 3136
3203 size_t size = msgs[0].size(); 3137 size_t size = msgs[0].size();
3204 3138
3205 EXPECT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[0][0].type()); 3139 EXPECT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[0][0].type());
3206 EXPECT_EQ(ResourceMsg_SetDataBuffer::ID, msgs[0][1].type()); 3140 EXPECT_EQ(ResourceMsg_SetDataBuffer::ID, msgs[0][1].type());
3207 for (size_t i = 2; i < size - 1; ++i) 3141 for (size_t i = 2; i < size - 1; ++i)
3208 EXPECT_EQ(ResourceMsg_DataReceived::ID, msgs[0][i].type()); 3142 EXPECT_EQ(ResourceMsg_DataReceived::ID, msgs[0][i].type());
3209 EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][size - 1].type()); 3143 EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][size - 1].type());
3210 } 3144 }
3211 3145
3212 // Request a very large detachable resource and cancel part way. Some of the 3146 // Request a very large detachable resource and cancel part way. Some of the
3213 // data should have been sent to the renderer, but not all. 3147 // data should have been sent to the renderer, but not all.
3214 TEST_P(ResourceDispatcherHostTest, DataSentBeforeDetach) { 3148 TEST_F(ResourceDispatcherHostTest, DataSentBeforeDetach) {
3215 EXPECT_EQ(0, host_.pending_requests()); 3149 EXPECT_EQ(0, host_.pending_requests());
3216 3150
3217 int render_view_id = 0; 3151 int render_view_id = 0;
3218 int request_id = 1; 3152 int request_id = 1;
3219 3153
3220 std::string raw_headers("HTTP\n" 3154 std::string raw_headers("HTTP\n"
3221 "Content-type: image/jpeg\n\n"); 3155 "Content-type: image/jpeg\n\n");
3222 std::string response_data("01234567890123456789\x01foobar"); 3156 std::string response_data("01234567890123456789\x01foobar");
3223 3157
3224 // Create a response larger than kMaxAllocationSize (currently 32K). Note 3158 // Create a response larger than kMaxAllocationSize (currently 32K). Note
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3260 EXPECT_GT(kAllocSize, data_length); 3194 EXPECT_GT(kAllocSize, data_length);
3261 3195
3262 // Verify the data that was received before cancellation. The request should 3196 // Verify the data that was received before cancellation. The request should
3263 // have appeared to cancel, however. 3197 // have appeared to cancel, however.
3264 CheckSuccessfulRequestWithErrorCode( 3198 CheckSuccessfulRequestWithErrorCode(
3265 msgs[0], 3199 msgs[0],
3266 std::string(response_data.begin(), response_data.begin() + data_length), 3200 std::string(response_data.begin(), response_data.begin() + data_length),
3267 net::ERR_ABORTED); 3201 net::ERR_ABORTED);
3268 } 3202 }
3269 3203
3270 TEST_P(ResourceDispatcherHostTest, DelayedDataReceivedACKs) { 3204 TEST_F(ResourceDispatcherHostTest, DelayedDataReceivedACKs) {
3271 EXPECT_EQ(0, host_.pending_requests()); 3205 EXPECT_EQ(0, host_.pending_requests());
3272 3206
3273 HandleScheme("big-job"); 3207 HandleScheme("big-job");
3274 MakeTestRequest(0, 1, GURL("big-job:0123456789,1000000")); 3208 MakeTestRequest(0, 1, GURL("big-job:0123456789,1000000"));
3275 3209
3276 base::RunLoop().RunUntilIdle(); 3210 base::RunLoop().RunUntilIdle();
3277 3211
3278 // Sort all the messages we saw by request. 3212 // Sort all the messages we saw by request.
3279 ResourceIPCAccumulator::ClassifiedMessages msgs; 3213 ResourceIPCAccumulator::ClassifiedMessages msgs;
3280 accum_.GetClassifiedMessages(&msgs); 3214 accum_.GetClassifiedMessages(&msgs);
(...skipping 28 matching lines...) Expand all
3309 3243
3310 base::RunLoop().RunUntilIdle(); 3244 base::RunLoop().RunUntilIdle();
3311 3245
3312 msgs.clear(); 3246 msgs.clear();
3313 accum_.GetClassifiedMessages(&msgs); 3247 accum_.GetClassifiedMessages(&msgs);
3314 } 3248 }
3315 } 3249 }
3316 3250
3317 // Flakyness of this test might indicate memory corruption issues with 3251 // Flakyness of this test might indicate memory corruption issues with
3318 // for example the ResourceBuffer of AsyncResourceHandler. 3252 // for example the ResourceBuffer of AsyncResourceHandler.
3319 TEST_P(ResourceDispatcherHostTest, DataReceivedUnexpectedACKs) { 3253 TEST_F(ResourceDispatcherHostTest, DataReceivedUnexpectedACKs) {
3320 EXPECT_EQ(0, host_.pending_requests()); 3254 EXPECT_EQ(0, host_.pending_requests());
3321 3255
3322 HandleScheme("big-job"); 3256 HandleScheme("big-job");
3323 MakeTestRequest(0, 1, GURL("big-job:0123456789,1000000")); 3257 MakeTestRequest(0, 1, GURL("big-job:0123456789,1000000"));
3324 3258
3325 base::RunLoop().RunUntilIdle(); 3259 base::RunLoop().RunUntilIdle();
3326 3260
3327 // Sort all the messages we saw by request. 3261 // Sort all the messages we saw by request.
3328 ResourceIPCAccumulator::ClassifiedMessages msgs; 3262 ResourceIPCAccumulator::ClassifiedMessages msgs;
3329 accum_.GetClassifiedMessages(&msgs); 3263 accum_.GetClassifiedMessages(&msgs);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3362 } 3296 }
3363 3297
3364 base::RunLoop().RunUntilIdle(); 3298 base::RunLoop().RunUntilIdle();
3365 3299
3366 msgs.clear(); 3300 msgs.clear();
3367 accum_.GetClassifiedMessages(&msgs); 3301 accum_.GetClassifiedMessages(&msgs);
3368 } 3302 }
3369 } 3303 }
3370 3304
3371 // Tests the dispatcher host's temporary file management. 3305 // Tests the dispatcher host's temporary file management.
3372 TEST_P(ResourceDispatcherHostTest, RegisterDownloadedTempFile) { 3306 TEST_F(ResourceDispatcherHostTest, RegisterDownloadedTempFile) {
3373 const int kRequestID = 1; 3307 const int kRequestID = 1;
3374 3308
3375 // Create a temporary file. 3309 // Create a temporary file.
3376 base::FilePath file_path; 3310 base::FilePath file_path;
3377 ASSERT_TRUE(base::CreateTemporaryFile(&file_path)); 3311 ASSERT_TRUE(base::CreateTemporaryFile(&file_path));
3378 EXPECT_TRUE(base::PathExists(file_path)); 3312 EXPECT_TRUE(base::PathExists(file_path));
3379 scoped_refptr<ShareableFileReference> deletable_file = 3313 scoped_refptr<ShareableFileReference> deletable_file =
3380 ShareableFileReference::GetOrCreate( 3314 ShareableFileReference::GetOrCreate(
3381 file_path, ShareableFileReference::DELETE_ON_FINAL_RELEASE, 3315 file_path, ShareableFileReference::DELETE_ON_FINAL_RELEASE,
3382 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get()); 3316 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get());
(...skipping 25 matching lines...) Expand all
3408 base::RunLoop().RunUntilIdle(); 3342 base::RunLoop().RunUntilIdle();
3409 3343
3410 // The file is no longer readable to the child and has been deleted. 3344 // The file is no longer readable to the child and has been deleted.
3411 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( 3345 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
3412 filter_->child_id(), file_path)); 3346 filter_->child_id(), file_path));
3413 EXPECT_FALSE(base::PathExists(file_path)); 3347 EXPECT_FALSE(base::PathExists(file_path));
3414 } 3348 }
3415 3349
3416 // Tests the dispatcher host's temporary file management in the mojo-enabled 3350 // Tests the dispatcher host's temporary file management in the mojo-enabled
3417 // loading. 3351 // loading.
3418 TEST_P(ResourceDispatcherHostTest, RegisterDownloadedTempFileWithMojo) { 3352 TEST_F(ResourceDispatcherHostTest, RegisterDownloadedTempFileWithMojo) {
3419 const int kRequestID = 1; 3353 const int kRequestID = 1;
3420 3354
3421 // Create a temporary file. 3355 // Create a temporary file.
3422 base::FilePath file_path; 3356 base::FilePath file_path;
3423 ASSERT_TRUE(base::CreateTemporaryFile(&file_path)); 3357 ASSERT_TRUE(base::CreateTemporaryFile(&file_path));
3424 EXPECT_TRUE(base::PathExists(file_path)); 3358 EXPECT_TRUE(base::PathExists(file_path));
3425 scoped_refptr<ShareableFileReference> deletable_file = 3359 scoped_refptr<ShareableFileReference> deletable_file =
3426 ShareableFileReference::GetOrCreate( 3360 ShareableFileReference::GetOrCreate(
3427 file_path, ShareableFileReference::DELETE_ON_FINAL_RELEASE, 3361 file_path, ShareableFileReference::DELETE_ON_FINAL_RELEASE,
3428 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get()); 3362 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get());
(...skipping 29 matching lines...) Expand all
3458 base::RunLoop().RunUntilIdle(); 3392 base::RunLoop().RunUntilIdle();
3459 3393
3460 // The file is no longer readable to the child and has been deleted. 3394 // The file is no longer readable to the child and has been deleted.
3461 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( 3395 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
3462 filter_->child_id(), file_path)); 3396 filter_->child_id(), file_path));
3463 EXPECT_FALSE(base::PathExists(file_path)); 3397 EXPECT_FALSE(base::PathExists(file_path));
3464 } 3398 }
3465 3399
3466 // Tests that temporary files held on behalf of child processes are released 3400 // Tests that temporary files held on behalf of child processes are released
3467 // when the child process dies. 3401 // when the child process dies.
3468 TEST_P(ResourceDispatcherHostTest, ReleaseTemporiesOnProcessExit) { 3402 TEST_F(ResourceDispatcherHostTest, ReleaseTemporiesOnProcessExit) {
3469 const int kRequestID = 1; 3403 const int kRequestID = 1;
3470 3404
3471 // Create a temporary file. 3405 // Create a temporary file.
3472 base::FilePath file_path; 3406 base::FilePath file_path;
3473 ASSERT_TRUE(base::CreateTemporaryFile(&file_path)); 3407 ASSERT_TRUE(base::CreateTemporaryFile(&file_path));
3474 scoped_refptr<ShareableFileReference> deletable_file = 3408 scoped_refptr<ShareableFileReference> deletable_file =
3475 ShareableFileReference::GetOrCreate( 3409 ShareableFileReference::GetOrCreate(
3476 file_path, ShareableFileReference::DELETE_ON_FINAL_RELEASE, 3410 file_path, ShareableFileReference::DELETE_ON_FINAL_RELEASE,
3477 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get()); 3411 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get());
3478 3412
3479 // Register it for a resource request. 3413 // Register it for a resource request.
3480 host_.RegisterDownloadedTempFile(filter_->child_id(), kRequestID, file_path); 3414 host_.RegisterDownloadedTempFile(filter_->child_id(), kRequestID, file_path);
3481 deletable_file = NULL; 3415 deletable_file = NULL;
3482 3416
3483 // Should be readable now. 3417 // Should be readable now.
3484 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( 3418 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
3485 filter_->child_id(), file_path)); 3419 filter_->child_id(), file_path));
3486 3420
3487 // Let the process die. 3421 // Let the process die.
3488 filter_->OnChannelClosing(); 3422 filter_->OnChannelClosing();
3489 base::RunLoop().RunUntilIdle(); 3423 base::RunLoop().RunUntilIdle();
3490 3424
3491 // The file is no longer readable to the child and has been deleted. 3425 // The file is no longer readable to the child and has been deleted.
3492 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( 3426 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
3493 filter_->child_id(), file_path)); 3427 filter_->child_id(), file_path));
3494 EXPECT_FALSE(base::PathExists(file_path)); 3428 EXPECT_FALSE(base::PathExists(file_path));
3495 } 3429 }
3496 3430
3497 TEST_P(ResourceDispatcherHostTest, DownloadToFile) { 3431 TEST_F(ResourceDispatcherHostTest, DownloadToFile) {
3498 // Make a request which downloads to file. 3432 // Make a request which downloads to file.
3499 ResourceRequest request = CreateResourceRequest( 3433 ResourceRequest request = CreateResourceRequest(
3500 "GET", RESOURCE_TYPE_SUB_RESOURCE, net::URLRequestTestJob::test_url_1()); 3434 "GET", RESOURCE_TYPE_SUB_RESOURCE, net::URLRequestTestJob::test_url_1());
3501 request.download_to_file = true; 3435 request.download_to_file = true;
3502 ResourceHostMsg_RequestResource request_msg(0, 1, request); 3436 ResourceHostMsg_RequestResource request_msg(0, 1, request);
3503 OnMessageReceived(request_msg, filter_.get()); 3437 OnMessageReceived(request_msg, filter_.get());
3504 3438
3505 // Running the message loop until idle does not work because 3439 // Running the message loop until idle does not work because
3506 // RedirectToFileResourceHandler posts things to base::WorkerPool. Instead, 3440 // RedirectToFileResourceHandler posts things to base::WorkerPool. Instead,
3507 // wait for the ResourceMsg_RequestComplete to go out. Then run the event loop 3441 // wait for the ResourceMsg_RequestComplete to go out. Then run the event loop
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
3564 3498
3565 EXPECT_FALSE(base::PathExists(response_head.download_file_path)); 3499 EXPECT_FALSE(base::PathExists(response_head.download_file_path));
3566 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( 3500 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
3567 filter_->child_id(), response_head.download_file_path)); 3501 filter_->child_id(), response_head.download_file_path));
3568 } 3502 }
3569 3503
3570 WebContents* WebContentsBinder(WebContents* rv) { return rv; } 3504 WebContents* WebContentsBinder(WebContents* rv) { return rv; }
3571 3505
3572 // Tests GetLoadInfoForAllRoutes when there are 3 requests from the same 3506 // Tests GetLoadInfoForAllRoutes when there are 3 requests from the same
3573 // RenderView. The second one is farthest along. 3507 // RenderView. The second one is farthest along.
3574 TEST_P(ResourceDispatcherHostTest, LoadInfo) { 3508 TEST_F(ResourceDispatcherHostTest, LoadInfo) {
3575 std::unique_ptr<LoadInfoList> infos(new LoadInfoList); 3509 std::unique_ptr<LoadInfoList> infos(new LoadInfoList);
3576 LoadInfo info; 3510 LoadInfo info;
3577 WebContents* wc1 = reinterpret_cast<WebContents*>(0x1); 3511 WebContents* wc1 = reinterpret_cast<WebContents*>(0x1);
3578 info.web_contents_getter = base::Bind(WebContentsBinder, wc1); 3512 info.web_contents_getter = base::Bind(WebContentsBinder, wc1);
3579 info.load_state = net::LoadStateWithParam(net::LOAD_STATE_SENDING_REQUEST, 3513 info.load_state = net::LoadStateWithParam(net::LOAD_STATE_SENDING_REQUEST,
3580 base::string16()); 3514 base::string16());
3581 info.url = GURL("test://1/"); 3515 info.url = GURL("test://1/");
3582 info.upload_position = 0; 3516 info.upload_position = 0;
3583 info.upload_size = 0; 3517 info.upload_size = 0;
3584 infos->push_back(info); 3518 infos->push_back(info);
(...skipping 12 matching lines...) Expand all
3597 ASSERT_TRUE(load_info_map->find(wc1) != load_info_map->end()); 3531 ASSERT_TRUE(load_info_map->find(wc1) != load_info_map->end());
3598 EXPECT_EQ(GURL("test://2/"), (*load_info_map)[wc1].url); 3532 EXPECT_EQ(GURL("test://2/"), (*load_info_map)[wc1].url);
3599 EXPECT_EQ(net::LOAD_STATE_READING_RESPONSE, 3533 EXPECT_EQ(net::LOAD_STATE_READING_RESPONSE,
3600 (*load_info_map)[wc1].load_state.state); 3534 (*load_info_map)[wc1].load_state.state);
3601 EXPECT_EQ(0u, (*load_info_map)[wc1].upload_position); 3535 EXPECT_EQ(0u, (*load_info_map)[wc1].upload_position);
3602 EXPECT_EQ(0u, (*load_info_map)[wc1].upload_size); 3536 EXPECT_EQ(0u, (*load_info_map)[wc1].upload_size);
3603 } 3537 }
3604 3538
3605 // Tests GetLoadInfoForAllRoutes when there are 2 requests with the same 3539 // Tests GetLoadInfoForAllRoutes when there are 2 requests with the same
3606 // priority. The first one (Which will have the lowest ID) should be returned. 3540 // priority. The first one (Which will have the lowest ID) should be returned.
3607 TEST_P(ResourceDispatcherHostTest, LoadInfoSamePriority) { 3541 TEST_F(ResourceDispatcherHostTest, LoadInfoSamePriority) {
3608 std::unique_ptr<LoadInfoList> infos(new LoadInfoList); 3542 std::unique_ptr<LoadInfoList> infos(new LoadInfoList);
3609 LoadInfo info; 3543 LoadInfo info;
3610 WebContents* wc1 = reinterpret_cast<WebContents*>(0x1); 3544 WebContents* wc1 = reinterpret_cast<WebContents*>(0x1);
3611 info.web_contents_getter = base::Bind(WebContentsBinder, wc1); 3545 info.web_contents_getter = base::Bind(WebContentsBinder, wc1);
3612 info.load_state = net::LoadStateWithParam(net::LOAD_STATE_IDLE, 3546 info.load_state = net::LoadStateWithParam(net::LOAD_STATE_IDLE,
3613 base::string16()); 3547 base::string16());
3614 info.url = GURL("test://1/"); 3548 info.url = GURL("test://1/");
3615 info.upload_position = 0; 3549 info.upload_position = 0;
3616 info.upload_size = 0; 3550 info.upload_size = 0;
3617 infos->push_back(info); 3551 infos->push_back(info);
3618 3552
3619 info.url = GURL("test://2/"); 3553 info.url = GURL("test://2/");
3620 infos->push_back(info); 3554 infos->push_back(info);
3621 3555
3622 std::unique_ptr<LoadInfoMap> load_info_map = 3556 std::unique_ptr<LoadInfoMap> load_info_map =
3623 ResourceDispatcherHostImpl::PickMoreInterestingLoadInfos( 3557 ResourceDispatcherHostImpl::PickMoreInterestingLoadInfos(
3624 std::move(infos)); 3558 std::move(infos));
3625 ASSERT_EQ(1u, load_info_map->size()); 3559 ASSERT_EQ(1u, load_info_map->size());
3626 ASSERT_TRUE(load_info_map->find(wc1) != load_info_map->end()); 3560 ASSERT_TRUE(load_info_map->find(wc1) != load_info_map->end());
3627 EXPECT_EQ(GURL("test://1/"), (*load_info_map)[wc1].url); 3561 EXPECT_EQ(GURL("test://1/"), (*load_info_map)[wc1].url);
3628 EXPECT_EQ(net::LOAD_STATE_IDLE, (*load_info_map)[wc1].load_state.state); 3562 EXPECT_EQ(net::LOAD_STATE_IDLE, (*load_info_map)[wc1].load_state.state);
3629 EXPECT_EQ(0u, (*load_info_map)[wc1].upload_position); 3563 EXPECT_EQ(0u, (*load_info_map)[wc1].upload_position);
3630 EXPECT_EQ(0u, (*load_info_map)[wc1].upload_size); 3564 EXPECT_EQ(0u, (*load_info_map)[wc1].upload_size);
3631 } 3565 }
3632 3566
3633 // Tests GetLoadInfoForAllRoutes when a request is uploading a body. 3567 // Tests GetLoadInfoForAllRoutes when a request is uploading a body.
3634 TEST_P(ResourceDispatcherHostTest, LoadInfoUploadProgress) { 3568 TEST_F(ResourceDispatcherHostTest, LoadInfoUploadProgress) {
3635 std::unique_ptr<LoadInfoList> infos(new LoadInfoList); 3569 std::unique_ptr<LoadInfoList> infos(new LoadInfoList);
3636 LoadInfo info; 3570 LoadInfo info;
3637 WebContents* wc1 = reinterpret_cast<WebContents*>(0x1); 3571 WebContents* wc1 = reinterpret_cast<WebContents*>(0x1);
3638 info.web_contents_getter = base::Bind(WebContentsBinder, wc1); 3572 info.web_contents_getter = base::Bind(WebContentsBinder, wc1);
3639 info.load_state = net::LoadStateWithParam(net::LOAD_STATE_READING_RESPONSE, 3573 info.load_state = net::LoadStateWithParam(net::LOAD_STATE_READING_RESPONSE,
3640 base::string16()); 3574 base::string16());
3641 info.url = GURL("test://1/"); 3575 info.url = GURL("test://1/");
3642 info.upload_position = 0; 3576 info.upload_position = 0;
3643 info.upload_size = 0; 3577 info.upload_size = 0;
3644 infos->push_back(info); 3578 infos->push_back(info);
(...skipping 29 matching lines...) Expand all
3674 EXPECT_EQ(GURL("test://2/"), (*load_info_map)[wc1].url); 3608 EXPECT_EQ(GURL("test://2/"), (*load_info_map)[wc1].url);
3675 EXPECT_EQ(net::LOAD_STATE_SENDING_REQUEST, 3609 EXPECT_EQ(net::LOAD_STATE_SENDING_REQUEST,
3676 (*load_info_map)[wc1].load_state.state); 3610 (*load_info_map)[wc1].load_state.state);
3677 EXPECT_EQ(50u, (*load_info_map)[wc1].upload_position); 3611 EXPECT_EQ(50u, (*load_info_map)[wc1].upload_position);
3678 EXPECT_EQ(100u, (*load_info_map)[wc1].upload_size); 3612 EXPECT_EQ(100u, (*load_info_map)[wc1].upload_size);
3679 } 3613 }
3680 3614
3681 // Tests GetLoadInfoForAllRoutes when there are 4 requests from 2 different 3615 // Tests GetLoadInfoForAllRoutes when there are 4 requests from 2 different
3682 // RenderViews. Also tests the case where the first / last requests are the 3616 // RenderViews. Also tests the case where the first / last requests are the
3683 // most interesting ones. 3617 // most interesting ones.
3684 TEST_P(ResourceDispatcherHostTest, LoadInfoTwoRenderViews) { 3618 TEST_F(ResourceDispatcherHostTest, LoadInfoTwoRenderViews) {
3685 std::unique_ptr<LoadInfoList> infos(new LoadInfoList); 3619 std::unique_ptr<LoadInfoList> infos(new LoadInfoList);
3686 LoadInfo info; 3620 LoadInfo info;
3687 WebContents* wc1 = reinterpret_cast<WebContents*>(0x1); 3621 WebContents* wc1 = reinterpret_cast<WebContents*>(0x1);
3688 info.web_contents_getter = base::Bind(WebContentsBinder, wc1); 3622 info.web_contents_getter = base::Bind(WebContentsBinder, wc1);
3689 info.load_state = net::LoadStateWithParam(net::LOAD_STATE_CONNECTING, 3623 info.load_state = net::LoadStateWithParam(net::LOAD_STATE_CONNECTING,
3690 base::string16()); 3624 base::string16());
3691 info.url = GURL("test://1/"); 3625 info.url = GURL("test://1/");
3692 info.upload_position = 0; 3626 info.upload_position = 0;
3693 info.upload_size = 0; 3627 info.upload_size = 0;
3694 infos->push_back(info); 3628 infos->push_back(info);
(...skipping 30 matching lines...) Expand all
3725 ASSERT_TRUE(load_info_map->find(wc2) != load_info_map->end()); 3659 ASSERT_TRUE(load_info_map->find(wc2) != load_info_map->end());
3726 EXPECT_EQ(GURL("test://4/"), (*load_info_map)[wc2].url); 3660 EXPECT_EQ(GURL("test://4/"), (*load_info_map)[wc2].url);
3727 EXPECT_EQ(net::LOAD_STATE_CONNECTING, 3661 EXPECT_EQ(net::LOAD_STATE_CONNECTING,
3728 (*load_info_map)[wc2].load_state.state); 3662 (*load_info_map)[wc2].load_state.state);
3729 EXPECT_EQ(0u, (*load_info_map)[wc2].upload_position); 3663 EXPECT_EQ(0u, (*load_info_map)[wc2].upload_position);
3730 EXPECT_EQ(0u, (*load_info_map)[wc2].upload_size); 3664 EXPECT_EQ(0u, (*load_info_map)[wc2].upload_size);
3731 } 3665 }
3732 3666
3733 // Confirm that resource response started notifications are correctly 3667 // Confirm that resource response started notifications are correctly
3734 // transmitted to the WebContents. 3668 // transmitted to the WebContents.
3735 TEST_P(ResourceDispatcherHostTest, TransferResponseStarted) { 3669 TEST_F(ResourceDispatcherHostTest, TransferResponseStarted) {
3736 int initial_count = web_contents_observer_->resource_response_start_count(); 3670 int initial_count = web_contents_observer_->resource_response_start_count();
3737 3671
3738 MakeWebContentsAssociatedTestRequest(1, net::URLRequestTestJob::test_url_1()); 3672 MakeWebContentsAssociatedTestRequest(1, net::URLRequestTestJob::test_url_1());
3739 base::RunLoop().RunUntilIdle(); 3673 base::RunLoop().RunUntilIdle();
3740 3674
3741 EXPECT_EQ(initial_count + 1, 3675 EXPECT_EQ(initial_count + 1,
3742 web_contents_observer_->resource_response_start_count()); 3676 web_contents_observer_->resource_response_start_count());
3743 } 3677 }
3744 3678
3745 // Confirm that request redirected notifications are correctly 3679 // Confirm that request redirected notifications are correctly
3746 // transmitted to the WebContents. 3680 // transmitted to the WebContents.
3747 TEST_P(ResourceDispatcherHostTest, TransferRequestRedirected) { 3681 TEST_F(ResourceDispatcherHostTest, TransferRequestRedirected) {
3748 int initial_count = web_contents_observer_->resource_request_redirect_count(); 3682 int initial_count = web_contents_observer_->resource_request_redirect_count();
3749 3683
3750 MakeWebContentsAssociatedTestRequest( 3684 MakeWebContentsAssociatedTestRequest(
3751 1, net::URLRequestTestJob::test_url_redirect_to_url_2()); 3685 1, net::URLRequestTestJob::test_url_redirect_to_url_2());
3752 base::RunLoop().RunUntilIdle(); 3686 base::RunLoop().RunUntilIdle();
3753 3687
3754 EXPECT_EQ(initial_count + 1, 3688 EXPECT_EQ(initial_count + 1,
3755 web_contents_observer_->resource_request_redirect_count()); 3689 web_contents_observer_->resource_request_redirect_count());
3756 } 3690 }
3757 3691
3758 // Confirm that DidChangePriority messages are respected. 3692 // Confirm that DidChangePriority messages are respected.
3759 TEST_P(ResourceDispatcherHostTest, DidChangePriority) { 3693 TEST_F(ResourceDispatcherHostTest, DidChangePriority) {
3760 // ResourceScheduler only throttles http and https requests. 3694 // ResourceScheduler only throttles http and https requests.
3761 HandleScheme("http"); 3695 HandleScheme("http");
3762 3696
3763 // Needed to enable scheduling for this child. 3697 // Needed to enable scheduling for this child.
3764 host_.OnRenderViewHostCreated(filter_->child_id(), // child_id 3698 host_.OnRenderViewHostCreated(filter_->child_id(), // child_id
3765 0); // route_id 3699 0); // route_id
3766 3700
3767 // Prevent any of these requests from completing. 3701 // Prevent any of these requests from completing.
3768 job_factory_->SetDelayedCompleteJobGeneration(true); 3702 job_factory_->SetDelayedCompleteJobGeneration(true);
3769 SetResponse("HTTP/1.1 200 OK\n\n", "<title>Dummy body</title>"); 3703 SetResponse("HTTP/1.1 200 OK\n\n", "<title>Dummy body</title>");
(...skipping 16 matching lines...) Expand all
3786 3720
3787 EXPECT_EQ(3, job_factory_->url_request_jobs_created_count()); 3721 EXPECT_EQ(3, job_factory_->url_request_jobs_created_count());
3788 3722
3789 // Cleanup. 3723 // Cleanup.
3790 host_.OnRenderViewHostDeleted(filter_->child_id(), // child_id 3724 host_.OnRenderViewHostDeleted(filter_->child_id(), // child_id
3791 0); // route_id 3725 0); // route_id
3792 } 3726 }
3793 3727
3794 // Confirm that resource response started notifications for downloads are not 3728 // Confirm that resource response started notifications for downloads are not
3795 // transmitted to the WebContents. 3729 // transmitted to the WebContents.
3796 TEST_P(ResourceDispatcherHostTest, TransferResponseStartedDownload) { 3730 TEST_F(ResourceDispatcherHostTest, TransferResponseStartedDownload) {
3797 int initial_count(web_contents_observer_->resource_response_start_count()); 3731 int initial_count(web_contents_observer_->resource_response_start_count());
3798 3732
3799 MakeWebContentsAssociatedDownloadRequest( 3733 MakeWebContentsAssociatedDownloadRequest(
3800 1, net::URLRequestTestJob::test_url_1()); 3734 1, net::URLRequestTestJob::test_url_1());
3801 base::RunLoop().RunUntilIdle(); 3735 base::RunLoop().RunUntilIdle();
3802 EXPECT_EQ(initial_count, 3736 EXPECT_EQ(initial_count,
3803 web_contents_observer_->resource_response_start_count()); 3737 web_contents_observer_->resource_response_start_count());
3804 } 3738 }
3805 3739
3806 // Confirm that request redirected notifications for downloads are not 3740 // Confirm that request redirected notifications for downloads are not
3807 // transmitted to the WebContents. 3741 // transmitted to the WebContents.
3808 TEST_P(ResourceDispatcherHostTest, TransferRequestRedirectedDownload) { 3742 TEST_F(ResourceDispatcherHostTest, TransferRequestRedirectedDownload) {
3809 int initial_count(web_contents_observer_->resource_request_redirect_count()); 3743 int initial_count(web_contents_observer_->resource_request_redirect_count());
3810 3744
3811 MakeWebContentsAssociatedDownloadRequest( 3745 MakeWebContentsAssociatedDownloadRequest(
3812 1, net::URLRequestTestJob::test_url_redirect_to_url_2()); 3746 1, net::URLRequestTestJob::test_url_redirect_to_url_2());
3813 base::RunLoop().RunUntilIdle(); 3747 base::RunLoop().RunUntilIdle();
3814 EXPECT_EQ(initial_count, 3748 EXPECT_EQ(initial_count,
3815 web_contents_observer_->resource_request_redirect_count()); 3749 web_contents_observer_->resource_request_redirect_count());
3816 } 3750 }
3817 3751
3818 // Tests that a ResourceThrottle that needs to process the response before any 3752 // Tests that a ResourceThrottle that needs to process the response before any
3819 // part of the body is read can do so. 3753 // part of the body is read can do so.
3820 TEST_P(ResourceDispatcherHostTest, ThrottleMustProcessResponseBeforeRead) { 3754 TEST_F(ResourceDispatcherHostTest, ThrottleMustProcessResponseBeforeRead) {
3821 // Ensure all jobs will check that no read operation is called. 3755 // Ensure all jobs will check that no read operation is called.
3822 job_factory_->SetMustNotReadJobGeneration(true); 3756 job_factory_->SetMustNotReadJobGeneration(true);
3823 HandleScheme("http"); 3757 HandleScheme("http");
3824 3758
3825 // Create a ResourceThrottle that must process the response before any part of 3759 // Create a ResourceThrottle that must process the response before any part of
3826 // the body is read. This throttle will also cancel the request in 3760 // the body is read. This throttle will also cancel the request in
3827 // WillProcessResponse. 3761 // WillProcessResponse.
3828 TestResourceDispatcherHostDelegate delegate; 3762 TestResourceDispatcherHostDelegate delegate;
3829 int throttle_flags = CANCEL_PROCESSING_RESPONSE | MUST_NOT_CACHE_BODY; 3763 int throttle_flags = CANCEL_PROCESSING_RESPONSE | MUST_NOT_CACHE_BODY;
3830 delegate.set_flags(throttle_flags); 3764 delegate.set_flags(throttle_flags);
(...skipping 24 matching lines...) Expand all
3855 const SyncLoadResult* result) { 3789 const SyncLoadResult* result) {
3856 *called = true; 3790 *called = true;
3857 *was_null = !result; 3791 *was_null = !result;
3858 3792
3859 if (result) 3793 if (result)
3860 *result_out = *result; 3794 *result_out = *result;
3861 } 3795 }
3862 3796
3863 } // namespace 3797 } // namespace
3864 3798
3865 TEST_P(ResourceDispatcherHostTest, SyncLoadWithMojoSuccess) { 3799 TEST_F(ResourceDispatcherHostTest, SyncLoadWithMojoSuccess) {
3866 ResourceRequest request = CreateResourceRequest( 3800 ResourceRequest request = CreateResourceRequest(
3867 "GET", RESOURCE_TYPE_XHR, net::URLRequestTestJob::test_url_1()); 3801 "GET", RESOURCE_TYPE_XHR, net::URLRequestTestJob::test_url_1());
3868 request.priority = net::MAXIMUM_PRIORITY; 3802 request.priority = net::MAXIMUM_PRIORITY;
3869 3803
3870 bool called = false; 3804 bool called = false;
3871 bool was_null = false; 3805 bool was_null = false;
3872 SyncLoadResult result; 3806 SyncLoadResult result;
3873 host_.OnSyncLoadWithMojo( 3807 host_.OnSyncLoadWithMojo(
3874 GetResourceRequesterInfo(filter_.get()), 0, 1, request, 3808 GetResourceRequesterInfo(filter_.get()), 0, 1, request,
3875 base::Bind(&StoreSyncLoadResult, &called, &was_null, &result)); 3809 base::Bind(&StoreSyncLoadResult, &called, &was_null, &result));
3876 base::RunLoop().RunUntilIdle(); 3810 base::RunLoop().RunUntilIdle();
3877 EXPECT_TRUE(called); 3811 EXPECT_TRUE(called);
3878 EXPECT_FALSE(was_null); 3812 EXPECT_FALSE(was_null);
3879 EXPECT_EQ(net::OK, result.error_code); 3813 EXPECT_EQ(net::OK, result.error_code);
3880 } 3814 }
3881 3815
3882 TEST_P(ResourceDispatcherHostTest, SyncLoadWithMojoError) { 3816 TEST_F(ResourceDispatcherHostTest, SyncLoadWithMojoError) {
3883 ResourceRequest request = CreateResourceRequest( 3817 ResourceRequest request = CreateResourceRequest(
3884 "GET", RESOURCE_TYPE_XHR, net::URLRequestTestJob::test_url_error()); 3818 "GET", RESOURCE_TYPE_XHR, net::URLRequestTestJob::test_url_error());
3885 request.priority = net::MAXIMUM_PRIORITY; 3819 request.priority = net::MAXIMUM_PRIORITY;
3886 3820
3887 bool called = false; 3821 bool called = false;
3888 bool was_null = false; 3822 bool was_null = false;
3889 SyncLoadResult result; 3823 SyncLoadResult result;
3890 host_.OnSyncLoadWithMojo( 3824 host_.OnSyncLoadWithMojo(
3891 GetResourceRequesterInfo(filter_.get()), 0, 1, request, 3825 GetResourceRequesterInfo(filter_.get()), 0, 1, request,
3892 base::Bind(&StoreSyncLoadResult, &called, &was_null, &result)); 3826 base::Bind(&StoreSyncLoadResult, &called, &was_null, &result));
3893 base::RunLoop().RunUntilIdle(); 3827 base::RunLoop().RunUntilIdle();
3894 EXPECT_TRUE(called); 3828 EXPECT_TRUE(called);
3895 EXPECT_FALSE(was_null); 3829 EXPECT_FALSE(was_null);
3896 EXPECT_EQ(net::ERR_INVALID_URL, result.error_code); 3830 EXPECT_EQ(net::ERR_INVALID_URL, result.error_code);
3897 } 3831 }
3898 3832
3899 TEST_P(ResourceDispatcherHostTest, SyncLoadWithMojoCancel) { 3833 TEST_F(ResourceDispatcherHostTest, SyncLoadWithMojoCancel) {
3900 ResourceRequest request = CreateResourceRequest( 3834 ResourceRequest request = CreateResourceRequest(
3901 "GET", RESOURCE_TYPE_XHR, net::URLRequestTestJob::test_url_error()); 3835 "GET", RESOURCE_TYPE_XHR, net::URLRequestTestJob::test_url_error());
3902 request.priority = net::MAXIMUM_PRIORITY; 3836 request.priority = net::MAXIMUM_PRIORITY;
3903 3837
3904 bool called = false; 3838 bool called = false;
3905 bool was_null = false; 3839 bool was_null = false;
3906 SyncLoadResult result; 3840 SyncLoadResult result;
3907 host_.OnSyncLoadWithMojo( 3841 host_.OnSyncLoadWithMojo(
3908 GetResourceRequesterInfo(filter_.get()), 0, 1, request, 3842 GetResourceRequesterInfo(filter_.get()), 0, 1, request,
3909 base::Bind(&StoreSyncLoadResult, &called, &was_null, &result)); 3843 base::Bind(&StoreSyncLoadResult, &called, &was_null, &result));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3989 const GURL& location) const { 3923 const GURL& location) const {
3990 return nullptr; 3924 return nullptr;
3991 } 3925 }
3992 3926
3993 net::URLRequestJob* TestURLRequestJobFactory::MaybeInterceptResponse( 3927 net::URLRequestJob* TestURLRequestJobFactory::MaybeInterceptResponse(
3994 net::URLRequest* request, 3928 net::URLRequest* request,
3995 net::NetworkDelegate* network_delegate) const { 3929 net::NetworkDelegate* network_delegate) const {
3996 return nullptr; 3930 return nullptr;
3997 } 3931 }
3998 3932
3999 INSTANTIATE_TEST_CASE_P(
4000 ResourceDispatcherHostTests,
4001 ResourceDispatcherHostTest,
4002 testing::Values(TestConfig::kDefault,
4003 TestConfig::kOptimizeIPCForSmallResourceEnabled));
4004
4005 } // namespace content 3933 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/async_resource_handler_unittest.cc ('k') | content/child/resource_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698