OLD | NEW |
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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 TEST_F(ResourceDispatcherHostTest, TestMany) { | 1060 TEST_F(ResourceDispatcherHostTest, TestMany) { |
1061 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); | 1061 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); |
1062 MakeTestRequest(0, 2, net::URLRequestTestJob::test_url_2()); | 1062 MakeTestRequest(0, 2, net::URLRequestTestJob::test_url_2()); |
1063 MakeTestRequest(0, 3, net::URLRequestTestJob::test_url_3()); | 1063 MakeTestRequest(0, 3, net::URLRequestTestJob::test_url_3()); |
1064 MakeTestRequestWithResourceType(filter_.get(), 0, 4, | 1064 MakeTestRequestWithResourceType(filter_.get(), 0, 4, |
1065 net::URLRequestTestJob::test_url_4(), | 1065 net::URLRequestTestJob::test_url_4(), |
1066 ResourceType::PREFETCH); // detachable type | 1066 ResourceType::PREFETCH); // detachable type |
1067 MakeTestRequest(0, 5, net::URLRequestTestJob::test_url_redirect_to_url_2()); | 1067 MakeTestRequest(0, 5, net::URLRequestTestJob::test_url_redirect_to_url_2()); |
1068 | 1068 |
1069 // Finish the redirection | 1069 // Finish the redirection |
1070 ResourceHostMsg_FollowRedirect redirect_msg(5, false, GURL()); | 1070 ResourceHostMsg_FollowRedirect redirect_msg(5); |
1071 bool msg_was_ok; | 1071 bool msg_was_ok; |
1072 host_.OnMessageReceived(redirect_msg, filter_.get(), &msg_was_ok); | 1072 host_.OnMessageReceived(redirect_msg, filter_.get(), &msg_was_ok); |
1073 base::MessageLoop::current()->RunUntilIdle(); | 1073 base::MessageLoop::current()->RunUntilIdle(); |
1074 | 1074 |
1075 // flush all the pending requests | 1075 // flush all the pending requests |
1076 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 1076 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
1077 | 1077 |
1078 // sorts out all the messages we saw by request | 1078 // sorts out all the messages we saw by request |
1079 ResourceIPCAccumulator::ClassifiedMessages msgs; | 1079 ResourceIPCAccumulator::ClassifiedMessages msgs; |
1080 accum_.GetClassifiedMessages(&msgs); | 1080 accum_.GetClassifiedMessages(&msgs); |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, | 2271 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, |
2272 GURL("http://example.com/blah"), | 2272 GURL("http://example.com/blah"), |
2273 ResourceType::MAIN_FRAME); | 2273 ResourceType::MAIN_FRAME); |
2274 | 2274 |
2275 // Now that we're blocked on the redirect, update the response and unblock by | 2275 // Now that we're blocked on the redirect, update the response and unblock by |
2276 // telling the AsyncResourceHandler to follow the redirect. | 2276 // telling the AsyncResourceHandler to follow the redirect. |
2277 const std::string kResponseBody = "hello world"; | 2277 const std::string kResponseBody = "hello world"; |
2278 SetResponse("HTTP/1.1 200 OK\n" | 2278 SetResponse("HTTP/1.1 200 OK\n" |
2279 "Content-Type: text/html\n\n", | 2279 "Content-Type: text/html\n\n", |
2280 kResponseBody); | 2280 kResponseBody); |
2281 ResourceHostMsg_FollowRedirect redirect_msg(request_id, false, GURL()); | 2281 ResourceHostMsg_FollowRedirect redirect_msg(request_id); |
2282 bool msg_was_ok; | 2282 bool msg_was_ok; |
2283 host_.OnMessageReceived(redirect_msg, filter_.get(), &msg_was_ok); | 2283 host_.OnMessageReceived(redirect_msg, filter_.get(), &msg_was_ok); |
2284 base::MessageLoop::current()->RunUntilIdle(); | 2284 base::MessageLoop::current()->RunUntilIdle(); |
2285 | 2285 |
2286 // Flush all the pending requests to get the response through the | 2286 // Flush all the pending requests to get the response through the |
2287 // BufferedResourceHandler. | 2287 // BufferedResourceHandler. |
2288 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 2288 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
2289 | 2289 |
2290 // Restore, now that we've set up a transfer. | 2290 // Restore, now that we've set up a transfer. |
2291 SetBrowserClientForTesting(old_client); | 2291 SetBrowserClientForTesting(old_client); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2346 ResourceType::MAIN_FRAME); | 2346 ResourceType::MAIN_FRAME); |
2347 | 2347 |
2348 // Now that we're blocked on the redirect, update the response and unblock by | 2348 // Now that we're blocked on the redirect, update the response and unblock by |
2349 // telling the AsyncResourceHandler to follow the redirect. Use a text/plain | 2349 // telling the AsyncResourceHandler to follow the redirect. Use a text/plain |
2350 // MIME type, which causes BufferedResourceHandler to buffer it before the | 2350 // MIME type, which causes BufferedResourceHandler to buffer it before the |
2351 // transfer occurs. | 2351 // transfer occurs. |
2352 const std::string kResponseBody = "hello world"; | 2352 const std::string kResponseBody = "hello world"; |
2353 SetResponse("HTTP/1.1 200 OK\n" | 2353 SetResponse("HTTP/1.1 200 OK\n" |
2354 "Content-Type: text/plain\n\n", | 2354 "Content-Type: text/plain\n\n", |
2355 kResponseBody); | 2355 kResponseBody); |
2356 ResourceHostMsg_FollowRedirect redirect_msg(request_id, false, GURL()); | 2356 ResourceHostMsg_FollowRedirect redirect_msg(request_id); |
2357 bool msg_was_ok; | 2357 bool msg_was_ok; |
2358 host_.OnMessageReceived(redirect_msg, filter_.get(), &msg_was_ok); | 2358 host_.OnMessageReceived(redirect_msg, filter_.get(), &msg_was_ok); |
2359 base::MessageLoop::current()->RunUntilIdle(); | 2359 base::MessageLoop::current()->RunUntilIdle(); |
2360 | 2360 |
2361 // Flush all the pending requests to get the response through the | 2361 // Flush all the pending requests to get the response through the |
2362 // BufferedResourceHandler. | 2362 // BufferedResourceHandler. |
2363 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 2363 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
2364 | 2364 |
2365 // Restore, now that we've set up a transfer. | 2365 // Restore, now that we've set up a transfer. |
2366 SetBrowserClientForTesting(old_client); | 2366 SetBrowserClientForTesting(old_client); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2429 bool msg_was_ok; | 2429 bool msg_was_ok; |
2430 host_.OnMessageReceived( | 2430 host_.OnMessageReceived( |
2431 first_request_msg, first_filter.get(), &msg_was_ok); | 2431 first_request_msg, first_filter.get(), &msg_was_ok); |
2432 base::MessageLoop::current()->RunUntilIdle(); | 2432 base::MessageLoop::current()->RunUntilIdle(); |
2433 | 2433 |
2434 // Now that we're blocked on the redirect, update the response and unblock | 2434 // Now that we're blocked on the redirect, update the response and unblock |
2435 // by telling the AsyncResourceHandler to follow the redirect. | 2435 // by telling the AsyncResourceHandler to follow the redirect. |
2436 SetResponse("HTTP/1.1 200 OK\n" | 2436 SetResponse("HTTP/1.1 200 OK\n" |
2437 "Content-Type: text/html\n\n", | 2437 "Content-Type: text/html\n\n", |
2438 kResponseBody); | 2438 kResponseBody); |
2439 ResourceHostMsg_FollowRedirect redirect_msg(request_id, false, GURL()); | 2439 ResourceHostMsg_FollowRedirect redirect_msg(request_id); |
2440 host_.OnMessageReceived(redirect_msg, first_filter.get(), &msg_was_ok); | 2440 host_.OnMessageReceived(redirect_msg, first_filter.get(), &msg_was_ok); |
2441 base::MessageLoop::current()->RunUntilIdle(); | 2441 base::MessageLoop::current()->RunUntilIdle(); |
2442 | 2442 |
2443 // Flush all the pending requests to get the response through the | 2443 // Flush all the pending requests to get the response through the |
2444 // BufferedResourceHandler. | 2444 // BufferedResourceHandler. |
2445 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 2445 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
2446 } | 2446 } |
2447 // The first filter is now deleted, as if the child process died. | 2447 // The first filter is now deleted, as if the child process died. |
2448 | 2448 |
2449 // Restore. | 2449 // Restore. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2503 TransfersAllNavigationsContentBrowserClient new_client; | 2503 TransfersAllNavigationsContentBrowserClient new_client; |
2504 ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client); | 2504 ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client); |
2505 | 2505 |
2506 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, | 2506 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, |
2507 GURL("http://example.com/blah"), | 2507 GURL("http://example.com/blah"), |
2508 ResourceType::MAIN_FRAME); | 2508 ResourceType::MAIN_FRAME); |
2509 | 2509 |
2510 // Now that we're blocked on the redirect, simulate hitting another redirect. | 2510 // Now that we're blocked on the redirect, simulate hitting another redirect. |
2511 SetResponse("HTTP/1.1 302 Found\n" | 2511 SetResponse("HTTP/1.1 302 Found\n" |
2512 "Location: http://other.com/blerg\n\n"); | 2512 "Location: http://other.com/blerg\n\n"); |
2513 ResourceHostMsg_FollowRedirect redirect_msg(request_id, false, GURL()); | 2513 ResourceHostMsg_FollowRedirect redirect_msg(request_id); |
2514 bool msg_was_ok; | 2514 bool msg_was_ok; |
2515 host_.OnMessageReceived(redirect_msg, filter_.get(), &msg_was_ok); | 2515 host_.OnMessageReceived(redirect_msg, filter_.get(), &msg_was_ok); |
2516 base::MessageLoop::current()->RunUntilIdle(); | 2516 base::MessageLoop::current()->RunUntilIdle(); |
2517 | 2517 |
2518 // Now that we're blocked on the second redirect, update the response and | 2518 // Now that we're blocked on the second redirect, update the response and |
2519 // unblock by telling the AsyncResourceHandler to follow the redirect. | 2519 // unblock by telling the AsyncResourceHandler to follow the redirect. |
2520 // Again, use text/plain to force BufferedResourceHandler to buffer before | 2520 // Again, use text/plain to force BufferedResourceHandler to buffer before |
2521 // the transfer. | 2521 // the transfer. |
2522 const std::string kResponseBody = "hello world"; | 2522 const std::string kResponseBody = "hello world"; |
2523 SetResponse("HTTP/1.1 200 OK\n" | 2523 SetResponse("HTTP/1.1 200 OK\n" |
2524 "Content-Type: text/plain\n\n", | 2524 "Content-Type: text/plain\n\n", |
2525 kResponseBody); | 2525 kResponseBody); |
2526 ResourceHostMsg_FollowRedirect redirect_msg2(request_id, false, GURL()); | 2526 ResourceHostMsg_FollowRedirect redirect_msg2(request_id); |
2527 host_.OnMessageReceived(redirect_msg2, filter_.get(), &msg_was_ok); | 2527 host_.OnMessageReceived(redirect_msg2, filter_.get(), &msg_was_ok); |
2528 base::MessageLoop::current()->RunUntilIdle(); | 2528 base::MessageLoop::current()->RunUntilIdle(); |
2529 | 2529 |
2530 // Flush all the pending requests to get the response through the | 2530 // Flush all the pending requests to get the response through the |
2531 // BufferedResourceHandler. | 2531 // BufferedResourceHandler. |
2532 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 2532 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
2533 | 2533 |
2534 // Restore. | 2534 // Restore. |
2535 SetBrowserClientForTesting(old_client); | 2535 SetBrowserClientForTesting(old_client); |
2536 | 2536 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2929 // message loop for the delete itself. (This relies on the delete happening on | 2929 // message loop for the delete itself. (This relies on the delete happening on |
2930 // the FILE thread which is mapped to main thread in this test.) | 2930 // the FILE thread which is mapped to main thread in this test.) |
2931 base::RunLoop().RunUntilIdle(); | 2931 base::RunLoop().RunUntilIdle(); |
2932 | 2932 |
2933 EXPECT_FALSE(base::PathExists(response_head.download_file_path)); | 2933 EXPECT_FALSE(base::PathExists(response_head.download_file_path)); |
2934 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( | 2934 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( |
2935 filter_->child_id(), response_head.download_file_path)); | 2935 filter_->child_id(), response_head.download_file_path)); |
2936 } | 2936 } |
2937 | 2937 |
2938 } // namespace content | 2938 } // namespace content |
OLD | NEW |