| 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/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 content::AppCacheService* appcache_service = | 113 content::AppCacheService* appcache_service = |
| 114 content::BrowserContext::GetDefaultStoragePartition( | 114 content::BrowserContext::GetDefaultStoragePartition( |
| 115 current_browser()->profile()) | 115 current_browser()->profile()) |
| 116 ->GetAppCacheService(); | 116 ->GetAppCacheService(); |
| 117 do { | 117 do { |
| 118 base::RunLoop wait_loop; | 118 base::RunLoop wait_loop; |
| 119 content::BrowserThread::PostTask( | 119 content::BrowserThread::PostTask( |
| 120 content::BrowserThread::IO, FROM_HERE, | 120 content::BrowserThread::IO, FROM_HERE, |
| 121 base::BindOnce(WaitForAppcacheOnIO, manifest_url, appcache_service, | 121 base::BindOnce(WaitForAppcacheOnIO, manifest_url, appcache_service, |
| 122 wait_loop.QuitClosure(), &found_manifest)); | 122 wait_loop.QuitClosure(), &found_manifest)); |
| 123 // There seems to be some flakiness in the appcache getting back to us, so |
| 124 // use a timeout task to try the appcache query again. |
| 125 content::BrowserThread::PostDelayedTask( |
| 126 content::BrowserThread::UI, FROM_HERE, wait_loop.QuitClosure(), |
| 127 base::TimeDelta::FromMilliseconds(2000)); |
| 123 wait_loop.Run(); | 128 wait_loop.Run(); |
| 124 } while (!found_manifest); | 129 } while (!found_manifest); |
| 125 } | 130 } |
| 126 | 131 |
| 127 protected: | 132 protected: |
| 128 std::unique_ptr<TestPrerender> PrefetchFromURL( | 133 std::unique_ptr<TestPrerender> PrefetchFromURL( |
| 129 const GURL& target_url, | 134 const GURL& target_url, |
| 130 FinalStatus expected_final_status) { | 135 FinalStatus expected_final_status) { |
| 131 GURL loader_url = ServeLoaderURL( | 136 GURL loader_url = ServeLoaderURL( |
| 132 kPrefetchLoaderPath, "REPLACE_WITH_PREFETCH_URL", target_url, ""); | 137 kPrefetchLoaderPath, "REPLACE_WITH_PREFETCH_URL", target_url, ""); |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 CountRequestFor(kPrefetchPage, &page_counter); | 757 CountRequestFor(kPrefetchPage, &page_counter); |
| 753 RequestCounter script_counter; | 758 RequestCounter script_counter; |
| 754 CountRequestFor(kPrefetchScript, &script_counter); | 759 CountRequestFor(kPrefetchScript, &script_counter); |
| 755 PrefetchFromURL(prefetch_page_url, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); | 760 PrefetchFromURL(prefetch_page_url, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); |
| 756 // Neither the page nor the script should be prefetched. | 761 // Neither the page nor the script should be prefetched. |
| 757 script_counter.WaitForCount(0); | 762 script_counter.WaitForCount(0); |
| 758 page_counter.WaitForCount(0); | 763 page_counter.WaitForCount(0); |
| 759 } | 764 } |
| 760 | 765 |
| 761 } // namespace prerender | 766 } // namespace prerender |
| OLD | NEW |