| 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 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 // A new navigation triggers abort updates in multiple trackers in | 86 // A new navigation triggers abort updates in multiple trackers in |
| 87 // |aborted_provisional_loads_|, when usually there should only be one (the | 87 // |aborted_provisional_loads_|, when usually there should only be one (the |
| 88 // navigation that just aborted because of this one). If this happens, the | 88 // navigation that just aborted because of this one). If this happens, the |
| 89 // latest aborted load is used to track the chain size. | 89 // latest aborted load is used to track the chain size. |
| 90 ERR_NAVIGATION_SIGNALS_MULIPLE_ABORTED_LOADS, | 90 ERR_NAVIGATION_SIGNALS_MULIPLE_ABORTED_LOADS, |
| 91 | 91 |
| 92 // Receives user input before navigation start | 92 // Receives user input before navigation start |
| 93 ERR_USER_INPUT_WITH_NO_RELEVANT_LOAD, | 93 ERR_USER_INPUT_WITH_NO_RELEVANT_LOAD, |
| 94 | 94 |
| 95 // A TimeTicks value in the browser process has value less than |
| 96 // navigation_start_. This could happen if navigation_start_ was computed in |
| 97 // renderer process and the system clock has inter process time tick skew. |
| 98 ERR_INTER_PROCESS_TIME_TICK_SKEW, |
| 99 |
| 95 // Add values before this final count. | 100 // Add values before this final count. |
| 96 ERR_LAST_ENTRY, | 101 ERR_LAST_ENTRY, |
| 97 }; | 102 }; |
| 98 | 103 |
| 99 // This class serves as a functional interface to various chrome// features. | 104 // This class serves as a functional interface to various chrome// features. |
| 100 // Impl version is defined in chrome/browser/page_load_metrics. | 105 // Impl version is defined in chrome/browser/page_load_metrics. |
| 101 class PageLoadMetricsEmbedderInterface { | 106 class PageLoadMetricsEmbedderInterface { |
| 102 public: | 107 public: |
| 103 virtual ~PageLoadMetricsEmbedderInterface() {} | 108 virtual ~PageLoadMetricsEmbedderInterface() {} |
| 104 virtual bool IsPrerendering(content::WebContents* web_contents) = 0; | 109 virtual bool IsPrerendering(content::WebContents* web_contents) = 0; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 148 } |
| 144 | 149 |
| 145 UserAbortType abort_type() const { return abort_type_; } | 150 UserAbortType abort_type() const { return abort_type_; } |
| 146 base::TimeTicks abort_time() const { return abort_time_; } | 151 base::TimeTicks abort_time() const { return abort_time_; } |
| 147 | 152 |
| 148 void AddObserver(std::unique_ptr<PageLoadMetricsObserver> observer); | 153 void AddObserver(std::unique_ptr<PageLoadMetricsObserver> observer); |
| 149 | 154 |
| 150 // If the user performs some abort-like action while we are tracking this page | 155 // If the user performs some abort-like action while we are tracking this page |
| 151 // load, notify the tracker. Note that we may not classify this as an abort if | 156 // load, notify the tracker. Note that we may not classify this as an abort if |
| 152 // we've already performed a first paint. | 157 // we've already performed a first paint. |
| 153 void NotifyAbort(UserAbortType abort_type, base::TimeTicks timestamp); | 158 // is_certainly_browser_timestamp signifies if the timestamp passed is taken |
| 154 void UpdateAbort(UserAbortType abort_type, base::TimeTicks timestamp); | 159 // in the |
| 160 // browser process or not. We need this to possibly clamp browser timestamp on |
| 161 // a machine with inter process time tick skew. |
| 162 void NotifyAbort(UserAbortType abort_type, |
| 163 base::TimeTicks timestamp, |
| 164 bool is_certainly_browser_timestamp); |
| 165 void UpdateAbort(UserAbortType abort_type, |
| 166 base::TimeTicks timestamp, |
| 167 bool is_certainly_browser_timestamp); |
| 155 | 168 |
| 156 // This method returns true if this page load has been aborted with type of | 169 // This method returns true if this page load has been aborted with type of |
| 157 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close | 170 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close |
| 158 // delta to when it was aborted. Note that only provisional loads can be | 171 // delta to when it was aborted. Note that only provisional loads can be |
| 159 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better | 172 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better |
| 160 // and is simpler than other feasible methods. See https://goo.gl/WKRG98. | 173 // and is simpler than other feasible methods. See https://goo.gl/WKRG98. |
| 161 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time); | 174 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time); |
| 162 | 175 |
| 163 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle); | 176 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle); |
| 164 | 177 |
| 165 // Only valid to call post-commit. | 178 // Only valid to call post-commit. |
| 166 const GURL& committed_url() const { | 179 const GURL& committed_url() const { |
| 167 DCHECK(!commit_time_.is_null()); | 180 DCHECK(!commit_time_.is_null()); |
| 168 return url_; | 181 return url_; |
| 169 } | 182 } |
| 170 | 183 |
| 184 PageLoadExtraInfo ComputePageLoadExtraInfo(); |
| 185 |
| 171 private: | 186 private: |
| 172 PageLoadExtraInfo GetPageLoadMetricsInfo(); | 187 // This function converts a TimeTicks value taken in the browser process |
| 188 // to navigation_start_ if: |
| 189 // - base::TimeTicks is not comparable across processes because the clock |
| 190 // is not system wide monotonic. |
| 191 // - *event_time < navigation_start_ |
| 192 void ClampBrowserTimestampIfInterProcessTimeTickSkew( |
| 193 base::TimeTicks* event_time); |
| 173 | 194 |
| 174 void UpdateAbortInternal(UserAbortType abort_type, | 195 void UpdateAbortInternal(UserAbortType abort_type, |
| 175 base::TimeTicks timestamp); | 196 base::TimeTicks timestamp, |
| 197 bool is_certainly_browser_timestamp); |
| 176 | 198 |
| 177 // If |final_navigation| is null, then this is an "unparented" abort chain, | 199 // If |final_navigation| is null, then this is an "unparented" abort chain, |
| 178 // and represents a sequence of provisional aborts that never ends with a | 200 // and represents a sequence of provisional aborts that never ends with a |
| 179 // committed load. | 201 // committed load. |
| 180 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); | 202 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); |
| 181 | 203 |
| 182 // Whether the renderer should be sending timing IPCs to this page load. | 204 // Whether the renderer should be sending timing IPCs to this page load. |
| 183 bool renderer_tracked_; | 205 bool renderer_tracked_; |
| 184 | 206 |
| 185 // The navigation start in TimeTicks, not the wall time reported by Blink. | 207 // The navigation start in TimeTicks, not the wall time reported by Blink. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 void DidRedirectNavigation( | 277 void DidRedirectNavigation( |
| 256 content::NavigationHandle* navigation_handle) override; | 278 content::NavigationHandle* navigation_handle) override; |
| 257 void NavigationStopped() override; | 279 void NavigationStopped() override; |
| 258 void OnInputEvent(const blink::WebInputEvent& event) override; | 280 void OnInputEvent(const blink::WebInputEvent& event) override; |
| 259 void WasShown() override; | 281 void WasShown() override; |
| 260 void WasHidden() override; | 282 void WasHidden() override; |
| 261 void RenderProcessGone(base::TerminationStatus status) override; | 283 void RenderProcessGone(base::TerminationStatus status) override; |
| 262 void RenderViewHostChanged(content::RenderViewHost* old_host, | 284 void RenderViewHostChanged(content::RenderViewHost* old_host, |
| 263 content::RenderViewHost* new_host) override; | 285 content::RenderViewHost* new_host) override; |
| 264 | 286 |
| 287 // This getter function is required for testing. |
| 288 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); |
| 289 |
| 265 private: | 290 private: |
| 266 friend class content::WebContentsUserData<MetricsWebContentsObserver>; | 291 friend class content::WebContentsUserData<MetricsWebContentsObserver>; |
| 267 | 292 |
| 268 // Notify all loads, provisional and committed, that we performed an action | 293 // Notify all loads, provisional and committed, that we performed an action |
| 269 // that might abort them. | 294 // that might abort them. |
| 270 void NotifyAbortAllLoads(UserAbortType abort_type); | 295 void NotifyAbortAllLoads(UserAbortType abort_type); |
| 271 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, | 296 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, |
| 272 base::TimeTicks timestamp); | 297 base::TimeTicks timestamp, |
| 298 bool is_certainly_browser_timestamp); |
| 273 | 299 |
| 274 // Register / Unregister input event callback to given RenderViewHost | 300 // Register / Unregister input event callback to given RenderViewHost |
| 275 void RegisterInputEventObserver(content::RenderViewHost* host); | 301 void RegisterInputEventObserver(content::RenderViewHost* host); |
| 276 void UnregisterInputEventObserver(content::RenderViewHost* host); | 302 void UnregisterInputEventObserver(content::RenderViewHost* host); |
| 277 | 303 |
| 278 // Notify aborted provisional loads that a new navigation occurred. This is | 304 // Notify aborted provisional loads that a new navigation occurred. This is |
| 279 // used for more consistent attribution tracking for aborted provisional | 305 // used for more consistent attribution tracking for aborted provisional |
| 280 // loads. This method returns the provisional load that was likely aborted | 306 // loads. This method returns the provisional load that was likely aborted |
| 281 // by this navigation, to help instantiate the new PageLoadTracker. | 307 // by this navigation, to help instantiate the new PageLoadTracker. |
| 282 std::unique_ptr<PageLoadTracker> NotifyAbortedProvisionalLoadsNewNavigation( | 308 std::unique_ptr<PageLoadTracker> NotifyAbortedProvisionalLoadsNewNavigation( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 311 | 337 |
| 312 // Has the MWCO observed at least one navigation? | 338 // Has the MWCO observed at least one navigation? |
| 313 bool has_navigated_; | 339 bool has_navigated_; |
| 314 | 340 |
| 315 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 341 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
| 316 }; | 342 }; |
| 317 | 343 |
| 318 } // namespace page_load_metrics | 344 } // namespace page_load_metrics |
| 319 | 345 |
| 320 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ | 346 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ |
| OLD | NEW |