OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ | 5 #ifndef CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ |
6 #define CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ | 6 #define CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ |
7 | 7 |
| 8 #include <set> |
| 9 |
8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
10 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
11 | 13 |
12 namespace content { | 14 namespace content { |
13 class WebContents; | 15 class WebContents; |
14 } // namespace content | 16 } // namespace content |
15 | 17 |
16 // Measures start up performance of the first active web contents. | 18 // Measures start up performance of the first active web contents. |
17 // This class is declared on all platforms, but only defined on non-Android | 19 // This class is declared on all platforms, but only defined on non-Android |
(...skipping 17 matching lines...) Expand all Loading... |
35 // Abandon if the content is hidden (lowers scheduling priority). | 37 // Abandon if the content is hidden (lowers scheduling priority). |
36 ABANDON_CONTENT_HIDDEN = 2, | 38 ABANDON_CONTENT_HIDDEN = 2, |
37 // Abandon if the content is destroyed. | 39 // Abandon if the content is destroyed. |
38 ABANDON_CONTENT_DESTROYED = 3, | 40 ABANDON_CONTENT_DESTROYED = 3, |
39 // Abandon if the WebContents navigates away from its initial page. | 41 // Abandon if the WebContents navigates away from its initial page. |
40 ABANDON_NAVIGATION = 4, | 42 ABANDON_NAVIGATION = 4, |
41 ENUM_MAX | 43 ENUM_MAX |
42 }; | 44 }; |
43 | 45 |
44 explicit FirstWebContentsProfiler(content::WebContents* web_contents); | 46 explicit FirstWebContentsProfiler(content::WebContents* web_contents); |
45 ~FirstWebContentsProfiler() = default; | 47 ~FirstWebContentsProfiler(); |
46 | 48 |
47 // content::WebContentsObserver: | 49 // content::WebContentsObserver: |
48 void DidFirstVisuallyNonEmptyPaint() override; | 50 void DidFirstVisuallyNonEmptyPaint() override; |
49 void DocumentOnLoadCompletedInMainFrame() override; | 51 void DocumentOnLoadCompletedInMainFrame() override; |
| 52 void DidStartNavigation( |
| 53 content::NavigationHandle* navigation_handle) override; |
| 54 void DidFinishNavigation( |
| 55 content::NavigationHandle* navigation_handle) override; |
50 void NavigationEntryCommitted( | 56 void NavigationEntryCommitted( |
51 const content::LoadCommittedDetails& load_details) override; | 57 const content::LoadCommittedDetails& load_details) override; |
52 void WasHidden() override; | 58 void WasHidden() override; |
53 void WebContentsDestroyed() override; | 59 void WebContentsDestroyed() override; |
54 | 60 |
55 // Whether this instance has finished collecting all of its metrics. | 61 // Whether this instance has finished collecting first-paint and main-frame- |
| 62 // load metrics (navigation metrics are recorded on a best effort but don't |
| 63 // prevent the FirstWebContentsProfiler from calling it). |
56 bool IsFinishedCollectingMetrics(); | 64 bool IsFinishedCollectingMetrics(); |
57 | 65 |
58 // Logs |finish_reason| to UMA and deletes this FirstWebContentsProfiler. | 66 // Logs |finish_reason| to UMA and deletes this FirstWebContentsProfiler. |
59 void FinishedCollectingMetrics(FinishReason finish_reason); | 67 void FinishedCollectingMetrics(FinishReason finish_reason); |
60 | 68 |
61 // Initialize histograms for unresponsiveness metrics. | 69 // Initialize histograms for unresponsiveness metrics. |
62 void InitHistograms(); | 70 void InitHistograms(); |
63 | 71 |
64 // Becomes true on the first invocation of NavigationEntryCommitted() for the | 72 // Becomes true on the first invocation of NavigationEntryCommitted() for the |
65 // main frame. Any follow-up navigation to a different page will result in | 73 // main frame. Any follow-up navigation to a different page will result in |
66 // aborting first WebContents profiling. | 74 // aborting first WebContents profiling. |
67 bool initial_entry_committed_; | 75 bool initial_entry_committed_; |
68 | 76 |
69 // Whether an attempt was made to collect the "NonEmptyPaint" metric. | 77 // Whether an attempt was made to collect the "NonEmptyPaint" metric. |
70 bool collected_paint_metric_; | 78 bool collected_paint_metric_; |
71 | 79 |
72 // Whether an attempt was made to collect the "MainFrameLoad" metric. | 80 // Whether an attempt was made to collect the "MainFrameLoad" metric. |
73 bool collected_load_metric_; | 81 bool collected_load_metric_; |
74 | 82 |
| 83 // Whether an attempt was made to collect the "MainNavigationStart" metric. |
| 84 bool collected_main_navigation_start_metric_; |
| 85 |
| 86 // Whether an attempt was made to collect the "MainNavigationFinished" metric. |
| 87 bool collected_main_navigation_finished_metric_; |
| 88 |
| 89 // Whether an attempt was made to collect the "MainNavigationFinishedAll" |
| 90 // metric. |
| 91 bool collected_main_navigation_finished_all_metric_; |
| 92 |
| 93 // The set of all live NavigationHandles for the main frame (i.e. handles seen |
| 94 // by DidStartNavigation() but not by DidFinishNavigation()). |
| 95 std::set<content::NavigationHandle*> main_navigation_handles_; |
| 96 |
75 // Histogram that keeps track of response times for the watched thread. | 97 // Histogram that keeps track of response times for the watched thread. |
76 base::HistogramBase* responsiveness_histogram_; | 98 base::HistogramBase* responsiveness_histogram_; |
77 | 99 |
78 // Histogram that keeps track of response times for the watched thread. | 100 // Histogram that keeps track of response times for the watched thread. |
79 base::HistogramBase* responsiveness_1sec_histogram_; | 101 base::HistogramBase* responsiveness_1sec_histogram_; |
80 | 102 |
81 // Histogram that keeps track of response times for the watched thread. | 103 // Histogram that keeps track of response times for the watched thread. |
82 base::HistogramBase* responsiveness_10sec_histogram_; | 104 base::HistogramBase* responsiveness_10sec_histogram_; |
83 | 105 |
84 // Histogram that keeps track of response times for the watched thread. | 106 // Histogram that keeps track of response times for the watched thread. |
85 base::HistogramBase* unresponsiveness_histogram_; | 107 base::HistogramBase* unresponsiveness_histogram_; |
86 | 108 |
87 // Histogram that keeps track of response times for the watched thread. | 109 // Histogram that keeps track of response times for the watched thread. |
88 base::HistogramBase* unresponsiveness_1sec_histogram_; | 110 base::HistogramBase* unresponsiveness_1sec_histogram_; |
89 | 111 |
90 // Histogram that keeps track of response times for the watched thread. | 112 // Histogram that keeps track of response times for the watched thread. |
91 base::HistogramBase* unresponsiveness_10sec_histogram_; | 113 base::HistogramBase* unresponsiveness_10sec_histogram_; |
92 | 114 |
93 DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler); | 115 DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler); |
94 }; | 116 }; |
95 | 117 |
96 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ | 118 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ |
OLD | NEW |