Commit 8f565846 authored by calamity's avatar calamity Committed by Commit bot

Don't warmup the app list if it hasn't been used in the past 28 days. [Win]

This CL adds a pref that tracks when the app list is last launched and
doesn't warm up the app list on Windows unless the app list has been
launched in the last 28 days.

BUG=440224

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

Cr-Commit-Position: refs/heads/master@{#324018}
parent e8585ee0
...@@ -145,6 +145,7 @@ void AppListService::RegisterPrefs(PrefRegistrySimple* registry) { ...@@ -145,6 +145,7 @@ void AppListService::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterIntegerPref(prefs::kAppListEnableMethod, registry->RegisterIntegerPref(prefs::kAppListEnableMethod,
ENABLE_NOT_RECORDED); ENABLE_NOT_RECORDED);
registry->RegisterInt64Pref(prefs::kAppListEnableTime, 0); registry->RegisterInt64Pref(prefs::kAppListEnableTime, 0);
registry->RegisterInt64Pref(prefs::kAppListLastLaunchTime, 0);
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
registry->RegisterIntegerPref(prefs::kAppLauncherShortcutVersion, 0); registry->RegisterIntegerPref(prefs::kAppLauncherShortcutVersion, 0);
......
...@@ -213,6 +213,7 @@ void AppListServiceImpl::RecordAppListLaunch() { ...@@ -213,6 +213,7 @@ void AppListServiceImpl::RecordAppListLaunch() {
prefs::kAppListLaunchCount, prefs::kAppListLaunchCount,
&SendAppListLaunch); &SendAppListLaunch);
RecordAppListDiscoverability(local_state_, false); RecordAppListDiscoverability(local_state_, false);
RecordAppListLastLaunch();
} }
// static // static
...@@ -222,6 +223,19 @@ void AppListServiceImpl::RecordAppListAppLaunch() { ...@@ -222,6 +223,19 @@ void AppListServiceImpl::RecordAppListAppLaunch() {
&SendAppListAppLaunch); &SendAppListAppLaunch);
} }
// static
void AppListServiceImpl::RecordAppListLastLaunch() {
if (!g_browser_process)
return; // In a unit test.
PrefService* local_state = g_browser_process->local_state();
if (!local_state)
return; // In a unit test.
local_state->SetInt64(prefs::kAppListLastLaunchTime,
base::Time::Now().ToInternalValue());
}
// static // static
void AppListServiceImpl::SendAppListStats() { void AppListServiceImpl::SendAppListStats() {
if (!g_browser_process || g_browser_process->IsShuttingDown()) if (!g_browser_process || g_browser_process->IsShuttingDown())
......
...@@ -45,6 +45,7 @@ class AppListServiceImpl : public AppListService, ...@@ -45,6 +45,7 @@ class AppListServiceImpl : public AppListService,
void RecordAppListLaunch(); void RecordAppListLaunch();
static void RecordAppListAppLaunch(); static void RecordAppListAppLaunch();
static void RecordAppListLastLaunch();
// AppListService overrides: // AppListService overrides:
void SetAppListNextPaintCallback(void (*callback)()) override; void SetAppListNextPaintCallback(void (*callback)()) override;
......
...@@ -72,6 +72,8 @@ void AppListService::InitAll(Profile* initial_profile, ...@@ -72,6 +72,8 @@ void AppListService::InitAll(Profile* initial_profile,
namespace { namespace {
const int kUnusedAppListNoWarmupDays = 28;
int GetAppListIconIndex() { int GetAppListIconIndex() {
BrowserDistribution* dist = BrowserDistribution::GetDistribution(); BrowserDistribution* dist = BrowserDistribution::GetDistribution();
return dist->GetIconIndex(BrowserDistribution::SHORTCUT_APP_LAUNCHER); return dist->GetIconIndex(BrowserDistribution::SHORTCUT_APP_LAUNCHER);
...@@ -356,6 +358,21 @@ bool AppListServiceWin::IsWarmupNeeded() { ...@@ -356,6 +358,21 @@ bool AppListServiceWin::IsWarmupNeeded() {
return false; return false;
} }
// Don't warm up the app list if it hasn't been used for a while. If the last
// launch is unknown, record it as "used" on the first warmup.
PrefService* local_state = g_browser_process->local_state();
int64 last_launch_time_pref =
local_state->GetInt64(prefs::kAppListLastLaunchTime);
if (last_launch_time_pref == 0)
RecordAppListLastLaunch();
base::Time last_launch_time =
base::Time::FromInternalValue(last_launch_time_pref);
if (base::Time::Now() - last_launch_time >
base::TimeDelta::FromDays(kUnusedAppListNoWarmupDays)) {
return false;
}
// We only need to initialize the view if there's no view already created and // We only need to initialize the view if there's no view already created and
// there's no profile loading to be shown. // there's no profile loading to be shown.
return !shower().HasView() && !profile_loader().IsAnyProfileLoading(); return !shower().HasView() && !profile_loader().IsAnyProfileLoading();
......
...@@ -2179,6 +2179,9 @@ const char kAppListEnableMethod[] = "app_list.how_enabled"; ...@@ -2179,6 +2179,9 @@ const char kAppListEnableMethod[] = "app_list.how_enabled";
// The time that the app launcher was enabled. Cleared when UMA is recorded. // The time that the app launcher was enabled. Cleared when UMA is recorded.
const char kAppListEnableTime[] = "app_list.when_enabled"; const char kAppListEnableTime[] = "app_list.when_enabled";
// The last time the app list was launched.
const char kAppListLastLaunchTime[] = "app_list.last_launch";
// Integer representing the version of the app launcher shortcut installed on // Integer representing the version of the app launcher shortcut installed on
// the system. Incremented, e.g., when embedded icons change. // the system. Incremented, e.g., when embedded icons change.
const char kAppLauncherShortcutVersion[] = "apps.app_launcher.shortcut_version"; const char kAppLauncherShortcutVersion[] = "apps.app_launcher.shortcut_version";
......
...@@ -784,6 +784,7 @@ extern const char kAppListAppLaunchCount[]; ...@@ -784,6 +784,7 @@ extern const char kAppListAppLaunchCount[];
extern const char kAppLauncherHasBeenEnabled[]; extern const char kAppLauncherHasBeenEnabled[];
extern const char kAppListEnableMethod[]; extern const char kAppListEnableMethod[];
extern const char kAppListEnableTime[]; extern const char kAppListEnableTime[];
extern const char kAppListLastLaunchTime[];
extern const char kAppLauncherShortcutVersion[]; extern const char kAppLauncherShortcutVersion[];
extern const char kShowAppLauncherPromo[]; extern const char kShowAppLauncherPromo[];
extern const char kAppLauncherDriveAppMapping[]; extern const char kAppLauncherDriveAppMapping[];
......
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