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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 enum FinishReason { | 39 enum FinishReason { |
40 // All metrics were successfully gathered. | 40 // All metrics were successfully gathered. |
41 DONE = 0, | 41 DONE = 0, |
42 // Abandon if blocking UI was shown during startup. | 42 // Abandon if blocking UI was shown during startup. |
43 ABANDON_BLOCKING_UI = 1, | 43 ABANDON_BLOCKING_UI = 1, |
44 // Abandon if the content is hidden (lowers scheduling priority). | 44 // Abandon if the content is hidden (lowers scheduling priority). |
45 ABANDON_CONTENT_HIDDEN = 2, | 45 ABANDON_CONTENT_HIDDEN = 2, |
46 // Abandon if the content is destroyed. | 46 // Abandon if the content is destroyed. |
47 ABANDON_CONTENT_DESTROYED = 3, | 47 ABANDON_CONTENT_DESTROYED = 3, |
48 // Abandon if the WebContents navigates away from its initial page. | 48 // Abandon if the WebContents navigates away from its initial page. |
49 ABANDON_NAVIGATION = 4, | 49 ABANDON_NEW_NAVIGATION = 4, |
| 50 // Abandon if the WebContents fails to load (e.g. network error, etc.). |
| 51 ABANDON_NAVIGATION_ERROR = 5, |
50 ENUM_MAX | 52 ENUM_MAX |
51 }; | 53 }; |
52 | 54 |
53 FirstWebContentsProfiler(content::WebContents* web_contents, | 55 FirstWebContentsProfiler(content::WebContents* web_contents, |
54 Delegate* delegate); | 56 Delegate* delegate); |
55 | 57 |
56 // content::WebContentsObserver: | 58 // content::WebContentsObserver: |
57 void DidFirstVisuallyNonEmptyPaint() override; | 59 void DidFirstVisuallyNonEmptyPaint() override; |
58 void DocumentOnLoadCompletedInMainFrame() override; | 60 void DocumentOnLoadCompletedInMainFrame() override; |
59 void NavigationEntryCommitted( | 61 void DidStartNavigation( |
60 const content::LoadCommittedDetails& load_details) override; | 62 content::NavigationHandle* navigation_handle) override; |
| 63 void DidFinishNavigation( |
| 64 content::NavigationHandle* navigation_handle) override; |
61 void WasHidden() override; | 65 void WasHidden() override; |
62 void WebContentsDestroyed() override; | 66 void WebContentsDestroyed() override; |
63 | 67 |
64 // Whether this instance has finished collecting all of its metrics. | 68 // Whether this instance has finished collecting first-paint and main-frame- |
| 69 // load metrics (navigation metrics are recorded on a best effort but don't |
| 70 // prevent the FirstWebContentsProfiler from calling it). |
65 bool IsFinishedCollectingMetrics(); | 71 bool IsFinishedCollectingMetrics(); |
66 | 72 |
67 // Informs the delegate that this instance has finished collecting all of its | 73 // Informs the delegate that this instance has finished collecting all of its |
68 // metrics. Logs |finish_reason| to UMA. | 74 // metrics. Logs |finish_reason| to UMA. |
69 void FinishedCollectingMetrics(FinishReason finish_reason); | 75 void FinishedCollectingMetrics(FinishReason finish_reason); |
70 | 76 |
71 // Initialize histograms for unresponsiveness metrics. | 77 // Initialize histograms for unresponsiveness metrics. |
72 void InitHistograms(); | 78 void InitHistograms(); |
73 | 79 |
74 // Becomes true on the first invocation of NavigationEntryCommitted() for the | |
75 // main frame. Any follow-up navigation to a different page will result in | |
76 // aborting first WebContents profiling. | |
77 bool initial_entry_committed_; | |
78 | |
79 // Whether an attempt was made to collect the "NonEmptyPaint" metric. | 80 // Whether an attempt was made to collect the "NonEmptyPaint" metric. |
80 bool collected_paint_metric_; | 81 bool collected_paint_metric_; |
81 | 82 |
82 // Whether an attempt was made to collect the "MainFrameLoad" metric. | 83 // Whether an attempt was made to collect the "MainFrameLoad" metric. |
83 bool collected_load_metric_; | 84 bool collected_load_metric_; |
84 | 85 |
| 86 // Whether an attempt was made to collect the "MainNavigationStart" metric. |
| 87 bool collected_main_navigation_start_metric_; |
| 88 |
| 89 // Whether an attempt was made to collect the "MainNavigationFinished" metric. |
| 90 bool collected_main_navigation_finished_metric_; |
| 91 |
85 // |delegate_| owns |this|. | 92 // |delegate_| owns |this|. |
86 Delegate* delegate_; | 93 Delegate* delegate_; |
87 | 94 |
88 // Histogram that keeps track of response times for the watched thread. | 95 // Histogram that keeps track of response times for the watched thread. |
89 base::HistogramBase* responsiveness_histogram_; | 96 base::HistogramBase* responsiveness_histogram_; |
90 | 97 |
91 // Histogram that keeps track of response times for the watched thread. | 98 // Histogram that keeps track of response times for the watched thread. |
92 base::HistogramBase* responsiveness_1sec_histogram_; | 99 base::HistogramBase* responsiveness_1sec_histogram_; |
93 | 100 |
94 // Histogram that keeps track of response times for the watched thread. | 101 // Histogram that keeps track of response times for the watched thread. |
95 base::HistogramBase* responsiveness_10sec_histogram_; | 102 base::HistogramBase* responsiveness_10sec_histogram_; |
96 | 103 |
97 // Histogram that keeps track of response times for the watched thread. | 104 // Histogram that keeps track of response times for the watched thread. |
98 base::HistogramBase* unresponsiveness_histogram_; | 105 base::HistogramBase* unresponsiveness_histogram_; |
99 | 106 |
100 // Histogram that keeps track of response times for the watched thread. | 107 // Histogram that keeps track of response times for the watched thread. |
101 base::HistogramBase* unresponsiveness_1sec_histogram_; | 108 base::HistogramBase* unresponsiveness_1sec_histogram_; |
102 | 109 |
103 // Histogram that keeps track of response times for the watched thread. | 110 // Histogram that keeps track of response times for the watched thread. |
104 base::HistogramBase* unresponsiveness_10sec_histogram_; | 111 base::HistogramBase* unresponsiveness_10sec_histogram_; |
105 | 112 |
106 DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler); | 113 DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler); |
107 }; | 114 }; |
108 | 115 |
109 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ | 116 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ |
OLD | NEW |