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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/strings/string16.h" | 6 #include "base/strings/string16.h" |
7 #include "base/strings/string_split.h" | 7 #include "base/strings/string_split.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/task_scheduler/post_task.h" | 9 #include "base/task_scheduler/post_task.h" |
10 #include "chrome/browser/history/history_service_factory.h" | 10 #include "chrome/browser/history/history_service_factory.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchSimultaneous) { | 277 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchSimultaneous) { |
278 RequestCounter second_main_counter; | 278 RequestCounter second_main_counter; |
279 CountRequestFor(kPrefetchPage2, &second_main_counter); | 279 CountRequestFor(kPrefetchPage2, &second_main_counter); |
280 RequestCounter second_script_counter; | 280 RequestCounter second_script_counter; |
281 CountRequestFor(kPrefetchScript2, &second_script_counter); | 281 CountRequestFor(kPrefetchScript2, &second_script_counter); |
282 | 282 |
283 GURL first_url = src_server()->GetURL(MakeAbsolute(kPrefetchPage)); | 283 GURL first_url = src_server()->GetURL(MakeAbsolute(kPrefetchPage)); |
284 base::FilePath first_path = ui_test_utils::GetTestFilePath( | 284 base::FilePath first_path = ui_test_utils::GetTestFilePath( |
285 base::FilePath(), base::FilePath().AppendASCII(kPrefetchPage)); | 285 base::FilePath(), base::FilePath().AppendASCII(kPrefetchPage)); |
286 | 286 |
287 test_utils::CreateHangingFirstRequestInterceptor( | 287 content::BrowserThread::PostTask( |
288 first_url, first_path, base::Callback<void(net::URLRequest*)>()); | 288 content::BrowserThread::IO, FROM_HERE, |
| 289 base::Bind(&test_utils::CreateHangingFirstRequestInterceptorOnIO, |
| 290 first_url, first_path, base::Closure())); |
289 | 291 |
290 // Start the first prefetch directly instead of via PrefetchFromFile for the | 292 // Start the first prefetch directly instead of via PrefetchFromFile for the |
291 // first prefetch to avoid the wait on prerender stop. | 293 // first prefetch to avoid the wait on prerender stop. |
292 GURL first_loader_url = ServeLoaderURL( | 294 GURL first_loader_url = ServeLoaderURL( |
293 kPrefetchLoaderPath, "REPLACE_WITH_PREFETCH_URL", first_url, ""); | 295 kPrefetchLoaderPath, "REPLACE_WITH_PREFETCH_URL", first_url, ""); |
294 std::vector<FinalStatus> first_expected_status_queue(1, | 296 std::vector<FinalStatus> first_expected_status_queue(1, |
295 FINAL_STATUS_CANCELLED); | 297 FINAL_STATUS_CANCELLED); |
296 NavigateWithPrerenders(first_loader_url, first_expected_status_queue); | 298 NavigateWithPrerenders(first_loader_url, first_expected_status_queue); |
297 | 299 |
298 PrefetchFromFile(kPrefetchPage2, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); | 300 PrefetchFromFile(kPrefetchPage2, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 // The SW intercepts kPrefetchPage and replaces it with a body that contains | 597 // The SW intercepts kPrefetchPage and replaces it with a body that contains |
596 // an <img> tage for kPrefetchPng. This verifies that the SW ran correctly by | 598 // an <img> tage for kPrefetchPng. This verifies that the SW ran correctly by |
597 // observing the fetch of the image. | 599 // observing the fetch of the image. |
598 RequestCounter image_counter; | 600 RequestCounter image_counter; |
599 CountRequestFor(kPrefetchPng, &image_counter); | 601 CountRequestFor(kPrefetchPng, &image_counter); |
600 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); | 602 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); |
601 image_counter.WaitForCount(1); | 603 image_counter.WaitForCount(1); |
602 } | 604 } |
603 | 605 |
604 } // namespace prerender | 606 } // namespace prerender |
OLD | NEW |