Index: chrome/browser/tab_contents/tab_contents.cc |
=================================================================== |
--- chrome/browser/tab_contents/tab_contents.cc (revision 72357) |
+++ chrome/browser/tab_contents/tab_contents.cc (working copy) |
@@ -375,6 +375,7 @@ |
waiting_for_response_(false), |
max_page_id_(-1), |
current_load_start_(), |
+ pplt_load_start_(), |
load_state_(net::LOAD_STATE_IDLE), |
load_state_host_(), |
upload_size_(0), |
@@ -1654,6 +1655,9 @@ |
Source<NavigationController>(&controller_), |
Details<ProvisionalLoadDetails>(&details)); |
if (is_main_frame) { |
+ // Record the beginning of a new PPLT navigation. |
brettw
2011/01/26 20:16:47
I realized how we can do this just in your compone
|
+ pplt_load_start_ = base::TimeTicks::Now(); |
+ |
// If we're displaying a network error page do not reset the content |
// settings delegate's cookies so the user has a chance to modify cookie |
// settings. |
@@ -2814,6 +2818,14 @@ |
SetIsLoading(false, details.get()); |
+ // Compute the PPLT metric and report it in a histogram, if needed. |
+ PrerenderManager* pm = profile()->GetPrerenderManager(); |
+ if (pm != NULL && !pplt_load_start_.is_null()) |
+ pm->RecordPerceivedPageLoadTime(base::TimeTicks::Now() - pplt_load_start_); |
+ |
+ // Reset the PPLT metric. |
+ pplt_load_start_ = base::TimeTicks(); |
+ |
// Notify observers about navigation. |
FOR_EACH_OBSERVER(WebNavigationObserver, web_navigation_observers_, |
DidStopLoading()); |
@@ -3393,12 +3405,8 @@ |
bool TabContents::MaybeUsePreloadedPage(const GURL& url) { |
PrerenderManager* pm = profile()->GetPrerenderManager(); |
if (pm != NULL) { |
- if (pm->MaybeUsePreloadedPage(this, url)) { |
- // TODO(tburkard): If the preloaded page has not finished preloading |
- // yet, we should not do this. |
- DidStopLoading(); |
+ if (pm->MaybeUsePreloadedPage(this, url)) |
return true; |
- } |
} |
return false; |
} |