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