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 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 // cc file for details). We use this error counter to understand how often it | 80 // cc file for details). We use this error counter to understand how often it |
| 81 // happens. | 81 // happens. |
| 82 ERR_ABORT_BEFORE_NAVIGATION_START, | 82 ERR_ABORT_BEFORE_NAVIGATION_START, |
| 83 | 83 |
| 84 // A new navigation triggers abort updates in multiple trackers in | 84 // A new navigation triggers abort updates in multiple trackers in |
| 85 // |aborted_provisional_loads_|, when usually there should only be one (the | 85 // |aborted_provisional_loads_|, when usually there should only be one (the |
| 86 // navigation that just aborted because of this one). If this happens, the | 86 // navigation that just aborted because of this one). If this happens, the |
| 87 // latest aborted load is used to track the chain size. | 87 // latest aborted load is used to track the chain size. |
| 88 ERR_NAVIGATION_SIGNALS_MULIPLE_ABORTED_LOADS, | 88 ERR_NAVIGATION_SIGNALS_MULIPLE_ABORTED_LOADS, |
| 89 | 89 |
| 90 // A TimeTicks value in the browser process has value less than | |
| 91 // navigation_start_. This could happen if the navigation_start_ was computed | |
| 92 // in the renderer process and the system clock has inter process time tick | |
| 93 // skew. | |
| 94 ERR_INTER_PROCESS_TIME_TICK_SKEW, | |
|
Charlie Harrison
2016/05/24 19:32:01
Looks like you need to update histograms.xml with
shivanisha
2016/05/24 20:09:56
Done. Thanks.
| |
| 95 | |
| 90 // Add values before this final count. | 96 // Add values before this final count. |
| 91 ERR_LAST_ENTRY | 97 ERR_LAST_ENTRY |
| 92 }; | 98 }; |
| 93 | 99 |
| 94 // This class serves as a functional interface to various chrome// features. | 100 // This class serves as a functional interface to various chrome// features. |
| 95 // Impl version is defined in chrome/browser/page_load_metrics. | 101 // Impl version is defined in chrome/browser/page_load_metrics. |
| 96 class PageLoadMetricsEmbedderInterface { | 102 class PageLoadMetricsEmbedderInterface { |
| 97 public: | 103 public: |
| 98 virtual ~PageLoadMetricsEmbedderInterface() {} | 104 virtual ~PageLoadMetricsEmbedderInterface() {} |
| 99 virtual bool IsPrerendering(content::WebContents* web_contents) = 0; | 105 virtual bool IsPrerendering(content::WebContents* web_contents) = 0; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 } | 142 } |
| 137 | 143 |
| 138 UserAbortType abort_type() const { return abort_type_; } | 144 UserAbortType abort_type() const { return abort_type_; } |
| 139 base::TimeTicks abort_time() const { return abort_time_; } | 145 base::TimeTicks abort_time() const { return abort_time_; } |
| 140 | 146 |
| 141 void AddObserver(std::unique_ptr<PageLoadMetricsObserver> observer); | 147 void AddObserver(std::unique_ptr<PageLoadMetricsObserver> observer); |
| 142 | 148 |
| 143 // If the user performs some abort-like action while we are tracking this page | 149 // If the user performs some abort-like action while we are tracking this page |
| 144 // load, notify the tracker. Note that we may not classify this as an abort if | 150 // load, notify the tracker. Note that we may not classify this as an abort if |
| 145 // we've already performed a first paint. | 151 // we've already performed a first paint. |
| 146 void NotifyAbort(UserAbortType abort_type, base::TimeTicks timestamp); | 152 // is_browser_timestamp signifies if the timestamp passed is taken in the |
| 147 void UpdateAbort(UserAbortType abort_type, base::TimeTicks timestamp); | 153 // browser process or not. We need this to possibly clamp browser timestamp on |
| 154 // a machine with inter process time tick skew. | |
| 155 void NotifyAbort(UserAbortType abort_type, | |
| 156 base::TimeTicks timestamp, | |
| 157 bool is_browser_timestamp); | |
| 158 void UpdateAbort(UserAbortType abort_type, | |
| 159 base::TimeTicks timestamp, | |
| 160 bool is_browser_timestamp); | |
| 148 | 161 |
| 149 // This method returns true if this page load has been aborted with type of | 162 // This method returns true if this page load has been aborted with type of |
| 150 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close | 163 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close |
| 151 // delta to when it was aborted. Note that only provisional loads can be | 164 // delta to when it was aborted. Note that only provisional loads can be |
| 152 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better | 165 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better |
| 153 // and is simpler than other feasible methods. See https://goo.gl/WKRG98. | 166 // and is simpler than other feasible methods. See https://goo.gl/WKRG98. |
| 154 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time); | 167 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time); |
| 155 | 168 |
| 156 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle); | 169 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle); |
| 157 | 170 |
| 158 // Only valid to call post-commit. | 171 // Only valid to call post-commit. |
| 159 const GURL& committed_url() const { | 172 const GURL& committed_url() const { |
| 160 DCHECK(!commit_time_.is_null()); | 173 DCHECK(!commit_time_.is_null()); |
| 161 return url_; | 174 return url_; |
| 162 } | 175 } |
| 163 | 176 |
| 177 PageLoadExtraInfo ComputePageLoadExtraInfo(); | |
| 178 | |
| 164 private: | 179 private: |
| 165 PageLoadExtraInfo GetPageLoadMetricsInfo(); | 180 // This function converts a TimeTicks value taken in the browser process |
| 181 // to navigation_start_ if: | |
| 182 // - base::TimeTicks is not comparable across processes because the clock | |
| 183 // is not system wide monotonic. | |
| 184 // - *event_time < navigation_start_ | |
| 185 void ClampBrowserTimestampIfInterProcessTimeTickSkew( | |
| 186 base::TimeTicks* event_time); | |
| 166 | 187 |
| 167 void UpdateAbortInternal(UserAbortType abort_type, | 188 void UpdateAbortInternal(UserAbortType abort_type, |
| 168 base::TimeTicks timestamp); | 189 base::TimeTicks timestamp, |
| 190 bool is_browser_timestamp); | |
| 169 | 191 |
| 170 // If |final_navigation| is null, then this is an "unparented" abort chain, | 192 // If |final_navigation| is null, then this is an "unparented" abort chain, |
| 171 // and represents a sequence of provisional aborts that never ends with a | 193 // and represents a sequence of provisional aborts that never ends with a |
| 172 // committed load. | 194 // committed load. |
| 173 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); | 195 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); |
| 174 | 196 |
| 175 // Whether the renderer should be sending timing IPCs to this page load. | 197 // Whether the renderer should be sending timing IPCs to this page load. |
| 176 bool renderer_tracked_; | 198 bool renderer_tracked_; |
| 177 | 199 |
| 178 // The navigation start in TimeTicks, not the wall time reported by Blink. | 200 // The navigation start in TimeTicks, not the wall time reported by Blink. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 content::NavigationHandle* navigation_handle) override; | 266 content::NavigationHandle* navigation_handle) override; |
| 245 void DidFinishNavigation( | 267 void DidFinishNavigation( |
| 246 content::NavigationHandle* navigation_handle) override; | 268 content::NavigationHandle* navigation_handle) override; |
| 247 void DidRedirectNavigation( | 269 void DidRedirectNavigation( |
| 248 content::NavigationHandle* navigation_handle) override; | 270 content::NavigationHandle* navigation_handle) override; |
| 249 void NavigationStopped() override; | 271 void NavigationStopped() override; |
| 250 void WasShown() override; | 272 void WasShown() override; |
| 251 void WasHidden() override; | 273 void WasHidden() override; |
| 252 void RenderProcessGone(base::TerminationStatus status) override; | 274 void RenderProcessGone(base::TerminationStatus status) override; |
| 253 | 275 |
| 276 // This getter function is required for testing. | |
| 277 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); | |
| 278 | |
| 254 private: | 279 private: |
| 255 friend class content::WebContentsUserData<MetricsWebContentsObserver>; | 280 friend class content::WebContentsUserData<MetricsWebContentsObserver>; |
| 256 | 281 |
| 257 // Notify all loads, provisional and committed, that we performed an action | 282 // Notify all loads, provisional and committed, that we performed an action |
| 258 // that might abort them. | 283 // that might abort them. |
| 259 void NotifyAbortAllLoads(UserAbortType abort_type); | 284 void NotifyAbortAllLoads(UserAbortType abort_type); |
| 260 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, | 285 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, |
| 261 base::TimeTicks timestamp); | 286 base::TimeTicks timestamp, |
| 287 bool is_browser_timestamp); | |
| 262 // Notify aborted provisional loads that a new navigation occurred. This is | 288 // Notify aborted provisional loads that a new navigation occurred. This is |
| 263 // used for more consistent attribution tracking for aborted provisional | 289 // used for more consistent attribution tracking for aborted provisional |
| 264 // loads. This method returns the provisional load that was likely aborted by | 290 // loads. This method returns the provisional load that was likely aborted by |
| 265 // this navigation, to help instantiate the new PageLoadTracker. | 291 // this navigation, to help instantiate the new PageLoadTracker. |
| 266 std::unique_ptr<PageLoadTracker> NotifyAbortedProvisionalLoadsNewNavigation( | 292 std::unique_ptr<PageLoadTracker> NotifyAbortedProvisionalLoadsNewNavigation( |
| 267 content::NavigationHandle* new_navigation); | 293 content::NavigationHandle* new_navigation); |
| 268 | 294 |
| 269 void OnTimingUpdated(content::RenderFrameHost*, | 295 void OnTimingUpdated(content::RenderFrameHost*, |
| 270 const PageLoadTiming& timing, | 296 const PageLoadTiming& timing, |
| 271 const PageLoadMetadata& metadata); | 297 const PageLoadMetadata& metadata); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 295 | 321 |
| 296 // Has the MWCO observed at least one navigation? | 322 // Has the MWCO observed at least one navigation? |
| 297 bool has_navigated_; | 323 bool has_navigated_; |
| 298 | 324 |
| 299 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 325 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
| 300 }; | 326 }; |
| 301 | 327 |
| 302 } // namespace page_load_metrics | 328 } // namespace page_load_metrics |
| 303 | 329 |
| 304 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ | 330 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ |
| OLD | NEW |