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" |
| 11 #include "components/page_load_metrics/common/page_load_timing.h" | 11 #include "components/page_load_metrics/common/page_load_timing.h" |
| 12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 14 #include "content/public/browser/web_contents_user_data.h" | 14 #include "content/public/browser/web_contents_user_data.h" |
| 15 #include "net/base/net_errors.h" | |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 class NavigationHandle; | 18 class NavigationHandle; |
| 18 class RenderFrameHost; | 19 class RenderFrameHost; |
| 19 } // namespace content | 20 } // namespace content |
| 20 | 21 |
| 21 namespace IPC { | 22 namespace IPC { |
| 22 class Message; | 23 class Message; |
| 23 } // namespace IPC | 24 } // namespace IPC |
| 24 | 25 |
| 25 namespace page_load_metrics { | 26 namespace page_load_metrics { |
| 26 | 27 |
| 28 enum PageLoadEvent { | |
| 29 PAGE_LOAD_STARTED, | |
| 30 | |
| 31 // A provisional load is a load before it commits. | |
|
Randy Smith (Not in Mondays)
2015/10/01 17:18:08
Define commits? I.e. (assuming I have the right d
Charlie Harrison
2015/10/01 17:58:17
Done.
| |
| 32 // A load failed before it was committed for any reason, e.g. from a user | |
| 33 // abort or a network timeout. | |
| 34 PAGE_LOAD_FAILED_PROVISIONAL, | |
|
Randy Smith (Not in Mondays)
2015/10/01 17:18:08
suggestion: I think "FAILED_BEFORE_COMMIT" would b
Charlie Harrison
2015/10/01 17:58:17
Done.
| |
| 35 | |
| 36 // A subset of PAGE_LOAD_FAILED_PROVISIONAL, this counts the specific failures | |
| 37 // due to user aborts. | |
| 38 PAGE_LOAD_ABORTED_PROVISIONAL, | |
| 39 | |
| 40 // When a load is aborted anytime before the page's first layout, we increase | |
| 41 // this count. This includes all failed provisional loads. | |
| 42 PAGE_LOAD_ABORTED_BEFORE_FIRST_LAYOUT, | |
| 43 | |
| 44 // We increase this count if a page load successfully has a layout. | |
|
Randy Smith (Not in Mondays)
2015/10/01 17:18:09
nit: "these counts"
Charlie Harrison
2015/10/01 17:58:17
Done.
| |
| 45 // Differentiate between loads that were backgrounded before first layout. | |
|
Randy Smith (Not in Mondays)
2015/10/01 17:18:08
Just confirming: If a page is backgrounded and the
Charlie Harrison
2015/10/01 17:58:17
Yupp, I edited the comment.
| |
| 46 PAGE_LOAD_SUCCESSFUL_FIRST_LAYOUT_FG, | |
| 47 PAGE_LOAD_SUCCESSFUL_FIRST_LAYOUT_BG, | |
|
Randy Smith (Not in Mondays)
2015/10/01 17:18:08
We historically discourage abbreviations in chromi
| |
| 48 | |
| 49 // Add values before this final count. Make sure you also update | |
| 50 // histograms.xml. | |
|
Randy Smith (Not in Mondays)
2015/10/01 17:18:09
Actually, the note about the link to histograms.xm
Charlie Harrison
2015/10/01 17:58:17
Done.
| |
| 51 PAGE_LOAD_LAST_ENTRY | |
| 52 }; | |
| 53 | |
| 27 class PageLoadTracker { | 54 class PageLoadTracker { |
| 28 public: | 55 public: |
| 29 explicit PageLoadTracker(bool in_foreground); | 56 explicit PageLoadTracker(bool in_foreground); |
| 30 ~PageLoadTracker(); | 57 ~PageLoadTracker(); |
| 31 void Commit(); | 58 void Commit(); |
| 32 void WebContentsHidden(); | 59 void WebContentsHidden(); |
| 33 | 60 |
| 34 // Returns true if the timing was successfully updated. | 61 // Returns true if the timing was successfully updated. |
| 35 bool UpdateTiming(const PageLoadTiming& timing); | 62 bool UpdateTiming(const PageLoadTiming& timing); |
| 63 void RecordEvent(PageLoadEvent event); | |
| 36 | 64 |
| 37 private: | 65 private: |
| 38 void RecordTimingHistograms(); | 66 void RecordTimingHistograms(); |
| 39 | 67 |
| 40 bool has_commit_; | 68 bool has_commit_; |
| 41 | 69 |
| 42 // We record separate metrics for events that occur after a background, | 70 // We record separate metrics for events that occur after a background, |
| 43 // because metrics like layout/paint are delayed artificially | 71 // because metrics like layout/paint are delayed artificially |
| 44 // when they occur in the bacground. | 72 // when they occur in the bacground. |
| 45 base::TimeTicks background_time_; | 73 base::TimeTicks background_time_; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 base::ScopedPtrMap<content::NavigationHandle*, scoped_ptr<PageLoadTracker>> | 118 base::ScopedPtrMap<content::NavigationHandle*, scoped_ptr<PageLoadTracker>> |
| 91 provisional_loads_; | 119 provisional_loads_; |
| 92 scoped_ptr<PageLoadTracker> committed_load_; | 120 scoped_ptr<PageLoadTracker> committed_load_; |
| 93 | 121 |
| 94 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 122 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
| 95 }; | 123 }; |
| 96 | 124 |
| 97 } // namespace page_load_metrics | 125 } // namespace page_load_metrics |
| 98 | 126 |
| 99 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_ | 127 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_ |
| OLD | NEW |