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

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: Attach the throttle first so it gets all notifications before any DEFERs 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 bool is_certainly_browser_timestamp); 172 bool is_certainly_browser_timestamp);
173 void UpdateAbort(UserAbortType abort_type, 173 void UpdateAbort(UserAbortType abort_type,
174 base::TimeTicks timestamp, 174 base::TimeTicks timestamp,
175 bool is_certainly_browser_timestamp); 175 bool is_certainly_browser_timestamp);
176 176
177 // This method returns true if this page load has been aborted with type of 177 // This method returns true if this page load has been aborted with type of
178 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close 178 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close
179 // delta to when it was aborted. Note that only provisional loads can be 179 // delta to when it was aborted. Note that only provisional loads can be
180 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better 180 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better
181 // and is simpler than other feasible methods. See https://goo.gl/WKRG98. 181 // and is simpler than other feasible methods. See https://goo.gl/WKRG98.
182 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time); 182 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time) const;
183 183
184 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle); 184 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle);
185 185
186 // Only valid to call post-commit. 186 // Only valid to call post-commit.
187 const GURL& committed_url() const { 187 const GURL& committed_url() const {
188 DCHECK(!commit_time_.is_null()); 188 DCHECK(!commit_time_.is_null());
189 return url_; 189 return url_;
190 } 190 }
191 191
192 base::TimeTicks navigation_start() const { return navigation_start_; } 192 base::TimeTicks navigation_start() const { return navigation_start_; }
193 193
194 PageLoadExtraInfo ComputePageLoadExtraInfo(); 194 PageLoadExtraInfo ComputePageLoadExtraInfo();
195 195
196 ui::PageTransition page_transition() const { return page_transition_; }
197
196 private: 198 private:
197 // This function converts a TimeTicks value taken in the browser process 199 // This function converts a TimeTicks value taken in the browser process
198 // to navigation_start_ if: 200 // to navigation_start_ if:
199 // - base::TimeTicks is not comparable across processes because the clock 201 // - base::TimeTicks is not comparable across processes because the clock
200 // is not system wide monotonic. 202 // is not system wide monotonic.
201 // - *event_time < navigation_start_ 203 // - *event_time < navigation_start_
202 void ClampBrowserTimestampIfInterProcessTimeTickSkew( 204 void ClampBrowserTimestampIfInterProcessTimeTickSkew(
203 base::TimeTicks* event_time); 205 base::TimeTicks* event_time);
204 206
205 void UpdateAbortInternal(UserAbortType abort_type, 207 void UpdateAbortInternal(UserAbortType abort_type,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // We record separate metrics for events that occur after a background, 239 // We record separate metrics for events that occur after a background,
238 // because metrics like layout/paint are delayed artificially 240 // because metrics like layout/paint are delayed artificially
239 // when they occur in the background. 241 // when they occur in the background.
240 base::TimeTicks background_time_; 242 base::TimeTicks background_time_;
241 base::TimeTicks foreground_time_; 243 base::TimeTicks foreground_time_;
242 bool started_in_foreground_; 244 bool started_in_foreground_;
243 245
244 PageLoadTiming timing_; 246 PageLoadTiming timing_;
245 PageLoadMetadata metadata_; 247 PageLoadMetadata metadata_;
246 248
249 ui::PageTransition page_transition_;
250
247 // This is a subtle member. If a provisional load A gets aborted by 251 // This is a subtle member. If a provisional load A gets aborted by
248 // provisional load B, which gets aborted by C that eventually commits, then 252 // provisional load B, which gets aborted by C that eventually commits, then
249 // there exists an abort chain of length 2, starting at A's navigation_start. 253 // there exists an abort chain of length 2, starting at A's navigation_start.
250 // This is useful because it allows histograming abort chain lengths based on 254 // This is useful because it allows histograming abort chain lengths based on
251 // what the last load's transition type is. i.e. holding down F-5 to spam 255 // what the last load's transition type is. i.e. holding down F-5 to spam
252 // reload will produce a long chain with the RELOAD transition. 256 // reload will produce a long chain with the RELOAD transition.
253 const int aborted_chain_size_; 257 const int aborted_chain_size_;
254 258
255 // This member counts consecutive provisional aborts that share a url. It will 259 // This member counts consecutive provisional aborts that share a url. It will
256 // always be less than or equal to |aborted_chain_size_|. 260 // always be less than or equal to |aborted_chain_size_|.
(...skipping 20 matching lines...) Expand all
277 content::WebContents* web_contents, 281 content::WebContents* web_contents,
278 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface); 282 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface);
279 MetricsWebContentsObserver( 283 MetricsWebContentsObserver(
280 content::WebContents* web_contents, 284 content::WebContents* web_contents,
281 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface); 285 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface);
282 ~MetricsWebContentsObserver() override; 286 ~MetricsWebContentsObserver() override;
283 287
284 // content::WebContentsObserver implementation: 288 // content::WebContentsObserver implementation:
285 bool OnMessageReceived(const IPC::Message& message, 289 bool OnMessageReceived(const IPC::Message& message,
286 content::RenderFrameHost* render_frame_host) override; 290 content::RenderFrameHost* render_frame_host) override;
287 void DidStartNavigation(
288 content::NavigationHandle* navigation_handle) override;
289 void DidFinishNavigation( 291 void DidFinishNavigation(
290 content::NavigationHandle* navigation_handle) override; 292 content::NavigationHandle* navigation_handle) override;
291 void DidRedirectNavigation( 293 void DidRedirectNavigation(
292 content::NavigationHandle* navigation_handle) override; 294 content::NavigationHandle* navigation_handle) override;
293 void NavigationStopped() override; 295 void NavigationStopped() override;
294 void OnInputEvent(const blink::WebInputEvent& event) override; 296 void OnInputEvent(const blink::WebInputEvent& event) override;
295 void WasShown() override; 297 void WasShown() override;
296 void WasHidden() override; 298 void WasHidden() override;
297 void RenderProcessGone(base::TerminationStatus status) override; 299 void RenderProcessGone(base::TerminationStatus status) override;
298 void RenderViewHostChanged(content::RenderViewHost* old_host, 300 void RenderViewHostChanged(content::RenderViewHost* old_host,
299 content::RenderViewHost* new_host) override; 301 content::RenderViewHost* new_host) override;
300 302
303 // This method is forwarded from the MetricsNavigationThrottle.
304 void WillStartNavigationRequest(content::NavigationHandle* navigation_handle);
305
301 // This getter function is required for testing. 306 // This getter function is required for testing.
302 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); 307 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad();
303 308
304 private: 309 private:
305 friend class content::WebContentsUserData<MetricsWebContentsObserver>; 310 friend class content::WebContentsUserData<MetricsWebContentsObserver>;
306 311
307 void HandleFailedNavigationForTrackedLoad( 312 void HandleFailedNavigationForTrackedLoad(
308 content::NavigationHandle* navigation_handle, 313 content::NavigationHandle* navigation_handle,
309 std::unique_ptr<PageLoadTracker> tracker); 314 std::unique_ptr<PageLoadTracker> tracker);
310 315
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 367
363 // Has the MWCO observed at least one navigation? 368 // Has the MWCO observed at least one navigation?
364 bool has_navigated_; 369 bool has_navigated_;
365 370
366 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); 371 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);
367 }; 372 };
368 373
369 } // namespace page_load_metrics 374 } // namespace page_load_metrics
370 375
371 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ 376 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698