Give a ServiceWorker WebContentProcess a different display name
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Nov 2017 07:34:06 +0000 (07:34 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Nov 2017 07:34:06 +0000 (07:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179653

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2017-11-13
Reviewed by Brady Eidson.

Source/WebCore:

* English.lproj/Localizable.strings:

Source/WebKit:

* UIProcess/WebProcessProxy.h:
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::create):
Call connect after construction so virtual methods will use subclass implementations.

* UIProcess/ServiceWorkerProcessProxy.h:
* UIProcess/ServiceWorkerProcessProxy.cpp:
(WebKit::ServiceWorkerProcessProxy::create):
Copy the pattern from WebProcessProxy to ensure connect() gets called after construction.

(WebKit::ServiceWorkerProcessProxy::getLaunchOptions):
Set a launch option to signal this is a Service Worker process.

* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
(WebKit::XPCServiceInitializerDelegate::getExtraInitializationData):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::initializeProcessName):
Consume the launch option to configuration the process name.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224806 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/English.lproj/Localizable.strings
Source/WebKit/ChangeLog
Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm
Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp
Source/WebKit/UIProcess/ServiceWorkerProcessProxy.h
Source/WebKit/UIProcess/WebProcessProxy.cpp
Source/WebKit/UIProcess/WebProcessProxy.h
Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

index 051132f..a96f7cd 100644 (file)
@@ -1,3 +1,12 @@
+2017-11-13  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Give a ServiceWorker WebContentProcess a different display name
+        https://bugs.webkit.org/show_bug.cgi?id=179653
+
+        Reviewed by Brady Eidson.
+
+        * English.lproj/Localizable.strings:
+
 2017-11-13  Chris Dumez  <cdumez@apple.com>
 
         Send ServiceWorkerData structs to the WebProcesses instead of ServiceWorkerIdentifiers
index e725e77..b58eb5c 100644 (file)
@@ -40,6 +40,9 @@
 /* Text track contains subtitles for the deaf and hard of hearing */
 "%@ SDH" = "%@ SDH";
 
+/* Visible name of Service Worker process. The argument is the application name. */
+"%@ Service Worker" = "%@ Service Worker";
+
 /* visible name of the storage process. The argument is the application name. */
 "%@ Storage" = "%@ Storage";
 
index 04ff276..48a0a37 100644 (file)
@@ -1,3 +1,29 @@
+2017-11-13  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Give a ServiceWorker WebContentProcess a different display name
+        https://bugs.webkit.org/show_bug.cgi?id=179653
+
+        Reviewed by Brady Eidson.
+
+        * UIProcess/WebProcessProxy.h:
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::create):
+        Call connect after construction so virtual methods will use subclass implementations.
+
+        * UIProcess/ServiceWorkerProcessProxy.h:
+        * UIProcess/ServiceWorkerProcessProxy.cpp:
+        (WebKit::ServiceWorkerProcessProxy::create):
+        Copy the pattern from WebProcessProxy to ensure connect() gets called after construction.
+
+        (WebKit::ServiceWorkerProcessProxy::getLaunchOptions):
+        Set a launch option to signal this is a Service Worker process.
+
+        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
+        (WebKit::XPCServiceInitializerDelegate::getExtraInitializationData):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::initializeProcessName):
+        Consume the launch option to configuration the process name.
+
 2017-11-13  Ryosuke Niwa  <rniwa@webkit.org>
 
         REGRESSION(r224799): WebKit crashes at launch on macOS Sierra due to a sandbox violation
