Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(914)

Side by Side Diff: chrome/browser/ui/app_list/app_list_service.cc

Issue 350883002: Refactor handling of --show-app-list command line. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: split off into crrev/366233002 Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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();
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);
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
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);
Matt Giuca 2014/07/04 04:37:15 nit (optional): Upon consideration, I think you sh
tapted 2014/07/07 07:52:34 Ahhh, that's the thing - ideally, HandleLaunchComm
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);
117 case COLD_START: 145 RecordStartupTimings(service, command_line);
118 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListColdStart", elapsed); 146 service->ShowForProfile(launch_profile);
119 break; 147 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 } 148 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_service.h ('k') | chrome/browser/ui/startup/startup_browser_creator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698