Commit bdd94418 authored by tapted@chromium.org's avatar tapted@chromium.org

Refine UMA quality for warm-start app list cases

Currently "warm start" app list cases (i.e. shown via the process
singleton) have noisy UMA data. Whether the profile to show is loaded or
not has a big impact on the metric. We are only interested in the case 
that the app list view is "warm", and can be immediately shown. 
Recording cases that first must load a profile from disk, or switch the 
app list view to a different profile, count as noise and skew the 
metric. 

This change filters out the noise, fixing an incorrect assumption in 
r270615 which resulted in only the noise being recorded (and a failed 
DCHECK otherwise). Before r270615, the UMA included cases requiring a 
profile load as well as those that didn't. After r270615, only cases 
that required a profile load were being recorded. 

Note that ShowAppListInteractiveTest.ShowAppListFlag was updated in
r281213 to include both cold and warm codepaths via
StartupBrowserCreator, to cover the aforementioned DCHECK.

BUG=382793

Review URL: https://codereview.chromium.org/366233002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282245 0039d316-1c4b-4281-b951-d872f2087c98
parent 1edc8010
......@@ -21,6 +21,15 @@ enum StartupType {
WARM_START_FAST,
};
// For when an app list show request is received via CommandLine. Indicates
// whether the Profile the app list was previously showing was the SAME, OTHER
// or NONE with respect to the new Profile to show.
enum ProfileLoadState {
PROFILE_LOADED_SAME,
PROFILE_LOADED_OTHER,
PROFILE_LOADED_NONE,
};
base::Time GetOriginalProcessStartTime(const CommandLine& command_line) {
if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) {
std::string start_time_string =
......@@ -57,26 +66,39 @@ int64 g_original_process_start_time;
// The type of startup the the current app list show has gone through.
StartupType g_app_show_startup_type;
// The state of the active app list profile at the most recent launch.
ProfileLoadState g_profile_load_state;
void RecordFirstPaintTiming() {
base::Time start_time(
base::Time::FromInternalValue(g_original_process_start_time));
base::TimeDelta elapsed = base::Time::Now() - start_time;
switch (g_app_show_startup_type) {
case COLD_START:
DCHECK_EQ(PROFILE_LOADED_NONE, g_profile_load_state);
UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintColdStart", elapsed);
break;
case WARM_START:
// For warm starts, only record showing the same profile. "NONE" should
// only occur in the first 30 seconds after startup. "OTHER" only occurs
// for multi-profile cases. In these cases, timings are also affected by
// whether or not a profile has been loaded from disk, which makes the
// profile load asynchronous and skews results unpredictably.
if (g_profile_load_state == PROFILE_LOADED_SAME)
UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStart", elapsed);
break;
case WARM_START_FAST:
if (g_profile_load_state == PROFILE_LOADED_SAME) {
UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStartFast",
elapsed);
}
break;
}
}
void RecordStartupInfo(AppListService* service,
const CommandLine& command_line) {
const CommandLine& command_line,
Profile* launch_profile) {
base::Time start_time = GetOriginalProcessStartTime(command_line);
if (start_time.is_null())
return;
......@@ -97,6 +119,15 @@ void RecordStartupInfo(AppListService* service,
g_original_process_start_time = start_time.ToInternalValue();
g_app_show_startup_type = startup_type;
Profile* current_profile = service->GetCurrentAppListProfile();
if (!current_profile)
g_profile_load_state = PROFILE_LOADED_NONE;
else if (current_profile == launch_profile)
g_profile_load_state = PROFILE_LOADED_SAME;
else
g_profile_load_state = PROFILE_LOADED_OTHER;
service->SetAppListNextPaintCallback(RecordFirstPaintTiming);
}
......@@ -136,7 +167,7 @@ bool AppListService::HandleLaunchCommandLine(
// The --show-app-list switch is used for shortcuts on the native desktop.
AppListService* service = Get(chrome::HOST_DESKTOP_TYPE_NATIVE);
DCHECK(service);
RecordStartupInfo(service, command_line);
RecordStartupInfo(service, command_line, launch_profile);
service->ShowForProfile(launch_profile);
return true;
}
......@@ -275,6 +275,9 @@ void AppListServiceWin::OnLoadProfileForWarmup(Profile* initial_profile) {
}
void AppListServiceWin::SetAppListNextPaintCallback(void (*callback)()) {
if (shower().app_list())
shower().app_list()->SetNextPaintCallback(base::Bind(callback));
else
next_paint_callback_ = base::Bind(callback);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment