[Mac] Don't open window server connection in network process
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Apr 2013 23:58:20 +0000 (23:58 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Apr 2013 23:58:20 +0000 (23:58 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=115446

        Reviewed by Anders Carlsson.

        * NetworkProcess/NetworkProcess.cpp:
        (WebKit::NetworkProcess::initializeProcess):
        * NetworkProcess/NetworkProcess.h:
        * NetworkProcess/mac/NetworkProcessMac.mm:
        (WebKit::NetworkProcess::initializeProcess):
        (WebKit::NetworkProcess::initializeProcessName):
        Instead of shutting down a connection after setting process name, just prevent
        it from being created.

        * Shared/ChildProcess.h:
        * Shared/mac/ChildProcessMac.mm: (WebKit::ChildProcess::setApplicationIsDaemon):
        Expose a function for client processes to call if they don't run an NSApplication
        run loop.

        * OfflineStorageProcess/OfflineStorageProcess.cpp:
        (WebKit::OfflineStorageProcess::initializeProcess):
        * OfflineStorageProcess/OfflineStorageProcess.h:
        * OfflineStorageProcess/mac/OfflineStorageProcessMac.mm:
        (WebKit::OfflineStorageProcess::initializeProcess):
        (WebKit::OfflineStorageProcess::initializeProcessName):
        * SharedWorkerProcess/SharedWorkerProcess.cpp:
        (WebKit::SharedWorkerProcess::initializeProcess):
        (WebKit::SharedWorkerProcess::initializeProcessName):
        * SharedWorkerProcess/SharedWorkerProcess.h:
        * SharedWorkerProcess/mac/SharedWorkerProcessMac.mm:
        (WebKit::SharedWorkerProcess::initializeProcess):
        (WebKit::SharedWorkerProcess::initializeProcessName):
        Match NetworkProcess for consistency.

        * WebProcess/mac/WebProcessMac.mm: (WebKit::WebProcess::initializeProcessName):
        Don't null check UI process name. First, it can't be null, and second, some other
        processes already don't have this check.

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

13 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkProcess.cpp
Source/WebKit2/NetworkProcess/NetworkProcess.h
Source/WebKit2/NetworkProcess/mac/NetworkProcessMac.mm
Source/WebKit2/OfflineStorageProcess/OfflineStorageProcess.cpp
Source/WebKit2/OfflineStorageProcess/OfflineStorageProcess.h
Source/WebKit2/OfflineStorageProcess/mac/OfflineStorageProcessMac.mm
Source/WebKit2/Shared/ChildProcess.h
Source/WebKit2/Shared/mac/ChildProcessMac.mm
Source/WebKit2/SharedWorkerProcess/SharedWorkerProcess.cpp
Source/WebKit2/SharedWorkerProcess/SharedWorkerProcess.h
Source/WebKit2/SharedWorkerProcess/mac/SharedWorkerProcessMac.mm
Source/WebKit2/WebProcess/mac/WebProcessMac.mm

index 51e0624..6342fe3 100644 (file)
@@ -1,3 +1,43 @@
+2013-04-30  Alexey Proskuryakov  <ap@apple.com>
+
+        [Mac] Don't open window server connection in network process
+        https://bugs.webkit.org/show_bug.cgi?id=115446
+
+        Reviewed by Anders Carlsson.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::initializeProcess):
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/mac/NetworkProcessMac.mm:
+        (WebKit::NetworkProcess::initializeProcess):
+        (WebKit::NetworkProcess::initializeProcessName):
+        Instead of shutting down a connection after setting process name, just prevent
+        it from being created.
+
+        * Shared/ChildProcess.h:
+        * Shared/mac/ChildProcessMac.mm: (WebKit::ChildProcess::setApplicationIsDaemon):
+        Expose a function for client processes to call if they don't run an NSApplication
+        run loop.
+
+        * OfflineStorageProcess/OfflineStorageProcess.cpp:
+        (WebKit::OfflineStorageProcess::initializeProcess):
+        * OfflineStorageProcess/OfflineStorageProcess.h:
+        * OfflineStorageProcess/mac/OfflineStorageProcessMac.mm:
+        (WebKit::OfflineStorageProcess::initializeProcess):
+        (WebKit::OfflineStorageProcess::initializeProcessName):
+        * SharedWorkerProcess/SharedWorkerProcess.cpp:
+        (WebKit::SharedWorkerProcess::initializeProcess):
+        (WebKit::SharedWorkerProcess::initializeProcessName):
+        * SharedWorkerProcess/SharedWorkerProcess.h:
+        * SharedWorkerProcess/mac/SharedWorkerProcessMac.mm:
+        (WebKit::SharedWorkerProcess::initializeProcess):
+        (WebKit::SharedWorkerProcess::initializeProcessName):
+        Match NetworkProcess for consistency.
+
+        * WebProcess/mac/WebProcessMac.mm: (WebKit::WebProcess::initializeProcessName):
+        Don't null check UI process name. First, it can't be null, and second, some other
+        processes already don't have this check.
+
 2013-04-30  Tim Horton  <timothy_horton@apple.com>
 
         Disable deprecation warnings around some NSProcessInfo API.
index 4c6492a..917ddc5 100644 (file)
@@ -253,6 +253,10 @@ void NetworkProcess::terminate()
 }
 
 #if !PLATFORM(MAC)
