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

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

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 #if !defined(OS_ANDROID) 5 #if !defined(OS_ANDROID)
6 6
7 #include "chrome/browser/metrics/first_web_contents_profiler.h" 7 #include "chrome/browser/metrics/first_web_contents_profiler.h"
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "components/metrics/profiler/tracking_synchronizer.h" 17 #include "components/metrics/profiler/tracking_synchronizer.h"
18 #include "components/metrics/proto/profiler_event.pb.h" 18 #include "components/metrics/proto/profiler_event.pb.h"
19 #include "components/startup_metric_utils/browser/startup_metric_utils.h" 19 #include "components/startup_metric_utils/browser/startup_metric_utils.h"
20 #include "content/public/browser/navigation_handle.h" 20 #include "content/public/browser/navigation_handle.h"
21 21
22 void FirstWebContentsProfiler::WebContentsStarted(
23 content::WebContents* web_contents) {
24 static bool first_web_contents_profiled = false;
25 if (first_web_contents_profiled)
26 return;
27
28 first_web_contents_profiled = true;
29 new FirstWebContentsProfiler(web_contents);
gab 2016/10/04 19:15:17 // FirstWebContentsProfiler owns itself.
jam 2016/10/04 19:19:17 acknowledged, although in this case I think if som
gab 2016/10/04 19:26:23 okay, I personally find bare "new" surprising and
30 }
31
22 FirstWebContentsProfiler::FirstWebContentsProfiler( 32 FirstWebContentsProfiler::FirstWebContentsProfiler(
23 content::WebContents* web_contents) 33 content::WebContents* web_contents)
24 : content::WebContentsObserver(web_contents), 34 : content::WebContentsObserver(web_contents),
25 collected_paint_metric_(false), 35 collected_paint_metric_(false),
26 collected_load_metric_(false), 36 collected_load_metric_(false),
27 collected_main_navigation_start_metric_(false), 37 collected_main_navigation_start_metric_(false),
28 collected_main_navigation_finished_metric_(false) {} 38 collected_main_navigation_finished_metric_(false) {}
29 39
30 void FirstWebContentsProfiler::DidFirstVisuallyNonEmptyPaint() { 40 void FirstWebContentsProfiler::DidFirstVisuallyNonEmptyPaint() {
31 if (collected_paint_metric_) 41 if (collected_paint_metric_)
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 149 }
140 if (!collected_load_metric_) { 150 if (!collected_load_metric_) {
141 UMA_HISTOGRAM_ENUMERATION("Startup.FirstWebContents.FinishReason_NoLoad", 151 UMA_HISTOGRAM_ENUMERATION("Startup.FirstWebContents.FinishReason_NoLoad",
142 finish_reason, FinishReason::ENUM_MAX); 152 finish_reason, FinishReason::ENUM_MAX);
143 } 153 }
144 154
145 delete this; 155 delete this;
146 } 156 }
147 157
148 #endif // !defined(OS_ANDROID) 158 #endif // !defined(OS_ANDROID)
OLDNEW
« no previous file with comments | « chrome/browser/metrics/first_web_contents_profiler.h ('k') | chrome/browser/sessions/session_restore.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698