| 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 "chrome/browser/prerender/prerender_manager.h" | 5 #include "chrome/browser/prerender/prerender_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <functional> | 10 #include <functional> |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 DCHECK(entry); | 519 DCHECK(entry); |
| 520 | 520 |
| 521 PrerenderDataVector::iterator it = FindIteratorForPrerenderContents(entry); | 521 PrerenderDataVector::iterator it = FindIteratorForPrerenderContents(entry); |
| 522 DCHECK(it != active_prerenders_.end()); | 522 DCHECK(it != active_prerenders_.end()); |
| 523 to_delete_prerenders_.push_back(std::move(*it)); | 523 to_delete_prerenders_.push_back(std::move(*it)); |
| 524 active_prerenders_.erase(it); | 524 active_prerenders_.erase(it); |
| 525 // Destroy the old WebContents relatively promptly to reduce resource usage. | 525 // Destroy the old WebContents relatively promptly to reduce resource usage. |
| 526 PostCleanupTask(); | 526 PostCleanupTask(); |
| 527 } | 527 } |
| 528 | 528 |
| 529 void PrerenderManager::RecordPageLoadTimeNotSwappedIn( | |
| 530 Origin origin, | |
| 531 base::TimeDelta page_load_time, | |
| 532 const GURL& url) { | |
| 533 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 534 histograms_->RecordPageLoadTimeNotSwappedIn(origin, page_load_time, url); | |
| 535 } | |
| 536 | |
| 537 void PrerenderManager::RecordPerceivedPageLoadTime( | |
| 538 Origin origin, | |
| 539 NavigationType navigation_type, | |
| 540 base::TimeDelta perceived_page_load_time, | |
| 541 double fraction_plt_elapsed_at_swap_in, | |
| 542 const GURL& url) { | |
| 543 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 544 if (GetPredictionStatusForOrigin(origin) | |
| 545 != NetworkPredictionStatus::ENABLED) { | |
| 546 return; | |
| 547 } | |
| 548 | |
| 549 histograms_->RecordPerceivedPageLoadTime( | |
| 550 origin, perceived_page_load_time, navigation_type, url); | |
| 551 | |
| 552 if (navigation_type == NAVIGATION_TYPE_PRERENDERED) { | |
| 553 histograms_->RecordPercentLoadDoneAtSwapin( | |
| 554 origin, fraction_plt_elapsed_at_swap_in); | |
| 555 } | |
| 556 } | |
| 557 | |
| 558 void PrerenderManager::RecordPrefetchResponseReceived(Origin origin, | 529 void PrerenderManager::RecordPrefetchResponseReceived(Origin origin, |
| 559 bool is_main_resource, | 530 bool is_main_resource, |
| 560 bool is_redirect, | 531 bool is_redirect, |
| 561 bool is_no_store) { | 532 bool is_no_store) { |
| 562 histograms_->RecordPrefetchResponseReceived(origin, is_main_resource, | 533 histograms_->RecordPrefetchResponseReceived(origin, is_main_resource, |
| 563 is_redirect, is_no_store); | 534 is_redirect, is_no_store); |
| 564 } | 535 } |
| 565 | 536 |
| 566 void PrerenderManager::RecordPrefetchRedirectCount(Origin origin, | 537 void PrerenderManager::RecordPrefetchRedirectCount(Origin origin, |
| 567 bool is_main_resource, | 538 bool is_main_resource, |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 IsGoogleOriginURL(referrer.url)) { | 906 IsGoogleOriginURL(referrer.url)) { |
| 936 origin = ORIGIN_GWS_PRERENDER; | 907 origin = ORIGIN_GWS_PRERENDER; |
| 937 } | 908 } |
| 938 | 909 |
| 939 if (IsPrerenderSilenceExperiment(origin)) | 910 if (IsPrerenderSilenceExperiment(origin)) |
| 940 return nullptr; | 911 return nullptr; |
| 941 | 912 |
| 942 GURL url = url_arg; | 913 GURL url = url_arg; |
| 943 GURL alias_url; | 914 GURL alias_url; |
| 944 | 915 |
| 945 // From here on, we will record a FinalStatus so we need to register with the | |
| 946 // histogram tracking. | |
| 947 histograms_->RecordPrerender(); | |
| 948 | |
| 949 if (profile_->GetPrefs()->GetBoolean(prefs::kBlockThirdPartyCookies) && | 916 if (profile_->GetPrefs()->GetBoolean(prefs::kBlockThirdPartyCookies) && |
| 950 origin != ORIGIN_OFFLINE) { | 917 origin != ORIGIN_OFFLINE) { |
| 951 RecordFinalStatusWithoutCreatingPrerenderContents( | 918 RecordFinalStatusWithoutCreatingPrerenderContents( |
| 952 url, origin, FINAL_STATUS_BLOCK_THIRD_PARTY_COOKIES); | 919 url, origin, FINAL_STATUS_BLOCK_THIRD_PARTY_COOKIES); |
| 953 return nullptr; | 920 return nullptr; |
| 954 } | 921 } |
| 955 | 922 |
| 956 NetworkPredictionStatus prerendering_status = | 923 NetworkPredictionStatus prerendering_status = |
| 957 GetPredictionStatusForOrigin(origin); | 924 GetPredictionStatusForOrigin(origin); |
| 958 if (prerendering_status != NetworkPredictionStatus::ENABLED) { | 925 if (prerendering_status != NetworkPredictionStatus::ENABLED) { |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1463 return weak_factory_.GetWeakPtr(); | 1430 return weak_factory_.GetWeakPtr(); |
| 1464 } | 1431 } |
| 1465 | 1432 |
| 1466 void PrerenderManager::SetPrerenderContentsFactoryForTest( | 1433 void PrerenderManager::SetPrerenderContentsFactoryForTest( |
| 1467 PrerenderContents::Factory* prerender_contents_factory) { | 1434 PrerenderContents::Factory* prerender_contents_factory) { |
| 1468 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1435 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1469 prerender_contents_factory_.reset(prerender_contents_factory); | 1436 prerender_contents_factory_.reset(prerender_contents_factory); |
| 1470 } | 1437 } |
| 1471 | 1438 |
| 1472 } // namespace prerender | 1439 } // namespace prerender |
| OLD | NEW |