Title: [138655] trunk/Source/WebKit2
Revision
138655
Author
wei...@apple.com
Date
2013-01-02 15:00:00 -0800 (Wed, 02 Jan 2013)

Log Message

Factor out NetworkProcess initialization into its own function in preparation of adding a NetworkProcess service
https://bugs.webkit.org/show_bug.cgi?id=105946

Reviewed by Brady Eidson.

* NetworkProcess/NetworkProcess.h:
* NetworkProcess/mac/NetworkProcessInitialization.h: Added.
(NetworkProcessInitializationParameters):
* NetworkProcess/mac/NetworkProcessInitialization.mm: Added.
(WebKit::initializeNetworkProcess):
* NetworkProcess/mac/NetworkProcessMac.mm:
(WebKit::NetworkProcess::initializeSandbox):
(WebKit::NetworkProcess::platformInitialize):
* NetworkProcess/mac/NetworkProcessMainMac.mm:
(WebKit::NetworkProcessMain):
* WebKit2.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (138654 => 138655)


--- trunk/Source/WebKit2/ChangeLog	2013-01-02 22:52:58 UTC (rev 138654)
+++ trunk/Source/WebKit2/ChangeLog	2013-01-02 23:00:00 UTC (rev 138655)
@@ -1,3 +1,22 @@
+2013-01-02  Sam Weinig  <s...@webkit.org>
+
+        Factor out NetworkProcess initialization into its own function in preparation of adding a NetworkProcess service
+        https://bugs.webkit.org/show_bug.cgi?id=105946
+
+        Reviewed by Brady Eidson.
+
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/mac/NetworkProcessInitialization.h: Added.
+        (NetworkProcessInitializationParameters):
+        * NetworkProcess/mac/NetworkProcessInitialization.mm: Added.
+        (WebKit::initializeNetworkProcess):
+        * NetworkProcess/mac/NetworkProcessMac.mm:
+        (WebKit::NetworkProcess::initializeSandbox):
+        (WebKit::NetworkProcess::platformInitialize):
+        * NetworkProcess/mac/NetworkProcessMainMac.mm:
+        (WebKit::NetworkProcessMain):
+        * WebKit2.xcodeproj/project.pbxproj:
+
 2013-01-02  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r138403.

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h (138654 => 138655)


--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h	2013-01-02 22:52:58 UTC (rev 138654)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h	2013-01-02 23:00:00 UTC (rev 138655)
@@ -64,6 +64,7 @@
         m_supplements.add(T::supplementName(), new T(this));
     }
 
+    void initializeSandbox(const String& clientIdentifier);
     void initialize(CoreIPC::Connection::Identifier, WebCore::RunLoop*);
 
     void removeNetworkConnectionToWebProcess(NetworkConnectionToWebProcess*);

Added: trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessInitialization.h (0 => 138655)


--- trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessInitialization.h	                        (rev 0)
+++ trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessInitialization.h	2013-01-02 23:00:00 UTC (rev 138655)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef NetworkProcessInitialization_h
+#define NetworkProcessInitialization_h
+
+#include "Connection.h"
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+struct NetworkProcessInitializationParameters {
+    String uiProcessName;
+
+    String clientIdentifier;
+    CoreIPC::Connection::Identifier connectionIdentifier;
+};
+
+void initializeNetworkProcess(const NetworkProcessInitializationParameters&);
+
+} // namespace WebKit
+
+#endif // NetworkProcessInitialization_h

Added: trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessInitialization.mm (0 => 138655)


--- trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessInitialization.mm	                        (rev 0)
+++ trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessInitialization.mm	2013-01-02 23:00:00 UTC (rev 138655)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "NetworkProcessInitialization.h"
+
+#import "NetworkProcess.h"
+#import "WebSystemInterface.h"
+#import <WebCore/LocalizedStrings.h>
+#import <WebCore/RunLoop.h>
+#import <WebKitSystemInterface.h>
+#import <runtime/InitializeThreading.h>
+#import <wtf/MainThread.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void initializeNetworkProcess(const NetworkProcessInitializationParameters& parameters)
+{
+    @autoreleasepool {
+        InitWebCoreSystemInterface();
+        JSC::initializeThreading();
+        WTF::initializeMainThread();
+        RunLoop::initializeMainRunLoop();
+
+        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);
+        }
+
+        NetworkProcess& networkProcess = NetworkProcess::shared();
+        networkProcess.initializeSandbox(parameters.clientIdentifier);
+        networkProcess.initialize(parameters.connectionIdentifier, RunLoop::main());
+    }
+}
+
+} // namespace WebKit

Modified: trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMac.mm (138654 => 138655)


--- trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMac.mm	2013-01-02 22:52:58 UTC (rev 138654)
+++ trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMac.mm	2013-01-02 23:00:00 UTC (rev 138655)
@@ -46,6 +46,11 @@
 
 namespace WebKit {
 
+void NetworkProcess::initializeSandbox(const String&)
+{
+    // FIXME: Initialize the sandbox.
+}
+
 void NetworkProcess::platformInitialize(const NetworkProcessCreationParameters& parameters)
 {
     m_diskCacheDirectory = parameters.diskCacheDirectory;
@@ -58,12 +63,6 @@
         RetainPtr<NSURLCache> parentProcessURLCache(AdoptNS, [[NSURLCache alloc] initWithMemoryCapacity:cacheMemoryCapacity diskCapacity:cacheDiskCapacity diskPath:parameters.diskCacheDirectory]);
         [NSURLCache setSharedURLCache:parentProcessURLCache.get()];
     }
-
-    // FIXME: This should be moved to earlier in the setup process, as this won't work once sandboxing is enable.
-    NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Networking", "visible name of the network process. The argument is the application name."),
-        (NSString *)parameters.parentProcessName];
-    
-    WKSetVisibleApplicationName((CFStringRef)applicationName);
 }
 
 static uint64_t memorySize()

Modified: trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMainMac.mm (138654 => 138655)


--- trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMainMac.mm	2013-01-02 22:52:58 UTC (rev 138654)
+++ trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMainMac.mm	2013-01-02 23:00:00 UTC (rev 138655)
@@ -29,13 +29,10 @@
 #if ENABLE(NETWORK_PROCESS)
 
 #import "CommandLine.h"
-#import "EnvironmentUtilities.h"
-#import "NetworkProcess.h"
-#import "WebSystemInterface.h"
+#import "NetworkProcessInitialization.h"
 #import <WebCore/RunLoop.h>
 #import <WebKitSystemInterface.h>
 #import <mach/mach_error.h>
-#import <runtime/InitializeThreading.h>
 #import <servers/bootstrap.h>
 #import <stdio.h>
 #import <wtf/MainThread.h>
@@ -79,16 +76,16 @@
     signal(SIGSEGV, _exit);
 #endif
 
-    InitWebCoreSystemInterface();
-    JSC::initializeThreading();
-    WTF::initializeMainThread();
-    RunLoop::initializeMainRunLoop();
-
-    // Initialize the network process connection.
-    NetworkProcess::shared().initialize(CoreIPC::Connection::Identifier(serverPort), RunLoop::main());
-
+    // FIXME: The Network process should not need to use AppKit, but right now, WebCore::RunLoop depends
+    // on the outer most runloop being an AppKit runloop.
     [NSApplication sharedApplication];
 
+    NetworkProcessInitializationParameters parameters;
+    parameters.uiProcessName = commandLine["ui-process-name"];
+    parameters.clientIdentifier = commandLine["client-identifier"];
+    parameters.connectionIdentifier = serverPort;
+    initializeNetworkProcess(parameters);
+
     RunLoop::run();
 
     return 0;

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (138654 => 138655)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2013-01-02 22:52:58 UTC (rev 138654)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2013-01-02 23:00:00 UTC (rev 138655)
@@ -647,6 +647,8 @@
 		BC111B5D112F629800337BAB /* WebEventFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = BC111B5B112F629800337BAB /* WebEventFactory.h */; };
 		BC111B5E112F629800337BAB /* WebEventFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC111B5C112F629800337BAB /* WebEventFactory.mm */; };
 		BC131BC911726C2800B69727 /* CoreIPCMessageKinds.h in Headers */ = {isa = PBXBuildFile; fileRef = BC131BC811726C2800B69727 /* CoreIPCMessageKinds.h */; };
