| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 NULL)); | 228 NULL)); |
| 229 content::ResourceRequestInfo::AllocateForTesting( | 229 content::ResourceRequestInfo::AllocateForTesting( |
| 230 request.get(), | 230 request.get(), |
| 231 content::RESOURCE_TYPE_IMAGE, | 231 content::RESOURCE_TYPE_IMAGE, |
| 232 NULL, | 232 NULL, |
| 233 kDefaultChildId, | 233 kDefaultChildId, |
| 234 kDefaultRouteId, | 234 kDefaultRouteId, |
| 235 MSG_ROUTING_NONE, | 235 MSG_ROUTING_NONE, |
| 236 false, // is_main_frame | 236 false, // is_main_frame |
| 237 false, // parent_is_main_frame | 237 false, // parent_is_main_frame |
| 238 true, // allow_download |
| 238 true); // is_async | 239 true); // is_async |
| 239 | 240 |
| 240 // Install a prerender throttle. | 241 // Install a prerender throttle. |
| 241 PrerenderResourceThrottle throttle(request.get()); | 242 PrerenderResourceThrottle throttle(request.get()); |
| 242 delegate.SetThrottle(&throttle); | 243 delegate.SetThrottle(&throttle); |
| 243 | 244 |
| 244 // Start the request and wait for a redirect. | 245 // Start the request and wait for a redirect. |
| 245 request->Start(); | 246 request->Start(); |
| 246 delegate.Run(); | 247 delegate.Run(); |
| 247 EXPECT_TRUE(delegate.was_deferred()); | 248 EXPECT_TRUE(delegate.was_deferred()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 274 NULL)); | 275 NULL)); |
| 275 content::ResourceRequestInfo::AllocateForTesting( | 276 content::ResourceRequestInfo::AllocateForTesting( |
| 276 request.get(), | 277 request.get(), |
| 277 content::RESOURCE_TYPE_MAIN_FRAME, | 278 content::RESOURCE_TYPE_MAIN_FRAME, |
| 278 NULL, | 279 NULL, |
| 279 kDefaultChildId, | 280 kDefaultChildId, |
| 280 kDefaultRouteId, | 281 kDefaultRouteId, |
| 281 MSG_ROUTING_NONE, | 282 MSG_ROUTING_NONE, |
| 282 true, // is_main_frame | 283 true, // is_main_frame |
| 283 false, // parent_is_main_frame | 284 false, // parent_is_main_frame |
| 285 true, // allow_download |
| 284 true); // is_async | 286 true); // is_async |
| 285 | 287 |
| 286 // Install a prerender throttle. | 288 // Install a prerender throttle. |
| 287 PrerenderResourceThrottle throttle(request.get()); | 289 PrerenderResourceThrottle throttle(request.get()); |
| 288 delegate.SetThrottle(&throttle); | 290 delegate.SetThrottle(&throttle); |
| 289 | 291 |
| 290 // Start the request and wait for a redirect. This time, it should | 292 // Start the request and wait for a redirect. This time, it should |
| 291 // not be deferred. | 293 // not be deferred. |
| 292 request->Start(); | 294 request->Start(); |
| 293 delegate.Run(); | 295 delegate.Run(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 318 NULL)); | 320 NULL)); |
| 319 content::ResourceRequestInfo::AllocateForTesting( | 321 content::ResourceRequestInfo::AllocateForTesting( |
| 320 request.get(), | 322 request.get(), |
| 321 content::RESOURCE_TYPE_XHR, | 323 content::RESOURCE_TYPE_XHR, |
| 322 NULL, | 324 NULL, |
| 323 kDefaultChildId, | 325 kDefaultChildId, |
| 324 kDefaultRouteId, | 326 kDefaultRouteId, |
| 325 MSG_ROUTING_NONE, | 327 MSG_ROUTING_NONE, |
| 326 false, // is_main_frame | 328 false, // is_main_frame |
| 327 false, // parent_is_main_frame | 329 false, // parent_is_main_frame |
| 330 true, // allow_download |
| 328 false); // is_async | 331 false); // is_async |
| 329 | 332 |
| 330 // Install a prerender throttle. | 333 // Install a prerender throttle. |
| 331 PrerenderResourceThrottle throttle(request.get()); | 334 PrerenderResourceThrottle throttle(request.get()); |
| 332 delegate.SetThrottle(&throttle); | 335 delegate.SetThrottle(&throttle); |
| 333 | 336 |
| 334 // Start the request and wait for a redirect. | 337 // Start the request and wait for a redirect. |
| 335 request->Start(); | 338 request->Start(); |
| 336 delegate.Run(); | 339 delegate.Run(); |
| 337 // This calls WillRedirectRequestOnUI(). | 340 // This calls WillRedirectRequestOnUI(). |
| 338 RunEvents(); | 341 RunEvents(); |
| 339 | 342 |
| 340 // We should have cancelled the prerender. | 343 // We should have cancelled the prerender. |
| 341 EXPECT_EQ(FINAL_STATUS_BAD_DEFERRED_REDIRECT, | 344 EXPECT_EQ(FINAL_STATUS_BAD_DEFERRED_REDIRECT, |
| 342 test_contents()->final_status()); | 345 test_contents()->final_status()); |
| 343 | 346 |
| 344 // Cleanup work so the prerender is gone. | 347 // Cleanup work so the prerender is gone. |
| 345 test_contents()->Cancel(); | 348 test_contents()->Cancel(); |
| 346 RunEvents(); | 349 RunEvents(); |
| 347 } | 350 } |
| 348 | 351 |
| 349 } // namespace prerender | 352 } // namespace prerender |
| OLD | NEW |