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

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

Issue 2651823002: Add .SingleTab and .MultiTabs suffix to Startup.FirstWebContents.MainNavigationStart histogram. (Closed)
Patch Set: Created 3 years, 11 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 | « chrome/browser/metrics/OWNERS ('k') | 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 <memory>
9
10 #include "base/macros.h" 8 #include "base/macros.h"
11 #include "content/public/browser/web_contents_observer.h"
12
13 namespace content {
14 class WebContents;
15 } // namespace content
16 9
17 // Measures start up performance of the first active web contents. 10 // Measures start up performance of the first active web contents.
18 // This class is declared on all platforms, but only defined on non-Android 11 // This class is declared on all platforms, but only defined on non-Android
19 // platforms. Android code should not call any non-trivial methods on this 12 // platforms. Android code should not call any non-trivial methods on this
20 // class. 13 // class.
21 class FirstWebContentsProfiler : public content::WebContentsObserver { 14 class FirstWebContentsProfiler {
22 public: 15 public:
23 // Creates a profiler for the active web contents. If there are multiple 16 // Creates a profiler for the active web contents. If there are multiple
24 // browsers, the first one is chosen. The resulting FirstWebContentsProfiler 17 // browsers, the first one is chosen. The resulting FirstWebContentsProfiler
25 // owns itself. 18 // owns itself.
26 static void Start(); 19 static void Start();
fdoray 2017/01/25 14:20:45 Should be a global function. https://google.github
gab 2017/01/26 19:57:56 Right, I can follow up when I get access to a codi
gab 2017/02/06 16:48:21 Done in this one as part of rebase and renamed Fir
27 20
28 private: 21 private:
29 // Reasons for which profiling is deemed complete. Logged in UMA (do not re- 22 DISALLOW_IMPLICIT_CONSTRUCTORS(FirstWebContentsProfiler);
30 // order or re-assign).
31 enum FinishReason {
32 // All metrics were successfully gathered.
33 DONE = 0,
34 // Abandon if blocking UI was shown during startup.
35 ABANDON_BLOCKING_UI = 1,
36 // Abandon if the content is hidden (lowers scheduling priority).
37 ABANDON_CONTENT_HIDDEN = 2,
38 // Abandon if the content is destroyed.
39 ABANDON_CONTENT_DESTROYED = 3,
40 // Abandon if the WebContents navigates away from its initial page.
41 ABANDON_NEW_NAVIGATION = 4,
42 // Abandon if the WebContents fails to load (e.g. network error, etc.).
43 ABANDON_NAVIGATION_ERROR = 5,
44 ENUM_MAX
45 };
46 explicit FirstWebContentsProfiler(content::WebContents* web_contents);
47 ~FirstWebContentsProfiler() override = default;
48
49 // content::WebContentsObserver:
50 void DidFirstVisuallyNonEmptyPaint() override;
51 void DocumentOnLoadCompletedInMainFrame() override;
52 void DidStartNavigation(
53 content::NavigationHandle* navigation_handle) override;
54 void DidFinishNavigation(
55 content::NavigationHandle* navigation_handle) override;
56 void WasHidden() override;
57 void WebContentsDestroyed() override;
58
59 // Whether this instance has finished collecting first-paint and main-frame-
60 // load metrics (navigation metrics are recorded on a best effort but don't
61 // prevent the FirstWebContentsProfiler from calling it).
62 bool IsFinishedCollectingMetrics();
63
64 // Logs |finish_reason| to UMA and deletes this FirstWebContentsProfiler.
65 void FinishedCollectingMetrics(FinishReason finish_reason);
66
67 // Whether an attempt was made to collect the "NonEmptyPaint" metric.
68 bool collected_paint_metric_;
69
70 // Whether an attempt was made to collect the "MainFrameLoad" metric.
71 bool collected_load_metric_;
72
73 // Whether an attempt was made to collect the "MainNavigationStart" metric.
74 bool collected_main_navigation_start_metric_;
75
76 // Whether an attempt was made to collect the "MainNavigationFinished" metric.
77 bool collected_main_navigation_finished_metric_;
78
79 DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler);
80 }; 23 };
81 24
82 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ 25 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_
OLDNEW
« no previous file with comments | « chrome/browser/metrics/OWNERS ('k') | chrome/browser/metrics/first_web_contents_profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698