| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/ui/app_list/app_list_service.h" | 5 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
| 10 #include "base/process/process_info.h" | 10 #include "base/process/process_info.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 } | 50 } |
| 51 | 51 |
| 52 // The time the process that caused the app list to be shown started. This isn't | 52 // The time the process that caused the app list to be shown started. This isn't |
| 53 // necessarily the currently executing process as we may be processing a command | 53 // necessarily the currently executing process as we may be processing a command |
| 54 // line given to a short-lived Chrome instance. | 54 // line given to a short-lived Chrome instance. |
| 55 int64 g_original_process_start_time; | 55 int64 g_original_process_start_time; |
| 56 | 56 |
| 57 // The type of startup the the current app list show has gone through. | 57 // The type of startup the the current app list show has gone through. |
| 58 StartupType g_app_show_startup_type; | 58 StartupType g_app_show_startup_type; |
| 59 | 59 |
| 60 void RecordStartupInfo(StartupType startup_type, const base::Time& start_time) { | |
| 61 g_original_process_start_time = start_time.ToInternalValue(); | |
| 62 g_app_show_startup_type = startup_type; | |
| 63 } | |
| 64 | |
| 65 void RecordFirstPaintTiming() { | 60 void RecordFirstPaintTiming() { |
| 66 base::Time start_time( | 61 base::Time start_time( |
| 67 base::Time::FromInternalValue(g_original_process_start_time)); | 62 base::Time::FromInternalValue(g_original_process_start_time)); |
| 68 base::TimeDelta elapsed = base::Time::Now() - start_time; | 63 base::TimeDelta elapsed = base::Time::Now() - start_time; |
| 69 switch (g_app_show_startup_type) { | 64 switch (g_app_show_startup_type) { |
| 70 case COLD_START: | 65 case COLD_START: |
| 71 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintColdStart", elapsed); | 66 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintColdStart", elapsed); |
| 72 break; | 67 break; |
| 73 case WARM_START: | 68 case WARM_START: |
| 74 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStart", elapsed); | 69 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStart", elapsed); |
| 75 break; | 70 break; |
| 76 case WARM_START_FAST: | 71 case WARM_START_FAST: |
| 77 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStartFast", | 72 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStartFast", |
| 78 elapsed); | 73 elapsed); |
| 79 break; | 74 break; |
| 80 } | 75 } |
| 81 } | 76 } |
| 82 | 77 |
| 78 void RecordStartupInfo(AppListService* service, |
| 79 const CommandLine& command_line) { |
| 80 base::Time start_time = GetOriginalProcessStartTime(command_line); |
| 81 if (start_time.is_null()) |
| 82 return; |
| 83 |
| 84 base::TimeDelta elapsed = base::Time::Now() - start_time; |
| 85 StartupType startup_type = GetStartupType(command_line); |
| 86 switch (startup_type) { |
| 87 case COLD_START: |
| 88 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListColdStart", elapsed); |
| 89 break; |
| 90 case WARM_START: |
| 91 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStart", elapsed); |
| 92 break; |
| 93 case WARM_START_FAST: |
| 94 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStartFast", elapsed); |
| 95 break; |
| 96 } |
| 97 |
| 98 g_original_process_start_time = start_time.ToInternalValue(); |
| 99 g_app_show_startup_type = startup_type; |
| 100 service->SetAppListNextPaintCallback(RecordFirstPaintTiming); |
| 101 } |
| 102 |
| 83 } // namespace | 103 } // namespace |
| 84 | 104 |
| 85 // static | 105 // static |
| 86 void AppListService::RegisterPrefs(PrefRegistrySimple* registry) { | 106 void AppListService::RegisterPrefs(PrefRegistrySimple* registry) { |
| 87 registry->RegisterInt64Pref(prefs::kLastAppListLaunchPing, 0); | 107 registry->RegisterInt64Pref(prefs::kLastAppListLaunchPing, 0); |
| 88 registry->RegisterIntegerPref(prefs::kAppListLaunchCount, 0); | 108 registry->RegisterIntegerPref(prefs::kAppListLaunchCount, 0); |
| 89 registry->RegisterInt64Pref(prefs::kLastAppListAppLaunchPing, 0); | 109 registry->RegisterInt64Pref(prefs::kLastAppListAppLaunchPing, 0); |
| 90 registry->RegisterIntegerPref(prefs::kAppListAppLaunchCount, 0); | 110 registry->RegisterIntegerPref(prefs::kAppListAppLaunchCount, 0); |
| 91 registry->RegisterStringPref(prefs::kAppListProfile, std::string()); | 111 registry->RegisterStringPref(prefs::kAppListProfile, std::string()); |
| 92 registry->RegisterBooleanPref(prefs::kAppLauncherIsEnabled, false); | 112 registry->RegisterBooleanPref(prefs::kAppLauncherIsEnabled, false); |
| 93 registry->RegisterBooleanPref(prefs::kAppLauncherHasBeenEnabled, false); | 113 registry->RegisterBooleanPref(prefs::kAppLauncherHasBeenEnabled, false); |
| 94 registry->RegisterIntegerPref(prefs::kAppListEnableMethod, | 114 registry->RegisterIntegerPref(prefs::kAppListEnableMethod, |
| 95 ENABLE_NOT_RECORDED); | 115 ENABLE_NOT_RECORDED); |
| 96 registry->RegisterInt64Pref(prefs::kAppListEnableTime, 0); | 116 registry->RegisterInt64Pref(prefs::kAppListEnableTime, 0); |
| 97 | 117 |
| 98 #if defined(OS_MACOSX) | 118 #if defined(OS_MACOSX) |
| 99 registry->RegisterIntegerPref(prefs::kAppLauncherShortcutVersion, 0); | 119 registry->RegisterIntegerPref(prefs::kAppLauncherShortcutVersion, 0); |
| 100 #endif | 120 #endif |
| 101 | 121 |
| 102 // Identifies whether we should show the app launcher promo or not. | 122 // Identifies whether we should show the app launcher promo or not. |
| 103 // Note that a field trial also controls the showing, so the promo won't show | 123 // Note that a field trial also controls the showing, so the promo won't show |
| 104 // unless the pref is set AND the field trial is set to a proper group. | 124 // unless the pref is set AND the field trial is set to a proper group. |
| 105 registry->RegisterBooleanPref(prefs::kShowAppLauncherPromo, true); | 125 registry->RegisterBooleanPref(prefs::kShowAppLauncherPromo, true); |
| 106 } | 126 } |
| 107 | 127 |
| 108 // static | 128 // static |
| 109 void AppListService::RecordShowTimings(const CommandLine& command_line) { | 129 bool AppListService::HandleLaunchCommandLine( |
| 110 base::Time start_time = GetOriginalProcessStartTime(command_line); | 130 const base::CommandLine& command_line, |
| 111 if (start_time.is_null()) | 131 Profile* launch_profile) { |
| 112 return; | 132 InitAll(launch_profile); |
| 133 if (!command_line.HasSwitch(switches::kShowAppList)) |
| 134 return false; |
| 113 | 135 |
| 114 base::TimeDelta elapsed = base::Time::Now() - start_time; | 136 // The --show-app-list switch is used for shortcuts on the native desktop. |
| 115 StartupType startup = GetStartupType(command_line); | 137 AppListService* service = Get(chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 116 switch (startup) { | 138 DCHECK(service); |
| 117 case COLD_START: | 139 RecordStartupInfo(service, command_line); |
| 118 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListColdStart", elapsed); | 140 service->ShowForProfile(launch_profile); |
| 119 break; | 141 return true; |
| 120 case WARM_START: | |
| 121 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStart", elapsed); | |
| 122 break; | |
| 123 case WARM_START_FAST: | |
| 124 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStartFast", elapsed); | |
| 125 break; | |
| 126 } | |
| 127 | |
| 128 RecordStartupInfo(startup, start_time); | |
| 129 Get(chrome::HOST_DESKTOP_TYPE_NATIVE)->SetAppListNextPaintCallback( | |
| 130 RecordFirstPaintTiming); | |
| 131 } | 142 } |
| OLD | NEW |