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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 // class. The PageLoadTracker must not hold on to | 121 // class. The PageLoadTracker must not hold on to |
122 // currently_committed_load_or_null or navigation_handle beyond the scope of | 122 // currently_committed_load_or_null or navigation_handle beyond the scope of |
123 // the constructor. | 123 // the constructor. |
124 PageLoadTracker(bool in_foreground, | 124 PageLoadTracker(bool in_foreground, |
125 PageLoadMetricsEmbedderInterface* embedder_interface, | 125 PageLoadMetricsEmbedderInterface* embedder_interface, |
126 const GURL& currently_committed_url, | 126 const GURL& currently_committed_url, |
127 content::NavigationHandle* navigation_handle, | 127 content::NavigationHandle* navigation_handle, |
128 int aborted_chain_size, | 128 int aborted_chain_size, |
129 int aborted_chain_size_same_url); | 129 int aborted_chain_size_same_url); |
130 ~PageLoadTracker(); | 130 ~PageLoadTracker(); |
131 void WillStartNavigationRequest(content::NavigationHandle* navigation_handle); | |
131 void Redirect(content::NavigationHandle* navigation_handle); | 132 void Redirect(content::NavigationHandle* navigation_handle); |
132 void Commit(content::NavigationHandle* navigation_handle); | 133 void Commit(content::NavigationHandle* navigation_handle); |
133 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle); | 134 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle); |
134 void WebContentsHidden(); | 135 void WebContentsHidden(); |
135 void WebContentsShown(); | 136 void WebContentsShown(); |
136 | 137 |
137 void OnInputEvent(const blink::WebInputEvent& event); | 138 void OnInputEvent(const blink::WebInputEvent& event); |
138 | 139 |
139 void NotifyClientRedirectTo(const PageLoadTracker& destination); | 140 void NotifyClientRedirectTo(const PageLoadTracker& destination); |
140 | 141 |
(...skipping 21 matching lines...) Expand all Loading... | |
162 // in the | 163 // in the |
163 // browser process or not. We need this to possibly clamp browser timestamp on | 164 // browser process or not. We need this to possibly clamp browser timestamp on |
164 // a machine with inter process time tick skew. | 165 // a machine with inter process time tick skew. |
165 void NotifyAbort(UserAbortType abort_type, | 166 void NotifyAbort(UserAbortType abort_type, |
166 base::TimeTicks timestamp, | 167 base::TimeTicks timestamp, |
167 bool is_certainly_browser_timestamp); | 168 bool is_certainly_browser_timestamp); |
168 void UpdateAbort(UserAbortType abort_type, | 169 void UpdateAbort(UserAbortType abort_type, |
169 base::TimeTicks timestamp, | 170 base::TimeTicks timestamp, |
170 bool is_certainly_browser_timestamp); | 171 bool is_certainly_browser_timestamp); |
171 | 172 |
172 // This method returns true if this page load has been aborted with type of | 173 // This method returns true if this page load has been aborted with the |
173 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close | 174 // |abort_cause_time| within a sufficiently close delta to when it was |
174 // delta to when it was aborted. Note that only provisional loads can be | 175 // aborted. This is used to update aborts with less precise abort causes like |
175 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better | 176 // ABORT_OTHER and ABORT_UNKNOWN_NAVIGATION. While this heuristic is coarse, |
176 // and is simpler than other feasible methods. See https://goo.gl/WKRG98. | 177 // it works better and is simpler than other feasible methods. See |
177 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time); | 178 // https://goo.gl/WKRG98. |
179 bool WasAbortedRecently(base::TimeTicks abort_cause_time); | |
Bryan McQuade
2016/07/13 18:23:36
let's make this a const method
Charlie Harrison
2016/07/13 18:58:19
Done.
| |
178 | 180 |
179 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle); | 181 bool MatchesOriginalNavigation(content::NavigationHandle* navigation_handle); |
180 | 182 |
181 // Only valid to call post-commit. | 183 // Only valid to call post-commit. |
182 const GURL& committed_url() const { | 184 const GURL& committed_url() const { |
183 DCHECK(!commit_time_.is_null()); | 185 DCHECK(!commit_time_.is_null()); |
184 return url_; | 186 return url_; |
185 } | 187 } |
186 | 188 |
187 base::TimeTicks navigation_start() const { return navigation_start_; } | 189 base::TimeTicks navigation_start() const { return navigation_start_; } |
188 | 190 |
189 PageLoadExtraInfo ComputePageLoadExtraInfo(); | 191 PageLoadExtraInfo ComputePageLoadExtraInfo(); |
190 | 192 |
193 const base::Optional<ui::PageTransition> page_transition() const { | |
Bryan McQuade
2016/07/13 18:23:36
do you want to return a const reference here, to a
Charlie Harrison
2016/07/13 18:58:19
Ah yes, this was a typo :)
| |
194 return page_transition_; | |
195 } | |
196 | |
191 private: | 197 private: |
192 // This function converts a TimeTicks value taken in the browser process | 198 // This function converts a TimeTicks value taken in the browser process |
193 // to navigation_start_ if: | 199 // to navigation_start_ if: |
194 // - base::TimeTicks is not comparable across processes because the clock | 200 // - base::TimeTicks is not comparable across processes because the clock |
195 // is not system wide monotonic. | 201 // is not system wide monotonic. |
196 // - *event_time < navigation_start_ | 202 // - *event_time < navigation_start_ |
197 void ClampBrowserTimestampIfInterProcessTimeTickSkew( | 203 void ClampBrowserTimestampIfInterProcessTimeTickSkew( |
198 base::TimeTicks* event_time); | 204 base::TimeTicks* event_time); |
199 | 205 |
200 void UpdateAbortInternal(UserAbortType abort_type, | 206 void UpdateAbortInternal(UserAbortType abort_type, |
(...skipping 27 matching lines...) Expand all Loading... | |
228 // We record separate metrics for events that occur after a background, | 234 // We record separate metrics for events that occur after a background, |
229 // because metrics like layout/paint are delayed artificially | 235 // because metrics like layout/paint are delayed artificially |
230 // when they occur in the background. | 236 // when they occur in the background. |
231 base::TimeTicks background_time_; | 237 base::TimeTicks background_time_; |
232 base::TimeTicks foreground_time_; | 238 base::TimeTicks foreground_time_; |
233 bool started_in_foreground_; | 239 bool started_in_foreground_; |
234 | 240 |
235 PageLoadTiming timing_; | 241 PageLoadTiming timing_; |
236 PageLoadMetadata metadata_; | 242 PageLoadMetadata metadata_; |
237 | 243 |
244 // The page transition type of this page load. This will not be set until | |
245 // WillStartRequest is called. | |
246 // TODO(csharrison): Some transitions are only known at commit time. Consider | |
Bryan McQuade
2016/07/13 18:23:36
is the value that NavigationHandle::GetPageTransit
Charlie Harrison
2016/07/13 18:58:19
It will only be more accurate. Done.
| |
247 // updating this member then. | |
248 base::Optional<ui::PageTransition> page_transition_; | |
249 | |
238 // This is a subtle member. If a provisional load A gets aborted by | 250 // This is a subtle member. If a provisional load A gets aborted by |
239 // provisional load B, which gets aborted by C that eventually commits, then | 251 // provisional load B, which gets aborted by C that eventually commits, then |
240 // there exists an abort chain of length 2, starting at A's navigation_start. | 252 // there exists an abort chain of length 2, starting at A's navigation_start. |
241 // This is useful because it allows histograming abort chain lengths based on | 253 // This is useful because it allows histograming abort chain lengths based on |
242 // what the last load's transition type is. i.e. holding down F-5 to spam | 254 // what the last load's transition type is. i.e. holding down F-5 to spam |
243 // reload will produce a long chain with the RELOAD transition. | 255 // reload will produce a long chain with the RELOAD transition. |
244 const int aborted_chain_size_; | 256 const int aborted_chain_size_; |
245 | 257 |
246 // This member counts consecutive provisional aborts that share a url. It will | 258 // This member counts consecutive provisional aborts that share a url. It will |
247 // always be less than or equal to |aborted_chain_size_|. | 259 // always be less than or equal to |aborted_chain_size_|. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 void DidRedirectNavigation( | 294 void DidRedirectNavigation( |
283 content::NavigationHandle* navigation_handle) override; | 295 content::NavigationHandle* navigation_handle) override; |
284 void NavigationStopped() override; | 296 void NavigationStopped() override; |
285 void OnInputEvent(const blink::WebInputEvent& event) override; | 297 void OnInputEvent(const blink::WebInputEvent& event) override; |
286 void WasShown() override; | 298 void WasShown() override; |
287 void WasHidden() override; | 299 void WasHidden() override; |
288 void RenderProcessGone(base::TerminationStatus status) override; | 300 void RenderProcessGone(base::TerminationStatus status) override; |
289 void RenderViewHostChanged(content::RenderViewHost* old_host, | 301 void RenderViewHostChanged(content::RenderViewHost* old_host, |
290 content::RenderViewHost* new_host) override; | 302 content::RenderViewHost* new_host) override; |
291 | 303 |
304 // Forwarded call from a navigation throttle. | |
305 void WillStartNavigationRequest(content::NavigationHandle* navigation_handle); | |
306 | |
292 // This getter function is required for testing. | 307 // This getter function is required for testing. |
293 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); | 308 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); |
294 | 309 |
295 private: | 310 private: |
296 friend class content::WebContentsUserData<MetricsWebContentsObserver>; | 311 friend class content::WebContentsUserData<MetricsWebContentsObserver>; |
297 | 312 |
298 // Notify all loads, provisional and committed, that we performed an action | 313 // Notify all loads, provisional and committed, that we performed an action |
299 // that might abort them. | 314 // that might abort them. |
300 void NotifyAbortAllLoads(UserAbortType abort_type); | 315 void NotifyAbortAllLoads(UserAbortType abort_type); |
301 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, | 316 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, |
302 base::TimeTicks timestamp, | 317 base::TimeTicks timestamp, |
303 bool is_certainly_browser_timestamp); | 318 bool is_certainly_browser_timestamp); |
304 | 319 |
305 // Register / Unregister input event callback to given RenderViewHost | 320 // Register / Unregister input event callback to given RenderViewHost |
306 void RegisterInputEventObserver(content::RenderViewHost* host); | 321 void RegisterInputEventObserver(content::RenderViewHost* host); |
307 void UnregisterInputEventObserver(content::RenderViewHost* host); | 322 void UnregisterInputEventObserver(content::RenderViewHost* host); |
308 | 323 |
309 // Notify aborted provisional loads that a new navigation occurred. This is | 324 // Notify aborted provisional loads that a new navigation occurred. This is |
310 // used for more consistent attribution tracking for aborted provisional | 325 // used for more consistent attribution tracking for aborted provisional |
311 // loads. This method returns the provisional load that was likely aborted | 326 // loads. |
312 // by this navigation, to help instantiate the new PageLoadTracker. | 327 void NotifyAbortedProvisionalLoadsNewNavigation( |
313 std::unique_ptr<PageLoadTracker> NotifyAbortedProvisionalLoadsNewNavigation( | 328 PageLoadTracker* new_navigation); |
314 content::NavigationHandle* new_navigation); | |
315 | 329 |
316 void OnTimingUpdated(content::RenderFrameHost*, | 330 void OnTimingUpdated(content::RenderFrameHost*, |
317 const PageLoadTiming& timing, | 331 const PageLoadTiming& timing, |
318 const PageLoadMetadata& metadata); | 332 const PageLoadMetadata& metadata); |
319 | 333 |
320 // True if the web contents is currently in the foreground. | 334 // True if the web contents is currently in the foreground. |
321 bool in_foreground_; | 335 bool in_foreground_; |
322 | 336 |
323 // The PageLoadTrackers must be deleted before the |embedder_interface_|, | 337 // The PageLoadTrackers must be deleted before the |embedder_interface_|, |
324 // because they hold a pointer to the |embedder_interface_|. | 338 // because they hold a pointer to the |embedder_interface_|. |
(...skipping 17 matching lines...) Expand all Loading... | |
342 | 356 |
343 // Has the MWCO observed at least one navigation? | 357 // Has the MWCO observed at least one navigation? |
344 bool has_navigated_; | 358 bool has_navigated_; |
345 | 359 |
346 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 360 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
347 }; | 361 }; |
348 | 362 |
349 } // namespace page_load_metrics | 363 } // namespace page_load_metrics |
350 | 364 |
351 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ | 365 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ |
OLD | NEW |