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 3969ed8a94cc70ee552aa861e1943d6f5493c887..8e38d8a9308438fa5c07b5defd0e68009b3cfe8c 100644 |
--- a/components/startup_metric_utils/browser/startup_metric_utils.cc |
+++ b/components/startup_metric_utils/browser/startup_metric_utils.cc |
@@ -29,7 +29,10 @@ volatile bool g_non_browser_ui_displayed = false; |
base::LazyInstance<base::Time>::Leaky g_process_creation_time = |
LAZY_INSTANCE_INITIALIZER; |
-base::LazyInstance<base::Time>::Leaky g_main_entry_point_time = |
+base::LazyInstance<base::Time>::Leaky g_browser_main_entry_point_time = |
+ LAZY_INSTANCE_INITIALIZER; |
+ |
+base::LazyInstance<base::Time>::Leaky g_renderer_main_entry_point_time = |
LAZY_INSTANCE_INITIALIZER; |
StartupTemperature g_startup_temperature = UNCERTAIN_STARTUP_TEMPERATURE; |
@@ -163,6 +166,8 @@ bool GetHardFaultCountForCurrentProcess(uint32_t* hard_fault_count, |
// ".ColdStart" or ".WarmStart", as appropriate. |
// |value_expr| is an expression evaluating to the value to be recorded. This |
// will be evaluated exactly once and cached, so side effects are not an issue. |
+// A metric logged using this macro must have an affected-histogram entry in the |
+// definition of the StartupTemperature suffix in histograms.xml. |
#define UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(type, basename, value_expr) \ |
{ \ |
const auto kValue = value_expr; \ |
@@ -290,6 +295,21 @@ void RecordMainEntryTimeHistogram() { |
browser_main_entry_time_raw_ms_low_word); |
} |
+// Record renderer main entry time histogram. |
+void RecordRendererMainEntryHistogram() { |
+ const base::Time& browser_main_entry_point_time = |
+ g_browser_main_entry_point_time.Get(); |
+ const base::Time& renderer_main_entry_point_time = |
+ g_renderer_main_entry_point_time.Get(); |
+ |
+ if (!browser_main_entry_point_time.is_null() && |
+ !renderer_main_entry_point_time.is_null()) { |
+ UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( |
+ UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMainToRendererMain", |
+ browser_main_entry_point_time, renderer_main_entry_point_time); |
+ } |
+} |
+ |
// Environment variable that stores the timestamp when the executable's main() |
// function was entered. |
const char kChromeMainTimeEnvVar[] = "CHROME_MAIN_TIME"; |
@@ -324,7 +344,7 @@ void RecordStartupProcessCreationTime(const base::Time& time) { |
void RecordMainEntryPointTime(const base::Time& time) { |
DCHECK(MainEntryPointTime().is_null()); |
- g_main_entry_point_time.Get() = time; |
+ g_browser_main_entry_point_time.Get() = time; |
DCHECK(!MainEntryPointTime().is_null()); |
} |
@@ -417,6 +437,13 @@ void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta) { |
"Startup.BrowserOpenTabs", delta); |
} |
+void RecordRendererMainEntryTime(const base::Time& time) { |
+ // 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_time.Get().is_null()) |
+ g_renderer_main_entry_point_time.Get() = time; |
+} |
+ |
void RecordFirstWebContentsMainFrameLoad(const base::Time& time) { |
static bool is_first_call = true; |
if (!is_first_call || time.is_null()) |
@@ -448,6 +475,11 @@ void RecordFirstWebContentsNonEmptyPaint(const base::Time& time) { |
if (!is_first_call || time.is_null()) |
return; |
is_first_call = false; |
+ |
+ // Log Startup.BrowserMainToRendererMain now that the first renderer main |
+ // entry time and the startup temperature are known. |
+ RecordRendererMainEntryHistogram(); |
+ |
if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) |
return; |
@@ -498,7 +530,7 @@ void RecordFirstWebContentsMainNavigationFinished(const base::Time& time) { |
} |
base::Time MainEntryPointTime() { |
- return g_main_entry_point_time.Get(); |
+ return g_browser_main_entry_point_time.Get(); |
} |
StartupTemperature GetStartupTemperature() { |