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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 NotifyClientRedirectTo(const PageLoadTracker& destination); | 142 void NotifyClientRedirectTo(const PageLoadTracker& destination); |
143 | 143 |
144 // Returns true if the timing was successfully updated. | 144 // Returns true if the timing was successfully updated. |
145 bool UpdateTiming(const PageLoadTiming& timing, | 145 bool UpdateTiming(const PageLoadTiming& timing, |
146 const PageLoadMetadata& metadata); | 146 const PageLoadMetadata& metadata); |
147 | 147 |
148 void set_renderer_tracked(bool renderer_tracked); | 148 // Signals that we should stop tracking metrics for the associated page load. |
149 bool renderer_tracked() const { return renderer_tracked_; } | 149 // We may stop tracking a page load if it doesn't meet the criteria for |
| 150 // tracking metrics in DidFinishNavigation. |
| 151 void StopTracking(); |
150 | 152 |
151 int aborted_chain_size() const { return aborted_chain_size_; } | 153 int aborted_chain_size() const { return aborted_chain_size_; } |
152 int aborted_chain_size_same_url() const { | 154 int aborted_chain_size_same_url() const { |
153 return aborted_chain_size_same_url_; | 155 return aborted_chain_size_same_url_; |
154 } | 156 } |
155 | 157 |
156 UserAbortType abort_type() const { return abort_type_; } | 158 UserAbortType abort_type() const { return abort_type_; } |
157 base::TimeTicks abort_time() const { return abort_time_; } | 159 base::TimeTicks abort_time() const { return abort_time_; } |
158 | 160 |
159 void AddObserver(std::unique_ptr<PageLoadMetricsObserver> observer); | 161 void AddObserver(std::unique_ptr<PageLoadMetricsObserver> observer); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 204 |
203 void UpdateAbortInternal(UserAbortType abort_type, | 205 void UpdateAbortInternal(UserAbortType abort_type, |
204 base::TimeTicks timestamp, | 206 base::TimeTicks timestamp, |
205 bool is_certainly_browser_timestamp); | 207 bool is_certainly_browser_timestamp); |
206 | 208 |
207 // If |final_navigation| is null, then this is an "unparented" abort chain, | 209 // If |final_navigation| is null, then this is an "unparented" abort chain, |
208 // and represents a sequence of provisional aborts that never ends with a | 210 // and represents a sequence of provisional aborts that never ends with a |
209 // committed load. | 211 // committed load. |
210 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); | 212 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); |
211 | 213 |
212 // Whether the renderer should be sending timing IPCs to this page load. | 214 // Whether we stopped tracking this navigation after it was initiated. We may |
213 bool renderer_tracked_; | 215 // stop tracking a navigation if it doesn't meet the criteria for tracking |
| 216 // metrics in DidFinishNavigation. |
| 217 bool did_stop_tracking_; |
214 | 218 |
215 // The navigation start in TimeTicks, not the wall time reported by Blink. | 219 // The navigation start in TimeTicks, not the wall time reported by Blink. |
216 const base::TimeTicks navigation_start_; | 220 const base::TimeTicks navigation_start_; |
217 | 221 |
218 // Time this page load was committed. If this page load hasn't committed, | 222 // Time this page load was committed. If this page load hasn't committed, |
219 // |commit_time_| will be zero. | 223 // |commit_time_| will be zero. |
220 base::TimeTicks commit_time_; | 224 base::TimeTicks commit_time_; |
221 | 225 |
222 // The URL of this page load. This is the provisional url before commit | 226 // The URL of this page load. This is the provisional url before commit |
223 // (before redirects), and the committed url after commit. | 227 // (before redirects), and the committed url after commit. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 void RenderProcessGone(base::TerminationStatus status) override; | 295 void RenderProcessGone(base::TerminationStatus status) override; |
292 void RenderViewHostChanged(content::RenderViewHost* old_host, | 296 void RenderViewHostChanged(content::RenderViewHost* old_host, |
293 content::RenderViewHost* new_host) override; | 297 content::RenderViewHost* new_host) override; |
294 | 298 |
295 // This getter function is required for testing. | 299 // This getter function is required for testing. |
296 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); | 300 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); |
297 | 301 |
298 private: | 302 private: |
299 friend class content::WebContentsUserData<MetricsWebContentsObserver>; | 303 friend class content::WebContentsUserData<MetricsWebContentsObserver>; |
300 | 304 |
| 305 void HandleFailedNavigationForTrackedLoad( |
| 306 content::NavigationHandle* navigation_handle, |
| 307 std::unique_ptr<PageLoadTracker> tracker); |
| 308 |
| 309 void HandleCommittedNavigationForTrackedLoad( |
| 310 content::NavigationHandle* navigation_handle, |
| 311 std::unique_ptr<PageLoadTracker> tracker); |
| 312 |
301 // Notify all loads, provisional and committed, that we performed an action | 313 // Notify all loads, provisional and committed, that we performed an action |
302 // that might abort them. | 314 // that might abort them. |
303 void NotifyAbortAllLoads(UserAbortType abort_type); | 315 void NotifyAbortAllLoads(UserAbortType abort_type); |
304 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, | 316 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, |
305 base::TimeTicks timestamp, | 317 base::TimeTicks timestamp, |
306 bool is_certainly_browser_timestamp); | 318 bool is_certainly_browser_timestamp); |
307 | 319 |
308 // Register / Unregister input event callback to given RenderViewHost | 320 // Register / Unregister input event callback to given RenderViewHost |
309 void RegisterInputEventObserver(content::RenderViewHost* host); | 321 void RegisterInputEventObserver(content::RenderViewHost* host); |
310 void UnregisterInputEventObserver(content::RenderViewHost* host); | 322 void UnregisterInputEventObserver(content::RenderViewHost* host); |
311 | 323 |
312 // Notify aborted provisional loads that a new navigation occurred. This is | 324 // Notify aborted provisional loads that a new navigation occurred. This is |
313 // used for more consistent attribution tracking for aborted provisional | 325 // used for more consistent attribution tracking for aborted provisional |
314 // loads. This method returns the provisional load that was likely aborted | 326 // loads. This method returns the provisional load that was likely aborted |
315 // by this navigation, to help instantiate the new PageLoadTracker. | 327 // by this navigation, to help instantiate the new PageLoadTracker. |
316 std::unique_ptr<PageLoadTracker> NotifyAbortedProvisionalLoadsNewNavigation( | 328 std::unique_ptr<PageLoadTracker> NotifyAbortedProvisionalLoadsNewNavigation( |
317 content::NavigationHandle* new_navigation); | 329 content::NavigationHandle* new_navigation); |
318 | 330 |
319 void OnTimingUpdated(content::RenderFrameHost*, | 331 void OnTimingUpdated(content::RenderFrameHost*, |
320 const PageLoadTiming& timing, | 332 const PageLoadTiming& timing, |
321 const PageLoadMetadata& metadata); | 333 const PageLoadMetadata& metadata); |
322 | 334 |
| 335 bool ShouldTrackNavigation( |
| 336 content::NavigationHandle* navigation_handle) const; |
| 337 |
323 // True if the web contents is currently in the foreground. | 338 // True if the web contents is currently in the foreground. |
324 bool in_foreground_; | 339 bool in_foreground_; |
325 | 340 |
326 // The PageLoadTrackers must be deleted before the |embedder_interface_|, | 341 // The PageLoadTrackers must be deleted before the |embedder_interface_|, |
327 // because they hold a pointer to the |embedder_interface_|. | 342 // because they hold a pointer to the |embedder_interface_|. |
328 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface_; | 343 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface_; |
329 | 344 |
330 // This map tracks all of the navigations ongoing that are not committed | 345 // This map tracks all of the navigations ongoing that are not committed |
331 // yet. Once a navigation is committed, it moves from the map to | 346 // yet. Once a navigation is committed, it moves from the map to |
332 // committed_load_. Note that a PageLoadTrackers NavigationHandle is only | 347 // committed_load_. Note that a PageLoadTrackers NavigationHandle is only |
(...skipping 12 matching lines...) Expand all Loading... |
345 | 360 |
346 // Has the MWCO observed at least one navigation? | 361 // Has the MWCO observed at least one navigation? |
347 bool has_navigated_; | 362 bool has_navigated_; |
348 | 363 |
349 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 364 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
350 }; | 365 }; |
351 | 366 |
352 } // namespace page_load_metrics | 367 } // namespace page_load_metrics |
353 | 368 |
354 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ | 369 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ |
OLD | NEW |