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

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

Issue 1837233002: Optional <TimeDelta> since they may be non existent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased, Fixed non-deterministic tests and Bryan's review comments. Created 4 years, 7 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_OBSERVER_H_ 5 #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_
6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ 6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/optional.h"
9 #include "components/page_load_metrics/common/page_load_timing.h" 10 #include "components/page_load_metrics/common/page_load_timing.h"
10 #include "content/public/browser/navigation_handle.h" 11 #include "content/public/browser/navigation_handle.h"
11 #include "url/gurl.h" 12 #include "url/gurl.h"
12 13
13 namespace page_load_metrics { 14 namespace page_load_metrics {
14 15
15 // This enum represents how a page load ends. If the action occurs before the 16 // This enum represents how a page load ends. If the action occurs before the
16 // page load finishes (or reaches some point like first paint), then we consider 17 // page load finishes (or reaches some point like first paint), then we consider
17 // the load to be aborted. 18 // the load to be aborted.
18 enum UserAbortType { 19 enum UserAbortType {
(...skipping 23 matching lines...) Expand all
42 43
43 // The load aborted due to another navigation, but it isn't clear what type of 44 // The load aborted due to another navigation, but it isn't clear what type of
44 // navigation it was. 45 // navigation it was.
45 ABORT_UNKNOWN_NAVIGATION, 46 ABORT_UNKNOWN_NAVIGATION,
46 47
47 // Add values before this final count. 48 // Add values before this final count.
48 ABORT_LAST_ENTRY 49 ABORT_LAST_ENTRY
49 }; 50 };
50 51
51 struct PageLoadExtraInfo { 52 struct PageLoadExtraInfo {
52 PageLoadExtraInfo(base::TimeDelta first_background_time, 53 PageLoadExtraInfo(
53 base::TimeDelta first_foreground_time, 54 const base::Optional<base::TimeDelta>& first_background_time,
54 bool started_in_foreground, 55 const base::Optional<base::TimeDelta>& first_foreground_time,
55 const GURL& committed_url, 56 bool started_in_foreground,
56 base::TimeDelta time_to_commit, 57 const GURL& committed_url,
57 UserAbortType abort_type, 58 const base::Optional<base::TimeDelta>& time_to_commit,
58 base::TimeDelta time_to_abort, 59 UserAbortType abort_type,
59 const PageLoadMetadata& metadata); 60 const base::Optional<base::TimeDelta>& time_to_abort,
61 const PageLoadMetadata& metadata);
62
60 PageLoadExtraInfo(const PageLoadExtraInfo& other); 63 PageLoadExtraInfo(const PageLoadExtraInfo& other);
61 64
65 ~PageLoadExtraInfo();
66
62 // The first time that the page was backgrounded since the navigation started. 67 // The first time that the page was backgrounded since the navigation started.
63 // If the page has not been backgrounded this will be base::TimeDelta(). 68 const base::Optional<base::TimeDelta> first_background_time;
64 const base::TimeDelta first_background_time;
65 69
66 // The first time that the page was foregrounded since the navigation started. 70 // The first time that the page was foregrounded since the navigation started.
67 // If the page has not been foregrounded this will be base::TimeDelta(). 71 const base::Optional<base::TimeDelta> first_foreground_time;
68 const base::TimeDelta first_foreground_time;
69 72
70 // True if the page load started in the foreground. 73 // True if the page load started in the foreground.
71 const bool started_in_foreground; 74 const bool started_in_foreground;
72 75
73 // Committed URL. If the page load did not commit, |committed_url| will be 76 // Committed URL. If the page load did not commit, |committed_url| will be
74 // empty. 77 // empty.
75 const GURL committed_url; 78 const GURL committed_url;
76 79
77 // Time from navigation start until commit. If the page load did not commit, 80 // Time from navigation start until commit.
78 // |time_to_commit| will be zero. 81 const base::Optional<base::TimeDelta> time_to_commit;
79 const base::TimeDelta time_to_commit;
80 82
81 // The abort time and time to abort for this page load. If the page was not 83 // The abort time and time to abort for this page load. If the page was not
82 // aborted, |abort_type| will be |ABORT_NONE| and |time_to_abort| will be 84 // aborted, |abort_type| will be |ABORT_NONE|
Charlie Harrison 2016/05/19 18:20:49 Add a period at the end of the sentence.
shivanisha 2016/05/23 15:06:44 done
83 // |base::TimeDelta()|.
84 const UserAbortType abort_type; 85 const UserAbortType abort_type;
85 const base::TimeDelta time_to_abort; 86 const base::Optional<base::TimeDelta> time_to_abort;
86 87
87 // Extra information supplied to the page load metrics system from the 88 // Extra information supplied to the page load metrics system from the
88 // renderer. 89 // renderer.
89 const PageLoadMetadata metadata; 90 const PageLoadMetadata metadata;
90 }; 91 };
91 92
92 // Interface for PageLoadMetrics observers. All instances of this class are 93 // Interface for PageLoadMetrics observers. All instances of this class are
93 // owned by the PageLoadTracker tracking a page load. They will be deleted after 94 // owned by the PageLoadTracker tracking a page load. They will be deleted after
94 // calling OnComplete. 95 // calling OnComplete.
95 class PageLoadMetricsObserver { 96 class PageLoadMetricsObserver {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 const PageLoadExtraInfo& extra_info) {} 163 const PageLoadExtraInfo& extra_info) {}
163 virtual void OnParseStart(const PageLoadTiming& timing, 164 virtual void OnParseStart(const PageLoadTiming& timing,
164 const PageLoadExtraInfo& extra_info) {} 165 const PageLoadExtraInfo& extra_info) {}
165 virtual void OnParseStop(const PageLoadTiming& timing, 166 virtual void OnParseStop(const PageLoadTiming& timing,
166 const PageLoadExtraInfo& extra_info) {} 167 const PageLoadExtraInfo& extra_info) {}
167 }; 168 };
168 169
169 } // namespace page_load_metrics 170 } // namespace page_load_metrics
170 171
171 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ 172 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698