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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
benwells
2013/11/18 05:13:32
Nit: are bind.h and callback.h still needed?
koz (OOO until 15th September)
2013/11/18 06:31:07
Done.
| |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
12 #include "base/process/process_info.h" | 12 #include "base/process/process_info.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
17 | 17 |
18 namespace { | 18 namespace { |
(...skipping 24 matching lines...) Expand all Loading... | |
43 StartupType GetStartupType(const CommandLine& command_line) { | 43 StartupType GetStartupType(const CommandLine& command_line) { |
44 // The presence of kOriginalProcessStartTime implies that another process | 44 // The presence of kOriginalProcessStartTime implies that another process |
45 // has sent us its command line to handle, ie: we are already running. | 45 // has sent us its command line to handle, ie: we are already running. |
46 if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) { | 46 if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) { |
47 return command_line.HasSwitch(switches::kFastStart) ? | 47 return command_line.HasSwitch(switches::kFastStart) ? |
48 WARM_START_FAST : WARM_START; | 48 WARM_START_FAST : WARM_START; |
49 } | 49 } |
50 return COLD_START; | 50 return COLD_START; |
51 } | 51 } |
52 | 52 |
53 void RecordFirstPaintTiming(StartupType startup_type, | 53 // The time the process that caused the app list to be shown started. This isn't |
54 const base::Time& start_time) { | 54 // necessarily the currently executing process as we may be processing a command |
55 // line given to a short-lived Chrome instance. | |
56 int64 g_original_process_start_time; | |
57 | |
58 // The type of startup the the current app list show has gone through. | |
59 StartupType g_app_show_startup_type; | |
60 | |
61 void RecordStartupInfo(StartupType startup_type, const base::Time& start_time) { | |
62 g_original_process_start_time = start_time.ToInternalValue(); | |
63 g_app_show_startup_type = startup_type; | |
64 } | |
65 | |
66 void RecordFirstPaintTiming() { | |
67 base::Time start_time( | |
68 base::Time::FromInternalValue(g_original_process_start_time)); | |
55 base::TimeDelta elapsed = base::Time::Now() - start_time; | 69 base::TimeDelta elapsed = base::Time::Now() - start_time; |
56 switch (startup_type) { | 70 switch (g_app_show_startup_type) { |
57 case COLD_START: | 71 case COLD_START: |
58 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintColdStart", elapsed); | 72 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintColdStart", elapsed); |
59 break; | 73 break; |
60 case WARM_START: | 74 case WARM_START: |
61 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStart", elapsed); | 75 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStart", elapsed); |
62 break; | 76 break; |
63 case WARM_START_FAST: | 77 case WARM_START_FAST: |
64 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStartFast", | 78 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStartFast", |
65 elapsed); | 79 elapsed); |
66 break; | 80 break; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListColdStart", elapsed); | 117 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListColdStart", elapsed); |
104 break; | 118 break; |
105 case WARM_START: | 119 case WARM_START: |
106 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStart", elapsed); | 120 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStart", elapsed); |
107 break; | 121 break; |
108 case WARM_START_FAST: | 122 case WARM_START_FAST: |
109 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStartFast", elapsed); | 123 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStartFast", elapsed); |
110 break; | 124 break; |
111 } | 125 } |
112 | 126 |
127 RecordStartupInfo(startup, start_time); | |
113 Get(chrome::HOST_DESKTOP_TYPE_NATIVE)->SetAppListNextPaintCallback( | 128 Get(chrome::HOST_DESKTOP_TYPE_NATIVE)->SetAppListNextPaintCallback( |
114 base::Bind(RecordFirstPaintTiming, startup, start_time)); | 129 RecordFirstPaintTiming); |
115 } | 130 } |
OLD | NEW |