+		BC13E9771694E2D000BC6C00 /* NetworkProcessInitialization.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC13E9751694E2D000BC6C00 /* NetworkProcessInitialization.mm */; };
+		BC13E9781694E2D000BC6C00 /* NetworkProcessInitialization.h in Headers */ = {isa = PBXBuildFile; fileRef = BC13E9761694E2D000BC6C00 /* NetworkProcessInitialization.h */; };
 		BC14DF77120B5B7900826C0C /* InjectedBundleScriptWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = BC14DF75120B5B7900826C0C /* InjectedBundleScriptWorld.h */; };
 		BC14DF78120B5B7900826C0C /* InjectedBundleScriptWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC14DF76120B5B7900826C0C /* InjectedBundleScriptWorld.cpp */; };
 		BC14DF9E120B635F00826C0C /* WKBundleScriptWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC14DF9C120B635F00826C0C /* WKBundleScriptWorld.cpp */; };
@@ -1915,6 +1917,8 @@
 		BC122FA3132707F300F7EAC1 /* PluginProcess.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = PluginProcess.xcconfig; sourceTree = "<group>"; };
 		BC122FA61327087400F7EAC1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = PluginProcess/Info.plist; sourceTree = "<group>"; };
 		BC131BC811726C2800B69727 /* CoreIPCMessageKinds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreIPCMessageKinds.h; sourceTree = "<group>"; };
+		BC13E9751694E2D000BC6C00 /* NetworkProcessInitialization.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkProcessInitialization.mm; sourceTree = "<group>"; };
+		BC13E9761694E2D000BC6C00 /* NetworkProcessInitialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkProcessInitialization.h; sourceTree = "<group>"; };
 		BC14DF75120B5B7900826C0C /* InjectedBundleScriptWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleScriptWorld.h; sourceTree = "<group>"; };
 		BC14DF76120B5B7900826C0C /* InjectedBundleScriptWorld.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleScriptWorld.cpp; sourceTree = "<group>"; };
 		BC14DF9C120B635F00826C0C /* WKBundleScriptWorld.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleScriptWorld.cpp; sourceTree = "<group>"; };
@@ -3176,6 +3180,8 @@
 		510CC7DC16138E2900D03ED3 /* mac */ = {
 			isa = PBXGroup;
 			children = (
+				BC13E9751694E2D000BC6C00 /* NetworkProcessInitialization.mm */,
+				BC13E9761694E2D000BC6C00 /* NetworkProcessInitialization.h */,
 				51A8A6151627F3F9000D90E9 /* NetworkProcessMac.mm */,
 				510CC7DD16138E2900D03ED3 /* NetworkProcessMainMac.mm */,
 				512C068F16390E6900ABB911 /* NetworkResourceLoadSchedulerMac.mm */,
@@ -5032,6 +5038,7 @@
 				BCE0E425168B7A280057E66A /* WebProcessSupplement.h in Headers */,
 				BCF4DE23168E4BD500C94AFC /* NetworkProcessSupplement.h in Headers */,
 				BCF4DE25168FA44800C94AFC /* WebContextSupplement.h in Headers */,
+				BC13E9781694E2D000BC6C00 /* NetworkProcessInitialization.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -6006,6 +6013,7 @@
 				BCF18638167D071E00A1A85A /* CacheModel.cpp in Sources */,
 				2989A411167D1834004F96D2 /* CustomProtocolManagerMac.mm in Sources */,
 				31A505F91680025500A930EB /* WebContextClient.cpp in Sources */,
+				BC13E9771694E2D000BC6C00 /* NetworkProcessInitialization.mm in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to