| Index: components/startup_metric_utils/browser/startup_metric_utils.cc
|
| diff --git a/components/startup_metric_utils/browser/startup_metric_utils.cc b/components/startup_metric_utils/browser/startup_metric_utils.cc
|
| index f1ad613d5df94bc95887beaafc255f963664c4c6..93c77d4b99b2f524320080ed0b57f3cca97d4b21 100644
|
| --- a/components/startup_metric_utils/browser/startup_metric_utils.cc
|
| +++ b/components/startup_metric_utils/browser/startup_metric_utils.cc
|
| @@ -39,7 +39,7 @@ namespace {
|
|
|
| // Mark as volatile to defensively make sure usage is thread-safe.
|
| // Note that at the time of this writing, access is only on the UI thread.
|
| -volatile bool g_non_browser_ui_displayed = false;
|
| +volatile bool g_main_window_startup_interrupted = false;
|
|
|
| base::LazyInstance<base::TimeTicks>::Leaky g_process_creation_ticks =
|
| LAZY_INSTANCE_INITIALIZER;
|
| @@ -388,12 +388,12 @@ void RecordHardFaultHistogram() {
|
| // also the time taken to synchronously resolve base::Time::Now() and
|
| // base::TimeTicks::Now() at play, but in practice it is pretty much instant
|
| // compared to multi-seconds startup timings.
|
| -base::TimeTicks StartupTimeToTimeTicks(const base::Time& time) {
|
| - // First get a base which represents the same point in time in both units.
|
| - // Bump the priority of this thread while doing this as the wall clock time it
|
| - // takes to resolve these two calls affects the precision of this method and
|
| - // bumping the priority reduces the likelihood of a context switch interfering
|
| - // with this computation.
|
| +base::TimeTicks StartupTimeToTimeTicks(base::Time time) {
|
| +// First get a base which represents the same point in time in both units.
|
| +// Bump the priority of this thread while doing this as the wall clock time it
|
| +// takes to resolve these two calls affects the precision of this method and
|
| +// bumping the priority reduces the likelihood of a context switch interfering
|
| +// with this computation.
|
|
|
| // Enabling this logic on OS X causes a significant performance regression.
|
| // https://crbug.com/601270
|
| @@ -455,9 +455,9 @@ void RecordMainEntryTimeHistogram() {
|
|
|
| // Record renderer main entry time histogram.
|
| void RecordRendererMainEntryHistogram() {
|
| - const base::TimeTicks& browser_main_entry_point_ticks =
|
| + const base::TimeTicks browser_main_entry_point_ticks =
|
| g_browser_main_entry_point_ticks.Get();
|
| - const base::TimeTicks& renderer_main_entry_point_ticks =
|
| + const base::TimeTicks renderer_main_entry_point_ticks =
|
| g_renderer_main_entry_point_ticks.Get();
|
|
|
| if (!browser_main_entry_point_ticks.is_null() &&
|
| @@ -548,6 +548,11 @@ void RecordSameVersionStartupCount(PrefService* pref_service) {
|
| g_startups_with_current_version);
|
| }
|
|
|
| +bool ShouldLogStartupHistogram() {
|
| + return !WasMainWindowStartupInterrupted() &&
|
| + !g_process_creation_ticks.Get().is_null();
|
| +}
|
| +
|
| } // namespace
|
|
|
| void RegisterPrefs(PrefRegistrySimple* registry) {
|
| @@ -557,21 +562,25 @@ void RegisterPrefs(PrefRegistrySimple* registry) {
|
| registry->RegisterIntegerPref(prefs::kSameVersionStartupCount, 0);
|
| }
|
|
|
| -bool WasNonBrowserUIDisplayed() {
|
| - return g_non_browser_ui_displayed;
|
| +bool WasMainWindowStartupInterrupted() {
|
| + return g_main_window_startup_interrupted;
|
| }
|
|
|
| void SetNonBrowserUIDisplayed() {
|
| - g_non_browser_ui_displayed = true;
|
| + g_main_window_startup_interrupted = true;
|
| +}
|
| +
|
| +void SetBackgroundModeEnabled() {
|
| + g_main_window_startup_interrupted = true;
|
| }
|
|
|
| -void RecordStartupProcessCreationTime(const base::Time& time) {
|
| +void RecordStartupProcessCreationTime(base::Time time) {
|
| DCHECK(g_process_creation_ticks.Get().is_null());
|
| g_process_creation_ticks.Get() = StartupTimeToTimeTicks(time);
|
| DCHECK(!g_process_creation_ticks.Get().is_null());
|
| }
|
|
|
| -void RecordMainEntryPointTime(const base::Time& time) {
|
| +void RecordMainEntryPointTime(base::Time time) {
|
| DCHECK(g_browser_main_entry_point_ticks.Get().is_null());
|
| g_browser_main_entry_point_ticks.Get() = StartupTimeToTimeTicks(time);
|
| DCHECK(!g_browser_main_entry_point_ticks.Get().is_null());
|
| @@ -583,13 +592,13 @@ void RecordMainEntryPointTime(const base::Time& time) {
|
| DCHECK(!g_browser_main_entry_point_time.Get().is_null());
|
| }
|
|
|
| -void RecordExeMainEntryPointTicks(const base::TimeTicks& ticks) {
|
| +void RecordExeMainEntryPointTicks(base::TimeTicks ticks) {
|
| DCHECK(g_browser_exe_main_entry_point_ticks.Get().is_null());
|
| g_browser_exe_main_entry_point_ticks.Get() = ticks;
|
| DCHECK(!g_browser_exe_main_entry_point_ticks.Get().is_null());
|
| }
|
|
|
| -void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks,
|
| +void RecordBrowserMainMessageLoopStart(base::TimeTicks ticks,
|
| bool is_first_run,
|
| PrefService* pref_service) {
|
| DCHECK(pref_service);
|
| @@ -604,8 +613,7 @@ void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks,
|
| // Record timing of the browser message-loop start time.
|
| base::StackSamplingProfiler::SetProcessMilestone(
|
| metrics::CallStackProfileMetricsProvider::MAIN_LOOP_START);
|
| - const base::TimeTicks& process_creation_ticks =
|
| - g_process_creation_ticks.Get();
|
| + const base::TimeTicks process_creation_ticks = g_process_creation_ticks.Get();
|
| if (!is_first_run && !process_creation_ticks.is_null()) {
|
| UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
|
| UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime",
|
| @@ -657,12 +665,12 @@ void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks,
|
| }
|
| }
|
|
|
| -void RecordBrowserWindowDisplay(const base::TimeTicks& ticks) {
|
| +void RecordBrowserWindowDisplay(base::TimeTicks ticks) {
|
| static bool is_first_call = true;
|
| if (!is_first_call || ticks.is_null())
|
| return;
|
| is_first_call = false;
|
| - if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
|
| + if (!ShouldLogStartupHistogram())
|
| return;
|
|
|
| UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
|
| @@ -670,7 +678,7 @@ void RecordBrowserWindowDisplay(const base::TimeTicks& ticks) {
|
| g_process_creation_ticks.Get(), ticks);
|
| }
|
|
|
| -void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta) {
|
| +void RecordBrowserOpenTabsDelta(base::TimeDelta delta) {
|
| static bool is_first_call = true;
|
| if (!is_first_call)
|
| return;
|
| @@ -680,19 +688,19 @@ void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta) {
|
| UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserOpenTabs", delta);
|
| }
|
|
|
| -void RecordRendererMainEntryTime(const base::TimeTicks& ticks) {
|
| +void RecordRendererMainEntryTime(base::TimeTicks ticks) {
|
| // Record the renderer main entry time, but don't log the UMA metric
|
| // immediately because the startup temperature is not known yet.
|
| if (g_renderer_main_entry_point_ticks.Get().is_null())
|
| g_renderer_main_entry_point_ticks.Get() = ticks;
|
| }
|
|
|
| -void RecordFirstWebContentsMainFrameLoad(const base::TimeTicks& ticks) {
|
| +void RecordFirstWebContentsMainFrameLoad(base::TimeTicks ticks) {
|
| static bool is_first_call = true;
|
| if (!is_first_call || ticks.is_null())
|
| return;
|
| is_first_call = false;
|
| - if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
|
| + if (!ShouldLogStartupHistogram())
|
| return;
|
|
|
| UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
|
| @@ -700,7 +708,7 @@ void RecordFirstWebContentsMainFrameLoad(const base::TimeTicks& ticks) {
|
| g_process_creation_ticks.Get(), ticks);
|
| }
|
|
|
| -void RecordFirstWebContentsNonEmptyPaint(const base::TimeTicks& ticks) {
|
| +void RecordFirstWebContentsNonEmptyPaint(base::TimeTicks ticks) {
|
| static bool is_first_call = true;
|
| if (!is_first_call || ticks.is_null())
|
| return;
|
| @@ -710,7 +718,7 @@ void RecordFirstWebContentsNonEmptyPaint(const base::TimeTicks& ticks) {
|
| // entry time and the startup temperature are known.
|
| RecordRendererMainEntryHistogram();
|
|
|
| - if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
|
| + if (!ShouldLogStartupHistogram())
|
| return;
|
|
|
| base::StackSamplingProfiler::SetProcessMilestone(
|
| @@ -720,13 +728,13 @@ void RecordFirstWebContentsNonEmptyPaint(const base::TimeTicks& ticks) {
|
| g_process_creation_ticks.Get(), ticks);
|
| }
|
|
|
| -void RecordFirstWebContentsMainNavigationStart(const base::TimeTicks& ticks,
|
| +void RecordFirstWebContentsMainNavigationStart(base::TimeTicks ticks,
|
| WebContentsWorkload workload) {
|
| static bool is_first_call = true;
|
| if (!is_first_call || ticks.is_null())
|
| return;
|
| is_first_call = false;
|
| - if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
|
| + if (!ShouldLogStartupHistogram())
|
| return;
|
|
|
| base::StackSamplingProfiler::SetProcessMilestone(
|
| @@ -752,13 +760,12 @@ void RecordFirstWebContentsMainNavigationStart(const base::TimeTicks& ticks,
|
| }
|
| }
|
|
|
| -void RecordFirstWebContentsMainNavigationFinished(
|
| - const base::TimeTicks& ticks) {
|
| +void RecordFirstWebContentsMainNavigationFinished(base::TimeTicks ticks) {
|
| static bool is_first_call = true;
|
| if (!is_first_call || ticks.is_null())
|
| return;
|
| is_first_call = false;
|
| - if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
|
| + if (!ShouldLogStartupHistogram())
|
| return;
|
|
|
| base::StackSamplingProfiler::SetProcessMilestone(
|
| @@ -769,6 +776,34 @@ void RecordFirstWebContentsMainNavigationFinished(
|
| g_process_creation_ticks.Get(), ticks);
|
| }
|
|
|
| +void RecordBrowserWindowFirstPaint(base::TimeTicks ticks) {
|
| + static bool is_first_call = true;
|
| + if (!is_first_call || ticks.is_null())
|
| + return;
|
| + is_first_call = false;
|
| + if (!ShouldLogStartupHistogram())
|
| + return;
|
| +
|
| + UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE(
|
| + UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserWindow.FirstPaint",
|
| + g_process_creation_ticks.Get(), ticks);
|
| +}
|
| +
|
| +void RecordBrowserWindowFirstPaintCompositingEnded(
|
| + const base::TimeTicks ticks) {
|
| + static bool is_first_call = true;
|
| + if (!is_first_call || ticks.is_null())
|
| + return;
|
| + is_first_call = false;
|
| + if (!ShouldLogStartupHistogram())
|
| + return;
|
| +
|
| + UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE(
|
| + UMA_HISTOGRAM_LONG_TIMES_100,
|
| + "Startup.BrowserWindow.FirstPaint.CompositingEnded",
|
| + g_process_creation_ticks.Get(), ticks);
|
| +}
|
| +
|
| base::TimeTicks MainEntryPointTicks() {
|
| return g_browser_main_entry_point_ticks.Get();
|
| }
|
|
|