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

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

Issue 1879413002: Provide currently_committed_url to PageLoadMetricsObservers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test 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
« no previous file with comments | « no previous file | components/page_load_metrics/browser/metrics_web_contents_observer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_METRICS_WEB_CONTENTS_OBSERVER_H_ 5 #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_
6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ 6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 virtual void RegisterObservers(PageLoadTracker* metrics) = 0; 99 virtual void RegisterObservers(PageLoadTracker* metrics) = 0;
100 }; 100 };
101 101
102 // This class tracks a given page load, starting from navigation start / 102 // This class tracks a given page load, starting from navigation start /
103 // provisional load, until a new navigation commits or the navigation fails. 103 // provisional load, until a new navigation commits or the navigation fails.
104 // MetricsWebContentsObserver manages a set of provisional PageLoadTrackers, as 104 // MetricsWebContentsObserver manages a set of provisional PageLoadTrackers, as
105 // well as a committed PageLoadTracker. 105 // well as a committed PageLoadTracker.
106 class PageLoadTracker { 106 class PageLoadTracker {
107 public: 107 public:
108 // Caller must guarantee that the embedder_interface pointer outlives this 108 // Caller must guarantee that the embedder_interface pointer outlives this
109 // class. 109 // class. The PageLoadTracker must not hold on to
110 // currently_committed_load_or_null beyond the scope of the constructor.
Charlie Harrison 2016/04/15 16:51:38 Might as well as the same thing about the Navigati
Bryan McQuade 2016/04/15 17:21:44 Done
110 PageLoadTracker(bool in_foreground, 111 PageLoadTracker(bool in_foreground,
111 PageLoadMetricsEmbedderInterface* embedder_interface, 112 PageLoadMetricsEmbedderInterface* embedder_interface,
113 PageLoadTracker* const currently_committed_load_or_null,
112 content::NavigationHandle* navigation_handle, 114 content::NavigationHandle* navigation_handle,
113 int aborted_chain_size, 115 int aborted_chain_size,
114 int aborted_chain_size_same_url); 116 int aborted_chain_size_same_url);
115 ~PageLoadTracker(); 117 ~PageLoadTracker();
116 void Redirect(content::NavigationHandle* navigation_handle); 118 void Redirect(content::NavigationHandle* navigation_handle);
117 void Commit(content::NavigationHandle* navigation_handle); 119 void Commit(content::NavigationHandle* navigation_handle);
118 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle); 120 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle);
119 void WebContentsHidden(); 121 void WebContentsHidden();
120 void WebContentsShown(); 122 void WebContentsShown();
121 123
122 // Returns true if the timing was successfully updated. 124 // Returns true if the timing was successfully updated.
123 bool UpdateTiming(const PageLoadTiming& timing, 125 bool UpdateTiming(const PageLoadTiming& timing,
124 const PageLoadMetadata& metadata); 126 const PageLoadMetadata& metadata);
125 bool HasBackgrounded();
126 127
127 void set_renderer_tracked(bool renderer_tracked); 128 void set_renderer_tracked(bool renderer_tracked);
128 bool renderer_tracked() const { return renderer_tracked_; } 129 bool renderer_tracked() const { return renderer_tracked_; }
129 130
130 int aborted_chain_size() const { return aborted_chain_size_; } 131 int aborted_chain_size() const { return aborted_chain_size_; }
131 int aborted_chain_size_same_url() const { 132 int aborted_chain_size_same_url() const {
132 return aborted_chain_size_same_url_; 133 return aborted_chain_size_same_url_;
133 } 134 }
134 135
135 UserAbortType abort_type() const { return abort_type_; } 136 UserAbortType abort_type() const { return abort_type_; }
136 base::TimeTicks abort_time() const { return abort_time_; } 137 base::TimeTicks abort_time() const { return abort_time_; }
137 138
138 void AddObserver(scoped_ptr<PageLoadMetricsObserver> observer); 139 void AddObserver(scoped_ptr<PageLoadMetricsObserver> observer);
139 140
140 // If the user performs some abort-like action while we are tracking this page 141 // If the user performs some abort-like action while we are tracking this page
141 // load, notify the tracker. Note that we may not classify this as an abort if 142 // load, notify the tracker. Note that we may not classify this as an abort if
142 // we've already performed a first paint. 143 // we've already performed a first paint.
143 void NotifyAbort(UserAbortType abort_type, base::TimeTicks timestamp); 144 void NotifyAbort(UserAbortType abort_type, base::TimeTicks timestamp);
144 void UpdateAbort(UserAbortType abort_type, base::TimeTicks timestamp); 145 void UpdateAbort(UserAbortType abort_type, base::TimeTicks timestamp);
145 146
146 // This method returns true if this page load has been aborted with type of 147 // This method returns true if this page load has been aborted with type of
147 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close 148 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close
148 // delta to when it was aborted. Note that only provisional loads can be 149 // delta to when it was aborted. Note that only provisional loads can be
149 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better 150 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better
150 // and is simpler than other feasible methods. See https://goo.gl/WKRG98. 151 // and is simpler than other feasible methods. See https://goo.gl/WKRG98.
151 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time); 152 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time);
152 153
153 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle); 154 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle);
154 155
156 // Only valid to call post-commit.
157 const GURL& committed_url() const {
158 DCHECK(!commit_time_.is_null());
159 return url_;
160 }
161
155 private: 162 private:
156 PageLoadExtraInfo GetPageLoadMetricsInfo(); 163 PageLoadExtraInfo GetPageLoadMetricsInfo();
157 164
158 // Only valid to call post-commit.
159 const GURL& committed_url();
160
161 void UpdateAbortInternal(UserAbortType abort_type, 165 void UpdateAbortInternal(UserAbortType abort_type,
162 base::TimeTicks timestamp); 166 base::TimeTicks timestamp);
163 167
164 // If |final_navigation| is null, then this is an "unparented" abort chain, 168 // If |final_navigation| is null, then this is an "unparented" abort chain,
165 // and represents a sequence of provisional aborts that never ends with a 169 // and represents a sequence of provisional aborts that never ends with a
166 // committed load. 170 // committed load.
167 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); 171 void LogAbortChainHistograms(content::NavigationHandle* final_navigation);
168 172
169 // Whether the renderer should be sending timing IPCs to this page load. 173 // Whether the renderer should be sending timing IPCs to this page load.
170 bool renderer_tracked_; 174 bool renderer_tracked_;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 std::vector<scoped_ptr<PageLoadTracker>> aborted_provisional_loads_; 290 std::vector<scoped_ptr<PageLoadTracker>> aborted_provisional_loads_;
287 291
288 scoped_ptr<PageLoadTracker> committed_load_; 292 scoped_ptr<PageLoadTracker> committed_load_;
289 293
290 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); 294 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);
291 }; 295 };
292 296
293 } // namespace page_load_metrics 297 } // namespace page_load_metrics
294 298
295 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ 299 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_
OLDNEW
« no previous file with comments | « no previous file | components/page_load_metrics/browser/metrics_web_contents_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698