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

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

Issue 2132603002: [page_load_metrics] Add a NavigationThrottle for richer abort metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More browser tests Created 4 years, 5 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_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 <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // class. The PageLoadTracker must not hold on to 121 // class. The PageLoadTracker must not hold on to
122 // currently_committed_load_or_null or navigation_handle beyond the scope of 122 // currently_committed_load_or_null or navigation_handle beyond the scope of
123 // the constructor. 123 // the constructor.
124 PageLoadTracker(bool in_foreground, 124 PageLoadTracker(bool in_foreground,
125 PageLoadMetricsEmbedderInterface* embedder_interface, 125 PageLoadMetricsEmbedderInterface* embedder_interface,
126 const GURL& currently_committed_url, 126 const GURL& currently_committed_url,
127 content::NavigationHandle* navigation_handle, 127 content::NavigationHandle* navigation_handle,
128 int aborted_chain_size, 128 int aborted_chain_size,
129 int aborted_chain_size_same_url); 129 int aborted_chain_size_same_url);
130 ~PageLoadTracker(); 130 ~PageLoadTracker();
131 void WillStartNavigationRequest(content::NavigationHandle* navigation_handle);
131 void Redirect(content::NavigationHandle* navigation_handle); 132 void Redirect(content::NavigationHandle* navigation_handle);
132 void Commit(content::NavigationHandle* navigation_handle); 133 void Commit(content::NavigationHandle* navigation_handle);
133 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle); 134 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle);
134 void WebContentsHidden(); 135 void WebContentsHidden();
135 void WebContentsShown(); 136 void WebContentsShown();
136 137
137 void OnInputEvent(const blink::WebInputEvent& event); 138 void OnInputEvent(const blink::WebInputEvent& event);
138 139
139 void NotifyClientRedirectTo(const PageLoadTracker& destination); 140 void NotifyClientRedirectTo(const PageLoadTracker& destination);
140 141
(...skipping 21 matching lines...) Expand all
162 // in the 163 // in the
163 // browser process or not. We need this to possibly clamp browser timestamp on 164 // browser process or not. We need this to possibly clamp browser timestamp on
164 // a machine with inter process time tick skew. 165 // a machine with inter process time tick skew.
165 void NotifyAbort(UserAbortType abort_type, 166 void NotifyAbort(UserAbortType abort_type,
166 base::TimeTicks timestamp, 167 base::TimeTicks timestamp,
167 bool is_certainly_browser_timestamp); 168 bool is_certainly_browser_timestamp);
168 void UpdateAbort(UserAbortType abort_type, 169 void UpdateAbort(UserAbortType abort_type,
169 base::TimeTicks timestamp, 170 base::TimeTicks timestamp,
170 bool is_certainly_browser_timestamp); 171 bool is_certainly_browser_timestamp);
171 172
172 // This method returns true if this page load has been aborted with type of 173 // This method returns true if this page load has been aborted with the
173 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close 174 // |abort_cause_time| within a sufficiently close delta to when it was
174 // delta to when it was aborted. Note that only provisional loads can be 175 // aborted. This is used to update aborts with less precise abort causes like
175 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better 176 // ABORT_OTHER and ABORT_UNKNOWN_NAVIGATION. While this heuristic is coarse,
176 // and is simpler than other feasible methods. See https://goo.gl/WKRG98. 177 // it works better and is simpler than other feasible methods. See
177 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time); 178 // https://goo.gl/WKRG98.
179 bool WasAbortedRecently(base::TimeTicks abort_cause_time);
178 180
179 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle); 181 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle);
180 182
181 // Only valid to call post-commit. 183 // Only valid to call post-commit.
182 const GURL& committed_url() const { 184 const GURL& committed_url() const {
183 DCHECK(!commit_time_.is_null()); 185 DCHECK(!commit_time_.is_null());
184 return url_; 186 return url_;
185 } 187 }
186 188
187 base::TimeTicks navigation_start() const { return navigation_start_; } 189 base::TimeTicks navigation_start() const { return navigation_start_; }
188 190
189 PageLoadExtraInfo ComputePageLoadExtraInfo(); 191 PageLoadExtraInfo ComputePageLoadExtraInfo();
190 192
193 ui::PageTransition page_transition() { return page_transition_; }
Bryan McQuade 2016/07/12 16:45:29 nit: can we make this method const?
Charlie Harrison 2016/07/12 19:20:22 Done.
194
191 private: 195 private:
192 // This function converts a TimeTicks value taken in the browser process 196 // This function converts a TimeTicks value taken in the browser process
193 // to navigation_start_ if: 197 // to navigation_start_ if:
194 // - base::TimeTicks is not comparable across processes because the clock 198 // - base::TimeTicks is not comparable across processes because the clock
195 // is not system wide monotonic. 199 // is not system wide monotonic.
196 // - *event_time < navigation_start_ 200 // - *event_time < navigation_start_
197 void ClampBrowserTimestampIfInterProcessTimeTickSkew( 201 void ClampBrowserTimestampIfInterProcessTimeTickSkew(
198 base::TimeTicks* event_time); 202 base::TimeTicks* event_time);
199 203
200 void UpdateAbortInternal(UserAbortType abort_type, 204 void UpdateAbortInternal(UserAbortType abort_type,
(...skipping 27 matching lines...) Expand all
228 // We record separate metrics for events that occur after a background, 232 // We record separate metrics for events that occur after a background,
229 // because metrics like layout/paint are delayed artificially 233 // because metrics like layout/paint are delayed artificially
230 // when they occur in the background. 234 // when they occur in the background.
231 base::TimeTicks background_time_; 235 base::TimeTicks background_time_;
232 base::TimeTicks foreground_time_; 236 base::TimeTicks foreground_time_;
233 bool started_in_foreground_; 237 bool started_in_foreground_;
234 238
235 PageLoadTiming timing_; 239 PageLoadTiming timing_;
236 PageLoadMetadata metadata_; 240 PageLoadMetadata metadata_;
237 241
242 // The page transition type of this page load. This will be
243 // PAGE_TRANSITION_LAST_CORE until PageLoadTracker::WillStartRequest.
244 // TODO(csharrison): Some transitions are only known at commit time. Consider
245 // updating this member then.
246 ui::PageTransition page_transition_;
Bryan McQuade 2016/07/12 16:45:29 rather than defaulting to PAGE_TRANSITION_LAST_COR
Charlie Harrison 2016/07/12 19:20:22 Done.
247
238 // This is a subtle member. If a provisional load A gets aborted by 248 // This is a subtle member. If a provisional load A gets aborted by
239 // provisional load B, which gets aborted by C that eventually commits, then 249 // provisional load B, which gets aborted by C that eventually commits, then
240 // there exists an abort chain of length 2, starting at A's navigation_start. 250 // there exists an abort chain of length 2, starting at A's navigation_start.
241 // This is useful because it allows histograming abort chain lengths based on 251 // This is useful because it allows histograming abort chain lengths based on
242 // what the last load's transition type is. i.e. holding down F-5 to spam 252 // what the last load's transition type is. i.e. holding down F-5 to spam
243 // reload will produce a long chain with the RELOAD transition. 253 // reload will produce a long chain with the RELOAD transition.
244 const int aborted_chain_size_; 254 const int aborted_chain_size_;
245 255
246 // This member counts consecutive provisional aborts that share a url. It will 256 // This member counts consecutive provisional aborts that share a url. It will
247 // always be less than or equal to |aborted_chain_size_|. 257 // always be less than or equal to |aborted_chain_size_|.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 void DidRedirectNavigation( 292 void DidRedirectNavigation(
283 content::NavigationHandle* navigation_handle) override; 293 content::NavigationHandle* navigation_handle) override;
284 void NavigationStopped() override; 294 void NavigationStopped() override;
285 void OnInputEvent(const blink::WebInputEvent& event) override; 295 void OnInputEvent(const blink::WebInputEvent& event) override;
286 void WasShown() override; 296 void WasShown() override;
287 void WasHidden() override; 297 void WasHidden() override;
288 void RenderProcessGone(base::TerminationStatus status) override; 298 void RenderProcessGone(base::TerminationStatus status) override;
289 void RenderViewHostChanged(content::RenderViewHost* old_host, 299 void RenderViewHostChanged(content::RenderViewHost* old_host,
290 content::RenderViewHost* new_host) override; 300 content::RenderViewHost* new_host) override;
291 301
302 // Forwarded call from a navigation throttle.
303 void WillStartNavigationRequest(content::NavigationHandle* navigation_handle);
304
292 // This getter function is required for testing. 305 // This getter function is required for testing.
293 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); 306 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad();
294 307
295 private: 308 private:
296 friend class content::WebContentsUserData<MetricsWebContentsObserver>; 309 friend class content::WebContentsUserData<MetricsWebContentsObserver>;
297 310
298 // Notify all loads, provisional and committed, that we performed an action 311 // Notify all loads, provisional and committed, that we performed an action
299 // that might abort them. 312 // that might abort them.
300 void NotifyAbortAllLoads(UserAbortType abort_type); 313 void NotifyAbortAllLoads(UserAbortType abort_type);
301 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, 314 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type,
302 base::TimeTicks timestamp, 315 base::TimeTicks timestamp,
303 bool is_certainly_browser_timestamp); 316 bool is_certainly_browser_timestamp);
304 317
305 // Register / Unregister input event callback to given RenderViewHost 318 // Register / Unregister input event callback to given RenderViewHost
306 void RegisterInputEventObserver(content::RenderViewHost* host); 319 void RegisterInputEventObserver(content::RenderViewHost* host);
307 void UnregisterInputEventObserver(content::RenderViewHost* host); 320 void UnregisterInputEventObserver(content::RenderViewHost* host);
308 321
309 // Notify aborted provisional loads that a new navigation occurred. This is 322 // Notify aborted provisional loads that a new navigation occurred. This is
310 // used for more consistent attribution tracking for aborted provisional 323 // used for more consistent attribution tracking for aborted provisional
311 // loads. This method returns the provisional load that was likely aborted 324 // loads.
312 // by this navigation, to help instantiate the new PageLoadTracker. 325 void NotifyAbortedProvisionalLoadsNewNavigation(
313 std::unique_ptr<PageLoadTracker> NotifyAbortedProvisionalLoadsNewNavigation( 326 PageLoadTracker* new_navigation);
314 content::NavigationHandle* new_navigation);
315 327
316 void OnTimingUpdated(content::RenderFrameHost*, 328 void OnTimingUpdated(content::RenderFrameHost*,
317 const PageLoadTiming& timing, 329 const PageLoadTiming& timing,
318 const PageLoadMetadata& metadata); 330 const PageLoadMetadata& metadata);
319 331
320 // True if the web contents is currently in the foreground. 332 // True if the web contents is currently in the foreground.
321 bool in_foreground_; 333 bool in_foreground_;
322 334
323 // The PageLoadTrackers must be deleted before the |embedder_interface_|, 335 // The PageLoadTrackers must be deleted before the |embedder_interface_|,
324 // because they hold a pointer to the |embedder_interface_|. 336 // because they hold a pointer to the |embedder_interface_|.
(...skipping 17 matching lines...) Expand all
342 354
343 // Has the MWCO observed at least one navigation? 355 // Has the MWCO observed at least one navigation?
344 bool has_navigated_; 356 bool has_navigated_;
345 357
346 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); 358 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);
347 }; 359 };
348 360
349 } // namespace page_load_metrics 361 } // namespace page_load_metrics
350 362
351 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ 363 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698