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