| 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 <deque> | 5 #include <deque> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 ++number_of_loads_; | 228 ++number_of_loads_; |
| 229 if (ShouldRenderPrerenderedPageCorrectly(expected_final_status_) && | 229 if (ShouldRenderPrerenderedPageCorrectly(expected_final_status_) && |
| 230 number_of_loads_ == expected_number_of_loads_) { | 230 number_of_loads_ == expected_number_of_loads_) { |
| 231 MessageLoopForUI::current()->Quit(); | 231 MessageLoopForUI::current()->Quit(); |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 | 234 |
| 235 virtual void AddPendingPrerender( | 235 virtual void AddPendingPrerender( |
| 236 base::WeakPtr<PrerenderHandle> weak_prerender_handle, | 236 base::WeakPtr<PrerenderHandle> weak_prerender_handle, |
| 237 const GURL& url, | 237 const GURL& url, |
| 238 const content::Referrer& referrer, | 238 const content::Referrer& referrer, |
| 239 const gfx::Size& size) OVERRIDE { | 239 const gfx::Size& size) OVERRIDE { |
| 240 PrerenderContents::AddPendingPrerender( | 240 PrerenderContents::AddPendingPrerender( |
| 241 weak_prerender_handle, url, referrer, size); | 241 weak_prerender_handle, url, referrer, size); |
| 242 if (expected_pending_prerenders_ > 0 && | 242 if (expected_pending_prerenders_ > 0 && |
| 243 pending_prerenders().size() == expected_pending_prerenders_) { | 243 pending_prerenders().size() == expected_pending_prerenders_) { |
| 244 MessageLoop::current()->Quit(); | 244 MessageLoop::current()->Quit(); |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 | 247 |
| 248 virtual WebContents* CreateWebContents( | 248 virtual WebContents* CreateWebContents( |
| 249 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE { | 249 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE { |
| (...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 // Checks that we don't prerender in an infinite loop and multiple links are | 1517 // Checks that we don't prerender in an infinite loop and multiple links are |
| 1518 // handled correctly. | 1518 // handled correctly. |
| 1519 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderInfiniteLoopMultiple) { | 1519 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderInfiniteLoopMultiple) { |
| 1520 const char* const kHtmlFileA = | 1520 const char* const kHtmlFileA = |
| 1521 "files/prerender/prerender_infinite_a_multiple.html"; | 1521 "files/prerender/prerender_infinite_a_multiple.html"; |
| 1522 const char* const kHtmlFileB = | 1522 const char* const kHtmlFileB = |
| 1523 "files/prerender/prerender_infinite_b_multiple.html"; | 1523 "files/prerender/prerender_infinite_b_multiple.html"; |
| 1524 const char* const kHtmlFileC = | 1524 const char* const kHtmlFileC = |
| 1525 "files/prerender/prerender_infinite_c_multiple.html"; | 1525 "files/prerender/prerender_infinite_c_multiple.html"; |
| 1526 | 1526 |
| 1527 // We need to set the final status to expect here before starting any | 1527 // This test is conceptually simplest if concurrency is at two, since we |
| 1528 // prerenders. We set them on a queue so whichever we see first is expected to | 1528 // don't have to worry about which of kHtmlFileB or kHtmlFileC gets evicted. |
| 1529 // be evicted, and the second should stick around until we exit. | 1529 GetPrerenderManager()->mutable_config().max_concurrency = 2; |
| 1530 |
| 1530 std::deque<FinalStatus> expected_final_status_queue; | 1531 std::deque<FinalStatus> expected_final_status_queue; |
| 1531 expected_final_status_queue.push_back(FINAL_STATUS_USED); | 1532 expected_final_status_queue.push_back(FINAL_STATUS_USED); |
| 1532 expected_final_status_queue.push_back(FINAL_STATUS_EVICTED); | 1533 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); |
| 1533 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); | 1534 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); |
| 1534 | 1535 |
| 1535 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1); | 1536 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1); |
| 1536 ASSERT_TRUE(GetPrerenderContents()); | 1537 ASSERT_TRUE(GetPrerenderContents()); |
| 1537 GetPrerenderContents()->WaitForPendingPrerenders(2u); | 1538 GetPrerenderContents()->WaitForPendingPrerenders(2u); |
| 1538 | 1539 |
| 1539 // Next url should be in pending list but not an active entry. | 1540 // Next url should be in pending list but not an active entry. |
| 1540 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileB)); | 1541 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileB)); |
| 1541 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileC)); | 1542 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileC)); |
| 1542 EXPECT_TRUE(UrlIsPending(kHtmlFileB)); | 1543 EXPECT_TRUE(UrlIsPending(kHtmlFileB)); |
| 1543 EXPECT_TRUE(UrlIsPending(kHtmlFileC)); | 1544 EXPECT_TRUE(UrlIsPending(kHtmlFileC)); |
| 1544 | 1545 |
| 1545 NavigateToDestURL(); | 1546 NavigateToDestURL(); |
| 1546 | 1547 |
| 1547 // Make sure the PrerenderContents for the next urls are now in the manager | 1548 // Make sure the PrerenderContents for the next urls are now in the manager |
| 1548 // and not pending. One and only one of the URLs (the last seen) should be the | 1549 // and not pending. One and only one of the URLs (the last seen) should be the |
| 1549 // active entry. | 1550 // active entry. |
| 1550 bool url_b_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileB); | 1551 bool url_b_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileB); |
| 1551 bool url_c_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileC); | 1552 bool url_c_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileC); |
| 1552 EXPECT_TRUE((url_b_is_active_prerender || url_c_is_active_prerender) && | 1553 EXPECT_TRUE(url_b_is_active_prerender && url_c_is_active_prerender); |
| 1553 !(url_b_is_active_prerender && url_c_is_active_prerender)); | |
| 1554 EXPECT_FALSE(UrlIsPending(kHtmlFileB)); | 1554 EXPECT_FALSE(UrlIsPending(kHtmlFileB)); |
| 1555 EXPECT_FALSE(UrlIsPending(kHtmlFileC)); | 1555 EXPECT_FALSE(UrlIsPending(kHtmlFileC)); |
| 1556 } | 1556 } |
| 1557 | 1557 |
| 1558 // See crbug.com/131836. | 1558 // See crbug.com/131836. |
| 1559 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderTaskManager) { | 1559 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderTaskManager) { |
| 1560 // Show the task manager. This populates the model. | 1560 // Show the task manager. This populates the model. |
| 1561 current_browser()->window()->ShowTaskManager(); | 1561 current_browser()->window()->ShowTaskManager(); |
| 1562 // Wait for the model of task manager to start. | 1562 // Wait for the model of task manager to start. |
| 1563 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | 1563 TaskManagerBrowserTestUtil::WaitForResourceChange(2); |
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2383 ResultCatcher catcher; | 2383 ResultCatcher catcher; |
| 2384 | 2384 |
| 2385 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | 2385 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); |
| 2386 NavigateToDestURL(); | 2386 NavigateToDestURL(); |
| 2387 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); | 2387 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); |
| 2388 | 2388 |
| 2389 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 2389 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 2390 } | 2390 } |
| 2391 | 2391 |
| 2392 } // namespace prerender | 2392 } // namespace prerender |
| OLD | NEW |