diff options
author | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-03 17:16:25 +0000 |
---|---|---|
committer | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-03 17:16:25 +0000 |
commit | a890386d01d56fc39304006f2616398f6106feda (patch) | |
tree | 5be28e050e2819f5e6bf170b1c95da6832613553 /chrome | |
parent | 483d1ff2232c26b1adcefbc820e2ac9b6b63ea99 (diff) | |
download | chromium_src-a890386d01d56fc39304006f2616398f6106feda.zip chromium_src-a890386d01d56fc39304006f2616398f6106feda.tar.gz chromium_src-a890386d01d56fc39304006f2616398f6106feda.tar.bz2 |
Fix up problems when bundle doesn't exist for service process on Mac.
BUG=74690
TEST=Start up cloud print or remoting, then quit chrome. Move chrome.app somewhere else on your system. Restart chrome. Shouldn't crash.
Review URL: http://codereview.chromium.org/6613004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76754 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/common/service_process_util_mac.mm | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/chrome/common/service_process_util_mac.mm b/chrome/common/service_process_util_mac.mm index dbc0f10..0f5746f 100644 --- a/chrome/common/service_process_util_mac.mm +++ b/chrome/common/service_process_util_mac.mm @@ -116,37 +116,40 @@ bool GetServiceProcessData(std::string* version, base::ProcessId* pid) { if (!launchd_conf.get()) { return false; } - + // Anything past here will return true in that there does appear + // to be a service process of some sort registered with launchd. if (version) { + *version = "0"; NSString *exe_path = [launchd_conf objectForKey:@ LAUNCH_JOBKEY_PROGRAM]; - if (!exe_path) { - NOTREACHED() << "Failed to get exe path"; - return false; - } - NSString *bundle_path = [[[exe_path stringByDeletingLastPathComponent] - stringByDeletingLastPathComponent] - stringByDeletingLastPathComponent]; - NSBundle *bundle = [NSBundle bundleWithPath:bundle_path]; - if (!bundle) { - NOTREACHED() << "Unable to get bundle at: " - << reinterpret_cast<CFStringRef>(bundle_path); - return false; - } - NSString *ns_version = - [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; - if (!ns_version) { - NOTREACHED() << "Unable to get version at: " + if (exe_path) { + NSString *bundle_path = [[[exe_path stringByDeletingLastPathComponent] + stringByDeletingLastPathComponent] + stringByDeletingLastPathComponent]; + NSBundle *bundle = [NSBundle bundleWithPath:bundle_path]; + if (bundle) { + NSString *ns_version = + [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; + if (ns_version) { + *version = base::SysNSStringToUTF8(ns_version); + } else { + LOG(ERROR) << "Unable to get version at: " + << reinterpret_cast<CFStringRef>(bundle_path); + } + } else { + // The bundle has been deleted out from underneath the registered + // job. + LOG(ERROR) << "Unable to get bundle at: " << reinterpret_cast<CFStringRef>(bundle_path); - return false; + } + } else { + LOG(ERROR) << "Unable to get executable path for service process"; } - *version = base::SysNSStringToUTF8(ns_version); } if (pid) { + *pid = -1; NSNumber* ns_pid = [launchd_conf objectForKey:@ LAUNCH_JOBKEY_PID]; if (ns_pid) { *pid = [ns_pid intValue]; - } else { - *pid = 0; } } return true; |