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

Side by Side Diff: chrome/browser/page_load_metrics/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: nasko@ nits Created 4 years, 4 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 CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_
6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 bool is_certainly_browser_timestamp); 183 bool is_certainly_browser_timestamp);
184 void UpdateAbort(UserAbortType abort_type, 184 void UpdateAbort(UserAbortType abort_type,
185 base::TimeTicks timestamp, 185 base::TimeTicks timestamp,
186 bool is_certainly_browser_timestamp); 186 bool is_certainly_browser_timestamp);
187 187
188 // This method returns true if this page load has been aborted with type of 188 // This method returns true if this page load has been aborted with type of
189 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close 189 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close
190 // delta to when it was aborted. Note that only provisional loads can be 190 // delta to when it was aborted. Note that only provisional loads can be
191 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better 191 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better
192 // and is simpler than other feasible methods. See https://goo.gl/WKRG98. 192 // and is simpler than other feasible methods. See https://goo.gl/WKRG98.
193 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time); 193 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time) const;
194 194
195 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle); 195 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle);
196 196
197 // Only valid to call post-commit. 197 // Only valid to call post-commit.
198 const GURL& committed_url() const { 198 const GURL& committed_url() const {
199 DCHECK(!commit_time_.is_null()); 199 DCHECK(!commit_time_.is_null());
200 return url_; 200 return url_;
201 } 201 }
202 202
203 base::TimeTicks navigation_start() const { return navigation_start_; } 203 base::TimeTicks navigation_start() const { return navigation_start_; }
204 204
205 PageLoadExtraInfo ComputePageLoadExtraInfo(); 205 PageLoadExtraInfo ComputePageLoadExtraInfo();
206 206
207 ui::PageTransition page_transition() const { return page_transition_; }
208
207 private: 209 private:
208 // This function converts a TimeTicks value taken in the browser process 210 // This function converts a TimeTicks value taken in the browser process
209 // to navigation_start_ if: 211 // to navigation_start_ if:
210 // - base::TimeTicks is not comparable across processes because the clock 212 // - base::TimeTicks is not comparable across processes because the clock
211 // is not system wide monotonic. 213 // is not system wide monotonic.
212 // - *event_time < navigation_start_ 214 // - *event_time < navigation_start_
213 void ClampBrowserTimestampIfInterProcessTimeTickSkew( 215 void ClampBrowserTimestampIfInterProcessTimeTickSkew(
214 base::TimeTicks* event_time); 216 base::TimeTicks* event_time);
215 217
216 void UpdateAbortInternal(UserAbortType abort_type, 218 void UpdateAbortInternal(UserAbortType abort_type,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // We record separate metrics for events that occur after a background, 254 // We record separate metrics for events that occur after a background,
253 // because metrics like layout/paint are delayed artificially 255 // because metrics like layout/paint are delayed artificially
254 // when they occur in the background. 256 // when they occur in the background.
255 base::TimeTicks background_time_; 257 base::TimeTicks background_time_;
256 base::TimeTicks foreground_time_; 258 base::TimeTicks foreground_time_;
257 bool started_in_foreground_; 259 bool started_in_foreground_;
258 260
259 PageLoadTiming timing_; 261 PageLoadTiming timing_;
260 PageLoadMetadata metadata_; 262 PageLoadMetadata metadata_;
261 263
264 ui::PageTransition page_transition_;
265
262 // This is a subtle member. If a provisional load A gets aborted by 266 // This is a subtle member. If a provisional load A gets aborted by
263 // provisional load B, which gets aborted by C that eventually commits, then 267 // provisional load B, which gets aborted by C that eventually commits, then
264 // there exists an abort chain of length 2, starting at A's navigation_start. 268 // there exists an abort chain of length 2, starting at A's navigation_start.
265 // This is useful because it allows histograming abort chain lengths based on 269 // This is useful because it allows histograming abort chain lengths based on
266 // what the last load's transition type is. i.e. holding down F-5 to spam 270 // what the last load's transition type is. i.e. holding down F-5 to spam
267 // reload will produce a long chain with the RELOAD transition. 271 // reload will produce a long chain with the RELOAD transition.
268 const int aborted_chain_size_; 272 const int aborted_chain_size_;
269 273
270 // This member counts consecutive provisional aborts that share a url. It will 274 // This member counts consecutive provisional aborts that share a url. It will
271 // always be less than or equal to |aborted_chain_size_|. 275 // always be less than or equal to |aborted_chain_size_|.
(...skipping 20 matching lines...) Expand all
292 content::WebContents* web_contents, 296 content::WebContents* web_contents,
293 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface); 297 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface);
294 MetricsWebContentsObserver( 298 MetricsWebContentsObserver(
295 content::WebContents* web_contents, 299 content::WebContents* web_contents,
296 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface); 300 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface);
297 ~MetricsWebContentsObserver() override; 301 ~MetricsWebContentsObserver() override;
298 302
299 // content::WebContentsObserver implementation: 303 // content::WebContentsObserver implementation:
300 bool OnMessageReceived(const IPC::Message& message, 304 bool OnMessageReceived(const IPC::Message& message,
301 content::RenderFrameHost* render_frame_host) override; 305 content::RenderFrameHost* render_frame_host) override;
302 void DidStartNavigation(
303 content::NavigationHandle* navigation_handle) override;
304 void DidFinishNavigation( 306 void DidFinishNavigation(
305 content::NavigationHandle* navigation_handle) override; 307 content::NavigationHandle* navigation_handle) override;
306 void DidRedirectNavigation( 308 void DidRedirectNavigation(
307 content::NavigationHandle* navigation_handle) override; 309 content::NavigationHandle* navigation_handle) override;
308 void NavigationStopped() override; 310 void NavigationStopped() override;
309 void OnInputEvent(const blink::WebInputEvent& event) override; 311 void OnInputEvent(const blink::WebInputEvent& event) override;
310 void WasShown() override; 312 void WasShown() override;
311 void WasHidden() override; 313 void WasHidden() override;
312 void RenderProcessGone(base::TerminationStatus status) override; 314 void RenderProcessGone(base::TerminationStatus status) override;
313 void RenderViewHostChanged(content::RenderViewHost* old_host, 315 void RenderViewHostChanged(content::RenderViewHost* old_host,
314 content::RenderViewHost* new_host) override; 316 content::RenderViewHost* new_host) override;
315 317
318 // This method is forwarded from the MetricsNavigationThrottle.
319 void WillStartNavigationRequest(content::NavigationHandle* navigation_handle);
320
316 // Flush any buffered metrics, as part of the metrics subsystem persisting 321 // Flush any buffered metrics, as part of the metrics subsystem persisting
317 // metrics as the application goes into the background. The application may be 322 // metrics as the application goes into the background. The application may be
318 // killed at any time after this method is invoked without further 323 // killed at any time after this method is invoked without further
319 // notification. 324 // notification.
320 void FlushMetricsOnAppEnterBackground(); 325 void FlushMetricsOnAppEnterBackground();
321 326
322 // This getter function is required for testing. 327 // This getter function is required for testing.
323 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); 328 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad();
324 329
325 private: 330 private:
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 388
384 // Has the MWCO observed at least one navigation? 389 // Has the MWCO observed at least one navigation?
385 bool has_navigated_; 390 bool has_navigated_;
386 391
387 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); 392 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);
388 }; 393 };
389 394
390 } // namespace page_load_metrics 395 } // namespace page_load_metrics
391 396
392 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ 397 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698