Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 10802024: Make three simultanious prerenders the default maximum in Canary and Dev only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add an histogram Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 ++number_of_loads_; 226 ++number_of_loads_;
227 if (ShouldRenderPrerenderedPageCorrectly(expected_final_status_) && 227 if (ShouldRenderPrerenderedPageCorrectly(expected_final_status_) &&
228 number_of_loads_ == expected_number_of_loads_) { 228 number_of_loads_ == expected_number_of_loads_) {
229 MessageLoopForUI::current()->Quit(); 229 MessageLoopForUI::current()->Quit();
230 } 230 }
231 } 231 }
232 232
233 virtual void AddPendingPrerender( 233 virtual void AddPendingPrerender(
234 base::WeakPtr<PrerenderHandle> weak_prerender_handle, 234 base::WeakPtr<PrerenderHandle> weak_prerender_handle,
235 const GURL& url, 235 const GURL& url,
236 const content::Referrer& referrer, 236 const content::Referrer& referrer,
gavinp 2012/07/19 11:06:54 ... (ooops)
237 const gfx::Size& size) OVERRIDE { 237 const gfx::Size& size) OVERRIDE {
238 PrerenderContents::AddPendingPrerender( 238 PrerenderContents::AddPendingPrerender(
239 weak_prerender_handle, url, referrer, size); 239 weak_prerender_handle, url, referrer, size);
240 if (expected_pending_prerenders_ > 0 && 240 if (expected_pending_prerenders_ > 0 &&
241 pending_prerenders().size() == expected_pending_prerenders_) { 241 pending_prerenders().size() == expected_pending_prerenders_) {
242 MessageLoop::current()->Quit(); 242 MessageLoop::current()->Quit();
243 } 243 }
244 } 244 }
245 245
246 virtual WebContents* CreateWebContents( 246 virtual WebContents* CreateWebContents(
247 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE { 247 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE {
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // We need to set the final status to expect here before starting any
1528 // prerenders. We set them on a queue so whichever we see first is expected to 1528 // prerenders. We set them on a queue so whichever we see first is expected to
1529 // be evicted, and the second should stick around until we exit. 1529 // be evicted, and the second should stick around until we exit.
dominich 2012/07/19 16:04:38 update comment.
gavinp 2012/07/23 18:35:21 Done.
1530 std::deque<FinalStatus> expected_final_status_queue; 1530 std::deque<FinalStatus> expected_final_status_queue;
1531 expected_final_status_queue.push_back(FINAL_STATUS_USED); 1531 expected_final_status_queue.push_back(FINAL_STATUS_USED);
1532 expected_final_status_queue.push_back(FINAL_STATUS_EVICTED); 1532 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING);
1533 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING); 1533 expected_final_status_queue.push_back(FINAL_STATUS_APP_TERMINATING);
1534 1534
1535 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1); 1535 PrerenderTestURL(kHtmlFileA, expected_final_status_queue, 1);
1536 ASSERT_TRUE(GetPrerenderContents()); 1536 ASSERT_TRUE(GetPrerenderContents());
1537 GetPrerenderContents()->WaitForPendingPrerenders(2u); 1537 GetPrerenderContents()->WaitForPendingPrerenders(2u);
1538 1538
1539 // Next url should be in pending list but not an active entry. 1539 // Next url should be in pending list but not an active entry.
1540 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileB)); 1540 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileB));
1541 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileC)); 1541 EXPECT_FALSE(UrlIsInPrerenderManager(kHtmlFileC));
1542 EXPECT_TRUE(UrlIsPending(kHtmlFileB)); 1542 EXPECT_TRUE(UrlIsPending(kHtmlFileB));
1543 EXPECT_TRUE(UrlIsPending(kHtmlFileC)); 1543 EXPECT_TRUE(UrlIsPending(kHtmlFileC));
1544 1544
1545 NavigateToDestURL(); 1545 NavigateToDestURL();
1546 1546
1547 // Make sure the PrerenderContents for the next urls are now in the manager 1547 // 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 1548 // and not pending. One and only one of the URLs (the last seen) should be the
1549 // active entry. 1549 // active entry.
1550 bool url_b_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileB); 1550 bool url_b_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileB);
1551 bool url_c_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileC); 1551 bool url_c_is_active_prerender = UrlIsInPrerenderManager(kHtmlFileC);
1552 EXPECT_TRUE((url_b_is_active_prerender || url_c_is_active_prerender) && 1552 EXPECT_TRUE(url_b_is_active_prerender && url_c_is_active_prerender);
gavinp 2012/07/19 11:06:54 Of course, now this test depends on concurrency >=
dominich 2012/07/19 16:04:38 Which is accurate. If you want to be very careful,
gavinp 2012/07/23 18:35:21 Since in another review comment, you asked me to m
1553 !(url_b_is_active_prerender && url_c_is_active_prerender));
1554 EXPECT_FALSE(UrlIsPending(kHtmlFileB)); 1553 EXPECT_FALSE(UrlIsPending(kHtmlFileB));
1555 EXPECT_FALSE(UrlIsPending(kHtmlFileC)); 1554 EXPECT_FALSE(UrlIsPending(kHtmlFileC));
1556 } 1555 }
1557 1556
1558 // See crbug.com/131836. 1557 // See crbug.com/131836.
1559 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderTaskManager) { 1558 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderTaskManager) {
1560 // Show the task manager. This populates the model. 1559 // Show the task manager. This populates the model.
1561 current_browser()->window()->ShowTaskManager(); 1560 current_browser()->window()->ShowTaskManager();
1562 // Wait for the model of task manager to start. 1561 // Wait for the model of task manager to start.
1563 TaskManagerBrowserTestUtil::WaitForResourceChange(2); 1562 TaskManagerBrowserTestUtil::WaitForResourceChange(2);
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
2383 ResultCatcher catcher; 2382 ResultCatcher catcher;
2384 2383
2385 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); 2384 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1);
2386 NavigateToDestURL(); 2385 NavigateToDestURL();
2387 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); 2386 ASSERT_TRUE(IsEmptyPrerenderLinkManager());
2388 2387
2389 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 2388 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
2390 } 2389 }
2391 2390
2392 } // namespace prerender 2391 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_config.h » ('j') | chrome/browser/prerender/prerender_config.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698