| 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_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE
RVER_H_ | 5 #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE
RVER_H_ |
| 6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE
RVER_H_ | 6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE
RVER_H_ |
| 7 | 7 |
| 8 #include "base/containers/scoped_ptr_map.h" | 8 #include "base/containers/scoped_ptr_map.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 namespace IPC { | 26 namespace IPC { |
| 27 class Message; | 27 class Message; |
| 28 } // namespace IPC | 28 } // namespace IPC |
| 29 | 29 |
| 30 namespace rappor { | 30 namespace rappor { |
| 31 class RapporService; | 31 class RapporService; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace page_load_metrics { | 34 namespace page_load_metrics { |
| 35 | 35 |
| 36 // Returns true if the given URL matches a Google CAPTCHA page. |
| 37 bool IsGoogleCaptcha(const GURL& url); |
| 38 |
| 36 // These constants are for keeping the tests in sync. | 39 // These constants are for keeping the tests in sync. |
| 37 const char kHistogramNameFirstLayout[] = | 40 const char kHistogramNameFirstLayout[] = |
| 38 "PageLoad.Timing2.NavigationToFirstLayout"; | 41 "PageLoad.Timing2.NavigationToFirstLayout"; |
| 39 const char kHistogramNameFirstTextPaint[] = | 42 const char kHistogramNameFirstTextPaint[] = |
| 40 "PageLoad.Timing2.NavigationToFirstTextPaint"; | 43 "PageLoad.Timing2.NavigationToFirstTextPaint"; |
| 41 const char kHistogramNameDomContent[] = | 44 const char kHistogramNameDomContent[] = |
| 42 "PageLoad.Timing2.NavigationToDOMContentLoadedEventFired"; | 45 "PageLoad.Timing2.NavigationToDOMContentLoadedEventFired"; |
| 43 const char kHistogramNameLoad[] = "PageLoad.Timing2.NavigationToLoadEventFired"; | 46 const char kHistogramNameLoad[] = "PageLoad.Timing2.NavigationToLoadEventFired"; |
| 44 const char kBGHistogramNameFirstLayout[] = | 47 const char kBGHistogramNameFirstLayout[] = |
| 45 "PageLoad.Timing2.NavigationToFirstLayout.Background"; | 48 "PageLoad.Timing2.NavigationToFirstLayout.Background"; |
| 46 const char kBGHistogramNameFirstTextPaint[] = | 49 const char kBGHistogramNameFirstTextPaint[] = |
| 47 "PageLoad.Timing2.NavigationToFirstTextPaint.Background"; | 50 "PageLoad.Timing2.NavigationToFirstTextPaint.Background"; |
| 48 const char kBGHistogramNameDomContent[] = | 51 const char kBGHistogramNameDomContent[] = |
| 49 "PageLoad.Timing2.NavigationToDOMContentLoadedEventFired.Background"; | 52 "PageLoad.Timing2.NavigationToDOMContentLoadedEventFired.Background"; |
| 50 const char kBGHistogramNameLoad[] = | 53 const char kBGHistogramNameLoad[] = |
| 51 "PageLoad.Timing2.NavigationToLoadEventFired.Background"; | 54 "PageLoad.Timing2.NavigationToLoadEventFired.Background"; |
| 52 | 55 |
| 53 const char kProvisionalEvents[] = "PageLoad.Events.Provisional"; | 56 const char kProvisionalEvents[] = "PageLoad.Events.Provisional"; |
| 54 const char kCommittedEvents[] = "PageLoad.Events.Committed"; | 57 const char kCommittedEvents[] = "PageLoad.Events.Committed"; |
| 55 const char kBGProvisionalEvents[] = "PageLoad.Events.Provisional.Background"; | 58 const char kBGProvisionalEvents[] = "PageLoad.Events.Provisional.Background"; |
| 56 const char kBGCommittedEvents[] = "PageLoad.Events.Committed.Background"; | 59 const char kBGCommittedEvents[] = "PageLoad.Events.Committed.Background"; |
| 57 | 60 |
| 58 const char kErrorEvents[] = "PageLoad.Events.InternalError"; | 61 const char kErrorEvents[] = "PageLoad.Events.InternalError"; |
| 59 | 62 |
| 60 const char kRapporMetricsNameCoarseTiming[] = | 63 const char kRapporMetricsNameCoarseTiming[] = |
| 61 "PageLoad.CoarseTiming.NavigationToFirstContentfulPaint"; | 64 "PageLoad.CoarseTiming.NavigationToFirstContentfulPaint"; |
| 62 | 65 |
| 66 const char kHistogramNameGoogleCaptcha[] = "PageLoad.Events.GoogleCaptcha"; |
| 67 |
| 63 // NOTE: Some of these histograms are separated into a separate histogram | 68 // NOTE: Some of these histograms are separated into a separate histogram |
| 64 // specified by the ".Background" suffix. For these events, we put them into the | 69 // specified by the ".Background" suffix. For these events, we put them into the |
| 65 // background histogram if the web contents was ever in the background from | 70 // background histogram if the web contents was ever in the background from |
| 66 // navigation start to the event in question. | 71 // navigation start to the event in question. |
| 67 | 72 |
| 68 // ProvisionalLoadEvents count all main frame navigations before they commit. | 73 // ProvisionalLoadEvents count all main frame navigations before they commit. |
| 69 // The events in this enum are all disjoint, and summing them yields the total | 74 // The events in this enum are all disjoint, and summing them yields the total |
| 70 // number of main frame provisional loads. | 75 // number of main frame provisional loads. |
| 71 // | 76 // |
| 72 // If you add elements from this enum, make sure you update the enum | 77 // If you add elements from this enum, make sure you update the enum |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 ERR_IPC_FROM_BAD_URL_SCHEME, | 156 ERR_IPC_FROM_BAD_URL_SCHEME, |
| 152 | 157 |
| 153 // If we track a navigation, but the renderer sends us no IPCs. This could | 158 // If we track a navigation, but the renderer sends us no IPCs. This could |
| 154 // occur if the browser filters loads less aggressively than the renderer. | 159 // occur if the browser filters loads less aggressively than the renderer. |
| 155 ERR_NO_IPCS_RECEIVED, | 160 ERR_NO_IPCS_RECEIVED, |
| 156 | 161 |
| 157 // Add values before this final count. | 162 // Add values before this final count. |
| 158 ERR_LAST_ENTRY | 163 ERR_LAST_ENTRY |
| 159 }; | 164 }; |
| 160 | 165 |
| 166 // Values of the UMA PageLoad.Events.GoogleCaptcha histogram. |
| 167 enum GoogleCaptchaEvent { |
| 168 // A Google CAPTCHA page was shown to the user. |
| 169 GOOGLE_CAPTCHA_SHOWN, |
| 170 // A Google CAPTCHA page was solved by the user. |
| 171 GOOGLE_CAPTCHA_SOLVED, |
| 172 // Add new values before this final count. |
| 173 GOOGLE_CAPTCHA_EVENT_BOUNDARY, |
| 174 }; |
| 175 |
| 161 // This class tracks a given page load, starting from navigation start / | 176 // This class tracks a given page load, starting from navigation start / |
| 162 // provisional load, until a new navigation commits or the navigation fails. It | 177 // provisional load, until a new navigation commits or the navigation fails. It |
| 163 // also records RAPPOR/UMA about the page load. | 178 // also records RAPPOR/UMA about the page load. |
| 164 // MetricsWebContentsObserver manages a set of provisional PageLoadTrackers, as | 179 // MetricsWebContentsObserver manages a set of provisional PageLoadTrackers, as |
| 165 // well as a committed PageLoadTracker. | 180 // well as a committed PageLoadTracker. |
| 166 class PageLoadTracker { | 181 class PageLoadTracker { |
| 167 public: | 182 public: |
| 168 // Caller must guarantee that the observers pointer outlives this class. | 183 // Caller must guarantee that the observers pointer outlives this class. |
| 169 PageLoadTracker(bool in_foreground, | 184 PageLoadTracker(bool in_foreground, |
| 170 rappor::RapporService* const rappor_service, | 185 rappor::RapporService* const rappor_service, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 void AddObserver(PageLoadMetricsObserver* observer) override; | 247 void AddObserver(PageLoadMetricsObserver* observer) override; |
| 233 void RemoveObserver(PageLoadMetricsObserver* observer) override; | 248 void RemoveObserver(PageLoadMetricsObserver* observer) override; |
| 234 | 249 |
| 235 // content::WebContentsObserver implementation: | 250 // content::WebContentsObserver implementation: |
| 236 bool OnMessageReceived(const IPC::Message& message, | 251 bool OnMessageReceived(const IPC::Message& message, |
| 237 content::RenderFrameHost* render_frame_host) override; | 252 content::RenderFrameHost* render_frame_host) override; |
| 238 void DidStartNavigation( | 253 void DidStartNavigation( |
| 239 content::NavigationHandle* navigation_handle) override; | 254 content::NavigationHandle* navigation_handle) override; |
| 240 void DidFinishNavigation( | 255 void DidFinishNavigation( |
| 241 content::NavigationHandle* navigation_handle) override; | 256 content::NavigationHandle* navigation_handle) override; |
| 257 void DidRedirectNavigation( |
| 258 content::NavigationHandle* navigation_handle) override; |
| 242 | 259 |
| 243 void WasShown() override; | 260 void WasShown() override; |
| 244 void WasHidden() override; | 261 void WasHidden() override; |
| 245 | 262 |
| 246 void RenderProcessGone(base::TerminationStatus status) override; | 263 void RenderProcessGone(base::TerminationStatus status) override; |
| 247 | 264 |
| 248 private: | 265 private: |
| 249 friend class content::WebContentsUserData<MetricsWebContentsObserver>; | 266 friend class content::WebContentsUserData<MetricsWebContentsObserver>; |
| 250 | 267 |
| 251 void OnTimingUpdated(content::RenderFrameHost*, const PageLoadTiming& timing); | 268 void OnTimingUpdated(content::RenderFrameHost*, const PageLoadTiming& timing); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 263 | 280 |
| 264 rappor::RapporService* const rappor_service_; | 281 rappor::RapporService* const rappor_service_; |
| 265 base::ObserverList<PageLoadMetricsObserver, true> observers_; | 282 base::ObserverList<PageLoadMetricsObserver, true> observers_; |
| 266 | 283 |
| 267 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 284 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
| 268 }; | 285 }; |
| 269 | 286 |
| 270 } // namespace page_load_metrics | 287 } // namespace page_load_metrics |
| 271 | 288 |
| 272 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O
BSERVER_H_ | 289 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O
BSERVER_H_ |
| OLD | NEW |