Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: chrome/browser/page_load_metrics/page_load_metrics_util.cc

Issue 2930583002: Add Foreground-to-FirstMeaningfulPaint histogram (Closed)
Patch Set: add FCP variant Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/page_load_metrics_util.h" 5 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "chrome/common/page_load_metrics/page_load_timing.h" 9 #include "chrome/common/page_load_metrics/page_load_timing.h"
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } // namespace 44 } // namespace
45 45
46 bool WasStartedInForegroundOptionalEventInForeground( 46 bool WasStartedInForegroundOptionalEventInForeground(
47 const base::Optional<base::TimeDelta>& event, 47 const base::Optional<base::TimeDelta>& event,
48 const PageLoadExtraInfo& info) { 48 const PageLoadExtraInfo& info) {
49 return info.started_in_foreground && event && 49 return info.started_in_foreground && event &&
50 (!info.first_background_time || 50 (!info.first_background_time ||
51 event.value() <= info.first_background_time.value()); 51 event.value() <= info.first_background_time.value());
52 } 52 }
53 53
54 bool WasStartedInBackgroundOptionalEventInForeground(
55 const base::Optional<base::TimeDelta>& event,
56 const PageLoadExtraInfo& info) {
57 return !info.started_in_foreground && event && info.first_foreground_time &&
58 info.first_foreground_time.value() <= event.value() &&
59 (!info.first_background_time ||
60 event.value() <= info.first_background_time.value());
61 }
62
54 PageAbortInfo GetPageAbortInfo(const PageLoadExtraInfo& info) { 63 PageAbortInfo GetPageAbortInfo(const PageLoadExtraInfo& info) {
55 if (IsBackgroundAbort(info)) { 64 if (IsBackgroundAbort(info)) {
56 // Though most cases where a tab is backgrounded are user initiated, we 65 // Though most cases where a tab is backgrounded are user initiated, we
57 // can't be certain that we were backgrounded due to a user action. For 66 // can't be certain that we were backgrounded due to a user action. For
58 // example, on Android, the screen times out after a period of inactivity, 67 // example, on Android, the screen times out after a period of inactivity,
59 // resulting in a non-user-initiated backgrounding. 68 // resulting in a non-user-initiated backgrounding.
60 return {ABORT_BACKGROUND, UserInitiatedInfo::NotUserInitiated(), 69 return {ABORT_BACKGROUND, UserInitiatedInfo::NotUserInitiated(),
61 info.first_background_time.value()}; 70 info.first_background_time.value()};
62 } 71 }
63 72
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 const page_load_metrics::PageLoadExtraInfo& info, 104 const page_load_metrics::PageLoadExtraInfo& info,
96 blink::WebLoadingBehaviorFlag behavior) { 105 blink::WebLoadingBehaviorFlag behavior) {
97 const int all_frame_loading_behavior_flags = 106 const int all_frame_loading_behavior_flags =
98 info.main_frame_metadata.behavior_flags | 107 info.main_frame_metadata.behavior_flags |
99 info.subframe_metadata.behavior_flags; 108 info.subframe_metadata.behavior_flags;
100 109
101 return (all_frame_loading_behavior_flags & behavior) != 0; 110 return (all_frame_loading_behavior_flags & behavior) != 0;
102 } 111 }
103 112
104 } // namespace page_load_metrics 113 } // namespace page_load_metrics
OLDNEW
« no previous file with comments | « chrome/browser/page_load_metrics/page_load_metrics_util.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698