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

Side by Side Diff: chrome/browser/web_applications/web_app_mac.mm

Issue 356893002: Add UMA for --app-shim-error. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #import "chrome/browser/web_applications/web_app_mac.h" 5 #import "chrome/browser/web_applications/web_app_mac.h"
6 6
7 #import <Carbon/Carbon.h> 7 #import <Carbon/Carbon.h>
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/file_enumerator.h" 12 #include "base/files/file_enumerator.h"
13 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
14 #include "base/mac/foundation_util.h" 14 #include "base/mac/foundation_util.h"
15 #include "base/mac/launch_services_util.h" 15 #include "base/mac/launch_services_util.h"
16 #include "base/mac/mac_util.h" 16 #include "base/mac/mac_util.h"
17 #include "base/mac/scoped_cftyperef.h" 17 #include "base/mac/scoped_cftyperef.h"
18 #include "base/mac/scoped_nsobject.h" 18 #include "base/mac/scoped_nsobject.h"
19 #include "base/metrics/histogram.h"
19 #include "base/path_service.h" 20 #include "base/path_service.h"
20 #include "base/process/process_handle.h" 21 #include "base/process/process_handle.h"
21 #include "base/strings/string16.h" 22 #include "base/strings/string16.h"
22 #include "base/strings/string_number_conversions.h" 23 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/string_split.h" 24 #include "base/strings/string_split.h"
24 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
25 #include "base/strings/sys_string_conversions.h" 26 #include "base/strings/sys_string_conversions.h"
26 #include "base/strings/utf_string_conversions.h" 27 #include "base/strings/utf_string_conversions.h"
28 #include "base/version.h"
27 #include "chrome/browser/browser_process.h" 29 #include "chrome/browser/browser_process.h"
28 #import "chrome/browser/mac/dock.h" 30 #import "chrome/browser/mac/dock.h"
29 #include "chrome/browser/browser_process.h" 31 #include "chrome/browser/browser_process.h"
30 #include "chrome/browser/profiles/profile.h" 32 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/profiles/profile_manager.h" 33 #include "chrome/browser/profiles/profile_manager.h"
32 #include "chrome/browser/shell_integration.h" 34 #include "chrome/browser/shell_integration.h"
33 #include "chrome/browser/ui/app_list/app_list_service.h" 35 #include "chrome/browser/ui/app_list/app_list_service.h"
34 #include "chrome/common/chrome_constants.h" 36 #include "chrome/common/chrome_constants.h"
35 #include "chrome/common/chrome_paths.h" 37 #include "chrome/common/chrome_paths.h"
36 #include "chrome/common/chrome_switches.h" 38 #include "chrome/common/chrome_switches.h"
(...skipping 13 matching lines...) Expand all
50 #include "ui/base/resource/resource_bundle.h" 52 #include "ui/base/resource/resource_bundle.h"
51 #include "ui/gfx/image/image_family.h" 53 #include "ui/gfx/image/image_family.h"
52 54
53 bool g_app_shims_allow_update_and_launch_in_tests = false; 55 bool g_app_shims_allow_update_and_launch_in_tests = false;
54 56
55 namespace { 57 namespace {
56 58
57 // Launch Services Key to run as an agent app, which doesn't launch in the dock. 59 // Launch Services Key to run as an agent app, which doesn't launch in the dock.
58 NSString* const kLSUIElement = @"LSUIElement"; 60 NSString* const kLSUIElement = @"LSUIElement";
59 61
62 // When a --app-shim-error is triggered, we record the version of the app shim.
63 // This is the number of buckets in the UMA histogram, i.e. the highest version
64 // we can track plus 1.
65 const int kAppShimErrorVersionMax = 51;
Robert Sesek 2014/07/02 14:53:51 FYI Chrome 51 will ship in December 2015/January 2
66
60 class ScopedCarbonHandle { 67 class ScopedCarbonHandle {
61 public: 68 public:
62 ScopedCarbonHandle(size_t initial_size) : handle_(NewHandle(initial_size)) { 69 ScopedCarbonHandle(size_t initial_size) : handle_(NewHandle(initial_size)) {
63 DCHECK(handle_); 70 DCHECK(handle_);
64 DCHECK_EQ(noErr, MemError()); 71 DCHECK_EQ(noErr, MemError());
65 } 72 }
66 ~ScopedCarbonHandle() { DisposeHandle(handle_); } 73 ~ScopedCarbonHandle() { DisposeHandle(handle_); }
67 74
68 Handle Get() { return handle_; } 75 Handle Get() { return handle_; }
69 char* Data() { return *handle_; } 76 char* Data() { return *handle_; }
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 base::FilePath profile_base_name = base::mac::NSStringToFilePath( 496 base::FilePath profile_base_name = base::mac::NSStringToFilePath(
490 [plist valueForKey:app_mode::kCrAppModeProfileDirKey]); 497 [plist valueForKey:app_mode::kCrAppModeProfileDirKey]);
491 if (user_data_dir.DirName().DirName().BaseName() == profile_base_name) 498 if (user_data_dir.DirName().DirName().BaseName() == profile_base_name)
492 shortcut_info.profile_path = user_data_dir.DirName().DirName(); 499 shortcut_info.profile_path = user_data_dir.DirName().DirName();
493 else 500 else
494 shortcut_info.profile_path = user_data_dir.Append(profile_base_name); 501 shortcut_info.profile_path = user_data_dir.Append(profile_base_name);
495 502
496 return shortcut_info; 503 return shortcut_info;
497 } 504 }
498 505
506 web_app::ShortcutInfo RecordAppShimErrorAndBuildShortcutInfo(
507 const base::FilePath& bundle_path) {
508 NSDictionary* plist = ReadPlist(GetPlistPath(bundle_path));
509 base::Version full_version(base::SysNSStringToUTF8(
510 [plist valueForKey:app_mode::kCFBundleShortVersionStringKey]));
511 int major_version = 0;
512 if (full_version.IsValid())
513 major_version = full_version.components()[0];
514 UMA_HISTOGRAM_ENUMERATION("Apps.AppShimErrorVersion",
515 major_version,
516 kAppShimErrorVersionMax);
Alexei Svitkine (slow) 2014/07/04 12:49:24 I suggest using UMA_HISTOGRAM_SPARSE_SLOWLY() inst
jackhou1 2014/07/07 05:38:36 Done.
517
518 return BuildShortcutInfoFromBundle(bundle_path);
519 }
520
499 void UpdateFileTypes(NSMutableDictionary* plist, 521 void UpdateFileTypes(NSMutableDictionary* plist,
500 const extensions::FileHandlersInfo& file_handlers_info) { 522 const extensions::FileHandlersInfo& file_handlers_info) {
501 NSMutableArray* document_types = 523 NSMutableArray* document_types =
502 [NSMutableArray arrayWithCapacity:file_handlers_info.size()]; 524 [NSMutableArray arrayWithCapacity:file_handlers_info.size()];
503 525
504 for (extensions::FileHandlersInfo::const_iterator info_it = 526 for (extensions::FileHandlersInfo::const_iterator info_it =
505 file_handlers_info.begin(); 527 file_handlers_info.begin();
506 info_it != file_handlers_info.end(); 528 info_it != file_handlers_info.end();
507 ++info_it) { 529 ++info_it) {
508 const extensions::FileHandlerInfo& info = *info_it; 530 const extensions::FileHandlerInfo& info = *info_it;
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 base::Bind(&LaunchShimOnFileThread, shortcut_info, false)); 954 base::Bind(&LaunchShimOnFileThread, shortcut_info, false));
933 } 955 }
934 956
935 bool MaybeRebuildShortcut(const CommandLine& command_line) { 957 bool MaybeRebuildShortcut(const CommandLine& command_line) {
936 if (!command_line.HasSwitch(app_mode::kAppShimError)) 958 if (!command_line.HasSwitch(app_mode::kAppShimError))
937 return false; 959 return false;
938 960
939 base::PostTaskAndReplyWithResult( 961 base::PostTaskAndReplyWithResult(
940 content::BrowserThread::GetBlockingPool(), 962 content::BrowserThread::GetBlockingPool(),
941 FROM_HERE, 963 FROM_HERE,
942 base::Bind(&BuildShortcutInfoFromBundle, 964 base::Bind(&RecordAppShimErrorAndBuildShortcutInfo,
943 command_line.GetSwitchValuePath(app_mode::kAppShimError)), 965 command_line.GetSwitchValuePath(app_mode::kAppShimError)),
944 base::Bind(&RebuildAppAndLaunch)); 966 base::Bind(&RebuildAppAndLaunch));
945 return true; 967 return true;
946 } 968 }
947 969
948 // Called when the app's ShortcutInfo (with icon) is loaded when creating app 970 // Called when the app's ShortcutInfo (with icon) is loaded when creating app
949 // shortcuts. 971 // shortcuts.
950 void CreateAppShortcutInfoLoaded( 972 void CreateAppShortcutInfoLoaded(
951 Profile* profile, 973 Profile* profile,
952 const extensions::Extension* app, 974 const extensions::Extension* app,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 web_app::UpdateShortcutInfoAndIconForApp( 1111 web_app::UpdateShortcutInfoAndIconForApp(
1090 app, 1112 app,
1091 profile, 1113 profile,
1092 base::Bind(&web_app::CreateAppShortcutInfoLoaded, 1114 base::Bind(&web_app::CreateAppShortcutInfoLoaded,
1093 profile, 1115 profile,
1094 app, 1116 app,
1095 close_callback)); 1117 close_callback));
1096 } 1118 }
1097 1119
1098 } // namespace chrome 1120 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/common/mac/app_mode_common.h » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698