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

Side by Side Diff: components/page_load_metrics/browser/page_load_metrics_util.h

Issue 1837233002: Optional <TimeDelta> since they may be non existent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Need to add Optional changes as well in this issue otherwise bots fail in compilation Created 4 years, 8 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 #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_UTIL_H_ 5 #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_UTIL_H_
6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_UTIL_H_ 6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_UTIL_H_
7 7
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/optional.h"
9 #include "base/time/time.h" 10 #include "base/time/time.h"
10 11
11 #define PAGE_LOAD_HISTOGRAM(name, sample) \ 12 #define PAGE_LOAD_HISTOGRAM(name, sample) \
12 UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, \ 13 UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, \
13 base::TimeDelta::FromMilliseconds(10), \ 14 base::TimeDelta::FromMilliseconds(10), \
14 base::TimeDelta::FromMinutes(10), 100) 15 base::TimeDelta::FromMinutes(10), 100)
15 16
16 namespace page_load_metrics { 17 namespace page_load_metrics {
17 18
18 struct PageLoadExtraInfo; 19 struct PageLoadExtraInfo;
19 struct PageLoadTiming; 20 struct PageLoadTiming;
20 21
21 // Returns true if: 22 // Returns true if:
22 // - We have timing information for the event. 23 // - We have timing information for the event.
23 // - The page load started while the page was in the foreground. 24 // - The page load started while the page was in the foreground.
24 // - The event occurred prior to the page being moved to the background. 25 // - The event occurred prior to the page being moved to the background.
25 // When a page is backgrounded, some events (e.g. paint) are delayed. Since 26 // When a page is backgrounded, some events (e.g. paint) are delayed. Since
26 // these data points can skew the mean, they should not be mixed with timing 27 // these data points can skew the mean, they should not be mixed with timing
27 // events that occurred in the foreground. 28 // events that occurred in the foreground.
28 bool WasStartedInForegroundEventInForeground(base::TimeDelta event, 29 bool WasStartedInForegroundEventInForeground(const base::TimeDelta& event,
29 const PageLoadExtraInfo& info); 30 const PageLoadExtraInfo& info);
30 31
32 // TODO (@shivanisha) Since the above function is currently also called for
33 // TimeDelta coming over IPC (PageLoadTiming) and since Optional is not
34 // currently supported in IPC, thus creating another function.
35 // They should ideally converge to one function in the future
36 // when serialization framework supports Optional
37 bool WasStartedInForegroundOptionalEventInForeground(
38 const base::Optional<base::TimeDelta>& event,
39 const PageLoadExtraInfo& info);
40
31 } // namespace page_load_metrics 41 } // namespace page_load_metrics
32 42
33 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_UTIL_H_ 43 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698