WebKit Bugzilla
Attachment 346683 Details for
Bug 188367
: Add SPI for launching WebContent process with pre-linked injected bundle
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188367-20180806213124.patch (text/plain), 17.08 KB, created by
Ben Richards
on 2018-08-06 21:31:25 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Ben Richards
Created:
2018-08-06 21:31:25 PDT
Size:
17.08 KB
patch
obsolete
>Subversion Revision: 234580 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index f459f8dbc592f665bea3faa5bc64b65cfeedfb45..bdaf83b789b3ea9abf104fc32f5f26a395d58b79 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,39 @@ >+2018-08-06 Ben Richards <benton_richards@apple.com> >+ >+ Add SPI for launching WebContent process with pre-linked injected bundle >+ https://bugs.webkit.org/show_bug.cgi?id=188367 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added SPI to allow applications to set a "customWebContentServiceBundleIdentifier" which will be launched instead of the default WebContent XPC service. >+ The "customWebContentServiceBundleIdentifier" should be the bundle identifier for an XPC service that calls [WKProcessPool _webContentProcessXPCMain]. >+ The new XPC service should be hard linked to the application's injected bundle in order to receive the intended performance benefit. >+ >+ * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h: >+ * Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm: >+ (WebKit::XPCServiceMain): >+ (main): >+ * UIProcess/API/APIProcessPoolConfiguration.h: >+ * UIProcess/API/C/WKContext.cpp: >+ (WKContextSetCustomWebContentServiceBundleIdentifier): >+ * UIProcess/API/C/WKContext.h: >+ * UIProcess/API/Cocoa/WKProcessPool.mm: >+ (+[WKProcessPool _webContentProcessXPCMain]): >+ * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: >+ * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h: >+ * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm: >+ (-[_WKProcessPoolConfiguration customWebContentServiceBundleIdentifier]): >+ (-[_WKProcessPoolConfiguration setCustomWebContentServiceBundleIdentifier:]): >+ * UIProcess/Launcher/ProcessLauncher.h: >+ * UIProcess/Launcher/mac/ProcessLauncherMac.mm: >+ (WebKit::ProcessLauncher::launchProcess): >+ * UIProcess/WebProcessPool.cpp: >+ (WebKit::WebProcessPool::setCustomWebContentServiceBundleIdentifier): >+ * UIProcess/WebProcessPool.h: >+ * UIProcess/WebProcessProxy.cpp: >+ (WebKit::WebProcessProxy::getLaunchOptions): >+ * WebKit.xcodeproj/project.pbxproj: >+ > 2018-08-03 Ben Richards <benton_richards@apple.com> > > We should cache the compiled sandbox profile in a data vault >diff --git a/Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h b/Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h >index f5e95648418e02e5eb7264733cec2ba32a34fb1a..f7ccbe2cc47e2464990b9e066cba1f3f0383d10f 100644 >--- a/Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h >+++ b/Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h >@@ -117,6 +117,8 @@ void XPCServiceInitializer(OSObjectPtr<xpc_connection_t> connection, xpc_object_ > XPCServiceType::singleton().initialize(parameters); > } > >+int XPCServiceMain(); >+ > void XPCServiceExit(OSObjectPtr<xpc_object_t>&& priorityBoostMessage); > > } // namespace WebKit >diff --git a/Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm b/Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm >index 5919a32836eca916f4db831cb67319e39183dbf3..cd447e69ab0f2e21e569f6a5d9a81696940f8368 100644 >--- a/Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm >+++ b/Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm >@@ -25,6 +25,7 @@ > > #import "config.h" > #import "WebProcessCocoa.h" >+#import "XPCServiceEntryPoint.h" > > #import <CoreFoundation/CoreFoundation.h> > #import <wtf/OSObjectPtr.h> >@@ -91,11 +92,7 @@ static void XPCServiceEventHandler(xpc_connection_t peer) > xpc_connection_resume(peer); > } > >-} // namespace WebKit >- >-using namespace WebKit; >- >-int main(int argc, char** argv) >+int XPCServiceMain() > { > #if defined(__i386__) > // FIXME: This should only be done for the 32-bit plug-in XPC service so we rely on the fact that >@@ -160,3 +157,12 @@ int main(int argc, char** argv) > xpc_main(XPCServiceEventHandler); > return 0; > } >+ >+} // namespace WebKit >+ >+using namespace WebKit; >+ >+int main(int argc, char** argv) >+{ >+ return XPCServiceMain(); >+} >diff --git a/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h b/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h >index f2d5c6118887c5214d4b4a6de53fad4986b74450..049c2145629be37f0942e151ef2c92007e4314bd 100644 >--- a/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h >+++ b/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h >@@ -150,6 +150,9 @@ public: > bool processSwapsOnWindowOpenWithOpener() const { return m_processSwapsOnWindowOpenWithOpener; } > void setProcessSwapsOnWindowOpenWithOpener(bool swaps) { m_processSwapsOnWindowOpenWithOpener = swaps; } > >+ const WTF::String& customWebContentServiceBundleIdentifier() const { return m_customWebContentServiceBundleIdentifier; } >+ void setCustomWebContentServiceBundleIdentifier(const WTF::String& customWebContentServiceBundleIdentifier) { m_customWebContentServiceBundleIdentifier = customWebContentServiceBundleIdentifier; } >+ > #if ENABLE(WIFI_ASSERTIONS) > unsigned wirelessContextIdentifier() const { return m_wirelessContextIdentifier; } > void setWirelessContextIdentifier(unsigned wirelessContextIdentifier) { m_wirelessContextIdentifier = wirelessContextIdentifier; } >@@ -196,6 +199,7 @@ private: > bool m_processSwapsOnNavigation { false }; > bool m_alwaysKeepAndReuseSwappedProcesses { false }; > bool m_processSwapsOnWindowOpenWithOpener { false }; >+ WTF::String m_customWebContentServiceBundleIdentifier; > > #if PLATFORM(IOS) > WTF::String m_ctDataConnectionServiceType; >diff --git a/Source/WebKit/UIProcess/API/C/WKContext.cpp b/Source/WebKit/UIProcess/API/C/WKContext.cpp >index 4fca7eedb2f5882ec64094c7396351682c0fad31..c8a6c35b5bdc3e1987b4b013f5cf26410d482979 100644 >--- a/Source/WebKit/UIProcess/API/C/WKContext.cpp >+++ b/Source/WebKit/UIProcess/API/C/WKContext.cpp >@@ -407,6 +407,11 @@ void WKContextSetMaximumNumberOfPrewarmedProcesses(WKContextRef contextRef, unsi > toImpl(contextRef)->setMaximumNumberOfPrewarmedProcesses(value); > } > >+void WKContextSetCustomWebContentServiceBundleIdentifier(WKContextRef contextRef, WKStringRef name) >+{ >+ toImpl(contextRef)->setCustomWebContentServiceBundleIdentifier(toImpl(name)->string()); >+} >+ > void WKContextSetDiskCacheSpeculativeValidationEnabled(WKContextRef contextRef, bool value) > { > toImpl(contextRef)->configuration().setDiskCacheSpeculativeValidationEnabled(value); >diff --git a/Source/WebKit/UIProcess/API/C/WKContext.h b/Source/WebKit/UIProcess/API/C/WKContext.h >index e5a07a6fe2d25fb2924d6f5079e1c5b02abeba26..dc0fe3897f35f2e9d5e5c79c87e975c8ed423c19 100644 >--- a/Source/WebKit/UIProcess/API/C/WKContext.h >+++ b/Source/WebKit/UIProcess/API/C/WKContext.h >@@ -165,6 +165,8 @@ WK_EXPORT void WKContextSetPlugInAutoStartOrigins(WKContextRef contextRef, WKArr > WK_EXPORT void WKContextSetPlugInAutoStartOriginsFilteringOutEntriesAddedAfterTime(WKContextRef contextRef, WKDictionaryRef dictionaryRef, double time); > WK_EXPORT void WKContextRefreshPlugIns(WKContextRef context); > >+WK_EXPORT void WKContextSetCustomWebContentServiceBundleIdentifier(WKContextRef contextRef, WKStringRef name); >+ > #ifdef __cplusplus > } > #endif >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm >index acefae518de852bc7ff00d39cb5c749a1d78e004..ab319e79edd17915fe9b15b69a8dbcaab5de1263 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm >@@ -40,6 +40,7 @@ > #import "WebCookieManagerProxy.h" > #import "WebProcessMessages.h" > #import "WebProcessPool.h" >+#import "XPCServiceEntryPoint.h" > #import "_WKAutomationDelegate.h" > #import "_WKAutomationSessionInternal.h" > #import "_WKDownloadDelegate.h" >@@ -181,6 +182,11 @@ + (NSURL *)_websiteDataURLForContainerWithURL:(NSURL *)containerURL bundleIdenti > return [url URLByAppendingPathComponent:@"WebsiteData" isDirectory:YES]; > } > >++ (int)_webContentProcessXPCMain >+{ >+ return WebKit::XPCServiceMain(); >+} >+ > - (void)_setAllowsSpecificHTTPSCertificate:(NSArray *)certificateChain forHost:(NSString *)host > { > _processPool->allowSpecificHTTPSCertificateForHost(WebKit::WebCertificateInfo::create(WebCore::CertificateInfo((__bridge CFArrayRef)certificateChain)).ptr(), host); >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h >index 7099a4464416239408586243d579cec41282e04e..364535a5f273d6aba1a9b07f91c5a6d70dc834cd 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h >@@ -79,6 +79,8 @@ > > - (void)_registerURLSchemeAsCanDisplayOnlyIfCanRequest:(NSString *)scheme WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > >++ (int)_webContentProcessXPCMain WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >+ > // Test only. Should be called only while no web content processes are running. > - (void)_terminateStorageProcess; > - (void)_terminateNetworkProcess; >diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h b/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h >index 644b16405990eaf3620e4bd5c6223dac6bc0bbbb..1bf13bb71ccb719f8836c3743ed487e4ffcfe267 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h >@@ -36,6 +36,7 @@ WK_CLASS_AVAILABLE(macosx(10.10), ios(8.0)) > @property (nonatomic, copy) NSURL *injectedBundleURL; > @property (nonatomic) NSUInteger maximumProcessCount; > @property (nonatomic) NSUInteger maximumPrewarmedProcessCount WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >+@property (nonatomic, nullable, copy) NSString *customWebContentServiceBundleIdentifier WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > > @property (nonatomic) BOOL ignoreSynchronousMessagingTimeoutsForTesting WK_API_AVAILABLE(macosx(10.12), ios(10.0)); > @property (nonatomic) BOOL attrStyleEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm b/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm >index 7a396c59df0f56cda29a9ffaee9ee9c77a661643..51b2049703769b5aa05c9b8766f063f8feefbf3e 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm >@@ -359,6 +359,16 @@ - (id)copyWithZone:(NSZone *)zone > return wrapper(_processPoolConfiguration->copy().leakRef()); > } > >+- (NSString *)customWebContentServiceBundleIdentifier >+{ >+ return _processPoolConfiguration->customWebContentServiceBundleIdentifier(); >+} >+ >+- (void)setCustomWebContentServiceBundleIdentifier:(NSString *)customWebContentServiceBundleIdentifier >+{ >+ _processPoolConfiguration->setCustomWebContentServiceBundleIdentifier(customWebContentServiceBundleIdentifier); >+} >+ > #pragma mark WKObject protocol implementation > > - (API::Object&)_apiObject >diff --git a/Source/WebKit/UIProcess/Launcher/ProcessLauncher.h b/Source/WebKit/UIProcess/Launcher/ProcessLauncher.h >index 831b18def4bc743670f7536b557ff8355a25929a..5c4bb3b9e11641d987811da6679465b6e31840a5 100644 >--- a/Source/WebKit/UIProcess/Launcher/ProcessLauncher.h >+++ b/Source/WebKit/UIProcess/Launcher/ProcessLauncher.h >@@ -66,6 +66,7 @@ public: > HashMap<String, String> extraInitializationData; > bool nonValidInjectedCodeAllowed { false }; > bool shouldMakeProcessLaunchFailForTesting { false }; >+ CString customWebContentServiceBundleIdentifier; > > #if ENABLE(DEVELOPER_MODE) && (PLATFORM(GTK) || PLATFORM(WPE)) > String processCmdPrefix; >diff --git a/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm b/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm >index b47f7d014c594bafa8db5522c6bb492de72a00f1..ee0eb935a6e5c9f407205d06c344b9abfe1db08c 100644 >--- a/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm >+++ b/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm >@@ -101,7 +101,13 @@ void ProcessLauncher::launchProcess() > { > ASSERT(!m_xpcConnection); > >- m_xpcConnection = adoptOSObject(xpc_connection_create(serviceName(m_launchOptions), dispatch_get_main_queue())); >+ const char* name; >+ if (!m_launchOptions.customWebContentServiceBundleIdentifier.isNull()) >+ name = m_launchOptions.customWebContentServiceBundleIdentifier.data(); >+ else >+ name = serviceName(m_launchOptions); >+ >+ m_xpcConnection = adoptOSObject(xpc_connection_create(name, dispatch_get_main_queue())); > > uuid_t uuid; > uuid_generate(uuid); >diff --git a/Source/WebKit/UIProcess/WebProcessPool.cpp b/Source/WebKit/UIProcess/WebProcessPool.cpp >index 50ffb9067471e949b55886e4c3a0b14e40da04c7..6a2a0927981083b295bc2b0f6d5d9a0cafa64022 100644 >--- a/Source/WebKit/UIProcess/WebProcessPool.cpp >+++ b/Source/WebKit/UIProcess/WebProcessPool.cpp >@@ -418,6 +418,15 @@ void WebProcessPool::setMaximumNumberOfPrewarmedProcesses(unsigned maximumNumber > m_configuration->setMaximumPrewarmedProcessCount(maximumNumberOfProcesses); > } > >+void WebProcessPool::setCustomWebContentServiceBundleIdentifier(const String& customWebContentServiceBundleIdentifier) >+{ >+ // Guard against API misuse. >+ if (m_processes.size()) >+ CRASH(); >+ >+ m_configuration->setCustomWebContentServiceBundleIdentifier(customWebContentServiceBundleIdentifier); >+} >+ > IPC::Connection* WebProcessPool::networkingProcessConnection() > { > return m_networkProcess->connection(); >diff --git a/Source/WebKit/UIProcess/WebProcessPool.h b/Source/WebKit/UIProcess/WebProcessPool.h >index 522faf102ac098a8ca4a3d3878abfb6a1827c250..25cc4d420c2e6f9acfea8b5e4cd81dcad66a47d8 100644 >--- a/Source/WebKit/UIProcess/WebProcessPool.h >+++ b/Source/WebKit/UIProcess/WebProcessPool.h >@@ -159,6 +159,9 @@ public: > void setMaximumNumberOfPrewarmedProcesses(unsigned); // Can only be called when there are no processes running. > unsigned maximumNumberOfPrewarmedProcesses() const { return m_configuration->maximumPrewarmedProcessCount(); } > >+ void setCustomWebContentServiceBundleIdentifier(const String&); >+ const String& customWebContentServiceBundleIdentifier() { return m_configuration->customWebContentServiceBundleIdentifier(); } >+ > const Vector<RefPtr<WebProcessProxy>>& processes() const { return m_processes; } > > // WebProcess or NetworkProcess as approporiate for current process model. The connection must be non-null. >diff --git a/Source/WebKit/UIProcess/WebProcessProxy.cpp b/Source/WebKit/UIProcess/WebProcessProxy.cpp >index eac8b5e54929b969b7778ce1f7dbaa511476bf90..5e0bc60b505f6b1c70dbcd4d32fb8f9aa817f617 100644 >--- a/Source/WebKit/UIProcess/WebProcessProxy.cpp >+++ b/Source/WebKit/UIProcess/WebProcessProxy.cpp >@@ -162,6 +162,8 @@ void WebProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOpt > > ChildProcessProxy::getLaunchOptions(launchOptions); > >+ if (!m_processPool->customWebContentServiceBundleIdentifier().isNull()) >+ launchOptions.customWebContentServiceBundleIdentifier = m_processPool->customWebContentServiceBundleIdentifier().ascii(); > if (WebKit::isInspectorProcessPool(processPool())) > launchOptions.extraInitializationData.add("inspector-process"_s, "1"_s); > >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index 35c4c5c9841b57c1adce47793fd95dd1c05972b0..865ada93556cf343fea7511bd88757b7ec0e3774 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -957,6 +957,7 @@ > 414DEDD71F9EDDE50047C40D /* ServiceWorkerProcessProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 414DEDD51F9EDDDF0047C40D /* ServiceWorkerProcessProxy.h */; }; > 414DEDD81F9EDDE50047C40D /* ServiceWorkerProcessProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 414DEDD61F9EDDE00047C40D /* ServiceWorkerProcessProxy.cpp */; }; > 4157E4B020E2ECDF00A6C0D7 /* com.google.o1dbrowserplugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 4157E4AF20E2EC9800A6C0D7 /* com.google.o1dbrowserplugin.sb */; }; >+ 41639A89211933ED001CEF14 /* XPCServiceMain.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC82839616B47EC400A278FE /* XPCServiceMain.mm */; }; > 41897ECF1F415D620016FA42 /* WebCacheStorageConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41897ECE1F415D5C0016FA42 /* WebCacheStorageConnection.cpp */; }; > 41897ED01F415D650016FA42 /* WebCacheStorageProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41897ECC1F415D5C0016FA42 /* WebCacheStorageProvider.cpp */; }; > 41897ED11F415D680016FA42 /* WebCacheStorageConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 41897ECD1F415D5C0016FA42 /* WebCacheStorageConnection.h */; }; >@@ -11818,6 +11819,7 @@ > 1AD60F5D18E20F4C0020C034 /* WKWindowFeatures.mm in Sources */, > 1A7C0DF61B7D1F1000A9B848 /* WKWindowFeaturesRef.cpp in Sources */, > BCBECDE716B6416800047A1A /* XPCServiceEntryPoint.mm in Sources */, >+ 41639A89211933ED001CEF14 /* XPCServiceMain.mm in Sources */, > ); > runOnlyForDeploymentPostprocessing = 0; > };
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188367
:
346679
|
346683
|
346716