diff options
author | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-11 14:48:50 +0000 |
---|---|---|
committer | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-11 14:48:50 +0000 |
commit | 11f595b2430eaa775245f7d7c24babf5a3e6fa09 (patch) | |
tree | cd9e11bf0c4d7cca402df5f98de59074c5e56e93 | |
parent | a1fc0f7f9f29b20f76d85820036f8482f99eb72f (diff) | |
download | chromium_src-11f595b2430eaa775245f7d7c24babf5a3e6fa09.zip chromium_src-11f595b2430eaa775245f7d7c24babf5a3e6fa09.tar.gz chromium_src-11f595b2430eaa775245f7d7c24babf5a3e6fa09.tar.bz2 |
HTML/Javascript redirects while prerendering are no longer
recorded as cancelled prerenders in the histograms.
Also, the time recorded for the time until display of
prerendered pages takes into account the time taken by any
redirects. This makes histograms for prerendered and
non-prerendered pages even less directly comparable than
before.
BUG=78506
TEST=renderer-side histograms look a bit more like what
we're seeing via other measurements.
Review URL: http://codereview.chromium.org/6735071
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81098 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/renderer/page_load_histograms.cc | 14 | ||||
-rw-r--r-- | content/renderer/navigation_state.cc | 21 | ||||
-rw-r--r-- | content/renderer/navigation_state.h | 18 | ||||
-rw-r--r-- | content/renderer/render_view.cc | 17 |
4 files changed, 60 insertions, 10 deletions
diff --git a/chrome/renderer/page_load_histograms.cc b/chrome/renderer/page_load_histograms.cc index 0a47fd0..97edd58 100644 --- a/chrome/renderer/page_load_histograms.cc +++ b/chrome/renderer/page_load_histograms.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -32,7 +32,7 @@ namespace { // Histograms to determine prerendering's impact on perceived PLT. void UpdatePrerenderHistograms(NavigationState* navigation_state, - const Time& begin, const Time& finish_all_loads, + const Time& finish_all_loads, const TimeDelta& begin_to_finish_all_loads) { // Load time for non-prerendered pages. static bool use_prerender_histogram = @@ -47,6 +47,10 @@ void UpdatePrerenderHistograms(NavigationState* navigation_state, return; } + // Do not record stats for redirected prerendered pages. + if (navigation_state->was_prerender_redirected()) + return; + // Histogram for usage rate of prerendered pages. Time prerendered_page_display = navigation_state->prerendered_page_display_time(); @@ -56,8 +60,10 @@ void UpdatePrerenderHistograms(NavigationState* navigation_state, return; // Histograms for perceived load time of prerendered pages. + Time prerendered_page_start = + navigation_state->prerendered_page_start_time(); PLT_HISTOGRAM("PLT.TimeUntilDisplay_PrerenderLoad", - prerendered_page_display - begin); + prerendered_page_display - prerendered_page_start); TimeDelta perceived_load_time = finish_all_loads - prerendered_page_display; if (perceived_load_time < TimeDelta::FromSeconds(0)) { PLT_HISTOGRAM("PLT.PrerenderIdleTime_PrerenderLoad", -perceived_load_time); @@ -313,7 +319,7 @@ void PageLoadHistograms::Dump(WebFrame* frame) { break; } - UpdatePrerenderHistograms(navigation_state, begin, finish_all_loads, + UpdatePrerenderHistograms(navigation_state, finish_all_loads, begin_to_finish_all_loads); // Histograms to determine if DNS prefetching has an impact on PLT. diff --git a/content/renderer/navigation_state.cc b/content/renderer/navigation_state.cc index 4ab7123..9019759 100644 --- a/content/renderer/navigation_state.cc +++ b/content/renderer/navigation_state.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,6 +9,15 @@ NavigationState::~NavigationState() {} +const base::Time& NavigationState::prerendered_page_start_time() const { + return prerendered_page_start_time_; +} + +void NavigationState::set_prerendered_page_start_time(const base::Time& value) { + DCHECK(prerendered_page_start_time_.is_null()); + start_load_time_ = value; +} + const base::Time& NavigationState::prerendered_page_display_time() const { return prerendered_page_display_time_; } @@ -38,6 +47,15 @@ void NavigationState::set_was_started_as_prerender( was_started_as_prerender_ = was_started_as_prerender; } +bool NavigationState::was_prerender_redirected() const { + return was_prerender_redirected_; +} + +void NavigationState::set_was_prerender_redirected( + bool was_prerender_redirected) { + was_prerender_redirected_ = was_prerender_redirected; +} + NavigationState::NavigationState(PageTransition::Type transition_type, const base::Time& request_time, bool is_content_initiated, @@ -54,6 +72,7 @@ NavigationState::NavigationState(PageTransition::Type transition_type, pending_history_list_offset_(pending_history_list_offset), use_error_page_(false), was_started_as_prerender_(false), + was_prerender_redirected_(false), cache_policy_override_set_(false), cache_policy_override_(WebKit::WebURLRequest::UseProtocolCachePolicy), http_status_code_(0), diff --git a/content/renderer/navigation_state.h b/content/renderer/navigation_state.h index 3037568..f8ff13f 100644 --- a/content/renderer/navigation_state.h +++ b/content/renderer/navigation_state.h @@ -151,6 +151,11 @@ class NavigationState : public WebKit::WebDataSource::ExtraData { first_paint_after_load_time_ = value; } + // The time that prerendering started. Note that this is preserved against + // HTML/Javascript redirects, until the page is displayed. + const base::Time& prerendered_page_start_time() const; + void set_prerendered_page_start_time(const base::Time& value); + // The time that a prerendered page was displayed. Invalid for // non-prerendered pages. Can be either before or after // |finish_document_load_time_|. @@ -202,14 +207,22 @@ class NavigationState : public WebKit::WebDataSource::ExtraData { security_info_ = security_info; } + // True if an error page should be used, if the http status code also + // indicates an error. bool use_error_page() const { return use_error_page_; } void set_use_error_page(bool use_error_page) { use_error_page_ = use_error_page; } + // True if a page load started as a prerender. Preserved across redirects. bool was_started_as_prerender() const; void set_was_started_as_prerender(bool was_started_as_prerender); + // True if there was an HTML/Javascript redirect while a page was still being + // prerendered. + bool was_prerender_redirected() const; + void set_was_prerender_redirected(bool was_prerender_redirected); + int http_status_code() const { return http_status_code_; } void set_http_status_code(int http_status_code) { http_status_code_ = http_status_code; @@ -287,6 +300,7 @@ class NavigationState : public WebKit::WebDataSource::ExtraData { base::Time finish_load_time_; base::Time first_paint_time_; base::Time first_paint_after_load_time_; + base::Time prerendered_page_start_time_; base::Time prerendered_page_display_time_; bool load_histograms_recorded_; bool web_timing_histograms_recorded_; @@ -300,12 +314,10 @@ class NavigationState : public WebKit::WebDataSource::ExtraData { scoped_ptr<webkit_glue::AltErrorPageResourceFetcher> alt_error_page_fetcher_; std::string security_info_; - // True if we should use an error page, if the http status code alos indicates - // an error. bool use_error_page_; - // True if a page load started as a prerender. Preserved across redirects. bool was_started_as_prerender_; + bool was_prerender_redirected_; bool cache_policy_override_set_; WebKit::WebURLRequest::CachePolicy cache_policy_override_; diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc index a6c559f..4eea883 100644 --- a/content/renderer/render_view.cc +++ b/content/renderer/render_view.cc @@ -2879,11 +2879,24 @@ void RenderView::didCreateDataSource(WebFrame* frame, WebDataSource* ds) { } } + state->set_was_started_as_prerender(is_prerendering_); + if (is_prerendering_ && !frame->parent()) { + if (content_initiated) { + NavigationState* old_state = + NavigationState::FromDataSource(webview()->mainFrame()->dataSource()); + state->set_prerendered_page_start_time( + old_state->prerendered_page_start_time()); + old_state->set_was_prerender_redirected(true); + } else if (!state->request_time().is_null()) { + state->set_prerendered_page_start_time(state->request_time()); + } else { + state->set_prerendered_page_start_time(state->start_load_time()); + } + } + FOR_EACH_OBSERVER( RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); - state->set_was_started_as_prerender(is_prerendering_); - ds->setExtraData(state); } |