Only export a single WebKitMain function for the Web Process to call
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jul 2010 17:09:35 +0000 (17:09 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jul 2010 17:09:35 +0000 (17:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=41702

Reviewed by Sam Weinig.

* Shared/CommandLine.h:
Add windows CommandLine::parse overload.

* Shared/win/CommandLineWin.cpp: Added.
(WebKit::CommandLine::parse):
Move parse overload from WebProcess/win/WebProcessMain.cpp.

* UIProcess/Launcher/win/ProcessLauncherWin.cpp:
(WebKit::ProcessLauncher::launchProcess):
Pass the right mode to.

* WebKit2.xcodeproj/project.pbxproj:
Update for moves.

* WebProcess/Launching/mac/WebProcessMain.mm: Removed.
* WebProcess/Launching/win/WebProcessWinMain.cpp: Removed.
* WebProcess/WebKitMain.cpp: Added.
(WebKitMain):
(enableTerminationOnHeapCorruption):
Add WebKitMain functions for Mac and Windows.

* WebProcess/WebProcessMain.h: Added.
* WebProcess/mac/WebProcessMainMac.mm: Added.
(WebKit::WebProcessMain):
Add Mac version of WebProcessMain.

* WebProcess/win/WebProcessMain.cpp: Removed.
* WebProcess/win/WebProcessMain.h: Removed.
* WebProcess/win/WebProcessMainWin.cpp: Added.
(WebKit::WebProcessMain):
Add Windows version of WebProcessMain.

* mac/MainMac.cpp: Added.
(main):
Add Mac WebProcess main function.

* mac/WebKit2.exp:
Remove functions that we don't need to export.

* win/MainWin.cpp: Added.
(wWinMain):
Add Windows WebProcess main function.

* win/WebKit2.vcproj:
* win/WebKit2WebProcess.vcproj:
Update for moves.

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

14 files changed:
WebKit2/ChangeLog
WebKit2/Shared/CommandLine.h
WebKit2/Shared/win/CommandLineWin.cpp [moved from WebKit2/WebProcess/win/WebProcessMain.cpp with 62% similarity]
WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp
WebKit2/WebKit2.xcodeproj/project.pbxproj
WebKit2/WebProcess/WebKitMain.cpp [moved from WebKit2/WebProcess/Launching/win/WebProcessWinMain.cpp with 69% similarity]
WebKit2/WebProcess/WebProcessMain.h [moved from WebKit2/WebProcess/win/WebProcessMain.h with 79% similarity]
WebKit2/WebProcess/mac/WebProcessMainMac.mm [moved from WebKit2/WebProcess/Launching/mac/WebProcessMain.mm with 88% similarity]
WebKit2/WebProcess/win/WebProcessMainWin.cpp [new file with mode: 0644]
WebKit2/mac/MainMac.cpp [new file with mode: 0644]
WebKit2/mac/WebKit2.exp
WebKit2/win/MainWin.cpp [new file with mode: 0644]
WebKit2/win/WebKit2.vcproj
WebKit2/win/WebKit2WebProcess.vcproj

index 5ef8dc592d06ee2d7925c55ed776bdf38228d47e..0593e838f3bd90cea0180433aadeeadf87eaab25 100644 (file)
@@ -1,3 +1,57 @@
+2010-07-06  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Only export a single WebKitMain function for the Web Process to call
+        https://bugs.webkit.org/show_bug.cgi?id=41702
+
+        * Shared/CommandLine.h:
+        Add windows CommandLine::parse overload.
+
+        * Shared/win/CommandLineWin.cpp: Added.
+        (WebKit::CommandLine::parse):
+        Move parse overload from WebProcess/win/WebProcessMain.cpp.
+
+        * UIProcess/Launcher/win/ProcessLauncherWin.cpp:
+        (WebKit::ProcessLauncher::launchProcess):
+        Pass the right mode to.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        Update for moves.
+        
+        * WebProcess/Launching/mac/WebProcessMain.mm: Removed.
+        * WebProcess/Launching/win/WebProcessWinMain.cpp: Removed.
+        * WebProcess/WebKitMain.cpp: Added.
+        (WebKitMain):
+        (enableTerminationOnHeapCorruption):
+        Add WebKitMain functions for Mac and Windows.
+
+        * WebProcess/WebProcessMain.h: Added.
+        * WebProcess/mac/WebProcessMainMac.mm: Added.
+        (WebKit::WebProcessMain):
+        Add Mac version of WebProcessMain.
+
+        * WebProcess/win/WebProcessMain.cpp: Removed.
+        * WebProcess/win/WebProcessMain.h: Removed.
+        * WebProcess/win/WebProcessMainWin.cpp: Added.
+        (WebKit::WebProcessMain):
+        Add Windows version of WebProcessMain.
+
+        * mac/MainMac.cpp: Added.
+        (main):
+        Add Mac WebProcess main function.
+
+        * mac/WebKit2.exp:
+        Remove functions that we don't need to export.
+
+        * win/MainWin.cpp: Added.
+        (wWinMain):
+        Add Windows WebProcess main function.
+
+        * win/WebKit2.vcproj:
+        * win/WebKit2WebProcess.vcproj:
+        Update for moves.
+
 2010-07-05  Luiz Agostini  <luiz.agostini@openbossa.org>
 
         Reviewed by Kenneth Rohde Christiansen.
index f9f9f97a1009985d4799d1a51573fa318678f5dc..119ceb10c597ae664ee7e8a98a069ec447f396cc 100644 (file)
@@ -40,6 +40,7 @@ public:
 #if PLATFORM(MAC)
     bool parse(int argc, char** argv);
 #elif PLATFORM(WIN)
+    bool parse(LPTSTR commandLineString);
 #endif
     WebCore::String operator[](const WebCore::String& key) const
     {
similarity index 62%
rename from WebKit2/WebProcess/win/WebProcessMain.cpp
rename to WebKit2/Shared/win/CommandLineWin.cpp
index 06860f247aeb11dd8015e6ae11f60aa7f7fa6b61..ba7c64a80f73f461976bad6b1b6d4b9907e991d8 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "WebProcessMain.h"
-
-#include "RunLoop.h"
-#include "WebProcess.h"
-#include <runtime/InitializeThreading.h>
-#include <WebCore/PlatformString.h>
-#include <WebCore/StringHash.h>
-#include <wtf/Threading.h>
+#include "CommandLine.h"
 
 using namespace WebCore;
 
 namespace WebKit {
 
-// FIXME: If the Mac port is going to need this we should consider moving it to Platform or Shared.
-class CommandLine {
-public:
-    CommandLine() { }
-    bool parse(LPTSTR commandLineString);
-
-    String operator[](const String&) const;
-
-private:
-    HashMap<String, String> m_args;
-};
-
 bool CommandLine::parse(LPTSTR commandLineString)
 {
     m_args.clear();
@@ -81,36 +62,4 @@ bool CommandLine::parse(LPTSTR commandLineString)
     return true;
 }
 
-String CommandLine::operator[](const String& key) const
-{
-    return m_args.get(key);
-}
-
-int WebProcessMain(HINSTANCE hInstance, LPWSTR commandLineString)
-{
-    CommandLine commandLine;
-
-    // FIXME: Should we return an error code here?
-    if (!commandLine.parse(commandLineString))
-        return 0;
-
-    OleInitialize(0);
-
-    JSC::initializeThreading();
-    WTF::initializeMainThread();
-    RunLoop::initializeMainRunLoop();
-
-    const String& identifierString = commandLine["clientIdentifier"];
-
-    // FIXME: Should we return an error code here?
-    HANDLE clientIdentifier = reinterpret_cast<HANDLE>(identifierString.toUInt64Strict());
-    if (!clientIdentifier)
-        return 0;
-
-    WebProcess::shared().initialize(clientIdentifier, RunLoop::main());
-    RunLoop::run();
-
-    return 0;
-}
-
 } // namespace WebKit
index e880d7de5c3e3e42243010c8a098975323a3a267..6d7979d595784c6d40ae2fb9b0cac6d9e69bc031 100644 (file)
@@ -58,6 +58,7 @@ void ProcessLauncher::launchProcess()
 #endif
 
     append(commandLineVector, commandLine);
+    append(commandLineVector, " -mode webprocess");
     append(commandLineVector, " -clientIdentifier ");
     append(commandLineVector, String::number(reinterpret_cast<uintptr_t>(clientIdentifier)));
     commandLineVector.append('\0');
@@ -80,7 +81,7 @@ void ProcessLauncher::launchProcess()
     ::CloseHandle(processInformation.hThread);
 
     // We've finished launching the process, message back to the run loop.
-    RunLoop::main()->scheduleWork(WorkItem::create(this, &ProcessLauncher::didFinishLaunchingProcess, processIdentifier(), serverIdentifier));
+    RunLoop::main()->scheduleWork(WorkItem::create(this, &ProcessLauncher::didFinishLaunchingProcess, processInformation.hProcess, serverIdentifier));
 }
 
 void ProcessLauncher::terminateProcess()
index 62e5974a4119c3b69697ae96fb225b515f7b2fb9..ab2529e5636d33a1794781fdb941a6c993f3dae0 100644 (file)
@@ -34,7 +34,6 @@
                1A1C4EC810D06099005E67E7 /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1C79A100E7FC50078DEBC /* WebCore.framework */; };
                1A30066E1110F4F70031937C /* ResponsivenessTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A30066C1110F4F70031937C /* ResponsivenessTimer.h */; };
                1A30EAC6115D7DA30053E937 /* ConnectionMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A30EAC5115D7DA30053E937 /* ConnectionMac.cpp */; };
