Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Side by Side Diff: chrome/browser/metrics/first_web_contents_profiler.h

Issue 1416963002: Abandon startup profiling for first WebContents when it gets hidden or navigated to a different ... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 16 matching lines...) Expand all
27 virtual void ProfilerFinishedCollectingMetrics() = 0; 27 virtual void ProfilerFinishedCollectingMetrics() = 0;
28 }; 28 };
29 29
30 // Creates a profiler for the active web contents. If there are multiple 30 // Creates a profiler for the active web contents. If there are multiple
31 // browsers, the first one is chosen. If there are no browsers, returns 31 // browsers, the first one is chosen. If there are no browsers, returns
32 // nullptr. 32 // nullptr.
33 static scoped_ptr<FirstWebContentsProfiler> CreateProfilerForFirstWebContents( 33 static scoped_ptr<FirstWebContentsProfiler> CreateProfilerForFirstWebContents(
34 Delegate* delegate); 34 Delegate* delegate);
35 35
36 private: 36 private:
37 // Reasons for which profiling is deemed complete. Logged in UMA (do not re-
38 // order or re-assign).
39 enum FinishReason {
40 // All metrics were successfully gathered.
41 DONE = 0,
42 // Abandon if blocking UI was shown during startup.
43 ABANDON_BLOCKING_UI = 1,
44 // Abandon if the content is hidden (lowers scheduling priority).
45 ABANDON_CONTENT_HIDDEN = 2,
46 // Abandon if the content is destroyed.
47 ABANDON_CONTENT_DESTROYED = 3,
48 // Abandon if the WebContents navigates away from its initial page.
49 ABANDON_NAVIGATION = 4,
50 // Must stay last.
51 COUNT
rkaplow 2015/10/20 20:08:30 usually I see this as something like ENUM_MAX whic
gab 2015/10/20 20:16:21 Done.
52 };
53
37 FirstWebContentsProfiler(content::WebContents* web_contents, 54 FirstWebContentsProfiler(content::WebContents* web_contents,
38 Delegate* delegate); 55 Delegate* delegate);
39 56
40 // content::WebContentsObserver: 57 // content::WebContentsObserver:
41 void DidFirstVisuallyNonEmptyPaint() override; 58 void DidFirstVisuallyNonEmptyPaint() override;
42 void DocumentOnLoadCompletedInMainFrame() override; 59 void DocumentOnLoadCompletedInMainFrame() override;
60 void NavigationEntryCommitted(
61 const content::LoadCommittedDetails& load_details) override;
62 void WasHidden() override;
43 void WebContentsDestroyed() override; 63 void WebContentsDestroyed() override;
44 64
45 // Whether this instance has finished collecting all of its metrics. 65 // Whether this instance has finished collecting all of its metrics.
46 bool IsFinishedCollectingMetrics(); 66 bool IsFinishedCollectingMetrics();
47 67
48 // Informs the delegate that this instance has finished collecting all of its 68 // Informs the delegate that this instance has finished collecting all of its
49 // metrics. 69 // metrics. Logs |finish_reason| to UMA.
50 void FinishedCollectingMetrics(); 70 void FinishedCollectingMetrics(FinishReason finish_reason);
51 71
52 // Initialize histograms for unresponsiveness metrics. 72 // Initialize histograms for unresponsiveness metrics.
53 void InitHistograms(); 73 void InitHistograms();
54 74
75 // Becomes true on the first invocation of NavigationEntryCommitted() for the
76 // main frame. Any follow-up navigation to a different page will result in
77 // aborting first WebContents profiling.
78 bool initial_entry_committed_;
79
55 // Whether an attempt was made to collect the "NonEmptyPaint" metric. 80 // Whether an attempt was made to collect the "NonEmptyPaint" metric.
56 bool collected_paint_metric_; 81 bool collected_paint_metric_;
57 82
58 // Whether an attempt was made to collect the "MainFrameLoad" metric. 83 // Whether an attempt was made to collect the "MainFrameLoad" metric.
59 bool collected_load_metric_; 84 bool collected_load_metric_;
60 85
61 // |delegate_| owns |this|. 86 // |delegate_| owns |this|.
62 Delegate* delegate_; 87 Delegate* delegate_;
63 88
64 // Histogram that keeps track of response times for the watched thread. 89 // Histogram that keeps track of response times for the watched thread.
(...skipping 11 matching lines...) Expand all
76 // Histogram that keeps track of response times for the watched thread. 101 // Histogram that keeps track of response times for the watched thread.
77 base::HistogramBase* unresponsiveness_1sec_histogram_; 102 base::HistogramBase* unresponsiveness_1sec_histogram_;
78 103
79 // Histogram that keeps track of response times for the watched thread. 104 // Histogram that keeps track of response times for the watched thread.
80 base::HistogramBase* unresponsiveness_10sec_histogram_; 105 base::HistogramBase* unresponsiveness_10sec_histogram_;
81 106
82 DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler); 107 DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler);
83 }; 108 };
84 109
85 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ 110 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698