RESOLVED FIXED 45564
Set the visible name for the web process
https://bugs.webkit.org/show_bug.cgi?id=45564
Summary Set the visible name for the web process
Anders Carlsson
Reported 2010-09-10 14:04:59 PDT
Set the visible name for the web process
Attachments
Patch (4.44 KB, patch)
2010-09-10 14:07 PDT, Anders Carlsson
mrowe: review+
Anders Carlsson
Comment 1 2010-09-10 14:07:25 PDT
Anders Carlsson
Comment 2 2010-09-10 14:07:58 PDT
Mark Rowe (bdash)
Comment 3 2010-09-10 14:29:44 PDT
Comment on attachment 67232 [details] Patch > @@ -45,6 +47,23 @@ extern "C" kern_return_t bootstrap_register2(mach_port_t, name_t, mach_port_t, u > > namespace WebKit { > > +// -[NSProcessInfo processName] isn't thread-safe so we have our own implementation. We should do this conditionally and use -[NSProcessInfo processName] on platforms where it is thread-safe. > +static const char* processName() { Misplaced {. > + static CString* processName; > + if (!processName) { > + uint32_t bufferSize = MAXPATHLEN; > + char executablePath[bufferSize]; > + > + if (_NSGetExecutablePath(executablePath, &bufferSize)) > + return “”; If _NSGetExecutablePath fails we’ll do this work every time the function is called. Is that expected? Does _NSGetExecutablePath fail temporarily and then later give us valid results? > @@ -95,6 +96,14 @@ int WebProcessMain(CommandLine* commandLine) > WTF::initializeMainThread(); > RunLoop::initializeMainRunLoop(); > > + // Set the visible application name. > + String parentProcessName = (*commandLine)["parentprocessname"]; > + if (!parentProcessName.isNull()) { > + // FIXME: Localization! > + NSString *applicationName = [NSString stringWithFormat:@"%@ Web Content", (NSString *)parentProcessName]; > + WKSetVisibleApplicationName((CFStringRef)applicationName); > + } It would’ve been nicer if WKSetVisibleApplicationName took an NSString*. r=me
Darin Adler
Comment 4 2010-09-10 14:41:49 PDT
Comment on attachment 67232 [details] Patch > +static const char* processName() { Brace should move to the next line. > + static CString* processName; > + if (!processName) { > + uint32_t bufferSize = MAXPATHLEN; > + char executablePath[bufferSize]; > + > + if (_NSGetExecutablePath(executablePath, &bufferSize)) > + return ""; > + > + char *name = strrchr(executablePath, '/') + 1; > + processName = new CString(name); > + } It would be better factoring to have this in a separate function called createProcessName. And if we want to leak this can we just strdup instead of using a CString? > + // FIXME: Localization! > + NSString *applicationName = [NSString stringWithFormat:@"%@ Web Content", (NSString *)parentProcessName]; > + WKSetVisibleApplicationName((CFStringRef)applicationName); That’s an admirable FIXME, but what’s your plan here?
Anders Carlsson
Comment 5 2010-09-10 14:50:50 PDT
(In reply to comment #4) > (From update of attachment 67232 [details]) > > +static const char* processName() { > > Brace should move to the next line. > > > + static CString* processName; > > + if (!processName) { > > + uint32_t bufferSize = MAXPATHLEN; > > + char executablePath[bufferSize]; > > + > > + if (_NSGetExecutablePath(executablePath, &bufferSize)) > > + return ""; > > + > > + char *name = strrchr(executablePath, '/') + 1; > > + processName = new CString(name); > > + } > > It would be better factoring to have this in a separate function called createProcessName. > Sure, I'll do that. (On platforms where NSProcessInfo is thread-safe I'll just have processName() return -[NSProcessInfo processName]). > And if we want to leak this can we just strdup instead of using a CString? Yes. > > > + // FIXME: Localization! > > + NSString *applicationName = [NSString stringWithFormat:@"%@ Web Content", (NSString *)parentProcessName]; > > + WKSetVisibleApplicationName((CFStringRef)applicationName); > > That’s an admirable FIXME, but what’s your plan here? I don't know how to set up the localization infrastructure, but we should probably do it sooner rather than later.
Anders Carlsson
Comment 6 2010-09-10 15:53:14 PDT
Note You need to log in before you can comment on or make changes to this bug.