diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/renderer/navigation_state.cc | 29 | ||||
-rw-r--r-- | chrome/renderer/navigation_state.h | 21 | ||||
-rw-r--r-- | chrome/renderer/page_load_histograms.cc | 57 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 7 |
4 files changed, 108 insertions, 6 deletions
diff --git a/chrome/renderer/navigation_state.cc b/chrome/renderer/navigation_state.cc index dff7ee4..5a92e1b 100644 --- a/chrome/renderer/navigation_state.cc +++ b/chrome/renderer/navigation_state.cc @@ -20,6 +20,16 @@ void NavigationState::swap_user_script_idle_scheduler( user_script_idle_scheduler_.swap(state->user_script_idle_scheduler_); } +const base::Time& NavigationState::prerendered_page_display_time() const { + return prerendered_page_display_time_; +} + +void NavigationState::set_prerendered_page_display_time( + const base::Time& value) { + DCHECK(prerendered_page_display_time_.is_null()); + prerendered_page_display_time_ = value; +} + void NavigationState::set_password_form_data(webkit_glue::PasswordForm* data) { password_form_data_.reset(data); } @@ -29,6 +39,24 @@ void NavigationState::set_alt_error_page_fetcher( alt_error_page_fetcher_.reset(f); } +bool NavigationState::is_prerendering() const { + return is_prerendering_; +} + +void NavigationState::set_is_prerendering(bool is_prerendering) { + is_prerendering_ = is_prerendering; +} + +bool NavigationState::was_started_as_prerender() const { + return was_started_as_prerender_; +} + +void NavigationState::set_was_started_as_prerender( + bool was_started_as_prerender) { + DCHECK(!was_started_as_prerender_); + was_started_as_prerender_ = was_started_as_prerender; +} + NavigationState::NavigationState(PageTransition::Type transition_type, const base::Time& request_time, bool is_content_initiated, @@ -45,6 +73,7 @@ NavigationState::NavigationState(PageTransition::Type transition_type, pending_history_list_offset_(pending_history_list_offset), postpone_loading_data_(false), is_prerendering_(false), + was_started_as_prerender_(false), cache_policy_override_set_(false), cache_policy_override_(WebKit::WebURLRequest::UseProtocolCachePolicy), user_script_idle_scheduler_(NULL), diff --git a/chrome/renderer/navigation_state.h b/chrome/renderer/navigation_state.h index 519b0ca..0873fe8 100644 --- a/chrome/renderer/navigation_state.h +++ b/chrome/renderer/navigation_state.h @@ -159,6 +159,12 @@ class NavigationState : public WebKit::WebDataSource::ExtraData { first_paint_after_load_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_|. + const base::Time& prerendered_page_display_time() const; + void set_prerendered_page_display_time(const base::Time& value); + // True iff the histograms for the associated frame have been dumped. bool load_histograms_recorded() const { return load_histograms_recorded_; } void set_load_histograms_recorded(bool value) { @@ -215,10 +221,11 @@ class NavigationState : public WebKit::WebDataSource::ExtraData { postponed_data_.append(data, data_len); } - bool is_prerendering() const { return is_prerendering_; } - void set_is_prerendering(bool is_prerendering) { - is_prerendering_ = is_prerendering; - } + bool is_prerendering() const; + void set_is_prerendering(bool is_prerendering); + + bool was_started_as_prerender() const; + void set_was_started_as_prerender(bool was_started_as_prerender); int http_status_code() const { return http_status_code_; } void set_http_status_code(int http_status_code) { @@ -297,6 +304,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_display_time_; bool load_histograms_recorded_; bool web_timing_histograms_recorded_; bool request_committed_; @@ -312,9 +320,12 @@ class NavigationState : public WebKit::WebDataSource::ExtraData { std::string postponed_data_; // True if page is being prerendered. False once prerendered page is - // displayed. + // displayed. Preserved across redirects. bool is_prerendering_; + // True if a page load started as a prerender. Preserved across redirects. + bool was_started_as_prerender_; + bool cache_policy_override_set_; WebKit::WebURLRequest::CachePolicy cache_policy_override_; diff --git a/chrome/renderer/page_load_histograms.cc b/chrome/renderer/page_load_histograms.cc index 48ef7e5..3603981 100644 --- a/chrome/renderer/page_load_histograms.cc +++ b/chrome/renderer/page_load_histograms.cc @@ -28,6 +28,54 @@ static const size_t kPLTCount(100); #define PLT_HISTOGRAM(name, sample) \ UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, kPLTMin, kPLTMax, kPLTCount); +namespace { + +// Histograms to determine prerendering's impact on perceived PLT. +void UpdatePrerenderHistograms(NavigationState* navigation_state, + const Time& begin, const Time& finish_all_loads, + const TimeDelta& begin_to_finish_all_loads) { + // Load time for non-prerendered pages. + static bool use_prerender_histogram = + base::FieldTrialList::Find("Prerender") && + !base::FieldTrialList::Find("Prerender")->group_name().empty(); + if (!navigation_state->was_started_as_prerender()) { + if (use_prerender_histogram) { + PLT_HISTOGRAM(base::FieldTrial::MakeName( + "PLT.PerceivedLoadTime", "Prerender"), + begin_to_finish_all_loads); + } + return; + } + + // Histogram for usage rate of prerendered pages. + Time prerendered_page_display = + navigation_state->prerendered_page_display_time(); + UMA_HISTOGRAM_ENUMERATION("PLT.PageUsed_PrerenderLoad", + prerendered_page_display.is_null() ? 0 : 1, 2); + if (prerendered_page_display.is_null()) + return; + + // Histograms for perceived load time of prerendered pages. + PLT_HISTOGRAM("PLT.TimeUntilDisplay_PrerenderLoad", + prerendered_page_display - begin); + 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); + perceived_load_time = TimeDelta::FromSeconds(0); + } + PLT_HISTOGRAM("PLT.PerceivedLoadTime_PrerenderLoad", perceived_load_time); + if (use_prerender_histogram) { + PLT_HISTOGRAM(base::FieldTrial::MakeName( + "PLT.PerceivedLoadTime_PrerenderLoad", "Prerender"), + perceived_load_time); + PLT_HISTOGRAM(base::FieldTrial::MakeName( + "PLT.PerceivedLoadTime", "Prerender"), + perceived_load_time); + } +} + +} // namespace + // Returns the scheme type of the given URL if its type is one for which we // dump page load histograms. Otherwise returns NULL. static URLPattern::SchemeMasks GetSupportedSchemeType(const GURL& url) { @@ -255,10 +303,19 @@ void PageLoadHistograms::Dump(WebFrame* frame) { PLT_HISTOGRAM("PLT.BeginToFinish_LinkLoadCacheOnly", begin_to_finish_all_loads); break; + case NavigationState::PRERENDER_LOAD: + PLT_HISTOGRAM("PLT.BeginToFinishDoc_PrerenderLoad", + begin_to_finish_doc); + PLT_HISTOGRAM("PLT.BeginToFinish_PrerenderLoad", + begin_to_finish_all_loads); + break; default: break; } + UpdatePrerenderHistograms(navigation_state, begin, finish_all_loads, + begin_to_finish_all_loads); + // Histograms to determine if DNS prefetching has an impact on PLT. static bool use_dns_histogram(base::FieldTrialList::Find("DnsImpact") && !base::FieldTrialList::Find("DnsImpact")->group_name().empty()); diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 95b8302..1057dfd 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -1424,6 +1424,7 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { navigation_state->set_load_type(NavigationState::NORMAL_LOAD); } else { navigation_state->set_load_type(NavigationState::PRERENDER_LOAD); + navigation_state->set_was_started_as_prerender(true); navigation_state->set_is_prerendering(true); } } @@ -3221,8 +3222,11 @@ void RenderView::didCreateDataSource(WebFrame* frame, WebDataSource* ds) { if (ds_old) { NavigationState* navigation_state = NavigationState::FromDataSource(ds_old); - if (navigation_state) + if (navigation_state) { state->set_is_prerendering(navigation_state->is_prerendering()); + state->set_was_started_as_prerender( + navigation_state->was_started_as_prerender()); + } } } @@ -4716,6 +4720,7 @@ void RenderView::OnDisplayPrerenderedPage() { DCHECK(navigation_state->is_prerendering()); navigation_state->set_is_prerendering(false); + navigation_state->set_prerendered_page_display_time(Time::Now()); } void RenderView::OnFileChooserResponse(const std::vector<FilePath>& paths) { |