| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 number_of_loads_(0), | 130 number_of_loads_(0), |
| 131 expected_number_of_loads_(expected_number_of_loads), | 131 expected_number_of_loads_(expected_number_of_loads), |
| 132 expected_final_status_(expected_final_status), | 132 expected_final_status_(expected_final_status), |
| 133 new_render_view_host_(NULL), | 133 new_render_view_host_(NULL), |
| 134 was_hidden_(false), | 134 was_hidden_(false), |
| 135 was_shown_(false), | 135 was_shown_(false), |
| 136 should_be_shown_(expected_final_status == FINAL_STATUS_USED), | 136 should_be_shown_(expected_final_status == FINAL_STATUS_USED), |
| 137 quit_message_loop_on_destruction_( | 137 quit_message_loop_on_destruction_( |
| 138 expected_final_status != FINAL_STATUS_EVICTED && | 138 expected_final_status != FINAL_STATUS_EVICTED && |
| 139 expected_final_status != FINAL_STATUS_APP_TERMINATING && | 139 expected_final_status != FINAL_STATUS_APP_TERMINATING && |
| 140 expected_final_status != FINAL_STATUS_MATCH_COMPLETE_DUMMY), | 140 expected_final_status != FINAL_STATUS_MAX), |
| 141 expected_pending_prerenders_(0) { | 141 expected_pending_prerenders_(0) { |
| 142 if (expected_number_of_loads == 0) | 142 if (expected_number_of_loads == 0) |
| 143 MessageLoopForUI::current()->Quit(); | 143 MessageLoopForUI::current()->Quit(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 virtual ~TestPrerenderContents() { | 146 virtual ~TestPrerenderContents() { |
| 147 EXPECT_EQ(expected_final_status_, final_status()) << | 147 if (expected_final_status_ == FINAL_STATUS_MAX) { |
| 148 " when testing URL " << prerender_url().path() << | 148 EXPECT_EQ(match_complete_status(), MATCH_COMPLETE_REPLACEMENT); |
| 149 " (Expected: " << NameFromFinalStatus(expected_final_status_) << | 149 } else { |
| 150 ", Actual: " << NameFromFinalStatus(final_status()) << ")"; | 150 EXPECT_EQ(expected_final_status_, final_status()) << |
| 151 " when testing URL " << prerender_url().path() << |
| 152 " (Expected: " << NameFromFinalStatus(expected_final_status_) << |
| 153 ", Actual: " << NameFromFinalStatus(final_status()) << ")"; |
| 154 } |
| 151 // Prerendering RenderViewHosts should be hidden before the first | 155 // Prerendering RenderViewHosts should be hidden before the first |
| 152 // navigation, so this should be happen for every PrerenderContents for | 156 // navigation, so this should be happen for every PrerenderContents for |
| 153 // which a RenderViewHost is created, regardless of whether or not it's | 157 // which a RenderViewHost is created, regardless of whether or not it's |
| 154 // used. | 158 // used. |
| 155 if (new_render_view_host_) | 159 if (new_render_view_host_) |
| 156 EXPECT_TRUE(was_hidden_); | 160 EXPECT_TRUE(was_hidden_); |
| 157 | 161 |
| 158 // A used PrerenderContents will only be destroyed when we swap out | 162 // A used PrerenderContents will only be destroyed when we swap out |
| 159 // TabContents, at the end of a navigation caused by a call to | 163 // TabContents, at the end of a navigation caused by a call to |
| 160 // NavigateToURLImpl(). | 164 // NavigateToURLImpl(). |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 } | 310 } |
| 307 | 311 |
| 308 virtual PrerenderContents* CreatePrerenderContents( | 312 virtual PrerenderContents* CreatePrerenderContents( |
| 309 PrerenderManager* prerender_manager, | 313 PrerenderManager* prerender_manager, |
| 310 PrerenderTracker* prerender_tracker, | 314 PrerenderTracker* prerender_tracker, |
| 311 Profile* profile, | 315 Profile* profile, |
| 312 const GURL& url, | 316 const GURL& url, |
| 313 const content::Referrer& referrer, | 317 const content::Referrer& referrer, |
| 314 Origin origin, | 318 Origin origin, |
| 315 uint8 experiment_id) OVERRIDE { | 319 uint8 experiment_id) OVERRIDE { |
| 316 FinalStatus expected_final_status = FINAL_STATUS_MATCH_COMPLETE_DUMMY; | 320 FinalStatus expected_final_status = FINAL_STATUS_MAX; |
| 317 if (!expected_final_status_queue_.empty()) { | 321 if (!expected_final_status_queue_.empty()) { |
| 318 expected_final_status = expected_final_status_queue_.front(); | 322 expected_final_status = expected_final_status_queue_.front(); |
| 319 expected_final_status_queue_.pop_front(); | 323 expected_final_status_queue_.pop_front(); |
| 320 } | 324 } |
| 321 VLOG(1) << "Creating prerender contents for " << url.path() << | 325 VLOG(1) << "Creating prerender contents for " << url.path() << |
| 322 " with expected final status " << expected_final_status; | 326 " with expected final status " << expected_final_status; |
| 323 VLOG(1) << expected_final_status_queue_.size() << " left in the queue."; | 327 VLOG(1) << expected_final_status_queue_.size() << " left in the queue."; |
| 324 return new TestPrerenderContents(prerender_manager, prerender_tracker, | 328 return new TestPrerenderContents(prerender_manager, prerender_tracker, |
| 325 profile, url, | 329 profile, url, |
| 326 referrer, expected_number_of_loads_, | 330 referrer, expected_number_of_loads_, |
| (...skipping 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderSessionStorage) { | 1906 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderSessionStorage) { |
| 1903 set_loader_path("files/prerender/prerender_loader_with_session_storage.html"); | 1907 set_loader_path("files/prerender/prerender_loader_with_session_storage.html"); |
| 1904 PrerenderTestURL(GetCrossDomainTestUrl("files/prerender/prerender_page.html"), | 1908 PrerenderTestURL(GetCrossDomainTestUrl("files/prerender/prerender_page.html"), |
| 1905 FINAL_STATUS_USED, | 1909 FINAL_STATUS_USED, |
| 1906 1); | 1910 1); |
| 1907 NavigateToDestURL(); | 1911 NavigateToDestURL(); |
| 1908 GoBackToPageBeforePrerender(browser()); | 1912 GoBackToPageBeforePrerender(browser()); |
| 1909 } | 1913 } |
| 1910 | 1914 |
| 1911 } // namespace prerender | 1915 } // namespace prerender |
| OLD | NEW |