| 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 "chrome/browser/prerender/prerender_manager.h" | 5 #include "chrome/browser/prerender/prerender_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 } | 515 } |
| 516 | 516 |
| 517 bool PrerenderManager::MaybeUsePreloadedPage(TabContents* tab_contents, | 517 bool PrerenderManager::MaybeUsePreloadedPage(TabContents* tab_contents, |
| 518 const GURL& url) { | 518 const GURL& url) { |
| 519 if (!PrerenderContents::UseTabContents()) { | 519 if (!PrerenderContents::UseTabContents()) { |
| 520 VLOG(1) << "Checking for prerender with LEGACY code"; | 520 VLOG(1) << "Checking for prerender with LEGACY code"; |
| 521 return PrerenderManager::MaybeUsePreloadedPageOld(tab_contents, url); | 521 return PrerenderManager::MaybeUsePreloadedPageOld(tab_contents, url); |
| 522 } | 522 } |
| 523 VLOG(1) << "Checking for prerender with NEW code"; | 523 VLOG(1) << "Checking for prerender with NEW code"; |
| 524 DCHECK(CalledOnValidThread()); | 524 DCHECK(CalledOnValidThread()); |
| 525 |
| 525 scoped_ptr<PrerenderContents> prerender_contents( | 526 scoped_ptr<PrerenderContents> prerender_contents( |
| 526 GetEntryButNotSpecifiedTC(url, tab_contents)); | 527 GetEntryButNotSpecifiedTC(url, tab_contents)); |
| 527 if (prerender_contents.get() == NULL) | 528 if (prerender_contents.get() == NULL) |
| 528 return false; | 529 return false; |
| 529 | 530 |
| 530 // If we are just in the control group (which can be detected by noticing | 531 // If we are just in the control group (which can be detected by noticing |
| 531 // that prerendering hasn't even started yet), record that |tab_contents| now | 532 // that prerendering hasn't even started yet), record that |tab_contents| now |
| 532 // would be showing a prerendered contents, but otherwise, don't do anything. | 533 // would be showing a prerendered contents, but otherwise, don't do anything. |
| 533 if (!prerender_contents->prerendering_has_started()) { | 534 if (!prerender_contents->prerendering_has_started()) { |
| 534 MarkTabContentsAsWouldBePrerendered(tab_contents); | 535 MarkTabContentsAsWouldBePrerendered(tab_contents); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 DCHECK(old_tab_contents); | 568 DCHECK(old_tab_contents); |
| 568 | 569 |
| 569 MarkTabContentsAsPrerendered(new_tab_contents->tab_contents()); | 570 MarkTabContentsAsPrerendered(new_tab_contents->tab_contents()); |
| 570 | 571 |
| 571 // Merge the browsing history. | 572 // Merge the browsing history. |
| 572 new_tab_contents->controller().CopyStateFromAndPrune( | 573 new_tab_contents->controller().CopyStateFromAndPrune( |
| 573 &old_tab_contents->controller(), | 574 &old_tab_contents->controller(), |
| 574 false); | 575 false); |
| 575 old_tab_contents->delegate()->SwapTabContents(old_tab_contents, | 576 old_tab_contents->delegate()->SwapTabContents(old_tab_contents, |
| 576 new_tab_contents); | 577 new_tab_contents); |
| 578 |
| 577 prerender_contents->CommitHistory(new_tab_contents->tab_contents()); | 579 prerender_contents->CommitHistory(new_tab_contents->tab_contents()); |
| 578 | 580 |
| 579 GURL icon_url = prerender_contents->icon_url(); | 581 GURL icon_url = prerender_contents->icon_url(); |
| 580 if (!icon_url.is_empty()) { | 582 if (!icon_url.is_empty()) { |
| 581 std::vector<FaviconURL> urls; | 583 std::vector<FaviconURL> urls; |
| 582 urls.push_back(FaviconURL(icon_url, FaviconURL::FAVICON)); | 584 urls.push_back(FaviconURL(icon_url, FaviconURL::FAVICON)); |
| 583 new_tab_contents->favicon_tab_helper()->OnUpdateFaviconURL( | 585 new_tab_contents->favicon_tab_helper()->OnUpdateFaviconURL( |
| 584 prerender_contents->page_id(), | 586 prerender_contents->page_id(), |
| 585 urls); | 587 urls); |
| 586 } | 588 } |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 base::TimeTicks cutoff = GetCurrentTimeTicks() - | 979 base::TimeTicks cutoff = GetCurrentTimeTicks() - |
| 978 base::TimeDelta::FromMilliseconds(kNavigationRecordWindowMs); | 980 base::TimeDelta::FromMilliseconds(kNavigationRecordWindowMs); |
| 979 while (!navigations_.empty()) { | 981 while (!navigations_.empty()) { |
| 980 if (navigations_.front().time_ > cutoff) | 982 if (navigations_.front().time_ > cutoff) |
| 981 break; | 983 break; |
| 982 navigations_.pop_front(); | 984 navigations_.pop_front(); |
| 983 } | 985 } |
| 984 } | 986 } |
| 985 | 987 |
| 986 } // namespace prerender | 988 } // namespace prerender |
| OLD | NEW |