-               1A39A54B1149D0700083E625 /* WebProcessMain.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC111B02112F5D1900337BAB /* WebProcessMain.mm */; };
                1A3E736111CC2659007BD539 /* WebPlatformStrategies.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3E735F11CC2659007BD539 /* WebPlatformStrategies.h */; };
                1A3E736211CC2659007BD539 /* WebPlatformStrategies.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3E736011CC2659007BD539 /* WebPlatformStrategies.cpp */; };
                1A433F0D113C53DD00FACDE9 /* WebErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A433F0C113C53DD00FACDE9 /* WebErrors.h */; };
                1A594ABB112A1FB6009DE7C7 /* WebUIClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A594AB9112A1FB6009DE7C7 /* WebUIClient.h */; };
                1A6F9F9011E13EFC00DB1371 /* CommandLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6F9F8E11E13EFC00DB1371 /* CommandLine.h */; };
                1A6F9FB711E1408500DB1371 /* CommandLineMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6F9FB611E1408500DB1371 /* CommandLineMac.cpp */; };
+               1A6FA01E11E1526300DB1371 /* WebProcessMainMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FA01D11E1526300DB1371 /* WebProcessMainMac.mm */; };
+               1A6FA02011E1528700DB1371 /* WebProcessMain.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6FA01F11E1528700DB1371 /* WebProcessMain.h */; };
+               1A6FA31111E3921E00DB1371 /* MainMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FA31011E3921E00DB1371 /* MainMac.cpp */; };
+               1A6FA31611E3923600DB1371 /* WebKitMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FA31511E3923600DB1371 /* WebKitMain.cpp */; };
                1AA1CC5D100FA1A10078DEBC /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1CC5C100FA1A10078DEBC /* QuartzCore.framework */; };
                1AA1CD07100FA1BA0078DEBC /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1CD06100FA1BA0078DEBC /* Carbon.framework */; };
                1AADE6FF10D855FC00D3D63D /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AADE6FE10D855FC00D3D63D /* ApplicationServices.framework */; };
                1A594AB9112A1FB6009DE7C7 /* WebUIClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebUIClient.h; sourceTree = "<group>"; };
                1A6F9F8E11E13EFC00DB1371 /* CommandLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandLine.h; sourceTree = "<group>"; };
                1A6F9FB611E1408500DB1371 /* CommandLineMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommandLineMac.cpp; sourceTree = "<group>"; };
+               1A6FA01D11E1526300DB1371 /* WebProcessMainMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessMainMac.mm; sourceTree = "<group>"; };
+               1A6FA01F11E1528700DB1371 /* WebProcessMain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebProcessMain.h; sourceTree = "<group>"; };
+               1A6FA31011E3921E00DB1371 /* MainMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MainMac.cpp; path = mac/MainMac.cpp; sourceTree = "<group>"; };
+               1A6FA31511E3923600DB1371 /* WebKitMain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitMain.cpp; sourceTree = "<group>"; };
                1AA1C79A100E7FC50078DEBC /* WebCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
                1AA1C7DE100E846E0078DEBC /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JavaScriptCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
                1AA1CC5C100FA1A10078DEBC /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = /System/Library/Frameworks/QuartzCore.framework; sourceTree = "<absolute>"; };
                BC111ADC112F5B9300337BAB /* WebFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebFrame.cpp; sourceTree = "<group>"; };
                BC111ADF112F5BC200337BAB /* WebErrorsMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebErrorsMac.mm; sourceTree = "<group>"; };
                BC111AE3112F5C2600337BAB /* WebProcess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebProcess.cpp; sourceTree = "<group>"; };
-               BC111B02112F5D1900337BAB /* WebProcessMain.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessMain.mm; sourceTree = "<group>"; };
                BC111B08112F5E3C00337BAB /* ResponsivenessTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResponsivenessTimer.cpp; sourceTree = "<group>"; };
                BC111B0A112F5E4F00337BAB /* WebFrameProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebFrameProxy.cpp; sourceTree = "<group>"; };
                BC111B0B112F5E4F00337BAB /* WebPageProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPageProxy.cpp; sourceTree = "<group>"; };
                        path = Configurations;
                        sourceTree = "<group>";
                };
+               1A6FA01C11E1526300DB1371 /* mac */ = {
+                       isa = PBXGroup;
+                       children = (
+                               1A6FA01D11E1526300DB1371 /* WebProcessMainMac.mm */,
+                       );
+                       path = mac;
+                       sourceTree = "<group>";
+               };
                1A7E814E1152D2240003695B /* mac */ = {
                        isa = PBXGroup;
                        children = (
                32C88DFF0371C24200C91783 /* Other Sources */ = {
                        isa = PBXGroup;
                        children = (
+                               1A6FA31011E3921E00DB1371 /* MainMac.cpp */,
                                32DBCF5E0370ADEE00C91783 /* WebKit2Prefix.h */,
                        );
                        name = "Other Sources";
                BC032D5C10F436D50058C15A /* WebProcess */ = {
                        isa = PBXGroup;
                        children = (
+                               1A6FA01C11E1526300DB1371 /* mac */,
                                BC204EDF11C83E72008F3375 /* InjectedBundle */,
-                               BC111AF6112F5CAC00337BAB /* Launching */,
                                BC032D5D10F437220058C15A /* WebCoreSupport */,
                                BC032D5E10F4372B0058C15A /* WebPage */,
+                               1A6FA31511E3923600DB1371 /* WebKitMain.cpp */,
                                BC111AE3112F5C2600337BAB /* WebProcess.cpp */,
                                BC032D9110F437AF0058C15A /* WebProcess.h */,
+                               1A6FA01F11E1528700DB1371 /* WebProcessMain.h */,
                        );
                        path = WebProcess;
                        sourceTree = "<group>";
                        path = mac;
                        sourceTree = "<group>";
                };
-               BC111AF6112F5CAC00337BAB /* Launching */ = {
-                       isa = PBXGroup;
-                       children = (
-                               BC111AF7112F5CBE00337BAB /* mac */,
-                       );
-                       path = Launching;
-                       sourceTree = "<group>";
-               };
-               BC111AF7112F5CBE00337BAB /* mac */ = {
-                       isa = PBXGroup;
-                       children = (
-                               BC111B02112F5D1900337BAB /* WebProcessMain.mm */,
-                       );
-                       path = mac;
-                       sourceTree = "<group>";
-               };
                BC111B18112F5FB400337BAB /* Launcher */ = {
                        isa = PBXGroup;
                        children = (
                                0F5265B411DD37680006D33C /* LayerBackedDrawingArea.h in Headers */,
                                0F5265BA11DD377F0006D33C /* LayerBackedDrawingAreaProxy.h in Headers */,
                                1A6F9F9011E13EFC00DB1371 /* CommandLine.h in Headers */,
+                               1A6FA02011E1528700DB1371 /* WebProcessMain.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
-                               1A39A54B1149D0700083E625 /* WebProcessMain.mm in Sources */,
+                               1A6FA31111E3921E00DB1371 /* MainMac.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                1AE117F611DBB30900981615 /* ProcessLauncher.cpp in Sources */,
                                0F52667411DD4A490006D33C /* WebProcessProxyMac.mm in Sources */,
                                1A6F9FB711E1408500DB1371 /* CommandLineMac.cpp in Sources */,
+                               1A6FA01E11E1526300DB1371 /* WebProcessMainMac.mm in Sources */,
+                               1A6FA31611E3923600DB1371 /* WebKitMain.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
similarity index 69%
rename from WebKit2/WebProcess/Launching/win/WebProcessWinMain.cpp
rename to WebKit2/WebProcess/WebKitMain.cpp
index daf14941794dc7b573ebd89877d182b397a32d1a..faa18530ac69c3275afff02690cc59812747d05c 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "CommandLine.h"
+
 #include "WebProcessMain.h"
-#include <tchar.h>
-#include <windows.h>
-
-#if defined _M_IX86
-#define PROCESSORARCHITECTURE "x86"
-#elif defined _M_IA64
-#define PROCESSORARCHITECTURE "ia64"
-#elif defined _M_X64
-#define PROCESSORARCHITECTURE "amd64"
-#else
-#define PROCESSORARCHITECTURE "*"
+
+#if PLATFORM(MAC)
+#include <objc/objc-auto.h>
 #endif
 
-#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='" PROCESSORARCHITECTURE "' publicKeyToken='6595b64144ccf1df' language='*'\"")
+using namespace WebCore;
+using namespace WebKit;
+
+#if PLATFORM(MAC)
+
+extern "C" int WebKitMain(int argc, char** argv);
+
+int WebKitMain(int argc, char** argv)
+{
+    ASSERT(!objc_collectingEnabled());
+    
+    CommandLine commandLine;
+    if (!commandLine.parse(argc, argv))
+        return EXIT_FAILURE;
+    
+    String mode = commandLine["mode"];
+    if (mode == "legacywebprocess")
+        return WebProcessMain(&commandLine);
+    
+    return EXIT_FAILURE;
+}
+
+#elif PLATFORM(WIN)
 
 static void enableTerminationOnHeapCorruption()
 {
@@ -58,9 +74,20 @@ static void enableTerminationOnHeapCorruption()
     heapSetInformation(0, heapEnableTerminationOnCorruption, 0, 0);
 }
 
-int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int /*nCmdShow*/)
+extern "C" __declspec(dllexport) 
+int WebKitMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrCmdLine, int nCmdShow)
 {
     enableTerminationOnHeapCorruption();
 
-    return WebKit::WebProcessMain(hInstance, lpstrCmdLine);
+    CommandLine commandLine;
+    if (!commandLine.parse(lpstrCmdLine))
+        return EXIT_FAILURE;
+
+    String mode = commandLine["mode"];
+    if (mode == "webprocess")
+        return WebKit::WebProcessMain(&commandLine);
+
+    return EXIT_FAILURE;
 }
+
+#endif
similarity index 79%
rename from WebKit2/WebProcess/win/WebProcessMain.h
rename to WebKit2/WebProcess/WebProcessMain.h
index f1ba0ee6934d7102765a00fa6860f1401d858b2b..9f15e3a69d1e19772f4321a84e62d618710a09d3 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebProcessMain_h
-#define WebProcessMain_h
-
-#include <windows.h>
+#include "WKBase.h"
 
 namespace WebKit {
 
-#if BUILDING_WEBKIT2
-#define DLL_EXPORT __declspec(dllexport)
-#else
-#define DLL_EXPORT __declspec(dllimport)
-#endif
+class CommandLine;
 
-// This is called only from the _tWinMain function of the WebProcess.
-DLL_EXPORT int WebProcessMain(HINSTANCE hInstance, LPWSTR commandLineString);
+int WebProcessMain(CommandLine*);
 
 } // namespace WebKit
-
-#endif // WebProcessMain_h
similarity index 88%
rename from WebKit2/WebProcess/Launching/mac/WebProcessMain.mm
rename to WebKit2/WebProcess/mac/WebProcessMainMac.mm
index 20eaf3b48919e226bd699ad761ce299ad6d7817d..7e540a33f255f4954f582605f191f43ad0b78c12 100644 (file)
@@ -23,6 +23,8 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#import "WebProcessMain.h"
+
 #import "CommandLine.h"
 #import "RunLoop.h"
 #import "WebProcess.h"
@@ -40,9 +42,10 @@ extern "C" kern_return_t bootstrap_look_up2(mach_port_t, const name_t, mach_port
 #define SHOW_CRASH_REPORTER 1
 
 using namespace WebCore;
-using namespace WebKit;
 
-static int webProcessMain(CommandLine*)
+namespace WebKit {
+
+int WebProcessMain(CommandLine*)
 {
     mach_port_t serverPort;
     kern_return_t kr = bootstrap_look_up2(bootstrap_port, "com.apple.WebKit.WebProcess", &serverPort, getppid(), /* BOOTSTRAP_PER_PID_SERVICE */ 1);
@@ -81,17 +84,5 @@ static int webProcessMain(CommandLine*)
     return 0;
 }
 
-int main(int argc, char** argv)
-{
-    ASSERT(!objc_collectingEnabled());
-
-    CommandLine commandLine;
-    if (!commandLine.parse(argc, argv))
-        return EXIT_FAILURE;
-
-    String mode = commandLine["mode"];
-    if (mode == "legacywebprocess")
-        return webProcessMain(&commandLine);
+} // namespace WebKit
 
-    return EXIT_FAILURE;
-}
diff --git a/WebKit2/WebProcess/win/WebProcessMainWin.cpp b/WebKit2/WebProcess/win/WebProcessMainWin.cpp
new file mode 100644 (file)
index 0000000..2bad204
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "WebProcessMain.h"
+
+#include "CommandLine.h"
+#include "RunLoop.h"
+#include "WebProcess.h"
+#include <runtime/InitializeThreading.h>
+#include <WebCore/PlatformString.h>
+#include <WebCore/StringHash.h>
+#include <wtf/Threading.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+int WebProcessMain(CommandLine* commandLine)
+{
+    ::OleInitialize(0);
+
+    JSC::initializeThreading();
+    WTF::initializeMainThread();
+    RunLoop::initializeMainRunLoop();
+
+    const String& identifierString = (*commandLine)["clientIdentifier"];
+
+    // FIXME: Should we return an error code here?
+    HANDLE clientIdentifier = reinterpret_cast<HANDLE>(identifierString.toUInt64Strict());
+    if (!clientIdentifier)
+        return 0;
+
+    WebProcess::shared().initialize(clientIdentifier, RunLoop::main());
+    RunLoop::run();
+
+    return 0;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/mac/MainMac.cpp b/WebKit2/mac/MainMac.cpp
new file mode 100644 (file)
index 0000000..a1c704e
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+// The framework entry point.
+extern "C" int WebKitMain(int argc, char **argv);
+
+int main(int argc, char** argv)
+{
+    return WebKitMain(argc, argv);
+}
index 151ec715fdd0e5474da716c716f5c5d5680b675d..a5284c58a541612550b4eb64bfed37febfa4d9ce 100644 (file)
@@ -65,10 +65,4 @@ _WKURLCopyCFURL
 _WKURLCreateWithCFURL
 _WKURLRelease
 _WKURLRetain
-__ZN6WebKit11CommandLine5parseEiPPc
-__Z26InitWebCoreSystemInterfacev
-__ZN6WebKit10WebProcess10initializeEjP7RunLoop
-__ZN6WebKit10WebProcess6sharedEv
-__ZN7RunLoop21initializeMainRunLoopEv
-__ZN7RunLoop3runEv
-__ZN7RunLoop4mainEv
+_WebKitMain
diff --git a/WebKit2/win/MainWin.cpp b/WebKit2/win/MainWin.cpp
new file mode 100644 (file)
index 0000000..7aea3f2
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include <windows.h>
+
+#if defined _M_IX86
+#define PROCESSORARCHITECTURE "x86"
+#elif defined _M_IA64
+#define PROCESSORARCHITECTURE "ia64"
+#elif defined _M_X64
+#define PROCESSORARCHITECTURE "amd64"
+#else
+#define PROCESSORARCHITECTURE "*"
+#endif
+
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='" PROCESSORARCHITECTURE "' publicKeyToken='6595b64144ccf1df' language='*'\"")
+
+extern "C" __declspec(dllimport) int WebKitMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrCmdLine, int nCmdShow);
+
+int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrCmdLine, int nCmdShow)
+{
+    return WebKitMain(hInstance, hPrevInstance, lpstrCmdLine, nCmdShow);
+}
index 91c7bcdcfa5de1a5620dadee4cacc7741db55c7d..664a2525f50412e3b75b33c64e5e15999e8bdb82 100755 (executable)
                        <Filter\r
                                Name="win"\r
                                >\r
+                               <File\r
+                                       RelativePath="..\Shared\win\CommandLineWin.cpp"\r
+                                       >\r
+                               </File>\r
                                <File\r
                                        RelativePath="..\Shared\win\UpdateChunk.cpp"\r
                                        >\r
                <Filter\r
                        Name="WebProcess"\r
                        >\r
+                       <File\r
+                               RelativePath="..\WebProcess\WebKitMain.cpp"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\WebProcess\WebProcess.cpp"\r
                                >\r
                                RelativePath="..\WebProcess\WebProcess.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\WebProcess\WebProcessMain.h"\r
+                               >\r
+                       </File>\r
                        <Filter\r
                                Name="WebCoreSupport"\r
                                >\r
                                        >\r
                                </File>\r
                                <File\r
-                                       RelativePath="..\WebProcess\win\WebProcessMain.cpp"\r
-                                       >\r
-                               </File>\r
-                               <File\r
-                                       RelativePath="..\WebProcess\win\WebProcessMain.h"\r
+                                       RelativePath="..\WebProcess\win\WebProcessMainWin.cpp"\r
                                        >\r
                                </File>\r
                        </Filter>\r
                        <Filter\r
                                Name="Launcher"\r
                                >\r
+                               <File\r
+                                       RelativePath="..\UIProcess\Launcher\ProcessLauncher.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\UIProcess\Launcher\ProcessLauncher.h"\r
+                                       >\r
+                               </File>\r
                                <Filter\r
                                        Name="win"\r
                                        >\r
-                                       <File\r
-                                               RelativePath="..\UIProcess\Launcher\ProcessLauncher.cpp"\r
-                                               >\r
-                                       </File>\r
-                                       <File\r
-                                               RelativePath="..\UIProcess\Launcher\ProcessLauncher.h"\r
-                                               >\r
-                                       </File>\r
                                        <File\r
                                                RelativePath="..\UIProcess\Launcher\win\ProcessLauncherWin.cpp"\r
                                                >\r
index 24274a54698dd98e0c519d5ab5a3c4fb737bb2bc..2ba2541a275a7685ebf8d854b33adec580a28ae8 100755 (executable)
                        UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
                        >\r
                        <File\r
-                               RelativePath="..\WebProcess\Launching\win\WebProcessWinMain.cpp"\r
+                               RelativePath=".\MainWin.cpp"\r
                                >\r
                        </File>\r
                </Filter>\r