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/memory/ptr_util.h" | 6 #include "base/memory/ptr_util.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchSimultaneous) { | 345 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, PrefetchSimultaneous) { |
346 RequestCounter second_main_counter; | 346 RequestCounter second_main_counter; |
347 CountRequestFor(kPrefetchPage2, &second_main_counter); | 347 CountRequestFor(kPrefetchPage2, &second_main_counter); |
348 RequestCounter second_script_counter; | 348 RequestCounter second_script_counter; |
349 CountRequestFor(kPrefetchScript2, &second_script_counter); | 349 CountRequestFor(kPrefetchScript2, &second_script_counter); |
350 | 350 |
351 GURL first_url = src_server()->GetURL(MakeAbsolute(kPrefetchPage)); | 351 GURL first_url = src_server()->GetURL(MakeAbsolute(kPrefetchPage)); |
352 base::FilePath first_path = ui_test_utils::GetTestFilePath( | 352 base::FilePath first_path = ui_test_utils::GetTestFilePath( |
353 base::FilePath(), base::FilePath().AppendASCII(kPrefetchPage)); | 353 base::FilePath(), base::FilePath().AppendASCII(kPrefetchPage)); |
354 | 354 |
355 content::BrowserThread::PostTask( | 355 test_utils::CreateHangingFirstRequestInterceptor( |
356 content::BrowserThread::IO, FROM_HERE, | 356 first_url, first_path, base::Callback<void(net::URLRequest*)>()); |
357 base::Bind(&test_utils::CreateHangingFirstRequestInterceptorOnIO, | |
358 first_url, first_path, base::Closure())); | |
359 | 357 |
360 // Start the first prefetch directly instead of via PrefetchFromFile for the | 358 // Start the first prefetch directly instead of via PrefetchFromFile for the |
361 // first prefetch to avoid the wait on prerender stop. | 359 // first prefetch to avoid the wait on prerender stop. |
362 GURL first_loader_url = ServeLoaderURL( | 360 GURL first_loader_url = ServeLoaderURL( |
363 kPrefetchLoaderPath, "REPLACE_WITH_PREFETCH_URL", first_url, ""); | 361 kPrefetchLoaderPath, "REPLACE_WITH_PREFETCH_URL", first_url, ""); |
364 std::vector<FinalStatus> first_expected_status_queue(1, | 362 std::vector<FinalStatus> first_expected_status_queue(1, |
365 FINAL_STATUS_CANCELLED); | 363 FINAL_STATUS_CANCELLED); |
366 NavigateWithPrerenders(first_loader_url, first_expected_status_queue); | 364 NavigateWithPrerenders(first_loader_url, first_expected_status_queue); |
367 | 365 |
368 PrefetchFromFile(kPrefetchPage2, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); | 366 PrefetchFromFile(kPrefetchPage2, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 CountRequestFor(kPrefetchPage, &page_counter); | 749 CountRequestFor(kPrefetchPage, &page_counter); |
752 RequestCounter script_counter; | 750 RequestCounter script_counter; |
753 CountRequestFor(kPrefetchScript, &script_counter); | 751 CountRequestFor(kPrefetchScript, &script_counter); |
754 PrefetchFromURL(prefetch_page_url, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); | 752 PrefetchFromURL(prefetch_page_url, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); |
755 // Neither the page nor the script should be prefetched. | 753 // Neither the page nor the script should be prefetched. |
756 script_counter.WaitForCount(0); | 754 script_counter.WaitForCount(0); |
757 page_counter.WaitForCount(0); | 755 page_counter.WaitForCount(0); |
758 } | 756 } |
759 | 757 |
760 } // namespace prerender | 758 } // namespace prerender |
OLD | NEW |