+void NetworkProcess::initializeProcess(const ChildProcessInitializationParameters&)
+{
+}
+
 void NetworkProcess::initializeProcessName(const ChildProcessInitializationParameters&)
 {
 }
index 7298a5c..8416fb7 100644 (file)
@@ -81,6 +81,7 @@ private:
     void platformTerminate();
 
     // ChildProcess
+    virtual void initializeProcess(const ChildProcessInitializationParameters&) OVERRIDE;
     virtual void initializeProcessName(const ChildProcessInitializationParameters&) OVERRIDE;
     virtual void initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&) OVERRIDE;
     virtual void initializeConnection(CoreIPC::Connection*) OVERRIDE;
index 0a210d5..3e96fa4 100644 (file)
@@ -62,15 +62,16 @@ using namespace WebCore;
 
 namespace WebKit {
 
-void NetworkProcess::initializeProcessName(const ChildProcessInitializationParameters& parameters)
+void NetworkProcess::initializeProcess(const ChildProcessInitializationParameters&)
 {
-    if (!parameters.uiProcessName.isNull()) {
-        NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Networking", "visible name of the network process. The argument is the application name."), (NSString *)parameters.uiProcessName];
-        WKSetVisibleApplicationName((CFStringRef)applicationName);
+    // Having a window server connection in this process would result in spin logs (<rdar://problem/13239119>).
+    setApplicationIsDaemon();
+}
 
-        // Having a window server connection in this process would result in spin logs (<rdar://problem/13239119>).
-        shutdownWindowServerConnection();
-    }
+void NetworkProcess::initializeProcessName(const ChildProcessInitializationParameters& parameters)
+{
+    NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Networking", "visible name of the network process. The argument is the application name."), (NSString *)parameters.uiProcessName];
+    WKSetVisibleApplicationName((CFStringRef)applicationName);
 }
 
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
index 22937d3..55df6c5 100644 (file)
@@ -82,6 +82,10 @@ void OfflineStorageProcess::initializeOfflineStorageProcess(const OfflineStorage
 }
 
 #if !PLATFORM(MAC)
+void OfflineStorageProcess::initializeProcess(const ChildProcessInitializationParameters&)
+{
+}
+
 void OfflineStorageProcess::initializeProcessName(const ChildProcessInitializationParameters&)
 {
 }
index b990896..75e2d6b 100644 (file)
@@ -42,6 +42,7 @@ private:
     ~OfflineStorageProcess();
 
     // ChildProcess
+    virtual void initializeProcess(const ChildProcessInitializationParameters&) OVERRIDE;
     virtual void initializeProcessName(const ChildProcessInitializationParameters&) OVERRIDE;
     virtual void initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&) OVERRIDE;
     virtual bool shouldTerminate() OVERRIDE;
