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> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "components/page_load_metrics/browser/page_load_metrics_observer.h" | 14 #include "components/page_load_metrics/browser/page_load_metrics_observer.h" |
| 15 #include "components/page_load_metrics/common/page_load_timing.h" | 15 #include "components/page_load_metrics/common/page_load_timing.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
| 18 #include "content/public/browser/web_contents_user_data.h" | 18 #include "content/public/browser/web_contents_user_data.h" |
| 19 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 20 #include "third_party/WebKit/public/web/WebInputEvent.h" | |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 class NavigationHandle; | 23 class NavigationHandle; |
| 23 class RenderFrameHost; | 24 class RenderFrameHost; |
| 24 } // namespace content | 25 } // namespace content |
| 25 | 26 |
| 26 namespace IPC { | 27 namespace IPC { |
| 27 class Message; | 28 class Message; |
| 28 } // namespace IPC | 29 } // namespace IPC |
| 29 | 30 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 // happens. | 82 // happens. |
| 82 ERR_ABORT_BEFORE_NAVIGATION_START, | 83 ERR_ABORT_BEFORE_NAVIGATION_START, |
| 83 | 84 |
| 84 // A new navigation triggers abort updates in multiple trackers in | 85 // A new navigation triggers abort updates in multiple trackers in |
| 85 // |aborted_provisional_loads_|, when usually there should only be one (the | 86 // |aborted_provisional_loads_|, when usually there should only be one (the |
| 86 // navigation that just aborted because of this one). If this happens, the | 87 // navigation that just aborted because of this one). If this happens, the |
| 87 // latest aborted load is used to track the chain size. | 88 // latest aborted load is used to track the chain size. |
| 88 ERR_NAVIGATION_SIGNALS_MULIPLE_ABORTED_LOADS, | 89 ERR_NAVIGATION_SIGNALS_MULIPLE_ABORTED_LOADS, |
| 89 | 90 |
| 90 // Add values before this final count. | 91 // Add values before this final count. |
| 91 ERR_LAST_ENTRY | 92 ERR_LAST_ENTRY, |
| 93 | |
| 94 // Receives user interaction before navigation start | |
| 95 ERR_USER_INTERACTION_WITH_NO_RELEVANT_LOAD | |
|
Bryan McQuade
2016/05/18 15:21:50
this needs to be before ERR_LAST_ENTRY
| |
| 92 }; | 96 }; |
| 93 | 97 |
| 94 // This class serves as a functional interface to various chrome// features. | 98 // This class serves as a functional interface to various chrome// features. |
| 95 // Impl version is defined in chrome/browser/page_load_metrics. | 99 // Impl version is defined in chrome/browser/page_load_metrics. |
| 96 class PageLoadMetricsEmbedderInterface { | 100 class PageLoadMetricsEmbedderInterface { |
| 97 public: | 101 public: |
| 98 virtual ~PageLoadMetricsEmbedderInterface() {} | 102 virtual ~PageLoadMetricsEmbedderInterface() {} |
| 99 virtual bool IsPrerendering(content::WebContents* web_contents) = 0; | 103 virtual bool IsPrerendering(content::WebContents* web_contents) = 0; |
| 100 virtual void RegisterObservers(PageLoadTracker* metrics) = 0; | 104 virtual void RegisterObservers(PageLoadTracker* metrics) = 0; |
| 101 }; | 105 }; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 116 content::NavigationHandle* navigation_handle, | 120 content::NavigationHandle* navigation_handle, |
| 117 int aborted_chain_size, | 121 int aborted_chain_size, |
| 118 int aborted_chain_size_same_url); | 122 int aborted_chain_size_same_url); |
| 119 ~PageLoadTracker(); | 123 ~PageLoadTracker(); |
| 120 void Redirect(content::NavigationHandle* navigation_handle); | 124 void Redirect(content::NavigationHandle* navigation_handle); |
| 121 void Commit(content::NavigationHandle* navigation_handle); | 125 void Commit(content::NavigationHandle* navigation_handle); |
| 122 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle); | 126 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle); |
| 123 void WebContentsHidden(); | 127 void WebContentsHidden(); |
| 124 void WebContentsShown(); | 128 void WebContentsShown(); |
| 125 | 129 |
| 130 void UserInteraction(blink::WebInputEvent::Type type); | |
| 131 | |
| 126 // Returns true if the timing was successfully updated. | 132 // Returns true if the timing was successfully updated. |
| 127 bool UpdateTiming(const PageLoadTiming& timing, | 133 bool UpdateTiming(const PageLoadTiming& timing, |
| 128 const PageLoadMetadata& metadata); | 134 const PageLoadMetadata& metadata); |
| 129 | 135 |
| 130 void set_renderer_tracked(bool renderer_tracked); | 136 void set_renderer_tracked(bool renderer_tracked); |
| 131 bool renderer_tracked() const { return renderer_tracked_; } | 137 bool renderer_tracked() const { return renderer_tracked_; } |
| 132 | 138 |
| 133 int aborted_chain_size() const { return aborted_chain_size_; } | 139 int aborted_chain_size() const { return aborted_chain_size_; } |
| 134 int aborted_chain_size_same_url() const { | 140 int aborted_chain_size_same_url() const { |
| 135 return aborted_chain_size_same_url_; | 141 return aborted_chain_size_same_url_; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 UserAbortType abort_type_; | 197 UserAbortType abort_type_; |
| 192 base::TimeTicks abort_time_; | 198 base::TimeTicks abort_time_; |
| 193 | 199 |
| 194 // We record separate metrics for events that occur after a background, | 200 // We record separate metrics for events that occur after a background, |
| 195 // because metrics like layout/paint are delayed artificially | 201 // because metrics like layout/paint are delayed artificially |
| 196 // when they occur in the background. | 202 // when they occur in the background. |
| 197 base::TimeTicks background_time_; | 203 base::TimeTicks background_time_; |
| 198 base::TimeTicks foreground_time_; | 204 base::TimeTicks foreground_time_; |
| 199 bool started_in_foreground_; | 205 bool started_in_foreground_; |
| 200 | 206 |
| 207 base::TimeTicks user_interaction_time_; | |
| 208 | |
| 201 PageLoadTiming timing_; | 209 PageLoadTiming timing_; |
| 202 PageLoadMetadata metadata_; | 210 PageLoadMetadata metadata_; |
| 203 | 211 |
| 204 // This is a subtle member. If a provisional load A gets aborted by | 212 // This is a subtle member. If a provisional load A gets aborted by |
| 205 // provisional load B, which gets aborted by C that eventually commits, then | 213 // provisional load B, which gets aborted by C that eventually commits, then |
| 206 // there exists an abort chain of length 2, starting at A's navigation_start. | 214 // there exists an abort chain of length 2, starting at A's navigation_start. |
| 207 // This is useful because it allows histograming abort chain lengths based on | 215 // This is useful because it allows histograming abort chain lengths based on |
| 208 // what the last load's transition type is. i.e. holding down F-5 to spam | 216 // what the last load's transition type is. i.e. holding down F-5 to spam |
| 209 // reload will produce a long chain with the RELOAD transition. | 217 // reload will produce a long chain with the RELOAD transition. |
| 210 const int aborted_chain_size_; | 218 const int aborted_chain_size_; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 240 // content::WebContentsObserver implementation: | 248 // content::WebContentsObserver implementation: |
| 241 bool OnMessageReceived(const IPC::Message& message, | 249 bool OnMessageReceived(const IPC::Message& message, |
| 242 content::RenderFrameHost* render_frame_host) override; | 250 content::RenderFrameHost* render_frame_host) override; |
| 243 void DidStartNavigation( | 251 void DidStartNavigation( |
| 244 content::NavigationHandle* navigation_handle) override; | 252 content::NavigationHandle* navigation_handle) override; |
| 245 void DidFinishNavigation( | 253 void DidFinishNavigation( |
| 246 content::NavigationHandle* navigation_handle) override; | 254 content::NavigationHandle* navigation_handle) override; |
| 247 void DidRedirectNavigation( | 255 void DidRedirectNavigation( |
| 248 content::NavigationHandle* navigation_handle) override; | 256 content::NavigationHandle* navigation_handle) override; |
| 249 void NavigationStopped() override; | 257 void NavigationStopped() override; |
| 258 void DidGetUserInteraction(const blink::WebInputEvent::Type type) override; | |
| 250 void WasShown() override; | 259 void WasShown() override; |
| 251 void WasHidden() override; | 260 void WasHidden() override; |
| 252 void RenderProcessGone(base::TerminationStatus status) override; | 261 void RenderProcessGone(base::TerminationStatus status) override; |
| 253 | 262 |
| 254 private: | 263 private: |
| 255 friend class content::WebContentsUserData<MetricsWebContentsObserver>; | 264 friend class content::WebContentsUserData<MetricsWebContentsObserver>; |
| 256 | 265 |
| 257 // Notify all loads, provisional and committed, that we performed an action | 266 // Notify all loads, provisional and committed, that we performed an action |
| 258 // that might abort them. | 267 // that might abort them. |
| 259 void NotifyAbortAllLoads(UserAbortType abort_type); | 268 void NotifyAbortAllLoads(UserAbortType abort_type); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 | 304 |
| 296 // Has the MWCO observed at least one navigation? | 305 // Has the MWCO observed at least one navigation? |
| 297 bool has_navigated_; | 306 bool has_navigated_; |
| 298 | 307 |
| 299 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 308 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
| 300 }; | 309 }; |
| 301 | 310 |
| 302 } // namespace page_load_metrics | 311 } // namespace page_load_metrics |
| 303 | 312 |
| 304 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ | 313 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_METRICS_WEB_CONTENTS_OBSERVER_H_ |
| OLD | NEW |