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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 | 137 |
138 UserAbortType abort_type() const { return abort_type_; } | 138 UserAbortType abort_type() const { return abort_type_; } |
139 base::TimeTicks abort_time() const { return abort_time_; } | 139 base::TimeTicks abort_time() const { return abort_time_; } |
140 | 140 |
141 void AddObserver(std::unique_ptr<PageLoadMetricsObserver> observer); | 141 void AddObserver(std::unique_ptr<PageLoadMetricsObserver> observer); |
142 | 142 |
143 // If the user performs some abort-like action while we are tracking this page | 143 // 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 | 144 // load, notify the tracker. Note that we may not classify this as an abort if |
145 // we've already performed a first paint. | 145 // we've already performed a first paint. |
146 void NotifyAbort(UserAbortType abort_type, base::TimeTicks timestamp); | 146 void NotifyAbort(UserAbortType abort_type, |
147 void UpdateAbort(UserAbortType abort_type, base::TimeTicks timestamp); | 147 base::TimeTicks timestamp, |
| 148 bool is_browser_timetick); |
| 149 void UpdateAbort(UserAbortType abort_type, |
| 150 base::TimeTicks timestamp, |
| 151 bool is_browser_timetick); |
148 | 152 |
149 // This method returns true if this page load has been aborted with type of | 153 // 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 | 154 // 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 | 155 // 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 | 156 // 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. | 157 // and is simpler than other feasible methods. See https://goo.gl/WKRG98. |
154 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time); | 158 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time); |
155 | 159 |
156 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle); | 160 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle); |
157 | 161 |
158 // Only valid to call post-commit. | 162 // Only valid to call post-commit. |
159 const GURL& committed_url() const { | 163 const GURL& committed_url() const { |
160 DCHECK(!commit_time_.is_null()); | 164 DCHECK(!commit_time_.is_null()); |
161 return url_; | 165 return url_; |
162 } | 166 } |
163 | 167 |
164 private: | 168 private: |
165 PageLoadExtraInfo GetPageLoadMetricsInfo(); | 169 PageLoadExtraInfo ComputePageLoadExtraInfo(); |
| 170 |
| 171 #if defined(OS_WIN) |
| 172 // This function converts a TimeTicks value taken in the browser process |
| 173 // to navigation_start_ if: |
| 174 // - base::TimeTicks is not comparable across processes because the clock |
| 175 // is not system wide monotonic. |
| 176 // - event_time < navigation_start_ |
| 177 void RebaseBrowserTimestampIfInterProcessTimeTickSkew( |
| 178 base::TimeTicks& event_time); |
| 179 #endif |
166 | 180 |
167 void UpdateAbortInternal(UserAbortType abort_type, | 181 void UpdateAbortInternal(UserAbortType abort_type, |
168 base::TimeTicks timestamp); | 182 base::TimeTicks timestamp, |
| 183 bool is_browser_timetick); |
169 | 184 |
170 // If |final_navigation| is null, then this is an "unparented" abort chain, | 185 // 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 | 186 // and represents a sequence of provisional aborts that never ends with a |
172 // committed load. | 187 // committed load. |
173 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); | 188 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); |
174 | 189 |
175 // Whether the renderer should be sending timing IPCs to this page load. | 190 // Whether the renderer should be sending timing IPCs to this page load. |
176 bool renderer_tracked_; | 191 bool renderer_tracked_; |
177 | 192 |
178 // The navigation start in TimeTicks, not the wall time reported by Blink. | 193 // The navigation start in TimeTicks, not the wall time reported by Blink. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 void WasHidden() override; | 266 void WasHidden() override; |
252 void RenderProcessGone(base::TerminationStatus status) override; | 267 void RenderProcessGone(base::TerminationStatus status) override; |
253 | 268 |
254 private: | 269 private: |
255 friend class content::WebContentsUserData<MetricsWebContentsObserver>; | 270 friend class content::WebContentsUserData<MetricsWebContentsObserver>; |
256 | 271 |
257 // Notify all loads, provisional and committed, that we performed an action | 272 // Notify all loads, provisional and committed, that we performed an action |
258 // that might abort them. | 273 // that might abort them. |
259 void NotifyAbortAllLoads(UserAbortType abort_type); | 274 void NotifyAbortAllLoads(UserAbortType abort_type); |
260 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, | 275 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, |
261 base::TimeTicks timestamp); | 276 base::TimeTicks timestamp, |
| 277 bool is_browser_timestamp); |
262 // Notify aborted provisional loads that a new navigation occurred. This is | 278 // Notify aborted provisional loads that a new navigation occurred. This is |
263 // used for more consistent attribution tracking for aborted provisional | 279 // used for more consistent attribution tracking for aborted provisional |
264 // loads. This method returns the provisional load that was likely aborted by | 280 // loads. This method returns the provisional load that was likely aborted by |
265 // this navigation, to help instantiate the new PageLoadTracker. | 281 // this navigation, to help instantiate the new PageLoadTracker. |
266 std::unique_ptr<PageLoadTracker> NotifyAbortedProvisionalLoadsNewNavigation( | 282 std::unique_ptr<PageLoadTracker> NotifyAbortedProvisionalLoadsNewNavigation( |
267 content::NavigationHandle* new_navigation); | 283 content::NavigationHandle* new_navigation); |
268 | 284 |
269 void OnTimingUpdated(content::RenderFrameHost*, | 285 void OnTimingUpdated(content::RenderFrameHost*, |
270 const PageLoadTiming& timing, | 286 const PageLoadTiming& timing, |
271 const PageLoadMetadata& metadata); | 287 const PageLoadMetadata& metadata); |
(...skipping 23 matching lines...) Expand all Loading... |
295 | 311 |
296 // Has the MWCO observed at least one navigation? | 312 // Has the MWCO observed at least one navigation? |
297 bool has_navigated_; | 313 bool has_navigated_; |
298 | 314 |
299 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 315 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
300 }; | 316 }; |
301 | 317 |
302 } // namespace page_load_metrics | 318 } // namespace page_load_metrics |
303 | 319 |
304 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ | 320 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ |
OLD | NEW |