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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 bool waiting_for_channel_destruction_; | 201 bool waiting_for_channel_destruction_; |
202 | 202 |
203 DISALLOW_COPY_AND_ASSIGN(ChannelDestructionWatcher); | 203 DISALLOW_COPY_AND_ASSIGN(ChannelDestructionWatcher); |
204 }; | 204 }; |
205 | 205 |
206 // PrerenderContents that stops the UI message loop on DidStopLoading(). | 206 // PrerenderContents that stops the UI message loop on DidStopLoading(). |
207 class TestPrerenderContents : public PrerenderContents { | 207 class TestPrerenderContents : public PrerenderContents { |
208 public: | 208 public: |
209 TestPrerenderContents( | 209 TestPrerenderContents( |
210 PrerenderManager* prerender_manager, | 210 PrerenderManager* prerender_manager, |
211 PrerenderTracker* prerender_tracker, | |
212 Profile* profile, | 211 Profile* profile, |
213 const GURL& url, | 212 const GURL& url, |
214 const content::Referrer& referrer, | 213 const content::Referrer& referrer, |
215 Origin origin, | 214 Origin origin, |
216 int expected_number_of_loads, | 215 int expected_number_of_loads, |
217 FinalStatus expected_final_status, | 216 FinalStatus expected_final_status, |
218 bool prerender_should_wait_for_ready_title) | 217 bool prerender_should_wait_for_ready_title) |
219 : PrerenderContents(prerender_manager, prerender_tracker, profile, url, | 218 : PrerenderContents(prerender_manager, profile, url, |
220 referrer, origin, PrerenderManager::kNoExperiment), | 219 referrer, origin, PrerenderManager::kNoExperiment), |
221 number_of_loads_(0), | 220 number_of_loads_(0), |
222 expected_number_of_loads_(expected_number_of_loads), | 221 expected_number_of_loads_(expected_number_of_loads), |
223 expected_final_status_(expected_final_status), | 222 expected_final_status_(expected_final_status), |
224 new_render_view_host_(NULL), | 223 new_render_view_host_(NULL), |
225 was_hidden_(false), | 224 was_hidden_(false), |
226 was_shown_(false), | 225 was_shown_(false), |
227 should_be_shown_(expected_final_status == FINAL_STATUS_USED), | 226 should_be_shown_(expected_final_status == FINAL_STATUS_USED), |
228 quit_message_loop_on_destruction_( | 227 quit_message_loop_on_destruction_( |
229 expected_final_status != FINAL_STATUS_EVICTED && | 228 expected_final_status != FINAL_STATUS_EVICTED && |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 : expected_number_of_loads_(expected_number_of_loads), | 432 : expected_number_of_loads_(expected_number_of_loads), |
434 expected_final_status_queue_(expected_final_status_queue), | 433 expected_final_status_queue_(expected_final_status_queue), |
435 prerender_should_wait_for_ready_title_( | 434 prerender_should_wait_for_ready_title_( |
436 prerender_should_wait_for_ready_title) { | 435 prerender_should_wait_for_ready_title) { |
437 VLOG(1) << "Factory created with queue length " << | 436 VLOG(1) << "Factory created with queue length " << |
438 expected_final_status_queue_.size(); | 437 expected_final_status_queue_.size(); |
439 } | 438 } |
440 | 439 |
441 virtual PrerenderContents* CreatePrerenderContents( | 440 virtual PrerenderContents* CreatePrerenderContents( |
442 PrerenderManager* prerender_manager, | 441 PrerenderManager* prerender_manager, |
443 PrerenderTracker* prerender_tracker, | |
444 Profile* profile, | 442 Profile* profile, |
445 const GURL& url, | 443 const GURL& url, |
446 const content::Referrer& referrer, | 444 const content::Referrer& referrer, |
447 Origin origin, | 445 Origin origin, |
448 uint8 experiment_id) OVERRIDE { | 446 uint8 experiment_id) OVERRIDE { |
449 FinalStatus expected_final_status = FINAL_STATUS_MAX; | 447 FinalStatus expected_final_status = FINAL_STATUS_MAX; |
450 if (!expected_final_status_queue_.empty()) { | 448 if (!expected_final_status_queue_.empty()) { |
451 expected_final_status = expected_final_status_queue_.front(); | 449 expected_final_status = expected_final_status_queue_.front(); |
452 expected_final_status_queue_.pop_front(); | 450 expected_final_status_queue_.pop_front(); |
453 } | 451 } |
454 VLOG(1) << "Creating prerender contents for " << url.path() << | 452 VLOG(1) << "Creating prerender contents for " << url.path() << |
455 " with expected final status " << expected_final_status; | 453 " with expected final status " << expected_final_status; |
456 VLOG(1) << expected_final_status_queue_.size() << " left in the queue."; | 454 VLOG(1) << expected_final_status_queue_.size() << " left in the queue."; |
457 return new TestPrerenderContents(prerender_manager, prerender_tracker, | 455 return new TestPrerenderContents(prerender_manager, |
458 profile, url, referrer, origin, | 456 profile, url, referrer, origin, |
459 expected_number_of_loads_, | 457 expected_number_of_loads_, |
460 expected_final_status, | 458 expected_final_status, |
461 prerender_should_wait_for_ready_title_); | 459 prerender_should_wait_for_ready_title_); |
462 } | 460 } |
463 | 461 |
464 private: | 462 private: |
465 int expected_number_of_loads_; | 463 int expected_number_of_loads_; |
466 std::deque<FinalStatus> expected_final_status_queue_; | 464 std::deque<FinalStatus> expected_final_status_queue_; |
467 bool prerender_should_wait_for_ready_title_; | 465 bool prerender_should_wait_for_ready_title_; |
(...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2519 channel_close_watcher.WatchChannel( | 2517 channel_close_watcher.WatchChannel( |
2520 chrome::GetActiveWebContents(browser())->GetRenderProcessHost()); | 2518 chrome::GetActiveWebContents(browser())->GetRenderProcessHost()); |
2521 NavigateToDestURL(); | 2519 NavigateToDestURL(); |
2522 channel_close_watcher.WaitForChannelClose(); | 2520 channel_close_watcher.WaitForChannelClose(); |
2523 | 2521 |
2524 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); | 2522 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); |
2525 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 2523 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
2526 } | 2524 } |
2527 | 2525 |
2528 } // namespace prerender | 2526 } // namespace prerender |
OLD | NEW |