Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 int aborted_chain_size_same_url); | 132 int aborted_chain_size_same_url); |
| 133 ~PageLoadTracker(); | 133 ~PageLoadTracker(); |
| 134 void Redirect(content::NavigationHandle* navigation_handle); | 134 void Redirect(content::NavigationHandle* navigation_handle); |
| 135 void Commit(content::NavigationHandle* navigation_handle); | 135 void Commit(content::NavigationHandle* navigation_handle); |
| 136 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle); | 136 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle); |
| 137 void WebContentsHidden(); | 137 void WebContentsHidden(); |
| 138 void WebContentsShown(); | 138 void WebContentsShown(); |
| 139 | 139 |
| 140 void OnInputEvent(const blink::WebInputEvent& event); | 140 void OnInputEvent(const blink::WebInputEvent& event); |
| 141 | 141 |
| 142 void FlushMetricsOnAppEnterBackground(); | |
| 143 | |
| 142 void NotifyClientRedirectTo(const PageLoadTracker& destination); | 144 void NotifyClientRedirectTo(const PageLoadTracker& destination); |
| 143 | 145 |
| 144 // Returns true if the timing was successfully updated. | 146 // Returns true if the timing was successfully updated. |
| 145 bool UpdateTiming(const PageLoadTiming& timing, | 147 bool UpdateTiming(const PageLoadTiming& timing, |
| 146 const PageLoadMetadata& metadata); | 148 const PageLoadMetadata& metadata); |
| 147 | 149 |
| 148 // Signals that we should stop tracking metrics for the associated page load. | 150 // Signals that we should stop tracking metrics for the associated page load. |
| 149 // We may stop tracking a page load if it doesn't meet the criteria for | 151 // We may stop tracking a page load if it doesn't meet the criteria for |
| 150 // tracking metrics in DidFinishNavigation. | 152 // tracking metrics in DidFinishNavigation. |
| 151 void StopTracking(); | 153 void StopTracking(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 // If |final_navigation| is null, then this is an "unparented" abort chain, | 211 // If |final_navigation| is null, then this is an "unparented" abort chain, |
| 210 // and represents a sequence of provisional aborts that never ends with a | 212 // and represents a sequence of provisional aborts that never ends with a |
| 211 // committed load. | 213 // committed load. |
| 212 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); | 214 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); |
| 213 | 215 |
| 214 // Whether we stopped tracking this navigation after it was initiated. We may | 216 // Whether we stopped tracking this navigation after it was initiated. We may |
| 215 // stop tracking a navigation if it doesn't meet the criteria for tracking | 217 // stop tracking a navigation if it doesn't meet the criteria for tracking |
| 216 // metrics in DidFinishNavigation. | 218 // metrics in DidFinishNavigation. |
| 217 bool did_stop_tracking_; | 219 bool did_stop_tracking_; |
| 218 | 220 |
| 221 // Whether the application went into the background when this PageLoadTracker | |
| 222 // was active. This is a temporary boolean for UMA tracking. | |
| 223 bool app_entered_background_; | |
| 224 | |
| 219 // The navigation start in TimeTicks, not the wall time reported by Blink. | 225 // The navigation start in TimeTicks, not the wall time reported by Blink. |
| 220 const base::TimeTicks navigation_start_; | 226 const base::TimeTicks navigation_start_; |
| 221 | 227 |
| 222 // Time this page load was committed. If this page load hasn't committed, | 228 // Time this page load was committed. If this page load hasn't committed, |
| 223 // |commit_time_| will be zero. | 229 // |commit_time_| will be zero. |
| 224 base::TimeTicks commit_time_; | 230 base::TimeTicks commit_time_; |
| 225 | 231 |
| 226 // The URL of this page load. This is the provisional url before commit | 232 // The URL of this page load. This is the provisional url before commit |
| 227 // (before redirects), and the committed url after commit. | 233 // (before redirects), and the committed url after commit. |
| 228 GURL url_; | 234 GURL url_; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 public: | 280 public: |
| 275 // Note that the returned metrics is owned by the web contents. | 281 // Note that the returned metrics is owned by the web contents. |
| 276 static MetricsWebContentsObserver* CreateForWebContents( | 282 static MetricsWebContentsObserver* CreateForWebContents( |
| 277 content::WebContents* web_contents, | 283 content::WebContents* web_contents, |
| 278 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface); | 284 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface); |
| 279 MetricsWebContentsObserver( | 285 MetricsWebContentsObserver( |
| 280 content::WebContents* web_contents, | 286 content::WebContents* web_contents, |
| 281 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface); | 287 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface); |
| 282 ~MetricsWebContentsObserver() override; | 288 ~MetricsWebContentsObserver() override; |
| 283 | 289 |
| 290 // Returns all currently active MetricsWebContentsObservers. Callers should | |
| 291 // not hold on to the returned observers beyond the scope of the current | |
| 292 // function, as the MetricsWebContentsObservers may be destroyed as their | |
| 293 // associated WebContents are destroyed. | |
| 294 static std::vector<MetricsWebContentsObserver*> GetAllObservers(); | |
| 295 | |
| 284 // content::WebContentsObserver implementation: | 296 // content::WebContentsObserver implementation: |
| 285 bool OnMessageReceived(const IPC::Message& message, | 297 bool OnMessageReceived(const IPC::Message& message, |
| 286 content::RenderFrameHost* render_frame_host) override; | 298 content::RenderFrameHost* render_frame_host) override; |
| 287 void DidStartNavigation( | 299 void DidStartNavigation( |
| 288 content::NavigationHandle* navigation_handle) override; | 300 content::NavigationHandle* navigation_handle) override; |
| 289 void DidFinishNavigation( | 301 void DidFinishNavigation( |
| 290 content::NavigationHandle* navigation_handle) override; | 302 content::NavigationHandle* navigation_handle) override; |
| 291 void DidRedirectNavigation( | 303 void DidRedirectNavigation( |
| 292 content::NavigationHandle* navigation_handle) override; | 304 content::NavigationHandle* navigation_handle) override; |
| 293 void NavigationStopped() override; | 305 void NavigationStopped() override; |
| 294 void OnInputEvent(const blink::WebInputEvent& event) override; | 306 void OnInputEvent(const blink::WebInputEvent& event) override; |
| 295 void WasShown() override; | 307 void WasShown() override; |
| 296 void WasHidden() override; | 308 void WasHidden() override; |
| 297 void RenderProcessGone(base::TerminationStatus status) override; | 309 void RenderProcessGone(base::TerminationStatus status) override; |
| 298 void RenderViewHostChanged(content::RenderViewHost* old_host, | 310 void RenderViewHostChanged(content::RenderViewHost* old_host, |
| 299 content::RenderViewHost* new_host) override; | 311 content::RenderViewHost* new_host) override; |
| 300 | 312 |
| 313 void FlushMetricsOnAppEnterBackground(); | |
|
Charlie Harrison
2016/07/28 14:45:28
Do we need to include "flush metrics" in the name?
Bryan McQuade
2016/07/28 16:26:11
Yeah - I debated this. Technically, this method is
Charlie Harrison
2016/07/28 16:38:04
SGTM.
| |
| 314 | |
| 301 // This getter function is required for testing. | 315 // This getter function is required for testing. |
| 302 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); | 316 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); |
| 303 | 317 |
| 304 private: | 318 private: |
| 305 friend class content::WebContentsUserData<MetricsWebContentsObserver>; | 319 friend class content::WebContentsUserData<MetricsWebContentsObserver>; |
| 306 | 320 |
| 307 void HandleFailedNavigationForTrackedLoad( | 321 void HandleFailedNavigationForTrackedLoad( |
| 308 content::NavigationHandle* navigation_handle, | 322 content::NavigationHandle* navigation_handle, |
| 309 std::unique_ptr<PageLoadTracker> tracker); | 323 std::unique_ptr<PageLoadTracker> tracker); |
| 310 | 324 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 | 376 |
| 363 // Has the MWCO observed at least one navigation? | 377 // Has the MWCO observed at least one navigation? |
| 364 bool has_navigated_; | 378 bool has_navigated_; |
| 365 | 379 |
| 366 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 380 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
| 367 }; | 381 }; |
| 368 | 382 |
| 369 } // namespace page_load_metrics | 383 } // namespace page_load_metrics |
| 370 | 384 |
| 371 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ | 385 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ |
| OLD | NEW |