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

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

Issue 292443004: Remove IPC_BEGIN_MESSAGE_MAP_EX macro since r270839 made all bad IPCs kill their child processes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 PickleIterator iter(messages[0]); 72 PickleIterator iter(messages[0]);
73 int request_id; 73 int request_id;
74 ASSERT_TRUE(IPC::ReadParam(&messages[0], &iter, &request_id)); 74 ASSERT_TRUE(IPC::ReadParam(&messages[0], &iter, &request_id));
75 ASSERT_TRUE(IPC::ReadParam(&messages[0], &iter, response_head)); 75 ASSERT_TRUE(IPC::ReadParam(&messages[0], &iter, response_head));
76 } 76 }
77 77
78 void GenerateIPCMessage( 78 void GenerateIPCMessage(
79 scoped_refptr<ResourceMessageFilter> filter, 79 scoped_refptr<ResourceMessageFilter> filter,
80 scoped_ptr<IPC::Message> message) { 80 scoped_ptr<IPC::Message> message) {
81 bool msg_is_ok;
82 ResourceDispatcherHostImpl::Get()->OnMessageReceived( 81 ResourceDispatcherHostImpl::Get()->OnMessageReceived(
83 *message, filter.get(), &msg_is_ok); 82 *message, filter.get());
84 } 83 }
85 84
86 // On Windows, ResourceMsg_SetDataBuffer supplies a HANDLE which is not 85 // On Windows, ResourceMsg_SetDataBuffer supplies a HANDLE which is not
87 // automatically released. 86 // automatically released.
88 // 87 //
89 // See ResourceDispatcher::ReleaseResourcesInDataMessage. 88 // See ResourceDispatcher::ReleaseResourcesInDataMessage.
90 // 89 //
91 // TODO(davidben): It would be nice if the behavior for base::SharedMemoryHandle 90 // TODO(davidben): It would be nice if the behavior for base::SharedMemoryHandle
92 // were more like it is in POSIX where the received fds are tracked in a 91 // were more like it is in POSIX where the received fds are tracked in a
93 // ref-counted core that closes them if not extracted. 92 // ref-counted core that closes them if not extracted.
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 919
921 void ResourceDispatcherHostTest::MakeTestRequestWithResourceType( 920 void ResourceDispatcherHostTest::MakeTestRequestWithResourceType(
922 ResourceMessageFilter* filter, 921 ResourceMessageFilter* filter,
923 int render_view_id, 922 int render_view_id,
924 int request_id, 923 int request_id,
925 const GURL& url, 924 const GURL& url,
926 ResourceType::Type type) { 925 ResourceType::Type type) {
927 ResourceHostMsg_Request request = 926 ResourceHostMsg_Request request =
928 CreateResourceRequest("GET", type, url); 927 CreateResourceRequest("GET", type, url);
929 ResourceHostMsg_RequestResource msg(render_view_id, request_id, request); 928 ResourceHostMsg_RequestResource msg(render_view_id, request_id, request);
930 bool msg_was_ok; 929 host_.OnMessageReceived(msg, filter);
931 host_.OnMessageReceived(msg, filter, &msg_was_ok);
932 KickOffRequest(); 930 KickOffRequest();
933 } 931 }
934 932
935 void ResourceDispatcherHostTest::CancelRequest(int request_id) { 933 void ResourceDispatcherHostTest::CancelRequest(int request_id) {
936 host_.CancelRequest(filter_->child_id(), request_id); 934 host_.CancelRequest(filter_->child_id(), request_id);
937 } 935 }
938 936
939 void ResourceDispatcherHostTest::CompleteStartRequest(int request_id) { 937 void ResourceDispatcherHostTest::CompleteStartRequest(int request_id) {
940 CompleteStartRequest(filter_.get(), request_id); 938 CompleteStartRequest(filter_.get(), request_id);
941 } 939 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); 1059 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1());
1062 MakeTestRequest(0, 2, net::URLRequestTestJob::test_url_2()); 1060 MakeTestRequest(0, 2, net::URLRequestTestJob::test_url_2());
1063 MakeTestRequest(0, 3, net::URLRequestTestJob::test_url_3()); 1061 MakeTestRequest(0, 3, net::URLRequestTestJob::test_url_3());
1064 MakeTestRequestWithResourceType(filter_.get(), 0, 4, 1062 MakeTestRequestWithResourceType(filter_.get(), 0, 4,
1065 net::URLRequestTestJob::test_url_4(), 1063 net::URLRequestTestJob::test_url_4(),
1066 ResourceType::PREFETCH); // detachable type 1064 ResourceType::PREFETCH); // detachable type
1067 MakeTestRequest(0, 5, net::URLRequestTestJob::test_url_redirect_to_url_2()); 1065 MakeTestRequest(0, 5, net::URLRequestTestJob::test_url_redirect_to_url_2());
1068 1066
1069 // Finish the redirection 1067 // Finish the redirection
1070 ResourceHostMsg_FollowRedirect redirect_msg(5); 1068 ResourceHostMsg_FollowRedirect redirect_msg(5);
1071 bool msg_was_ok; 1069 host_.OnMessageReceived(redirect_msg, filter_.get());
1072 host_.OnMessageReceived(redirect_msg, filter_.get(), &msg_was_ok);
1073 base::MessageLoop::current()->RunUntilIdle(); 1070 base::MessageLoop::current()->RunUntilIdle();
1074 1071
1075 // flush all the pending requests 1072 // flush all the pending requests
1076 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 1073 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
1077 1074
1078 // sorts out all the messages we saw by request 1075 // sorts out all the messages we saw by request
1079 ResourceIPCAccumulator::ClassifiedMessages msgs; 1076 ResourceIPCAccumulator::ClassifiedMessages msgs;
1080 accum_.GetClassifiedMessages(&msgs); 1077 accum_.GetClassifiedMessages(&msgs);
1081 1078
1082 // there are five requests, so we should have gotten them classified as such 1079 // there are five requests, so we should have gotten them classified as such
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 1185
1189 // If the filter has disappeared then detachable resources should continue to 1186 // If the filter has disappeared then detachable resources should continue to
1190 // load. 1187 // load.
1191 TEST_F(ResourceDispatcherHostTest, DeletedFilterDetached) { 1188 TEST_F(ResourceDispatcherHostTest, DeletedFilterDetached) {
1192 // test_url_1's data is available synchronously, so use 2 and 3. 1189 // test_url_1's data is available synchronously, so use 2 and 3.
1193 ResourceHostMsg_Request request_prefetch = CreateResourceRequest( 1190 ResourceHostMsg_Request request_prefetch = CreateResourceRequest(
1194 "GET", ResourceType::PREFETCH, net::URLRequestTestJob::test_url_2()); 1191 "GET", ResourceType::PREFETCH, net::URLRequestTestJob::test_url_2());
1195 ResourceHostMsg_Request request_ping = CreateResourceRequest( 1192 ResourceHostMsg_Request request_ping = CreateResourceRequest(
1196 "GET", ResourceType::PING, net::URLRequestTestJob::test_url_3()); 1193 "GET", ResourceType::PING, net::URLRequestTestJob::test_url_3());
1197 1194
1198 bool msg_was_ok;
1199 ResourceHostMsg_RequestResource msg_prefetch(0, 1, request_prefetch); 1195 ResourceHostMsg_RequestResource msg_prefetch(0, 1, request_prefetch);
1200 host_.OnMessageReceived(msg_prefetch, filter_, &msg_was_ok); 1196 host_.OnMessageReceived(msg_prefetch, filter_);
1201 ResourceHostMsg_RequestResource msg_ping(0, 2, request_ping); 1197 ResourceHostMsg_RequestResource msg_ping(0, 2, request_ping);
1202 host_.OnMessageReceived(msg_ping, filter_, &msg_was_ok); 1198 host_.OnMessageReceived(msg_ping, filter_);
1203 1199
1204 // Remove the filter before processing the requests by simulating channel 1200 // Remove the filter before processing the requests by simulating channel
1205 // closure. 1201 // closure.
1206 ResourceRequestInfoImpl* info_prefetch = ResourceRequestInfoImpl::ForRequest( 1202 ResourceRequestInfoImpl* info_prefetch = ResourceRequestInfoImpl::ForRequest(
1207 host_.GetURLRequest(GlobalRequestID(filter_->child_id(), 1))); 1203 host_.GetURLRequest(GlobalRequestID(filter_->child_id(), 1)));
1208 ResourceRequestInfoImpl* info_ping = ResourceRequestInfoImpl::ForRequest( 1204 ResourceRequestInfoImpl* info_ping = ResourceRequestInfoImpl::ForRequest(
1209 host_.GetURLRequest(GlobalRequestID(filter_->child_id(), 2))); 1205 host_.GetURLRequest(GlobalRequestID(filter_->child_id(), 2)));
1210 DCHECK_EQ(filter_.get(), info_prefetch->filter()); 1206 DCHECK_EQ(filter_.get(), info_prefetch->filter());
1211 DCHECK_EQ(filter_.get(), info_ping->filter()); 1207 DCHECK_EQ(filter_.get(), info_ping->filter());
1212 filter_->OnChannelClosing(); 1208 filter_->OnChannelClosing();
(...skipping 27 matching lines...) Expand all
1240 } 1236 }
1241 1237
1242 // If the filter has disappeared (original process dies) then detachable 1238 // If the filter has disappeared (original process dies) then detachable
1243 // resources should continue to load, even when redirected. 1239 // resources should continue to load, even when redirected.
1244 TEST_F(ResourceDispatcherHostTest, DeletedFilterDetachedRedirect) { 1240 TEST_F(ResourceDispatcherHostTest, DeletedFilterDetachedRedirect) {
1245 ResourceHostMsg_Request request = CreateResourceRequest( 1241 ResourceHostMsg_Request request = CreateResourceRequest(
1246 "GET", ResourceType::PREFETCH, 1242 "GET", ResourceType::PREFETCH,
1247 net::URLRequestTestJob::test_url_redirect_to_url_2()); 1243 net::URLRequestTestJob::test_url_redirect_to_url_2());
1248 1244
1249 ResourceHostMsg_RequestResource msg(0, 1, request); 1245 ResourceHostMsg_RequestResource msg(0, 1, request);
1250 bool msg_was_ok; 1246 host_.OnMessageReceived(msg, filter_);
1251 host_.OnMessageReceived(msg, filter_, &msg_was_ok);
1252 1247
1253 // Remove the filter before processing the request by simulating channel 1248 // Remove the filter before processing the request by simulating channel
1254 // closure. 1249 // closure.
1255 GlobalRequestID global_request_id(filter_->child_id(), 1); 1250 GlobalRequestID global_request_id(filter_->child_id(), 1);
1256 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest( 1251 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(
1257 host_.GetURLRequest(global_request_id)); 1252 host_.GetURLRequest(global_request_id));
1258 info->filter_->OnChannelClosing(); 1253 info->filter_->OnChannelClosing();
1259 info->filter_.reset(); 1254 info->filter_.reset();
1260 1255
1261 // From the renderer's perspective, the request was cancelled. 1256 // From the renderer's perspective, the request was cancelled.
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
2116 2111
2117 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 2112 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
2118 GURL("http://example.com/blah"), 2113 GURL("http://example.com/blah"),
2119 ResourceType::MAIN_FRAME); 2114 ResourceType::MAIN_FRAME);
2120 // Return some data so that the request is identified as a download 2115 // Return some data so that the request is identified as a download
2121 // and the proper resource handlers are created. 2116 // and the proper resource handlers are created.
2122 EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage()); 2117 EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage());
2123 2118
2124 // And now simulate a cancellation coming from the renderer. 2119 // And now simulate a cancellation coming from the renderer.
2125 ResourceHostMsg_CancelRequest msg(request_id); 2120 ResourceHostMsg_CancelRequest msg(request_id);
2126 bool msg_was_ok; 2121 host_.OnMessageReceived(msg, filter_.get());
2127 host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok);
2128 2122
2129 // Since the request had already started processing as a download, 2123 // Since the request had already started processing as a download,
2130 // the cancellation above should have been ignored and the request 2124 // the cancellation above should have been ignored and the request
2131 // should still be alive. 2125 // should still be alive.
2132 EXPECT_EQ(1, host_.pending_requests()); 2126 EXPECT_EQ(1, host_.pending_requests());
2133 2127
2134 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2128 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2135 } 2129 }
2136 2130
2137 TEST_F(ResourceDispatcherHostTest, CancelRequestsForContext) { 2131 TEST_F(ResourceDispatcherHostTest, CancelRequestsForContext) {
(...skipping 14 matching lines...) Expand all
2152 2146
2153 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 2147 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
2154 GURL("http://example.com/blah"), 2148 GURL("http://example.com/blah"),
2155 ResourceType::MAIN_FRAME); 2149 ResourceType::MAIN_FRAME);
2156 // Return some data so that the request is identified as a download 2150 // Return some data so that the request is identified as a download
2157 // and the proper resource handlers are created. 2151 // and the proper resource handlers are created.
2158 EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage()); 2152 EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage());
2159 2153
2160 // And now simulate a cancellation coming from the renderer. 2154 // And now simulate a cancellation coming from the renderer.
2161 ResourceHostMsg_CancelRequest msg(request_id); 2155 ResourceHostMsg_CancelRequest msg(request_id);
2162 bool msg_was_ok; 2156 host_.OnMessageReceived(msg, filter_.get());
2163 host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok);
2164 2157
2165 // Since the request had already started processing as a download, 2158 // Since the request had already started processing as a download,
2166 // the cancellation above should have been ignored and the request 2159 // the cancellation above should have been ignored and the request
2167 // should still be alive. 2160 // should still be alive.
2168 EXPECT_EQ(1, host_.pending_requests()); 2161 EXPECT_EQ(1, host_.pending_requests());
2169 2162
2170 // Cancelling by other methods shouldn't work either. 2163 // Cancelling by other methods shouldn't work either.
2171 host_.CancelRequestsForProcess(render_view_id); 2164 host_.CancelRequestsForProcess(render_view_id);
2172 EXPECT_EQ(1, host_.pending_requests()); 2165 EXPECT_EQ(1, host_.pending_requests());
2173 2166
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 2214 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
2222 GURL("http://example.com/blah"), 2215 GURL("http://example.com/blah"),
2223 ResourceType::MAIN_FRAME); 2216 ResourceType::MAIN_FRAME);
2224 2217
2225 2218
2226 GlobalRequestID global_request_id(filter_->child_id(), request_id); 2219 GlobalRequestID global_request_id(filter_->child_id(), request_id);
2227 host_.MarkAsTransferredNavigation(global_request_id); 2220 host_.MarkAsTransferredNavigation(global_request_id);
2228 2221
2229 // And now simulate a cancellation coming from the renderer. 2222 // And now simulate a cancellation coming from the renderer.
2230 ResourceHostMsg_CancelRequest msg(request_id); 2223 ResourceHostMsg_CancelRequest msg(request_id);
2231 bool msg_was_ok; 2224 host_.OnMessageReceived(msg, filter_.get());
2232 host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok);
2233 2225
2234 // Since the request is marked as being transferred, 2226 // Since the request is marked as being transferred,
2235 // the cancellation above should have been ignored and the request 2227 // the cancellation above should have been ignored and the request
2236 // should still be alive. 2228 // should still be alive.
2237 EXPECT_EQ(1, host_.pending_requests()); 2229 EXPECT_EQ(1, host_.pending_requests());
2238 2230
2239 // Cancelling by other methods shouldn't work either. 2231 // Cancelling by other methods shouldn't work either.
2240 host_.CancelRequestsForProcess(render_view_id); 2232 host_.CancelRequestsForProcess(render_view_id);
2241 EXPECT_EQ(1, host_.pending_requests()); 2233 EXPECT_EQ(1, host_.pending_requests());
2242 2234
(...skipping 29 matching lines...) Expand all
2272 GURL("http://example.com/blah"), 2264 GURL("http://example.com/blah"),
2273 ResourceType::MAIN_FRAME); 2265 ResourceType::MAIN_FRAME);
2274 2266
2275 // Now that we're blocked on the redirect, update the response and unblock by 2267 // Now that we're blocked on the redirect, update the response and unblock by
2276 // telling the AsyncResourceHandler to follow the redirect. 2268 // telling the AsyncResourceHandler to follow the redirect.
2277 const std::string kResponseBody = "hello world"; 2269 const std::string kResponseBody = "hello world";
2278 SetResponse("HTTP/1.1 200 OK\n" 2270 SetResponse("HTTP/1.1 200 OK\n"
2279 "Content-Type: text/html\n\n", 2271 "Content-Type: text/html\n\n",
2280 kResponseBody); 2272 kResponseBody);
2281 ResourceHostMsg_FollowRedirect redirect_msg(request_id); 2273 ResourceHostMsg_FollowRedirect redirect_msg(request_id);
2282 bool msg_was_ok; 2274 host_.OnMessageReceived(redirect_msg, filter_.get());
2283 host_.OnMessageReceived(redirect_msg, filter_.get(), &msg_was_ok);
2284 base::MessageLoop::current()->RunUntilIdle(); 2275 base::MessageLoop::current()->RunUntilIdle();
2285 2276
2286 // Flush all the pending requests to get the response through the 2277 // Flush all the pending requests to get the response through the
2287 // BufferedResourceHandler. 2278 // BufferedResourceHandler.
2288 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2279 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2289 2280
2290 // Restore, now that we've set up a transfer. 2281 // Restore, now that we've set up a transfer.
2291 SetBrowserClientForTesting(old_client); 2282 SetBrowserClientForTesting(old_client);
2292 2283
2293 // This second filter is used to emulate a second process. 2284 // This second filter is used to emulate a second process.
2294 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 2285 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
2295 2286
2296 int new_render_view_id = 1; 2287 int new_render_view_id = 1;
2297 int new_request_id = 2; 2288 int new_request_id = 2;
2298 2289
2299 ResourceHostMsg_Request request = 2290 ResourceHostMsg_Request request =
2300 CreateResourceRequest("GET", ResourceType::MAIN_FRAME, 2291 CreateResourceRequest("GET", ResourceType::MAIN_FRAME,
2301 GURL("http://other.com/blech")); 2292 GURL("http://other.com/blech"));
2302 request.transferred_request_child_id = filter_->child_id(); 2293 request.transferred_request_child_id = filter_->child_id();
2303 request.transferred_request_request_id = request_id; 2294 request.transferred_request_request_id = request_id;
2304 2295
2305 ResourceHostMsg_RequestResource transfer_request_msg( 2296 ResourceHostMsg_RequestResource transfer_request_msg(
2306 new_render_view_id, new_request_id, request); 2297 new_render_view_id, new_request_id, request);
2307 host_.OnMessageReceived( 2298 host_.OnMessageReceived(transfer_request_msg, second_filter.get());
2308 transfer_request_msg, second_filter.get(), &msg_was_ok);
2309 base::MessageLoop::current()->RunUntilIdle(); 2299 base::MessageLoop::current()->RunUntilIdle();
2310 2300
2311 // Check generated messages. 2301 // Check generated messages.
2312 ResourceIPCAccumulator::ClassifiedMessages msgs; 2302 ResourceIPCAccumulator::ClassifiedMessages msgs;
2313 accum_.GetClassifiedMessages(&msgs); 2303 accum_.GetClassifiedMessages(&msgs);
2314 2304
2315 ASSERT_EQ(2U, msgs.size()); 2305 ASSERT_EQ(2U, msgs.size());
2316 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 2306 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
2317 CheckSuccessfulRequest(msgs[1], kResponseBody); 2307 CheckSuccessfulRequest(msgs[1], kResponseBody);
2318 } 2308 }
(...skipping 28 matching lines...) Expand all
2347 2337
2348 // Now that we're blocked on the redirect, update the response and unblock by 2338 // 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 2339 // telling the AsyncResourceHandler to follow the redirect. Use a text/plain
2350 // MIME type, which causes BufferedResourceHandler to buffer it before the 2340 // MIME type, which causes BufferedResourceHandler to buffer it before the
2351 // transfer occurs. 2341 // transfer occurs.
2352 const std::string kResponseBody = "hello world"; 2342 const std::string kResponseBody = "hello world";
2353 SetResponse("HTTP/1.1 200 OK\n" 2343 SetResponse("HTTP/1.1 200 OK\n"
2354 "Content-Type: text/plain\n\n", 2344 "Content-Type: text/plain\n\n",
2355 kResponseBody); 2345 kResponseBody);
2356 ResourceHostMsg_FollowRedirect redirect_msg(request_id); 2346 ResourceHostMsg_FollowRedirect redirect_msg(request_id);
2357 bool msg_was_ok; 2347 host_.OnMessageReceived(redirect_msg, filter_.get());
2358 host_.OnMessageReceived(redirect_msg, filter_.get(), &msg_was_ok);
2359 base::MessageLoop::current()->RunUntilIdle(); 2348 base::MessageLoop::current()->RunUntilIdle();
2360 2349
2361 // Flush all the pending requests to get the response through the 2350 // Flush all the pending requests to get the response through the
2362 // BufferedResourceHandler. 2351 // BufferedResourceHandler.
2363 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2352 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2364 2353
2365 // Restore, now that we've set up a transfer. 2354 // Restore, now that we've set up a transfer.
2366 SetBrowserClientForTesting(old_client); 2355 SetBrowserClientForTesting(old_client);
2367 2356
2368 // This second filter is used to emulate a second process. 2357 // This second filter is used to emulate a second process.
2369 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 2358 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
2370 2359
2371 int new_render_view_id = 1; 2360 int new_render_view_id = 1;
2372 int new_request_id = 2; 2361 int new_request_id = 2;
2373 2362
2374 ResourceHostMsg_Request request = 2363 ResourceHostMsg_Request request =
2375 CreateResourceRequest("GET", ResourceType::MAIN_FRAME, 2364 CreateResourceRequest("GET", ResourceType::MAIN_FRAME,
2376 GURL("http://other.com/blech")); 2365 GURL("http://other.com/blech"));
2377 request.transferred_request_child_id = filter_->child_id(); 2366 request.transferred_request_child_id = filter_->child_id();
2378 request.transferred_request_request_id = request_id; 2367 request.transferred_request_request_id = request_id;
2379 2368
2380 ResourceHostMsg_RequestResource transfer_request_msg( 2369 ResourceHostMsg_RequestResource transfer_request_msg(
2381 new_render_view_id, new_request_id, request); 2370 new_render_view_id, new_request_id, request);
2382 host_.OnMessageReceived( 2371 host_.OnMessageReceived(transfer_request_msg, second_filter.get());
2383 transfer_request_msg, second_filter.get(), &msg_was_ok);
2384 base::MessageLoop::current()->RunUntilIdle(); 2372 base::MessageLoop::current()->RunUntilIdle();
2385 2373
2386 // Check generated messages. 2374 // Check generated messages.
2387 ResourceIPCAccumulator::ClassifiedMessages msgs; 2375 ResourceIPCAccumulator::ClassifiedMessages msgs;
2388 accum_.GetClassifiedMessages(&msgs); 2376 accum_.GetClassifiedMessages(&msgs);
2389 2377
2390 ASSERT_EQ(2U, msgs.size()); 2378 ASSERT_EQ(2U, msgs.size());
2391 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 2379 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
2392 CheckSuccessfulRequest(msgs[1], kResponseBody); 2380 CheckSuccessfulRequest(msgs[1], kResponseBody);
2393 } 2381 }
(...skipping 25 matching lines...) Expand all
2419 { 2407 {
2420 scoped_refptr<ForwardingFilter> first_filter = MakeForwardingFilter(); 2408 scoped_refptr<ForwardingFilter> first_filter = MakeForwardingFilter();
2421 first_child_id = first_filter->child_id(); 2409 first_child_id = first_filter->child_id();
2422 2410
2423 ResourceHostMsg_Request first_request = 2411 ResourceHostMsg_Request first_request =
2424 CreateResourceRequest("GET", ResourceType::MAIN_FRAME, 2412 CreateResourceRequest("GET", ResourceType::MAIN_FRAME,
2425 GURL("http://example.com/blah")); 2413 GURL("http://example.com/blah"));
2426 2414
2427 ResourceHostMsg_RequestResource first_request_msg( 2415 ResourceHostMsg_RequestResource first_request_msg(
2428 render_view_id, request_id, first_request); 2416 render_view_id, request_id, first_request);
2429 bool msg_was_ok; 2417 host_.OnMessageReceived(first_request_msg, first_filter.get());
2430 host_.OnMessageReceived(
2431 first_request_msg, first_filter.get(), &msg_was_ok);
2432 base::MessageLoop::current()->RunUntilIdle(); 2418 base::MessageLoop::current()->RunUntilIdle();
2433 2419
2434 // Now that we're blocked on the redirect, update the response and unblock 2420 // Now that we're blocked on the redirect, update the response and unblock
2435 // by telling the AsyncResourceHandler to follow the redirect. 2421 // by telling the AsyncResourceHandler to follow the redirect.
2436 SetResponse("HTTP/1.1 200 OK\n" 2422 SetResponse("HTTP/1.1 200 OK\n"
2437 "Content-Type: text/html\n\n", 2423 "Content-Type: text/html\n\n",
2438 kResponseBody); 2424 kResponseBody);
2439 ResourceHostMsg_FollowRedirect redirect_msg(request_id); 2425 ResourceHostMsg_FollowRedirect redirect_msg(request_id);
2440 host_.OnMessageReceived(redirect_msg, first_filter.get(), &msg_was_ok); 2426 host_.OnMessageReceived(redirect_msg, first_filter.get());
2441 base::MessageLoop::current()->RunUntilIdle(); 2427 base::MessageLoop::current()->RunUntilIdle();
2442 2428
2443 // Flush all the pending requests to get the response through the 2429 // Flush all the pending requests to get the response through the
2444 // BufferedResourceHandler. 2430 // BufferedResourceHandler.
2445 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2431 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2446 } 2432 }
2447 // The first filter is now deleted, as if the child process died. 2433 // The first filter is now deleted, as if the child process died.
2448 2434
2449 // Restore. 2435 // Restore.
2450 SetBrowserClientForTesting(old_client); 2436 SetBrowserClientForTesting(old_client);
(...skipping 10 matching lines...) Expand all
2461 ResourceHostMsg_Request request = 2447 ResourceHostMsg_Request request =
2462 CreateResourceRequest("GET", ResourceType::MAIN_FRAME, 2448 CreateResourceRequest("GET", ResourceType::MAIN_FRAME,
2463 GURL("http://other.com/blech")); 2449 GURL("http://other.com/blech"));
2464 request.transferred_request_child_id = first_child_id; 2450 request.transferred_request_child_id = first_child_id;
2465 request.transferred_request_request_id = request_id; 2451 request.transferred_request_request_id = request_id;
2466 2452
2467 // For cleanup. 2453 // For cleanup.
2468 child_ids_.insert(second_filter->child_id()); 2454 child_ids_.insert(second_filter->child_id());
2469 ResourceHostMsg_RequestResource transfer_request_msg( 2455 ResourceHostMsg_RequestResource transfer_request_msg(
2470 new_render_view_id, new_request_id, request); 2456 new_render_view_id, new_request_id, request);
2471 bool msg_was_ok; 2457 host_.OnMessageReceived(transfer_request_msg, second_filter.get());
2472 host_.OnMessageReceived(
2473 transfer_request_msg, second_filter.get(), &msg_was_ok);
2474 base::MessageLoop::current()->RunUntilIdle(); 2458 base::MessageLoop::current()->RunUntilIdle();
2475 2459
2476 // Check generated messages. 2460 // Check generated messages.
2477 ResourceIPCAccumulator::ClassifiedMessages msgs; 2461 ResourceIPCAccumulator::ClassifiedMessages msgs;
2478 accum_.GetClassifiedMessages(&msgs); 2462 accum_.GetClassifiedMessages(&msgs);
2479 2463
2480 ASSERT_EQ(2U, msgs.size()); 2464 ASSERT_EQ(2U, msgs.size());
2481 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 2465 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
2482 CheckSuccessfulRequest(msgs[1], kResponseBody); 2466 CheckSuccessfulRequest(msgs[1], kResponseBody);
2483 } 2467 }
(...skipping 20 matching lines...) Expand all
2504 ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client); 2488 ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
2505 2489
2506 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 2490 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
2507 GURL("http://example.com/blah"), 2491 GURL("http://example.com/blah"),
2508 ResourceType::MAIN_FRAME); 2492 ResourceType::MAIN_FRAME);
2509 2493
2510 // Now that we're blocked on the redirect, simulate hitting another redirect. 2494 // Now that we're blocked on the redirect, simulate hitting another redirect.
2511 SetResponse("HTTP/1.1 302 Found\n" 2495 SetResponse("HTTP/1.1 302 Found\n"
2512 "Location: http://other.com/blerg\n\n"); 2496 "Location: http://other.com/blerg\n\n");
2513 ResourceHostMsg_FollowRedirect redirect_msg(request_id); 2497 ResourceHostMsg_FollowRedirect redirect_msg(request_id);
2514 bool msg_was_ok; 2498 host_.OnMessageReceived(redirect_msg, filter_.get());
2515 host_.OnMessageReceived(redirect_msg, filter_.get(), &msg_was_ok);
2516 base::MessageLoop::current()->RunUntilIdle(); 2499 base::MessageLoop::current()->RunUntilIdle();
2517 2500
2518 // Now that we're blocked on the second redirect, update the response and 2501 // Now that we're blocked on the second redirect, update the response and
2519 // unblock by telling the AsyncResourceHandler to follow the redirect. 2502 // unblock by telling the AsyncResourceHandler to follow the redirect.
2520 // Again, use text/plain to force BufferedResourceHandler to buffer before 2503 // Again, use text/plain to force BufferedResourceHandler to buffer before
2521 // the transfer. 2504 // the transfer.
2522 const std::string kResponseBody = "hello world"; 2505 const std::string kResponseBody = "hello world";
2523 SetResponse("HTTP/1.1 200 OK\n" 2506 SetResponse("HTTP/1.1 200 OK\n"
2524 "Content-Type: text/plain\n\n", 2507 "Content-Type: text/plain\n\n",
2525 kResponseBody); 2508 kResponseBody);
2526 ResourceHostMsg_FollowRedirect redirect_msg2(request_id); 2509 ResourceHostMsg_FollowRedirect redirect_msg2(request_id);
2527 host_.OnMessageReceived(redirect_msg2, filter_.get(), &msg_was_ok); 2510 host_.OnMessageReceived(redirect_msg2, filter_.get());
2528 base::MessageLoop::current()->RunUntilIdle(); 2511 base::MessageLoop::current()->RunUntilIdle();
2529 2512
2530 // Flush all the pending requests to get the response through the 2513 // Flush all the pending requests to get the response through the
2531 // BufferedResourceHandler. 2514 // BufferedResourceHandler.
2532 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2515 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2533 2516
2534 // Restore. 2517 // Restore.
2535 SetBrowserClientForTesting(old_client); 2518 SetBrowserClientForTesting(old_client);
2536 2519
2537 // This second filter is used to emulate a second process. 2520 // This second filter is used to emulate a second process.
2538 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 2521 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
2539 2522
2540 int new_render_view_id = 1; 2523 int new_render_view_id = 1;
2541 int new_request_id = 2; 2524 int new_request_id = 2;
2542 2525
2543 ResourceHostMsg_Request request = 2526 ResourceHostMsg_Request request =
2544 CreateResourceRequest("GET", ResourceType::MAIN_FRAME, 2527 CreateResourceRequest("GET", ResourceType::MAIN_FRAME,
2545 GURL("http://other.com/blech")); 2528 GURL("http://other.com/blech"));
2546 request.transferred_request_child_id = filter_->child_id(); 2529 request.transferred_request_child_id = filter_->child_id();
2547 request.transferred_request_request_id = request_id; 2530 request.transferred_request_request_id = request_id;
2548 2531
2549 // For cleanup. 2532 // For cleanup.
2550 child_ids_.insert(second_filter->child_id()); 2533 child_ids_.insert(second_filter->child_id());
2551 ResourceHostMsg_RequestResource transfer_request_msg( 2534 ResourceHostMsg_RequestResource transfer_request_msg(
2552 new_render_view_id, new_request_id, request); 2535 new_render_view_id, new_request_id, request);
2553 host_.OnMessageReceived( 2536 host_.OnMessageReceived(transfer_request_msg, second_filter.get());
2554 transfer_request_msg, second_filter.get(), &msg_was_ok);
2555 2537
2556 // Verify that we update the ResourceRequestInfo. 2538 // Verify that we update the ResourceRequestInfo.
2557 GlobalRequestID global_request_id(second_filter->child_id(), new_request_id); 2539 GlobalRequestID global_request_id(second_filter->child_id(), new_request_id);
2558 const ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest( 2540 const ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(
2559 host_.GetURLRequest(global_request_id)); 2541 host_.GetURLRequest(global_request_id));
2560 EXPECT_EQ(second_filter->child_id(), info->GetChildID()); 2542 EXPECT_EQ(second_filter->child_id(), info->GetChildID());
2561 EXPECT_EQ(new_render_view_id, info->GetRouteID()); 2543 EXPECT_EQ(new_render_view_id, info->GetRouteID());
2562 EXPECT_EQ(new_request_id, info->GetRequestID()); 2544 EXPECT_EQ(new_request_id, info->GetRequestID());
2563 EXPECT_EQ(second_filter, info->filter()); 2545 EXPECT_EQ(second_filter, info->filter());
2564 2546
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2642 2624
2643 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 2625 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
2644 GURL("http://example.com/blah"), 2626 GURL("http://example.com/blah"),
2645 ResourceType::PREFETCH); 2627 ResourceType::PREFETCH);
2646 2628
2647 // Get a bit of data before cancelling. 2629 // Get a bit of data before cancelling.
2648 EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage()); 2630 EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage());
2649 2631
2650 // Simulate a cancellation coming from the renderer. 2632 // Simulate a cancellation coming from the renderer.
2651 ResourceHostMsg_CancelRequest msg(request_id); 2633 ResourceHostMsg_CancelRequest msg(request_id);
2652 bool msg_was_ok; 2634 host_.OnMessageReceived(msg, filter_.get());
2653 host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok);
2654 2635
2655 EXPECT_EQ(1, host_.pending_requests()); 2636 EXPECT_EQ(1, host_.pending_requests());
2656 2637
2657 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2638 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2658 2639
2659 // Sort all the messages we saw by request. 2640 // Sort all the messages we saw by request.
2660 ResourceIPCAccumulator::ClassifiedMessages msgs; 2641 ResourceIPCAccumulator::ClassifiedMessages msgs;
2661 accum_.GetClassifiedMessages(&msgs); 2642 accum_.GetClassifiedMessages(&msgs);
2662 2643
2663 EXPECT_EQ(4U, msgs[0].size()); 2644 EXPECT_EQ(4U, msgs[0].size());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2706 while (!complete) { 2687 while (!complete) {
2707 for (size_t i = 0; i < msgs[0].size(); ++i) { 2688 for (size_t i = 0; i < msgs[0].size(); ++i) {
2708 if (msgs[0][i].type() == ResourceMsg_RequestComplete::ID) { 2689 if (msgs[0][i].type() == ResourceMsg_RequestComplete::ID) {
2709 complete = true; 2690 complete = true;
2710 break; 2691 break;
2711 } 2692 }
2712 2693
2713 EXPECT_EQ(ResourceMsg_DataReceived::ID, msgs[0][i].type()); 2694 EXPECT_EQ(ResourceMsg_DataReceived::ID, msgs[0][i].type());
2714 2695
2715 ResourceHostMsg_DataReceived_ACK msg(1); 2696 ResourceHostMsg_DataReceived_ACK msg(1);
2716 bool msg_was_ok; 2697 host_.OnMessageReceived(msg, filter_.get());
2717 host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok);
2718 } 2698 }
2719 2699
2720 base::MessageLoop::current()->RunUntilIdle(); 2700 base::MessageLoop::current()->RunUntilIdle();
2721 2701
2722 msgs.clear(); 2702 msgs.clear();
2723 accum_.GetClassifiedMessages(&msgs); 2703 accum_.GetClassifiedMessages(&msgs);
2724 } 2704 }
2725 } 2705 }
2726 2706
2727 // Flakyness of this test might indicate memory corruption issues with 2707 // Flakyness of this test might indicate memory corruption issues with
(...skipping 13 matching lines...) Expand all
2741 EXPECT_EQ(ResourceMsg_SetDataBuffer::ID, msgs[0][1].type()); 2721 EXPECT_EQ(ResourceMsg_SetDataBuffer::ID, msgs[0][1].type());
2742 for (size_t i = 2; i < msgs[0].size(); ++i) 2722 for (size_t i = 2; i < msgs[0].size(); ++i)
2743 EXPECT_EQ(ResourceMsg_DataReceived::ID, msgs[0][i].type()); 2723 EXPECT_EQ(ResourceMsg_DataReceived::ID, msgs[0][i].type());
2744 2724
2745 // NOTE: If we fail the above checks then it means that we probably didn't 2725 // NOTE: If we fail the above checks then it means that we probably didn't
2746 // load a big enough response to trigger the delay mechanism. 2726 // load a big enough response to trigger the delay mechanism.
2747 2727
2748 // Send some unexpected ACKs. 2728 // Send some unexpected ACKs.
2749 for (size_t i = 0; i < 128; ++i) { 2729 for (size_t i = 0; i < 128; ++i) {
2750 ResourceHostMsg_DataReceived_ACK msg(1); 2730 ResourceHostMsg_DataReceived_ACK msg(1);
2751 bool msg_was_ok; 2731 host_.OnMessageReceived(msg, filter_.get());
2752 host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok);
2753 } 2732 }
2754 2733
2755 msgs[0].erase(msgs[0].begin()); 2734 msgs[0].erase(msgs[0].begin());
2756 msgs[0].erase(msgs[0].begin()); 2735 msgs[0].erase(msgs[0].begin());
2757 2736
2758 // ACK all DataReceived messages until we find a RequestComplete message. 2737 // ACK all DataReceived messages until we find a RequestComplete message.
2759 bool complete = false; 2738 bool complete = false;
2760 while (!complete) { 2739 while (!complete) {
2761 for (size_t i = 0; i < msgs[0].size(); ++i) { 2740 for (size_t i = 0; i < msgs[0].size(); ++i) {
2762 if (msgs[0][i].type() == ResourceMsg_RequestComplete::ID) { 2741 if (msgs[0][i].type() == ResourceMsg_RequestComplete::ID) {
2763 complete = true; 2742 complete = true;
2764 break; 2743 break;
2765 } 2744 }
2766 2745
2767 EXPECT_EQ(ResourceMsg_DataReceived::ID, msgs[0][i].type()); 2746 EXPECT_EQ(ResourceMsg_DataReceived::ID, msgs[0][i].type());
2768 2747
2769 ResourceHostMsg_DataReceived_ACK msg(1); 2748 ResourceHostMsg_DataReceived_ACK msg(1);
2770 bool msg_was_ok; 2749 host_.OnMessageReceived(msg, filter_.get());
2771 host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok);
2772 } 2750 }
2773 2751
2774 base::MessageLoop::current()->RunUntilIdle(); 2752 base::MessageLoop::current()->RunUntilIdle();
2775 2753
2776 msgs.clear(); 2754 msgs.clear();
2777 accum_.GetClassifiedMessages(&msgs); 2755 accum_.GetClassifiedMessages(&msgs);
2778 } 2756 }
2779 } 2757 }
2780 2758
2781 // Tests the dispatcher host's temporary file management. 2759 // Tests the dispatcher host's temporary file management.
(...skipping 15 matching lines...) Expand all
2797 filter_->child_id(), file_path)); 2775 filter_->child_id(), file_path));
2798 2776
2799 // Register it for a resource request. 2777 // Register it for a resource request.
2800 host_.RegisterDownloadedTempFile(filter_->child_id(), kRequestID, file_path); 2778 host_.RegisterDownloadedTempFile(filter_->child_id(), kRequestID, file_path);
2801 2779
2802 // Should be readable now. 2780 // Should be readable now.
2803 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( 2781 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
2804 filter_->child_id(), file_path)); 2782 filter_->child_id(), file_path));
2805 2783
2806 // The child releases from the request. 2784 // The child releases from the request.
2807 bool msg_was_ok = true;
2808 ResourceHostMsg_ReleaseDownloadedFile release_msg(kRequestID); 2785 ResourceHostMsg_ReleaseDownloadedFile release_msg(kRequestID);
2809 host_.OnMessageReceived(release_msg, filter_, &msg_was_ok); 2786 host_.OnMessageReceived(release_msg, filter_);
2810 ASSERT_TRUE(msg_was_ok);
2811 2787
2812 // Still readable because there is another reference to the file. (The child 2788 // Still readable because there is another reference to the file. (The child
2813 // may take additional blob references.) 2789 // may take additional blob references.)
2814 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( 2790 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
2815 filter_->child_id(), file_path)); 2791 filter_->child_id(), file_path));
2816 2792
2817 // Release extra references and wait for the file to be deleted. (This relies 2793 // Release extra references and wait for the file to be deleted. (This relies
2818 // on the delete happening on the FILE thread which is mapped to main thread 2794 // on the delete happening on the FILE thread which is mapped to main thread
2819 // in this test.) 2795 // in this test.)
2820 deletable_file = NULL; 2796 deletable_file = NULL;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2858 filter_->child_id(), file_path)); 2834 filter_->child_id(), file_path));
2859 EXPECT_FALSE(base::PathExists(file_path)); 2835 EXPECT_FALSE(base::PathExists(file_path));
2860 } 2836 }
2861 2837
2862 TEST_F(ResourceDispatcherHostTest, DownloadToFile) { 2838 TEST_F(ResourceDispatcherHostTest, DownloadToFile) {
2863 // Make a request which downloads to file. 2839 // Make a request which downloads to file.
2864 ResourceHostMsg_Request request = CreateResourceRequest( 2840 ResourceHostMsg_Request request = CreateResourceRequest(
2865 "GET", ResourceType::SUB_RESOURCE, net::URLRequestTestJob::test_url_1()); 2841 "GET", ResourceType::SUB_RESOURCE, net::URLRequestTestJob::test_url_1());
2866 request.download_to_file = true; 2842 request.download_to_file = true;
2867 ResourceHostMsg_RequestResource request_msg(0, 1, request); 2843 ResourceHostMsg_RequestResource request_msg(0, 1, request);
2868 bool msg_was_ok; 2844 host_.OnMessageReceived(request_msg, filter_);
2869 host_.OnMessageReceived(request_msg, filter_, &msg_was_ok);
2870 ASSERT_TRUE(msg_was_ok);
2871 2845
2872 // Running the message loop until idle does not work because 2846 // Running the message loop until idle does not work because
2873 // RedirectToFileResourceHandler posts things to base::WorkerPool. Instead, 2847 // RedirectToFileResourceHandler posts things to base::WorkerPool. Instead,
2874 // wait for the ResourceMsg_RequestComplete to go out. Then run the event loop 2848 // wait for the ResourceMsg_RequestComplete to go out. Then run the event loop
2875 // until idle so the loader is gone. 2849 // until idle so the loader is gone.
2876 WaitForRequestComplete(); 2850 WaitForRequestComplete();
2877 base::RunLoop().RunUntilIdle(); 2851 base::RunLoop().RunUntilIdle();
2878 EXPECT_EQ(0, host_.pending_requests()); 2852 EXPECT_EQ(0, host_.pending_requests());
2879 2853
2880 ResourceIPCAccumulator::ClassifiedMessages msgs; 2854 ResourceIPCAccumulator::ClassifiedMessages msgs;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2915 EXPECT_EQ(net::URLRequestTestJob::test_data_1(), contents); 2889 EXPECT_EQ(net::URLRequestTestJob::test_data_1(), contents);
2916 2890
2917 // The file should be readable by the child. 2891 // The file should be readable by the child.
2918 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( 2892 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
2919 filter_->child_id(), response_head.download_file_path)); 2893 filter_->child_id(), response_head.download_file_path));
2920 2894
2921 // When the renderer releases the file, it should be deleted. Again, 2895 // When the renderer releases the file, it should be deleted. Again,
2922 // RunUntilIdle doesn't work because base::WorkerPool is involved. 2896 // RunUntilIdle doesn't work because base::WorkerPool is involved.
2923 ShareableFileReleaseWaiter waiter(response_head.download_file_path); 2897 ShareableFileReleaseWaiter waiter(response_head.download_file_path);
2924 ResourceHostMsg_ReleaseDownloadedFile release_msg(1); 2898 ResourceHostMsg_ReleaseDownloadedFile release_msg(1);
2925 host_.OnMessageReceived(release_msg, filter_, &msg_was_ok); 2899 host_.OnMessageReceived(release_msg, filter_);
2926 ASSERT_TRUE(msg_was_ok);
2927 waiter.Wait(); 2900 waiter.Wait();
2928 // The release callback runs before the delete is scheduled, so pump the 2901 // The release callback runs before the delete is scheduled, so pump the
2929 // message loop for the delete itself. (This relies on the delete happening on 2902 // 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.) 2903 // the FILE thread which is mapped to main thread in this test.)
2931 base::RunLoop().RunUntilIdle(); 2904 base::RunLoop().RunUntilIdle();
2932 2905
2933 EXPECT_FALSE(base::PathExists(response_head.download_file_path)); 2906 EXPECT_FALSE(base::PathExists(response_head.download_file_path));
2934 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( 2907 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
2935 filter_->child_id(), response_head.download_file_path)); 2908 filter_->child_id(), response_head.download_file_path));
2936 } 2909 }
2937 2910
2938 } // namespace content 2911 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.cc ('k') | content/browser/loader/resource_message_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698