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_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/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 // these counts. This includes all failed provisional loads. | 45 // these counts. This includes all failed provisional loads. |
| 46 PAGE_LOAD_ABORTED_BEFORE_FIRST_LAYOUT, | 46 PAGE_LOAD_ABORTED_BEFORE_FIRST_LAYOUT, |
| 47 | 47 |
| 48 // We increase this count if a page load successfully has a layout. | 48 // We increase this count if a page load successfully has a layout. |
| 49 // Differentiate between loads that were backgrounded before first layout. | 49 // Differentiate between loads that were backgrounded before first layout. |
| 50 // Note that a load that is backgrounded, then foregrounded before first | 50 // Note that a load that is backgrounded, then foregrounded before first |
| 51 // layout will still end up in the backgrounded bucket. | 51 // layout will still end up in the backgrounded bucket. |
| 52 PAGE_LOAD_SUCCESSFUL_FIRST_LAYOUT_FOREGROUND, | 52 PAGE_LOAD_SUCCESSFUL_FIRST_LAYOUT_FOREGROUND, |
| 53 PAGE_LOAD_SUCCESSFUL_FIRST_LAYOUT_BACKGROUND, | 53 PAGE_LOAD_SUCCESSFUL_FIRST_LAYOUT_BACKGROUND, |
| 54 | 54 |
| 55 // The user aborted the page load before first layout, and the page is one | |
| 56 // that we would have logged first layout info from (e.g. it is http/https, | |
| 57 // not same-page, etc.). | |
| 58 PAGE_LOAD_RELEVANT_ABORTED_BEFORE_FIRST_LAYOUT, | |
| 59 | |
| 60 // Counts the number of page loads started in foreground / background. | |
| 61 PAGE_LOAD_RELEVANT_STARTED_IN_FOREGROUND, | |
| 62 PAGE_LOAD_RELEVANT_STARTED_IN_BACKGROUND, | |
| 63 | |
| 64 // A timing IPC was sent from the renderer that did not line up with previous | |
| 65 // data we've received (i.e. navigation start is different or the timing | |
| 66 // struct is somehow invalid). | |
| 67 PAGE_LOAD_BAD_IPC, | |
|
Randy Smith (Not in Mondays)
2015/10/06 19:24:00
I'd like the comments for these instances to make
| |
| 68 | |
| 55 // Add values before this final count. | 69 // Add values before this final count. |
| 56 PAGE_LOAD_LAST_ENTRY | 70 PAGE_LOAD_LAST_ENTRY |
| 57 }; | 71 }; |
| 58 | 72 |
| 59 class PageLoadTracker { | 73 class PageLoadTracker { |
| 60 public: | 74 public: |
| 61 explicit PageLoadTracker(bool in_foreground); | 75 explicit PageLoadTracker(bool in_foreground); |
| 62 ~PageLoadTracker(); | 76 ~PageLoadTracker(); |
| 63 void Commit(); | 77 void Commit(); |
| 64 void WebContentsHidden(); | 78 void WebContentsHidden(); |
| 79 void WebContentsShown(); | |
| 65 | 80 |
| 66 // Returns true if the timing was successfully updated. | 81 // Returns true if the timing was successfully updated. |
| 67 bool UpdateTiming(const PageLoadTiming& timing); | 82 bool UpdateTiming(const PageLoadTiming& timing); |
| 68 void RecordEvent(PageLoadEvent event); | 83 void RecordEvent(PageLoadEvent event); |
| 69 | 84 |
| 70 private: | 85 private: |
| 71 void RecordTimingHistograms(); | 86 void RecordTimingHistograms(); |
| 72 | 87 |
| 73 bool has_commit_; | 88 bool has_commit_; |
| 74 | 89 |
| 75 // We record separate metrics for events that occur after a background, | 90 // We record separate metrics for events that occur after a background, |
| 76 // because metrics like layout/paint are delayed artificially | 91 // because metrics like layout/paint are delayed artificially |
| 77 // when they occur in the bacground. | 92 // when they occur in the bacground. |
| 78 base::TimeTicks background_time_; | 93 base::TimeTicks background_time_; |
| 94 base::TimeTicks foreground_time_; | |
| 79 bool started_in_foreground_; | 95 bool started_in_foreground_; |
| 80 | 96 |
| 81 PageLoadTiming timing_; | 97 PageLoadTiming timing_; |
| 82 | 98 |
| 83 DISALLOW_COPY_AND_ASSIGN(PageLoadTracker); | 99 DISALLOW_COPY_AND_ASSIGN(PageLoadTracker); |
| 84 }; | 100 }; |
| 85 | 101 |
| 86 // MetricsWebContentsObserver logs page load UMA metrics based on | 102 // MetricsWebContentsObserver logs page load UMA metrics based on |
| 87 // IPC messages received from a MetricsRenderFrameObserver. | 103 // IPC messages received from a MetricsRenderFrameObserver. |
| 88 class MetricsWebContentsObserver | 104 class MetricsWebContentsObserver |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 base::ScopedPtrMap<content::NavigationHandle*, scoped_ptr<PageLoadTracker>> | 139 base::ScopedPtrMap<content::NavigationHandle*, scoped_ptr<PageLoadTracker>> |
| 124 provisional_loads_; | 140 provisional_loads_; |
| 125 scoped_ptr<PageLoadTracker> committed_load_; | 141 scoped_ptr<PageLoadTracker> committed_load_; |
| 126 | 142 |
| 127 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 143 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
| 128 }; | 144 }; |
| 129 | 145 |
| 130 } // namespace page_load_metrics | 146 } // namespace page_load_metrics |
| 131 | 147 |
| 132 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_ | 148 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_ |
| OLD | NEW |