Changeset 128021 in webkit
- Timestamp:
- Sep 10, 2012 12:05:28 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r128006 r128021 1 2012-09-09 Sam Weinig <sam@webkit.org> 2 3 Simplify WebKit2 XPC service backend now that I know it doesn't need to soft link WebKit2.framework 4 https://bugs.webkit.org/show_bug.cgi?id=96228 5 6 Reviewed by Dan Bernstein. 7 8 We soft link the non-XPC service WebProcess backend to the WebKit2 framework to 9 ensure that we can close all the necessary file descriptors at launch, without 10 fear that we will be closing one we open while initializing WebKit2 or one of its 11 dependencies. Since we don't need to close file descriptors in the XPC service 12 backend, we don't need to soft link! While here, also do some cleanup and code 13 sharing. 14 15 * UIProcess/Launcher/mac/ProcessLauncherMac.mm: 16 (WebKit::launchXPCService): 17 We don't need to send the framework executable path anymore (it was used for the 18 soft linking), but we do need the client identifier. 19 20 * WebKit2.xcodeproj/project.pbxproj: 21 Add new files. Link the XPC service to WebKit2.framework. 22 23 * WebKit2Service/MainMacService.mm: 24 Now that we don't have to soft link, just make this a stub that calls immediately 25 into the WebKit2 framework. 26 27 * WebProcess/mac/WebProcessInitialization.h: Added. 28 * WebProcess/mac/WebProcessInitialization.mm: Added. 29 (WebKit::InitializeWebProcess): 30 Move initialization that is common between the XPC and non-XPC backends here. 31 32 * WebProcess/mac/WebProcessMainMac.mm: 33 (WebKit::WebProcessMain): 34 Remove XPC backend related code. Use new shared InitializeWebProcess function. 35 36 * WebProcess/mac/WebProcessXPCServiceMain.h: Added. 37 * WebProcess/mac/WebProcessXPCServiceMain.mm: Added. 38 (WebKit::WebKit2ServiceEventHandler): 39 (WebProcessXPCServiceMain): 40 Move XPC service backend initialization here. 41 1 42 2012-09-09 Emil A Eklund <eae@chromium.org> 2 43 -
trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
r128003 r128021 106 106 mach_port_insert_right(mach_task_self(), listeningPort, listeningPort, MACH_MSG_TYPE_MAKE_SEND); 107 107 108 NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier]; 109 CString clientIdentifier = bundleIdentifier ? String([[NSBundle mainBundle] bundleIdentifier]).utf8() : *_NSGetProgname(); 110 108 111 xpc_object_t bootStrapMessage = xpc_dictionary_create(0, 0, 0); 109 112 xpc_dictionary_set_string(bootStrapMessage, "message-name", "bootstrap"); 110 xpc_dictionary_set_string(bootStrapMessage, "framework-executable-path", [[[NSBundle bundleWithIdentifier:@"com.apple.WebKit2"] executablePath] fileSystemRepresentation]);111 113 xpc_dictionary_set_mach_send(bootStrapMessage, "server-port", listeningPort); 114 xpc_dictionary_set_string(bootStrapMessage, "client-identifier", clientIdentifier.data()); 112 115 113 116 that->ref(); -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r126549 r128021 582 582 BC33E0D112408E8600360F3F /* InjectedBundleRangeHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = BC33E0CF12408E8600360F3F /* InjectedBundleRangeHandle.h */; }; 583 583 BC33E0D212408E8600360F3F /* InjectedBundleRangeHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC33E0D012408E8600360F3F /* InjectedBundleRangeHandle.cpp */; }; 584 BC3DE46915A91763008D26FC /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC3DE46815A91763008D26FC /* Foundation.framework */; };585 584 BC3DE47215A91764008D26FC /* MainMacService.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC3DE47115A91764008D26FC /* MainMacService.mm */; }; 586 585 BC4075F3124FF0270068F20A /* WKArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC4075D7124FF0270068F20A /* WKArray.cpp */; }; … … 797 796 BCD598AD112B7FDF00EC8C23 /* WebPreferencesStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD598AB112B7FDF00EC8C23 /* WebPreferencesStore.cpp */; }; 798 797 BCDB86C11200FB97007254BE /* WebURL.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDB86C01200FB97007254BE /* WebURL.h */; }; 798 BCDC308715FD6A8B006B6695 /* WebProcessInitialization.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCDC308515FD6A8B006B6695 /* WebProcessInitialization.mm */; }; 799 BCDC308815FD6A8B006B6695 /* WebProcessInitialization.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDC308615FD6A8B006B6695 /* WebProcessInitialization.h */; }; 800 BCDC308B15FD6CD1006B6695 /* WebProcessXPCServiceMain.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCDC308915FD6CD1006B6695 /* WebProcessXPCServiceMain.mm */; }; 801 BCDC308C15FD6CD1006B6695 /* WebProcessXPCServiceMain.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDC308A15FD6CD1006B6695 /* WebProcessXPCServiceMain.h */; }; 802 BCDC308E15FDB9A7006B6695 /* WebKit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* WebKit2.framework */; }; 799 803 BCDDB317124EBD130048D13C /* WKBase.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDDB316124EBD130048D13C /* WKBase.h */; settings = {ATTRIBUTES = (Public, ); }; }; 800 804 BCDDB32B124EC2AB0048D13C /* WKSharedAPICast.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDDB32A124EC2AB0048D13C /* WKSharedAPICast.h */; }; … … 1874 1878 BCD598AB112B7FDF00EC8C23 /* WebPreferencesStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPreferencesStore.cpp; sourceTree = "<group>"; }; 1875 1879 BCDB86C01200FB97007254BE /* WebURL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebURL.h; sourceTree = "<group>"; }; 1880 BCDC308515FD6A8B006B6695 /* WebProcessInitialization.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessInitialization.mm; sourceTree = "<group>"; }; 1881 BCDC308615FD6A8B006B6695 /* WebProcessInitialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebProcessInitialization.h; sourceTree = "<group>"; }; 1882 BCDC308915FD6CD1006B6695 /* WebProcessXPCServiceMain.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessXPCServiceMain.mm; sourceTree = "<group>"; }; 1883 BCDC308A15FD6CD1006B6695 /* WebProcessXPCServiceMain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebProcessXPCServiceMain.h; sourceTree = "<group>"; }; 1876 1884 BCDDB316124EBD130048D13C /* WKBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBase.h; sourceTree = "<group>"; }; 1877 1885 BCDDB32A124EC2AB0048D13C /* WKSharedAPICast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKSharedAPICast.h; sourceTree = "<group>"; }; … … 2064 2072 runOnlyForDeploymentPostprocessing = 0; 2065 2073 }; 2066 BC 3DE46315A91763008D26FC/* Frameworks */ = {2074 BCDC308D15FDB99A006B6695 /* Frameworks */ = { 2067 2075 isa = PBXFrameworksBuildPhase; 2068 2076 buildActionMask = 2147483647; 2069 2077 files = ( 2070 BC 3DE46915A91763008D26FC /* Foundation.framework in Frameworks */,2078 BCDC308E15FDB9A7006B6695 /* WebKit2.framework in Frameworks */, 2071 2079 ); 2072 2080 runOnlyForDeploymentPostprocessing = 0; … … 2265 2273 511F8A7D138B46FE00A95F44 /* SecItemShimMethods.h */, 2266 2274 511F8A7E138B46FE00A95F44 /* SecItemShimMethods.mm */, 2275 BCDC308615FD6A8B006B6695 /* WebProcessInitialization.h */, 2276 BCDC308515FD6A8B006B6695 /* WebProcessInitialization.mm */, 2267 2277 BC3065C312592F8900E71278 /* WebProcessMac.mm */, 2268 2278 1A6FA01D11E1526300DB1371 /* WebProcessMainMac.mm */, 2269 2279 511F8A77138B460900A95F44 /* WebProcessShim.h */, 2270 2280 511F8A78138B460900A95F44 /* WebProcessShim.mm */, 2281 BCDC308A15FD6CD1006B6695 /* WebProcessXPCServiceMain.h */, 2282 BCDC308915FD6CD1006B6695 /* WebProcessXPCServiceMain.mm */, 2271 2283 ); 2272 2284 path = mac; … … 4240 4252 3F87B9C0158940D80090FF62 /* WebColorChooserProxy.h in Headers */, 4241 4253 BC59548915C7868500FD1E3E /* WebKit2.h in Headers */, 4254 BCDC308815FD6A8B006B6695 /* WebProcessInitialization.h in Headers */, 4255 BCDC308C15FD6CD1006B6695 /* WebProcessXPCServiceMain.h in Headers */, 4242 4256 ); 4243 4257 runOnlyForDeploymentPostprocessing = 0; … … 4332 4346 buildPhases = ( 4333 4347 BC3DE46215A91763008D26FC /* Sources */, 4334 BC 3DE46315A91763008D26FC/* Frameworks */,4348 BCDC308D15FDB99A006B6695 /* Frameworks */, 4335 4349 BC3DE46415A91763008D26FC /* Resources */, 4336 4350 ); … … 5030 5044 3F87B9BD158940120090FF62 /* WebColorChooser.cpp in Sources */, 5031 5045 CD67D30E15C08F9A00843ADF /* InjectedBundlePageDiagnosticLoggingClient.cpp in Sources */, 5046 BCDC308715FD6A8B006B6695 /* WebProcessInitialization.mm in Sources */, 5047 BCDC308B15FD6CD1006B6695 /* WebProcessXPCServiceMain.mm in Sources */, 5032 5048 ); 5033 5049 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebKit2/WebKit2Service/MainMacService.mm
r125358 r128021 24 24 */ 25 25 26 #i nclude<AvailabilityMacros.h>26 #import <AvailabilityMacros.h> 27 27 28 28 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 29 29 30 #include <dlfcn.h> 31 #include <stdio.h> 32 #include <stdlib.h> 33 #include <xpc/xpc.h> 34 35 extern "C" mach_port_t xpc_dictionary_copy_mach_send(xpc_object_t, const char*); 36 37 static void WebKit2ServiceEventHandler(xpc_connection_t peer) 38 { 39 xpc_connection_set_target_queue(peer, dispatch_get_main_queue()); 40 xpc_connection_set_event_handler(peer, ^(xpc_object_t event) { 41 xpc_type_t type = xpc_get_type(event); 42 if (type == XPC_TYPE_ERROR) { 43 if (event == XPC_ERROR_CONNECTION_INVALID || event == XPC_ERROR_TERMINATION_IMMINENT) { 44 // FIXME: Handle this case more gracefully. 45 exit(EXIT_FAILURE); 46 } 47 } else { 48 assert(type == XPC_TYPE_DICTIONARY); 49 50 if (!strcmp(xpc_dictionary_get_string(event, "message-name"), "bootstrap")) { 51 static void* frameworkLibrary = dlopen(xpc_dictionary_get_string(event, "framework-executable-path"), RTLD_NOW); 52 if (!frameworkLibrary) { 53 NSLog(@"Unable to load WebKit2.framework: %s\n", dlerror()); 54 exit(EXIT_FAILURE); 55 } 56 57 typedef int (*WebKitMainFunction)(xpc_connection_t connection, mach_port_t serverPort); 58 WebKitMainFunction webKitMainXPC = reinterpret_cast<WebKitMainFunction>(dlsym(frameworkLibrary, "WebKitMainXPC")); 59 if (!webKitMainXPC) { 60 NSLog(@"Unable to find entry point in WebKit2.framework: %s\n", dlerror()); 61 exit(EXIT_FAILURE); 62 } 63 64 xpc_object_t reply = xpc_dictionary_create_reply(event); 65 xpc_dictionary_set_string(reply, "message-name", "process-finished-launching"); 66 xpc_connection_send_message(xpc_dictionary_get_remote_connection(event), reply); 67 xpc_release(reply); 68 69 webKitMainXPC(peer, xpc_dictionary_copy_mach_send(event, "server-port")); 70 } 71 } 72 }); 73 74 xpc_connection_resume(peer); 75 } 30 #import "WebProcessXPCServiceMain.h" 76 31 77 32 int main(int argc, char** argv) 78 33 { 79 xpc_main(WebKit2ServiceEventHandler); 80 return 0; 34 return WebProcessXPCServiceMain(argc, argv); 81 35 } 82 36 -
trunk/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm
r128003 r128021 32 32 #import "StringUtilities.h" 33 33 #import "WebProcess.h" 34 #import "Web SystemInterface.h"34 #import "WebProcessInitialization.h" 35 35 #import <WebCore/RunLoop.h> 36 36 #import <WebKitSystemInterface.h> 37 37 #import <mach/mach_error.h> 38 38 #import <objc/objc-auto.h> 39 #import <runtime/InitializeThreading.h>40 39 #import <servers/bootstrap.h> 41 40 #import <signal.h> … … 44 43 #import <sysexits.h> 45 44 #import <unistd.h> 46 #import <wtf/MainThread.h>47 45 #import <wtf/RetainPtr.h> 48 46 #import <wtf/text/CString.h> 49 #import <wtf/text/StringBuilder.h> 50 51 #if HAVE(XPC) 52 #import <xpc/xpc.h> 53 #endif 47 #import <wtf/text/WTFString.h> 54 48 55 49 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 … … 67 61 using namespace WebCore; 68 62 69 #if HAVE(XPC)70 63 namespace WebKit { 71 int WebProcessMainXPC(xpc_connection_t xpcConnection, mach_port_t serverPort);72 }73 74 extern "C" WK_EXPORT int WebKitMainXPC(xpc_connection_t xpcConnection, mach_port_t serverPort);75 76 int WebKitMainXPC(xpc_connection_t xpcConnection, mach_port_t serverPort)77 {78 ASSERT(!objc_collectingEnabled());79 80 return WebKit::WebProcessMainXPC(xpcConnection, serverPort);81 }82 #endif83 84 namespace WebKit {85 86 #if HAVE(XPC)87 88 int WebProcessMainXPC(xpc_connection_t xpcConnection, mach_port_t serverPort)89 {90 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];91 92 InitWebCoreSystemInterface();93 JSC::initializeThreading();94 WTF::initializeMainThread();95 RunLoop::initializeMainRunLoop();96 97 // FIXME: Make the shim work.98 WebProcess::shared().initializeShim();99 // FIXME: Pass the client identifier here.100 WebProcess::shared().initializeSandbox(String());101 WebProcess::shared().initialize(CoreIPC::Connection::Identifier(serverPort, xpcConnection), RunLoop::main());102 103 WKAXRegisterRemoteApp();104 105 [pool drain];106 107 return 0;108 }109 #endif110 64 111 65 int WebProcessMain(const CommandLine& commandLine) … … 212 166 WKSetDefaultLocalization(cfLocalization.get()); 213 167 168 [pool drain]; 169 214 170 #if !SHOW_CRASH_REPORTER 215 171 // Installs signal handlers that exit on a crash so that CrashReporter does not show up. … … 219 175 signal(SIGSEGV, _exit); 220 176 #endif 221 222 InitWebCoreSystemInterface();223 JSC::initializeThreading();224 WTF::initializeMainThread();225 RunLoop::initializeMainRunLoop();226 177 227 178 #if USE(APPKIT) … … 234 185 #endif 235 186 236 WebProcess::shared().initializeShim(); 237 WebProcess::shared().initializeSandbox(clientIdentifier); 238 WebProcess::shared().initialize(CoreIPC::Connection::Identifier(serverPort), RunLoop::main()); 239 240 WKAXRegisterRemoteApp(); 241 242 [pool drain]; 187 InitializeWebProcess(clientIdentifier, CoreIPC::Connection::Identifier(serverPort)); 243 188 244 189 RunLoop::run();
Note: See TracChangeset
for help on using the changeset viewer.