index dd05140..d46d8a2 100644 (file)
@@ -97,6 +97,12 @@ bool XPCServiceInitializerDelegate::getExtraInitializationData(HashMap<String, S
     if (!inspectorProcess.isEmpty())
         extraInitializationData.add(ASCIILiteral("inspector-process"), inspectorProcess);
 
+#if ENABLE(SERVICE_WORKER)
+    String serviceWorkerProcess = xpc_dictionary_get_string(extraDataInitializationDataObject, "service-worker-process");
+    if (!serviceWorkerProcess.isEmpty())
+        extraInitializationData.add(ASCIILiteral("service-worker-process"), serviceWorkerProcess);
+#endif
+
     if (!isClientSandboxed()) {
         String userDirectorySuffix = xpc_dictionary_get_string(extraDataInitializationDataObject, "user-directory-suffix");
         if (!userDirectorySuffix.isEmpty())
index 043ebc9..e6bc4c2 100644 (file)
 
 namespace WebKit {
 
+Ref<ServiceWorkerProcessProxy> ServiceWorkerProcessProxy::create(WebProcessPool& pool, WebsiteDataStore& store)
+{
+    auto proxy = adoptRef(*new ServiceWorkerProcessProxy { pool, store });
+    proxy->connect();
+    return proxy;
+}
+
 ServiceWorkerProcessProxy::ServiceWorkerProcessProxy(WebProcessPool& pool, WebsiteDataStore& store)
     : WebProcessProxy { pool, store }
     , m_serviceWorkerPageID(generatePageID())
@@ -45,6 +52,13 @@ ServiceWorkerProcessProxy::~ServiceWorkerProcessProxy()
 {
 }
 
+void ServiceWorkerProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions)
+{
+    WebProcessProxy::getLaunchOptions(launchOptions);
+
+    launchOptions.extraInitializationData.add(ASCIILiteral("service-worker-process"), ASCIILiteral("1"));
+}
+
 void ServiceWorkerProcessProxy::start(const WebPreferencesStore& store)
 {
     send(Messages::WebProcess::GetWorkerContextConnection(m_serviceWorkerPageID, store), 0);
index 2960f9d..1186b7a 100644 (file)
@@ -33,10 +33,7 @@ struct WebPreferencesStore;
 
 class ServiceWorkerProcessProxy final : public WebProcessProxy {
 public:
-    static Ref<ServiceWorkerProcessProxy> create(WebProcessPool& pool, WebsiteDataStore& store)
-    {
-        return adoptRef(*new ServiceWorkerProcessProxy { pool, store });
-    }
+    static Ref<ServiceWorkerProcessProxy> create(WebProcessPool&, WebsiteDataStore&);
     ~ServiceWorkerProcessProxy();
 
     void didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, Ref<AuthenticationChallengeProxy>&&);
@@ -44,6 +41,10 @@ public:
     void start(const WebPreferencesStore&);
     uint64_t pageID() const { return m_serviceWorkerPageID; }
 
+protected:
+    // ChildProcessProxy
+    void getLaunchOptions(ProcessLauncher::LaunchOptions&) final;
+
 private:
     ServiceWorkerProcessProxy(WebProcessPool&, WebsiteDataStore&);
     uint64_t m_serviceWorkerPageID { 0 };
index 2473ecf..0e8fd09 100644 (file)
@@ -92,7 +92,9 @@ static WebProcessProxy::WebPageProxyMap& globalPageMap()
 
 Ref<WebProcessProxy> WebProcessProxy::create(WebProcessPool& processPool, WebsiteDataStore& websiteDataStore)
 {
-    return adoptRef(*new WebProcessProxy(processPool, websiteDataStore));
+    auto proxy = adoptRef(*new WebProcessProxy(processPool, websiteDataStore));
+    proxy->connect();
+    return proxy;
 }
 
 WebProcessProxy::WebProcessProxy(WebProcessPool& processPool, WebsiteDataStore& websiteDataStore)
@@ -111,8 +113,6 @@ WebProcessProxy::WebProcessProxy(WebProcessPool& processPool, WebsiteDataStore&
 #endif
 {
     WebPasteboardProxy::singleton().addWebProcessProxy(*this);
-
-    connect();
 }
 
 WebProcessProxy::~WebProcessProxy()
index 637ecc8..e28cdb2 100644 (file)
@@ -194,14 +194,14 @@ public:
 
 protected:
     static uint64_t generatePageID();
-    explicit WebProcessProxy(WebProcessPool&, WebsiteDataStore&);
+    WebProcessProxy(WebProcessPool&, WebsiteDataStore&);
 
-private:
-    // From ChildProcessProxy
+    // ChildProcessProxy
     void getLaunchOptions(ProcessLauncher::LaunchOptions&) override;
     void connectionWillOpen(IPC::Connection&) override;
     void processWillShutDown(IPC::Connection&) override;
 
+private:
     // Called when the web process has crashed or we know that it will terminate soon.
     // Will potentially cause the WebProcessProxy object to be freed.
     void shutDown();
index 963aa73..71acd05 100644 (file)
@@ -171,6 +171,10 @@ void WebProcess::initializeProcessName(const ChildProcessInitializationParameter
     NSString *applicationName;
     if (parameters.extraInitializationData.get(ASCIILiteral("inspector-process")) == "1")
         applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Inspector", "Visible name of Web Inspector's web process. The argument is the application name."), (NSString *)parameters.uiProcessName];
+#if ENABLE(SERVICE_WORKER)
+    else if (parameters.extraInitializationData.get(ASCIILiteral("service-worker-process")) == "1")
+        applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Service Worker", "Visible name of Service Worker process. The argument is the application name."), (NSString *)parameters.uiProcessName];
+#endif
     else
         applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Content", "Visible name of the web process. The argument is the application name."), (NSString *)parameters.uiProcessName];
     _LSSetApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSDisplayNameKey, (CFStringRef)applicationName, nullptr);