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 <set> | 5 #include <set> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 RunEvents(); | 221 RunEvents(); |
222 | 222 |
223 // Fake a request. | 223 // Fake a request. |
224 net::TestURLRequestContext url_request_context; | 224 net::TestURLRequestContext url_request_context; |
225 DeferredRedirectDelegate delegate; | 225 DeferredRedirectDelegate delegate; |
226 net::URLRequest request( | 226 net::URLRequest request( |
227 content::URLRequestMockHTTPJob::GetMockUrl(base::FilePath(kRedirectPath)), | 227 content::URLRequestMockHTTPJob::GetMockUrl(base::FilePath(kRedirectPath)), |
228 net::DEFAULT_PRIORITY, | 228 net::DEFAULT_PRIORITY, |
229 &delegate, | 229 &delegate, |
230 &url_request_context); | 230 &url_request_context); |
231 content::ResourceRequestInfo::AllocateForTesting( | 231 content::ResourceRequestInfo::AllocateForTesting(&request, |
232 &request, ResourceType::IMAGE, NULL, | 232 content::RESOURCE_TYPE_IMAGE, |
233 kDefaultChildId, kDefaultRouteId, MSG_ROUTING_NONE, true); | 233 NULL, |
| 234 kDefaultChildId, |
| 235 kDefaultRouteId, |
| 236 MSG_ROUTING_NONE, |
| 237 true); |
234 | 238 |
235 // Install a prerender throttle. | 239 // Install a prerender throttle. |
236 PrerenderResourceThrottle throttle(&request); | 240 PrerenderResourceThrottle throttle(&request); |
237 delegate.SetThrottle(&throttle); | 241 delegate.SetThrottle(&throttle); |
238 | 242 |
239 // Start the request and wait for a redirect. | 243 // Start the request and wait for a redirect. |
240 request.Start(); | 244 request.Start(); |
241 delegate.Run(); | 245 delegate.Run(); |
242 EXPECT_TRUE(delegate.was_deferred()); | 246 EXPECT_TRUE(delegate.was_deferred()); |
243 // This calls WillRedirectRequestOnUI(). | 247 // This calls WillRedirectRequestOnUI(). |
(...skipping 17 matching lines...) Expand all Loading... |
261 | 265 |
262 // Fake a request. | 266 // Fake a request. |
263 net::TestURLRequestContext url_request_context; | 267 net::TestURLRequestContext url_request_context; |
264 DeferredRedirectDelegate delegate; | 268 DeferredRedirectDelegate delegate; |
265 net::URLRequest request( | 269 net::URLRequest request( |
266 content::URLRequestMockHTTPJob::GetMockUrl(base::FilePath(kRedirectPath)), | 270 content::URLRequestMockHTTPJob::GetMockUrl(base::FilePath(kRedirectPath)), |
267 net::DEFAULT_PRIORITY, | 271 net::DEFAULT_PRIORITY, |
268 &delegate, | 272 &delegate, |
269 &url_request_context); | 273 &url_request_context); |
270 content::ResourceRequestInfo::AllocateForTesting( | 274 content::ResourceRequestInfo::AllocateForTesting( |
271 &request, ResourceType::MAIN_FRAME, NULL, | 275 &request, |
272 kDefaultChildId, kDefaultRouteId, MSG_ROUTING_NONE, true); | 276 content::RESOURCE_TYPE_MAIN_FRAME, |
| 277 NULL, |
| 278 kDefaultChildId, |
| 279 kDefaultRouteId, |
| 280 MSG_ROUTING_NONE, |
| 281 true); |
273 | 282 |
274 // Install a prerender throttle. | 283 // Install a prerender throttle. |
275 PrerenderResourceThrottle throttle(&request); | 284 PrerenderResourceThrottle throttle(&request); |
276 delegate.SetThrottle(&throttle); | 285 delegate.SetThrottle(&throttle); |
277 | 286 |
278 // Start the request and wait for a redirect. This time, it should | 287 // Start the request and wait for a redirect. This time, it should |
279 // not be deferred. | 288 // not be deferred. |
280 request.Start(); | 289 request.Start(); |
281 delegate.Run(); | 290 delegate.Run(); |
282 // This calls WillRedirectRequestOnUI(). | 291 // This calls WillRedirectRequestOnUI(). |
(...skipping 14 matching lines...) Expand all Loading... |
297 RunEvents(); | 306 RunEvents(); |
298 | 307 |
299 // Fake a request. | 308 // Fake a request. |
300 net::TestURLRequestContext url_request_context; | 309 net::TestURLRequestContext url_request_context; |
301 DeferredRedirectDelegate delegate; | 310 DeferredRedirectDelegate delegate; |
302 net::URLRequest request( | 311 net::URLRequest request( |
303 content::URLRequestMockHTTPJob::GetMockUrl(base::FilePath(kRedirectPath)), | 312 content::URLRequestMockHTTPJob::GetMockUrl(base::FilePath(kRedirectPath)), |
304 net::DEFAULT_PRIORITY, | 313 net::DEFAULT_PRIORITY, |
305 &delegate, | 314 &delegate, |
306 &url_request_context); | 315 &url_request_context); |
307 content::ResourceRequestInfo::AllocateForTesting( | 316 content::ResourceRequestInfo::AllocateForTesting(&request, |
308 &request, ResourceType::XHR, NULL, | 317 content::RESOURCE_TYPE_XHR, |
309 kDefaultChildId, kDefaultRouteId, MSG_ROUTING_NONE, false); | 318 NULL, |
| 319 kDefaultChildId, |
| 320 kDefaultRouteId, |
| 321 MSG_ROUTING_NONE, |
| 322 false); |
310 | 323 |
311 // Install a prerender throttle. | 324 // Install a prerender throttle. |
312 PrerenderResourceThrottle throttle(&request); | 325 PrerenderResourceThrottle throttle(&request); |
313 delegate.SetThrottle(&throttle); | 326 delegate.SetThrottle(&throttle); |
314 | 327 |
315 // Start the request and wait for a redirect. | 328 // Start the request and wait for a redirect. |
316 request.Start(); | 329 request.Start(); |
317 delegate.Run(); | 330 delegate.Run(); |
318 // This calls WillRedirectRequestOnUI(). | 331 // This calls WillRedirectRequestOnUI(). |
319 RunEvents(); | 332 RunEvents(); |
320 | 333 |
321 // We should have cancelled the prerender. | 334 // We should have cancelled the prerender. |
322 EXPECT_EQ(FINAL_STATUS_BAD_DEFERRED_REDIRECT, | 335 EXPECT_EQ(FINAL_STATUS_BAD_DEFERRED_REDIRECT, |
323 test_contents()->final_status()); | 336 test_contents()->final_status()); |
324 | 337 |
325 // Cleanup work so the prerender is gone. | 338 // Cleanup work so the prerender is gone. |
326 test_contents()->Cancel(); | 339 test_contents()->Cancel(); |
327 RunEvents(); | 340 RunEvents(); |
328 } | 341 } |
329 | 342 |
330 } // namespace prerender | 343 } // namespace prerender |
OLD | NEW |