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

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

Issue 2388803003: Fix FirstWebContentsProfiler not getting created when using session restore. (Closed)
Patch Set: Created 4 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 <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "content/public/browser/web_contents_observer.h" 11 #include "content/public/browser/web_contents_observer.h"
12 12
13 namespace content { 13 namespace content {
14 class WebContents; 14 class WebContents;
15 } // namespace content 15 } // namespace content
16 16
17 // Measures start up performance of the first active web contents. 17 // Measures start up performance of the first active web contents.
18 // This class is declared on all platforms, but only defined on non-Android 18 // 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 19 // platforms. Android code should not call any non-trivial methods on this
20 // class. 20 // class.
21 class FirstWebContentsProfiler : public content::WebContentsObserver { 21 class FirstWebContentsProfiler : public content::WebContentsObserver {
22 public: 22 public:
23 explicit FirstWebContentsProfiler(content::WebContents* web_contents); 23 // Creates a profiler for the active web contents. If there are multiple
24 // browsers, the first one is chosen. The resulting FirstWebContentsProfiler
25 // owns itself.
26 static void WebContentsStarted(content::WebContents* web_contents);
24 27
25 private: 28 private:
26 // Reasons for which profiling is deemed complete. Logged in UMA (do not re- 29 // Reasons for which profiling is deemed complete. Logged in UMA (do not re-
27 // order or re-assign). 30 // order or re-assign).
28 enum FinishReason { 31 enum FinishReason {
29 // All metrics were successfully gathered. 32 // All metrics were successfully gathered.
30 DONE = 0, 33 DONE = 0,
31 // Abandon if blocking UI was shown during startup. 34 // Abandon if blocking UI was shown during startup.
32 ABANDON_BLOCKING_UI = 1, 35 ABANDON_BLOCKING_UI = 1,
33 // Abandon if the content is hidden (lowers scheduling priority). 36 // Abandon if the content is hidden (lowers scheduling priority).
34 ABANDON_CONTENT_HIDDEN = 2, 37 ABANDON_CONTENT_HIDDEN = 2,
35 // Abandon if the content is destroyed. 38 // Abandon if the content is destroyed.
36 ABANDON_CONTENT_DESTROYED = 3, 39 ABANDON_CONTENT_DESTROYED = 3,
37 // Abandon if the WebContents navigates away from its initial page. 40 // Abandon if the WebContents navigates away from its initial page.
38 ABANDON_NEW_NAVIGATION = 4, 41 ABANDON_NEW_NAVIGATION = 4,
39 // Abandon if the WebContents fails to load (e.g. network error, etc.). 42 // Abandon if the WebContents fails to load (e.g. network error, etc.).
40 ABANDON_NAVIGATION_ERROR = 5, 43 ABANDON_NAVIGATION_ERROR = 5,
41 ENUM_MAX 44 ENUM_MAX
42 }; 45 };
43 46 explicit FirstWebContentsProfiler(content::WebContents* web_contents);
44 ~FirstWebContentsProfiler() override = default; 47 ~FirstWebContentsProfiler() override = default;
45 48
46 // content::WebContentsObserver: 49 // content::WebContentsObserver:
47 void DidFirstVisuallyNonEmptyPaint() override; 50 void DidFirstVisuallyNonEmptyPaint() override;
48 void DocumentOnLoadCompletedInMainFrame() override; 51 void DocumentOnLoadCompletedInMainFrame() override;
49 void DidStartNavigation( 52 void DidStartNavigation(
50 content::NavigationHandle* navigation_handle) override; 53 content::NavigationHandle* navigation_handle) override;
51 void DidFinishNavigation( 54 void DidFinishNavigation(
52 content::NavigationHandle* navigation_handle) override; 55 content::NavigationHandle* navigation_handle) override;
53 void WasHidden() override; 56 void WasHidden() override;
(...skipping 16 matching lines...) Expand all
70 // Whether an attempt was made to collect the "MainNavigationStart" metric. 73 // Whether an attempt was made to collect the "MainNavigationStart" metric.
71 bool collected_main_navigation_start_metric_; 74 bool collected_main_navigation_start_metric_;
72 75
73 // Whether an attempt was made to collect the "MainNavigationFinished" metric. 76 // Whether an attempt was made to collect the "MainNavigationFinished" metric.
74 bool collected_main_navigation_finished_metric_; 77 bool collected_main_navigation_finished_metric_;
75 78
76 DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler); 79 DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler);
77 }; 80 };
78 81
79 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ 82 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698