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 12 matching lines...) Expand all Loading... |
23 | 23 |
24 // For when an app list show request is received via CommandLine. Indicates | 24 // For when an app list show request is received via CommandLine. Indicates |
25 // whether the Profile the app list was previously showing was the SAME, OTHER | 25 // whether the Profile the app list was previously showing was the SAME, OTHER |
26 // or NONE with respect to the new Profile to show. | 26 // or NONE with respect to the new Profile to show. |
27 enum ProfileLoadState { | 27 enum ProfileLoadState { |
28 PROFILE_LOADED_SAME, | 28 PROFILE_LOADED_SAME, |
29 PROFILE_LOADED_OTHER, | 29 PROFILE_LOADED_OTHER, |
30 PROFILE_LOADED_NONE, | 30 PROFILE_LOADED_NONE, |
31 }; | 31 }; |
32 | 32 |
33 base::Time GetOriginalProcessStartTime(const CommandLine& command_line) { | 33 base::Time GetOriginalProcessStartTime(const base::CommandLine& command_line) { |
34 if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) { | 34 if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) { |
35 std::string start_time_string = | 35 std::string start_time_string = |
36 command_line.GetSwitchValueASCII(switches::kOriginalProcessStartTime); | 36 command_line.GetSwitchValueASCII(switches::kOriginalProcessStartTime); |
37 int64 remote_start_time; | 37 int64 remote_start_time; |
38 base::StringToInt64(start_time_string, &remote_start_time); | 38 base::StringToInt64(start_time_string, &remote_start_time); |
39 return base::Time::FromInternalValue(remote_start_time); | 39 return base::Time::FromInternalValue(remote_start_time); |
40 } | 40 } |
41 | 41 |
42 // base::CurrentProcessInfo::CreationTime() is only defined on some | 42 // base::CurrentProcessInfo::CreationTime() is only defined on some |
43 // platforms. | 43 // platforms. |
44 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) | 44 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) |
45 return base::CurrentProcessInfo::CreationTime(); | 45 return base::CurrentProcessInfo::CreationTime(); |
46 #else | 46 #else |
47 return base::Time(); | 47 return base::Time(); |
48 #endif | 48 #endif |
49 } | 49 } |
50 | 50 |
51 StartupType GetStartupType(const CommandLine& command_line) { | 51 StartupType GetStartupType(const base::CommandLine& command_line) { |
52 // The presence of kOriginalProcessStartTime implies that another process | 52 // The presence of kOriginalProcessStartTime implies that another process |
53 // has sent us its command line to handle, ie: we are already running. | 53 // has sent us its command line to handle, ie: we are already running. |
54 if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) { | 54 if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) { |
55 return command_line.HasSwitch(switches::kFastStart) ? | 55 return command_line.HasSwitch(switches::kFastStart) ? |
56 WARM_START_FAST : WARM_START; | 56 WARM_START_FAST : WARM_START; |
57 } | 57 } |
58 return COLD_START; | 58 return COLD_START; |
59 } | 59 } |
60 | 60 |
61 // The time the process that caused the app list to be shown started. This isn't | 61 // The time the process that caused the app list to be shown started. This isn't |
(...skipping 28 matching lines...) Expand all Loading... |
90 case WARM_START_FAST: | 90 case WARM_START_FAST: |
91 if (g_profile_load_state == PROFILE_LOADED_SAME) { | 91 if (g_profile_load_state == PROFILE_LOADED_SAME) { |
92 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStartFast", | 92 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStartFast", |
93 elapsed); | 93 elapsed); |
94 } | 94 } |
95 break; | 95 break; |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 void RecordStartupInfo(AppListService* service, | 99 void RecordStartupInfo(AppListService* service, |
100 const CommandLine& command_line, | 100 const base::CommandLine& command_line, |
101 Profile* launch_profile) { | 101 Profile* launch_profile) { |
102 base::Time start_time = GetOriginalProcessStartTime(command_line); | 102 base::Time start_time = GetOriginalProcessStartTime(command_line); |
103 if (start_time.is_null()) | 103 if (start_time.is_null()) |
104 return; | 104 return; |
105 | 105 |
106 base::TimeDelta elapsed = base::Time::Now() - start_time; | 106 base::TimeDelta elapsed = base::Time::Now() - start_time; |
107 StartupType startup_type = GetStartupType(command_line); | 107 StartupType startup_type = GetStartupType(command_line); |
108 switch (startup_type) { | 108 switch (startup_type) { |
109 case COLD_START: | 109 case COLD_START: |
110 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListColdStart", elapsed); | 110 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListColdStart", elapsed); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 if (!command_line.HasSwitch(switches::kShowAppList)) | 164 if (!command_line.HasSwitch(switches::kShowAppList)) |
165 return false; | 165 return false; |
166 | 166 |
167 // The --show-app-list switch is used for shortcuts on the native desktop. | 167 // The --show-app-list switch is used for shortcuts on the native desktop. |
168 AppListService* service = Get(chrome::HOST_DESKTOP_TYPE_NATIVE); | 168 AppListService* service = Get(chrome::HOST_DESKTOP_TYPE_NATIVE); |
169 DCHECK(service); | 169 DCHECK(service); |
170 RecordStartupInfo(service, command_line, launch_profile); | 170 RecordStartupInfo(service, command_line, launch_profile); |
171 service->ShowForProfile(launch_profile); | 171 service->ShowForProfile(launch_profile); |
172 return true; | 172 return true; |
173 } | 173 } |
OLD | NEW |