| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 177 |
| 178 // This class tracks a given page load, starting from navigation start / | 178 // This class tracks a given page load, starting from navigation start / |
| 179 // provisional load, until a new navigation commits or the navigation fails. It | 179 // provisional load, until a new navigation commits or the navigation fails. It |
| 180 // also records RAPPOR/UMA about the page load. | 180 // also records RAPPOR/UMA about the page load. |
| 181 // MetricsWebContentsObserver manages a set of provisional PageLoadTrackers, as | 181 // MetricsWebContentsObserver manages a set of provisional PageLoadTrackers, as |
| 182 // well as a committed PageLoadTracker. | 182 // well as a committed PageLoadTracker. |
| 183 class PageLoadTracker { | 183 class PageLoadTracker { |
| 184 public: | 184 public: |
| 185 // Caller must guarantee that the observers pointer outlives this class. | 185 // Caller must guarantee that the observers pointer outlives this class. |
| 186 PageLoadTracker(bool in_foreground, | 186 PageLoadTracker(bool in_foreground, |
| 187 content::NavigationHandle* navigation_handle, |
| 187 rappor::RapporService* const rappor_service, | 188 rappor::RapporService* const rappor_service, |
| 188 base::ObserverList<PageLoadMetricsObserver, true>* observers); | 189 base::ObserverList<PageLoadMetricsObserver, true>* observers); |
| 189 ~PageLoadTracker(); | 190 ~PageLoadTracker(); |
| 190 void Commit(content::NavigationHandle* navigation_handle); | 191 void Commit(content::NavigationHandle* navigation_handle); |
| 191 void WebContentsHidden(); | 192 void WebContentsHidden(); |
| 192 void WebContentsShown(); | 193 void WebContentsShown(); |
| 193 | 194 |
| 194 // Returns true if the timing was successfully updated. | 195 // Returns true if the timing was successfully updated. |
| 195 bool UpdateTiming(const PageLoadTiming& timing); | 196 bool UpdateTiming(const PageLoadTiming& timing); |
| 196 void RecordProvisionalEvent(ProvisionalLoadEvent event); | 197 void RecordProvisionalEvent(ProvisionalLoadEvent event); |
| 197 void RecordCommittedEvent(CommittedLoadEvent event, bool backgrounded); | 198 void RecordCommittedEvent(CommittedLoadEvent event, bool backgrounded); |
| 198 bool HasBackgrounded(); | 199 bool HasBackgrounded(); |
| 199 | 200 |
| 200 private: | 201 private: |
| 201 PageLoadExtraInfo GetPageLoadMetricsInfo(); | 202 PageLoadExtraInfo GetPageLoadMetricsInfo(); |
| 202 // Only valid to call post-commit. | 203 // Only valid to call post-commit. |
| 203 const GURL& GetCommittedURL(); | 204 const GURL& GetCommittedURL(); |
| 204 | 205 |
| 205 base::TimeDelta GetBackgroundDelta(); | 206 base::TimeDelta GetBackgroundDelta(); |
| 206 void RecordTimingHistograms(); | 207 void RecordTimingHistograms(); |
| 207 void RecordRappor(); | 208 void RecordRappor(); |
| 208 | 209 |
| 209 bool has_commit_; | 210 bool has_commit_; |
| 210 | 211 |
| 212 // The navigation start in TimeTicks, not the wall time reported by Blink. |
| 213 const base::TimeTicks navigation_start_; |
| 214 |
| 211 // We record separate metrics for events that occur after a background, | 215 // We record separate metrics for events that occur after a background, |
| 212 // because metrics like layout/paint are delayed artificially | 216 // because metrics like layout/paint are delayed artificially |
| 213 // when they occur in the background. | 217 // when they occur in the background. |
| 214 base::TimeTicks background_time_; | 218 base::TimeTicks background_time_; |
| 215 base::TimeTicks foreground_time_; | 219 base::TimeTicks foreground_time_; |
| 216 bool started_in_foreground_; | 220 bool started_in_foreground_; |
| 217 | 221 |
| 218 PageLoadTiming timing_; | 222 PageLoadTiming timing_; |
| 219 GURL url_; | 223 GURL url_; |
| 220 | 224 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 284 |
| 281 rappor::RapporService* const rappor_service_; | 285 rappor::RapporService* const rappor_service_; |
| 282 base::ObserverList<PageLoadMetricsObserver, true> observers_; | 286 base::ObserverList<PageLoadMetricsObserver, true> observers_; |
| 283 | 287 |
| 284 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 288 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
| 285 }; | 289 }; |
| 286 | 290 |
| 287 } // namespace page_load_metrics | 291 } // namespace page_load_metrics |
| 288 | 292 |
| 289 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O
BSERVER_H_ | 293 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O
BSERVER_H_ |
| OLD | NEW |