index b590da2..029ef8b 100644 (file)
 
 namespace WebKit {
 
+void OfflineStorageProcess::initializeProcess(const ChildProcessInitializationParameters&)
+{
+    // Having a window server connection in this process would result in spin logs (<rdar://problem/13239119>).
+    setApplicationIsDaemon();
+}
+
 void OfflineStorageProcess::initializeProcessName(const ChildProcessInitializationParameters& parameters)
 {
     NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Offline Storage", "visible name of the offline storage process. The argument is the application name."), (NSString *)parameters.uiProcessName];
     WKSetVisibleApplicationName((CFStringRef)applicationName);
-
-    // Having a window server connection in this process would result in spin logs (<rdar://problem/13239119>).
-    shutdownWindowServerConnection();
 }
 
 void OfflineStorageProcess::initializeSandbox(const ChildProcessInitializationParameters& parameters, SandboxInitializationParameters& sandboxParameters)
index c9c74f9..878d5bd 100644 (file)
@@ -65,7 +65,7 @@ public:
     bool processSuppressionEnabled() const { return !m_processSuppressionAssertion; }
     void setProcessSuppressionEnabled(bool);
 
-    void shutdownWindowServerConnection();
+    void setApplicationIsDaemon();
 #endif
 
     CoreIPC::Connection* parentProcessConnection() const { return m_connection.get(); }
index a20ee97..3487b66 100644 (file)
 extern "C" int sandbox_init_with_parameters(const char *profile, uint64_t flags, const char *const parameters[], char **errorbuf);
 
 #ifdef __has_include
-#if __has_include(<CoreGraphics/CGSConnection.h>)
-#include <CoreGraphics/CGSConnection.h>
-#endif
-
 #if __has_include(<HIServices/ProcessesPriv.h>)
 #include <HIServices/ProcessesPriv.h>
 #endif
 #endif
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1080 // Temporary workaround for <rdar://problem/13564588>. We should have the forward declaration on all OS X versions again eventually.
-extern "C" CGError CGSShutdownServerConnections();
-#endif
-
 extern "C" OSStatus SetApplicationIsDaemon(Boolean isDaemon);
 
 using namespace WebCore;
@@ -89,10 +81,10 @@ static void initializeTimerCoalescingPolicy()
 }
 #endif
 
-void ChildProcess::shutdownWindowServerConnection()
+void ChildProcess::setApplicationIsDaemon()
 {
-    CGSShutdownServerConnections();
-    SetApplicationIsDaemon(true);
+    OSStatus error = SetApplicationIsDaemon(true);
+    ASSERT_UNUSED(error, error == noErr);
 }
 
 void ChildProcess::platformInitialize()
index 35b87d2..d42ab4e 100644 (file)
@@ -182,6 +182,16 @@ void SharedWorkerProcess::minimumLifetimeTimerFired()
     enableTermination();
 }
 
+#if !PLATFORM(MAC)
+void SharedWorkerProcess::initializeProcess(const ChildProcessInitializationParameters&)
+{
+}
+
+void SharedWorkerProcess::initializeProcessName(const ChildProcessInitializationParameters&)
+{
+}
+#endif
+
 } // namespace WebKit
 
 #endif // ENABLE(SHARED_WORKER_PROCESS)
index 7fb1e01..6fbcc70 100644 (file)
@@ -48,6 +48,7 @@ private:
     ~SharedWorkerProcess();
 
     // ChildProcess
+    virtual void initializeProcess(const ChildProcessInitializationParameters&) OVERRIDE;
     virtual void initializeProcessName(const ChildProcessInitializationParameters&) OVERRIDE;
     virtual bool shouldTerminate() OVERRIDE;
 
index a69bb81..275c41b 100644 (file)
 
 namespace WebKit {
 
+void SharedWorkerProcess::initializeProcess(const ChildProcessInitializationParameters&)
+{
+    // Having a window server connection in this process would result in spin logs (<rdar://problem/13239119>).
+    setApplicationIsDaemon();
+}
+
 void SharedWorkerProcess::initializeProcessName(const ChildProcessInitializationParameters& parameters)
 {
     NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Shared Worker", "Visible name of the shared worker process. The argument is the application name."), (NSString *)parameters.uiProcessName];
     WKSetVisibleApplicationName((CFStringRef)applicationName);
-
-    // Having a window server connection in this process would result in spin logs (<rdar://problem/13239119>).
-    shutdownWindowServerConnection();
 }
 
 } // namespace WebKit
index 63d5e5d..31b78a7 100644 (file)
@@ -189,10 +189,8 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
 
 void WebProcess::initializeProcessName(const ChildProcessInitializationParameters& parameters)
 {
-    if (!parameters.uiProcessName.isNull()) {
-        NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Content", "Visible name of the web process. The argument is the application name."), (NSString *)parameters.uiProcessName];
-        WKSetVisibleApplicationName((CFStringRef)applicationName);
-    }
+    NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Content", "Visible name of the web process. The argument is the application name."), (NSString *)parameters.uiProcessName];
+    WKSetVisibleApplicationName((CFStringRef)applicationName);
 }
 
 void WebProcess::platformInitializeProcess(const ChildProcessInitializationParameters&)