Chromium Code Reviews| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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) { | 60 void RecordStartupInfo(StartupType startup_type, const base::Time& start_time) { |
| 61 g_original_process_start_time = start_time.ToInternalValue(); | 61 g_original_process_start_time = start_time.ToInternalValue(); |
| 62 g_app_show_startup_type = startup_type; | 62 g_app_show_startup_type = startup_type; |
| 63 } | 63 } |
| 64 | 64 |
| 65 void RecordFirstPaintTiming(); | |
|
msw
2014/07/08 01:05:07
Remove this, reorder RecordStartupTimings after it
tapted
2014/07/08 01:41:32
Done.
| |
| 66 | |
| 67 void RecordStartupTimings(AppListService* service, | |
| 68 const CommandLine& command_line) { | |
| 69 base::Time start_time = GetOriginalProcessStartTime(command_line); | |
| 70 if (start_time.is_null()) | |
| 71 return; | |
| 72 | |
| 73 base::TimeDelta elapsed = base::Time::Now() - start_time; | |
| 74 StartupType startup = GetStartupType(command_line); | |
| 75 switch (startup) { | |
| 76 case COLD_START: | |
| 77 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListColdStart", elapsed); | |
| 78 break; | |
| 79 case WARM_START: | |
| 80 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStart", elapsed); | |
| 81 break; | |
| 82 case WARM_START_FAST: | |
| 83 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStartFast", elapsed); | |
| 84 break; | |
| 85 } | |
| 86 | |
| 87 RecordStartupInfo(startup, start_time); | |
|
msw
2014/07/08 01:05:07
nit: inline RecordStartupInfo and maybe use that m
tapted
2014/07/08 01:41:32
Done.
| |
| 88 service->SetAppListNextPaintCallback(RecordFirstPaintTiming); | |
| 89 } | |
| 90 | |
| 65 void RecordFirstPaintTiming() { | 91 void RecordFirstPaintTiming() { |
| 66 base::Time start_time( | 92 base::Time start_time( |
| 67 base::Time::FromInternalValue(g_original_process_start_time)); | 93 base::Time::FromInternalValue(g_original_process_start_time)); |
| 68 base::TimeDelta elapsed = base::Time::Now() - start_time; | 94 base::TimeDelta elapsed = base::Time::Now() - start_time; |
| 69 switch (g_app_show_startup_type) { | 95 switch (g_app_show_startup_type) { |
| 70 case COLD_START: | 96 case COLD_START: |
| 71 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintColdStart", elapsed); | 97 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintColdStart", elapsed); |
| 72 break; | 98 break; |
| 73 case WARM_START: | 99 case WARM_START: |
| 74 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStart", elapsed); | 100 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStart", elapsed); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 99 registry->RegisterIntegerPref(prefs::kAppLauncherShortcutVersion, 0); | 125 registry->RegisterIntegerPref(prefs::kAppLauncherShortcutVersion, 0); |
| 100 #endif | 126 #endif |
| 101 | 127 |
| 102 // Identifies whether we should show the app launcher promo or not. | 128 // 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 | 129 // 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. | 130 // unless the pref is set AND the field trial is set to a proper group. |
| 105 registry->RegisterBooleanPref(prefs::kShowAppLauncherPromo, true); | 131 registry->RegisterBooleanPref(prefs::kShowAppLauncherPromo, true); |
| 106 } | 132 } |
| 107 | 133 |
| 108 // static | 134 // static |
| 109 void AppListService::RecordShowTimings(const CommandLine& command_line) { | 135 bool AppListService::HandleLaunchCommandLine( |
| 110 base::Time start_time = GetOriginalProcessStartTime(command_line); | 136 const base::CommandLine& command_line, |
| 111 if (start_time.is_null()) | 137 Profile* launch_profile) { |
| 112 return; | 138 InitAll(launch_profile); |
| 139 if (!command_line.HasSwitch(switches::kShowAppList)) | |
| 140 return false; | |
| 113 | 141 |
| 114 base::TimeDelta elapsed = base::Time::Now() - start_time; | 142 // The --show-app-list switch is used for shortcuts on the native desktop. |
| 115 StartupType startup = GetStartupType(command_line); | 143 AppListService* service = |
| 116 switch (startup) { | 144 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE); |
|
msw
2014/07/08 01:05:07
nit: can you avoid explicitly qualifying the AppLi
tapted
2014/07/08 01:41:32
Of course! Done.
| |
| 117 case COLD_START: | 145 DCHECK(service); |
| 118 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListColdStart", elapsed); | 146 RecordStartupTimings(service, command_line); |
| 119 break; | 147 service->ShowForProfile(launch_profile); |
| 120 case WARM_START: | 148 return true; |
| 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 } | 149 } |
| OLD | NEW |