| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/page_load_metrics/observers/reload_page_load_metrics_ob
server.h" | 5 #include "chrome/browser/page_load_metrics/observers/reload_page_load_metrics_ob
server.h" |
| 6 | 6 |
| 7 #include "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse
rver.h" | 7 #include "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse
rver.h" |
| 8 #include "components/page_load_metrics/browser/page_load_metrics_util.h" | 8 #include "components/page_load_metrics/browser/page_load_metrics_util.h" |
| 9 #include "ui/base/page_transition_types.h" | 9 #include "ui/base/page_transition_types.h" |
| 10 | 10 |
| 11 namespace chrome { | 11 namespace chrome { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 const char kHistogramFirstContentfulPaintReload[] = | 15 const char kHistogramFirstContentfulPaintReload[] = |
| 16 "PageLoad.Clients.Reload.PaintTiming.NavigationToFirstContentfulPaint"; | 16 "PageLoad.Clients.Reload.PaintTiming.NavigationToFirstContentfulPaint"; |
| 17 const char kHistogramFirstContentfulPaintReloadByGesture[] = | |
| 18 "PageLoad.Clients.Reload.PaintTiming.NavigationToFirstContentfulPaint." | |
| 19 "UserGesture"; | |
| 20 | 17 |
| 21 } // namespace | 18 } // namespace |
| 22 | 19 |
| 23 ReloadPageLoadMetricsObserver::ReloadPageLoadMetricsObserver() | 20 ReloadPageLoadMetricsObserver::ReloadPageLoadMetricsObserver() |
| 24 : page_transition_was_reload_(false), initiated_by_user_gesture_(false) {} | 21 : page_transition_was_reload_(false) {} |
| 25 | 22 |
| 26 void ReloadPageLoadMetricsObserver::OnCommit( | 23 void ReloadPageLoadMetricsObserver::OnCommit( |
| 27 content::NavigationHandle* navigation_handle) { | 24 content::NavigationHandle* navigation_handle) { |
| 28 page_transition_was_reload_ = ui::PageTransitionCoreTypeIs( | 25 page_transition_was_reload_ = ui::PageTransitionCoreTypeIs( |
| 29 navigation_handle->GetPageTransition(), ui::PAGE_TRANSITION_RELOAD); | 26 navigation_handle->GetPageTransition(), ui::PAGE_TRANSITION_RELOAD); |
| 30 initiated_by_user_gesture_ = navigation_handle->HasUserGesture(); | |
| 31 } | 27 } |
| 32 | 28 |
| 33 void ReloadPageLoadMetricsObserver::OnFirstContentfulPaint( | 29 void ReloadPageLoadMetricsObserver::OnFirstContentfulPaint( |
| 34 const page_load_metrics::PageLoadTiming& timing, | 30 const page_load_metrics::PageLoadTiming& timing, |
| 35 const page_load_metrics::PageLoadExtraInfo& extra_info) { | 31 const page_load_metrics::PageLoadExtraInfo& extra_info) { |
| 36 if (!page_transition_was_reload_ || | 32 if (!page_transition_was_reload_ || |
| 37 !WasStartedInForegroundEventInForeground(timing.first_contentful_paint, | 33 !WasStartedInForegroundEventInForeground(timing.first_contentful_paint, |
| 38 extra_info)) { | 34 extra_info)) { |
| 39 return; | 35 return; |
| 40 } | 36 } |
| 41 | 37 |
| 42 PAGE_LOAD_HISTOGRAM(kHistogramFirstContentfulPaintReload, | 38 PAGE_LOAD_HISTOGRAM(kHistogramFirstContentfulPaintReload, |
| 43 timing.first_contentful_paint); | 39 timing.first_contentful_paint); |
| 44 if (initiated_by_user_gesture_) { | |
| 45 PAGE_LOAD_HISTOGRAM(kHistogramFirstContentfulPaintReloadByGesture, | |
| 46 timing.first_contentful_paint); | |
| 47 } | |
| 48 } | 40 } |
| 49 | 41 |
| 50 } // namespace chrome | 42 } // namespace chrome |
| OLD | NEW |