| 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 content::BrowserThread::PostTask( | 287 test_utils::CreateHangingFirstRequestInterceptor( |
| 288 content::BrowserThread::IO, FROM_HERE, | 288 first_url, first_path, base::Callback<void(net::URLRequest*)>()); |
| 289 base::Bind(&test_utils::CreateHangingFirstRequestInterceptorOnIO, | |
| 290 first_url, first_path, base::Closure())); | |
| 291 | 289 |
| 292 // Start the first prefetch directly instead of via PrefetchFromFile for the | 290 // Start the first prefetch directly instead of via PrefetchFromFile for the |
| 293 // first prefetch to avoid the wait on prerender stop. | 291 // first prefetch to avoid the wait on prerender stop. |
| 294 GURL first_loader_url = ServeLoaderURL( | 292 GURL first_loader_url = ServeLoaderURL( |
| 295 kPrefetchLoaderPath, "REPLACE_WITH_PREFETCH_URL", first_url, ""); | 293 kPrefetchLoaderPath, "REPLACE_WITH_PREFETCH_URL", first_url, ""); |
| 296 std::vector<FinalStatus> first_expected_status_queue(1, | 294 std::vector<FinalStatus> first_expected_status_queue(1, |
| 297 FINAL_STATUS_CANCELLED); | 295 FINAL_STATUS_CANCELLED); |
| 298 NavigateWithPrerenders(first_loader_url, first_expected_status_queue); | 296 NavigateWithPrerenders(first_loader_url, first_expected_status_queue); |
| 299 | 297 |
| 300 PrefetchFromFile(kPrefetchPage2, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); | 298 PrefetchFromFile(kPrefetchPage2, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 // The SW intercepts kPrefetchPage and replaces it with a body that contains | 595 // The SW intercepts kPrefetchPage and replaces it with a body that contains |
| 598 // an <img> tage for kPrefetchPng. This verifies that the SW ran correctly by | 596 // an <img> tage for kPrefetchPng. This verifies that the SW ran correctly by |
| 599 // observing the fetch of the image. | 597 // observing the fetch of the image. |
| 600 RequestCounter image_counter; | 598 RequestCounter image_counter; |
| 601 CountRequestFor(kPrefetchPng, &image_counter); | 599 CountRequestFor(kPrefetchPng, &image_counter); |
| 602 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); | 600 PrefetchFromFile(kPrefetchPage, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); |
| 603 image_counter.WaitForCount(1); | 601 image_counter.WaitForCount(1); |
| 604 } | 602 } |
| 605 | 603 |
| 606 } // namespace prerender | 604 } // namespace prerender |
| OLD | NEW |