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

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

Issue 23315002: Add UMA for first app list paint on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linux compile Created 7 years, 4 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/bind.h"
8 #include "base/callback.h"
7 #include "base/command_line.h" 9 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
9 #include "base/prefs/pref_registry_simple.h" 11 #include "base/prefs/pref_registry_simple.h"
10 #include "base/process/process_info.h" 12 #include "base/process/process_info.h"
11 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
12 #include "base/time/time.h" 14 #include "base/time/time.h"
13 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
15 17
16 namespace { 18 namespace {
17 19
18 base::TimeDelta GetTimeFromOriginalProcessStart( 20 enum StartupType {
19 const CommandLine& command_line) { 21 COLD_START,
20 std::string start_time_string = 22 WARM_START,
21 command_line.GetSwitchValueASCII(switches::kOriginalProcessStartTime); 23 WARM_START_FAST,
22 int64 remote_start_time; 24 };
23 base::StringToInt64(start_time_string, &remote_start_time); 25
24 return base::Time::Now() - base::Time::FromInternalValue(remote_start_time); 26 base::Time GetOriginalProcessStartTime(const CommandLine& command_line) {
27 if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) {
28 std::string start_time_string =
29 command_line.GetSwitchValueASCII(switches::kOriginalProcessStartTime);
30 int64 remote_start_time;
31 base::StringToInt64(start_time_string, &remote_start_time);
32 return base::Time::FromInternalValue(remote_start_time);
33 }
34
35 // base::CurrentProcessInfo::CreationTime() is only defined on some
36 // platforms.
37 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
38 return base::CurrentProcessInfo::CreationTime();
39 #endif
40 return base::Time();
41 }
42
43 StartupType GetStartupType(const CommandLine& command_line) {
44 // The presence of kOriginalProcessStartTime implies that another process
45 // has sent us its command line to handle, ie: we are already running.
46 if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) {
47 return command_line.HasSwitch(switches::kFastStart) ?
48 WARM_START_FAST : WARM_START;
49 }
50 return COLD_START;
51 }
52
53 void RecordFirstPaintTiming(StartupType startup_type,
54 const base::Time& start_time) {
55 base::TimeDelta elapsed = base::Time::Now() - start_time;
56 switch (startup_type) {
57 case COLD_START:
58 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintColdStart", elapsed);
59 break;
60 case WARM_START:
61 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStart", elapsed);
62 break;
63 case WARM_START_FAST:
64 UMA_HISTOGRAM_LONG_TIMES("Startup.AppListFirstPaintWarmStartFast",
65 elapsed);
66 break;
67 }
25 } 68 }
26 69
27 } // namespace 70 } // namespace
28 71
29 // static 72 // static
30 void AppListService::RegisterPrefs(PrefRegistrySimple* registry) { 73 void AppListService::RegisterPrefs(PrefRegistrySimple* registry) {
31 registry->RegisterInt64Pref(prefs::kLastAppListLaunchPing, 0); 74 registry->RegisterInt64Pref(prefs::kLastAppListLaunchPing, 0);
32 registry->RegisterIntegerPref(prefs::kAppListLaunchCount, 0); 75 registry->RegisterIntegerPref(prefs::kAppListLaunchCount, 0);
33 registry->RegisterInt64Pref(prefs::kLastAppListAppLaunchPing, 0); 76 registry->RegisterInt64Pref(prefs::kLastAppListAppLaunchPing, 0);
34 registry->RegisterIntegerPref(prefs::kAppListAppLaunchCount, 0); 77 registry->RegisterIntegerPref(prefs::kAppListAppLaunchCount, 0);
35 registry->RegisterStringPref(prefs::kAppListProfile, std::string()); 78 registry->RegisterStringPref(prefs::kAppListProfile, std::string());
36 registry->RegisterBooleanPref(prefs::kRestartWithAppList, false); 79 registry->RegisterBooleanPref(prefs::kRestartWithAppList, false);
37 } 80 }
38 81
39 // static 82 // static
40 void AppListService::RecordShowTimings(const CommandLine& command_line) { 83 void AppListService::RecordShowTimings(const CommandLine& command_line) {
41 // The presence of kOriginalProcessStartTime implies that another process 84 base::Time start_time = GetOriginalProcessStartTime(command_line);
42 // has sent us its command line to handle, ie: we are already running. 85 if (start_time.is_null())
43 if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) { 86 return;
44 base::TimeDelta elapsed = GetTimeFromOriginalProcessStart(command_line); 87
45 if (command_line.HasSwitch(switches::kFastStart)) 88 base::TimeDelta elapsed = base::Time::Now() - start_time;
89 StartupType startup = GetStartupType(command_line);
90 switch (startup) {
91 case COLD_START:
92 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListColdStart", elapsed);
93 break;
94 case WARM_START:
95 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStart", elapsed);
96 break;
97 case WARM_START_FAST:
46 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStartFast", elapsed); 98 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStartFast", elapsed);
47 else 99 break;
48 UMA_HISTOGRAM_LONG_TIMES("Startup.ShowAppListWarmStart", elapsed);
49 } else {
50 // base::CurrentProcessInfo::CreationTime() is only defined on some
51 // platforms.
52 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
53 UMA_HISTOGRAM_LONG_TIMES(
54 "Startup.ShowAppListColdStart",
55 base::Time::Now() - base::CurrentProcessInfo::CreationTime());
56 #endif
57 } 100 }
101
102 AppListService::Get()->SetAppListNextPaintCallback(
103 base::Bind(RecordFirstPaintTiming, startup, start_time));
58 } 104 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_service.h ('k') | chrome/browser/ui/app_list/app_list_service_disabled.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698