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

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: review:rkaplow 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
« no previous file with comments | « no previous file | chrome/browser/metrics/first_web_contents_profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ENUM_MAX
51 };
52
37 FirstWebContentsProfiler(content::WebContents* web_contents, 53 FirstWebContentsProfiler(content::WebContents* web_contents,
38 Delegate* delegate); 54 Delegate* delegate);
39 55
40 // content::WebContentsObserver: 56 // content::WebContentsObserver:
41 void DidFirstVisuallyNonEmptyPaint() override; 57 void DidFirstVisuallyNonEmptyPaint() override;
42 void DocumentOnLoadCompletedInMainFrame() override; 58 void DocumentOnLoadCompletedInMainFrame() override;
59 void NavigationEntryCommitted(
60 const content::LoadCommittedDetails& load_details) override;
61 void WasHidden() override;
43 void WebContentsDestroyed() override; 62 void WebContentsDestroyed() override;
44 63
45 // Whether this instance has finished collecting all of its metrics. 64 // Whether this instance has finished collecting all of its metrics.
46 bool IsFinishedCollectingMetrics(); 65 bool IsFinishedCollectingMetrics();
47 66
48 // Informs the delegate that this instance has finished collecting all of its 67 // Informs the delegate that this instance has finished collecting all of its
49 // metrics. 68 // metrics. Logs |finish_reason| to UMA.
50 void FinishedCollectingMetrics(); 69 void FinishedCollectingMetrics(FinishReason finish_reason);
51 70
52 // Initialize histograms for unresponsiveness metrics. 71 // Initialize histograms for unresponsiveness metrics.
53 void InitHistograms(); 72 void InitHistograms();
54 73
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
55 // Whether an attempt was made to collect the "NonEmptyPaint" metric. 79 // Whether an attempt was made to collect the "NonEmptyPaint" metric.
56 bool collected_paint_metric_; 80 bool collected_paint_metric_;
57 81
58 // Whether an attempt was made to collect the "MainFrameLoad" metric. 82 // Whether an attempt was made to collect the "MainFrameLoad" metric.
59 bool collected_load_metric_; 83 bool collected_load_metric_;
60 84
61 // |delegate_| owns |this|. 85 // |delegate_| owns |this|.
62 Delegate* delegate_; 86 Delegate* delegate_;
63 87
64 // Histogram that keeps track of response times for the watched thread. 88 // 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. 100 // Histogram that keeps track of response times for the watched thread.
77 base::HistogramBase* unresponsiveness_1sec_histogram_; 101 base::HistogramBase* unresponsiveness_1sec_histogram_;
78 102
79 // Histogram that keeps track of response times for the watched thread. 103 // Histogram that keeps track of response times for the watched thread.
80 base::HistogramBase* unresponsiveness_10sec_histogram_; 104 base::HistogramBase* unresponsiveness_10sec_histogram_;
81 105
82 DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler); 106 DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler);
83 }; 107 };
84 108
85 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ 109 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/first_web_contents_profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698