Diff
Modified: trunk/Source/WTF/ChangeLog (264127 => 264128)
--- trunk/Source/WTF/ChangeLog 2020-07-08 19:34:18 UTC (rev 264127)
+++ trunk/Source/WTF/ChangeLog 2020-07-08 19:42:08 UTC (rev 264128)
@@ -1,3 +1,14 @@
+2020-07-08 Per Arne Vollan <[email protected]>
+
+ [Cocoa] Make it possible to establish direct XPC connections between WebKit processes
+ https://bugs.webkit.org/show_bug.cgi?id=214079
+
+ Reviewed by Brent Fulgham.
+
+ Declare function to create a xpc endpoint, as well as a function to create a connection from an endpoint.
+
+ * wtf/spi/darwin/XPCSPI.h:
+
2020-07-08 Geoffrey Garen <[email protected]>
dyld: Symbol not found: __ZN3WTF19initializeThreadingEv - webkit MacOSX
Modified: trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h (264127 => 264128)
--- trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h 2020-07-08 19:34:18 UTC (rev 264127)
+++ trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h 2020-07-08 19:42:08 UTC (rev 264128)
@@ -49,6 +49,7 @@
typedef void* xpc_object_t;
typedef void* xpc_connection_t;
+typedef void* xpc_endpoint_t;
#define XPC_GLOBAL_OBJECT(object) (&(object))
@@ -121,6 +122,8 @@
bool xpc_bool_get_value(xpc_object_t);
void xpc_connection_cancel(xpc_connection_t);
xpc_connection_t xpc_connection_create(const char* name, dispatch_queue_t);
+xpc_endpoint_t xpc_endpoint_create(xpc_connection_t);
+xpc_connection_t xpc_connection_create_from_endpoint(xpc_endpoint_t);
xpc_connection_t xpc_connection_create_mach_service(const char* name, dispatch_queue_t, uint64_t flags);
pid_t xpc_connection_get_pid(xpc_connection_t);
void xpc_connection_resume(xpc_connection_t);
Modified: trunk/Source/WebCore/ChangeLog (264127 => 264128)
--- trunk/Source/WebCore/ChangeLog 2020-07-08 19:34:18 UTC (rev 264127)
+++ trunk/Source/WebCore/ChangeLog 2020-07-08 19:42:08 UTC (rev 264128)
@@ -1,3 +1,31 @@
+2020-07-08 Per Arne Vollan <[email protected]>
+
+ [Cocoa] Make it possible to establish direct XPC connections between WebKit processes
+ https://bugs.webkit.org/show_bug.cgi?id=214079
+
+ Reviewed by Brent Fulgham.
+
+ Add abstract classes XPCEndpoint and XPCEndpointClient to handle the creation of direct xpc connections between WebKit processes.
+ In order to create a direct xpc connection between two processes, these two classes can be subclassed, and the xpc endpoint created
+ by the XPCEndpoint object, can be sent via the UI process over the bootstrap xpc connection. The UI process can then forward this
+ endpoint to another WebKit process by sending it over the bootstrap xpc connection. The receiving process can then initialize an
+ XPCEndpointClient object with this endpoint, and a new direct connection will then be available, over which the two processes can
+ communicate.
+
+ API test: WebKit.XPCEndpoint
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/cocoa/XPCEndpoint.h: Added.
+ * platform/cocoa/XPCEndpoint.mm: Added.
+ (WebCore::XPCEndpoint::XPCEndpoint):
+ (WebCore::XPCEndpoint::sendEndpointToConnection):
+ (WebCore::XPCEndpoint::endpoint const):
+ * platform/cocoa/XPCEndpointClient.h: Added.
+ (WebCore::XPCEndpointClient::~XPCEndpointClient):
+ * platform/cocoa/XPCEndpointClient.mm: Added.
+ (WebCore::XPCEndpointClient::setEndpoint):
+ (WebCore::XPCEndpointClient::connection):
+
2020-07-08 Stephan Szabo <[email protected]>
[PlayStation] Build fix after r264050
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (264127 => 264128)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-07-08 19:34:18 UTC (rev 264127)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-07-08 19:42:08 UTC (rev 264128)
@@ -4002,6 +4002,10 @@
C149D55D242EA6B9003EBB12 /* SleepDisabler.h in Headers */ = {isa = PBXBuildFile; fileRef = C149D55A242EA4F9003EBB12 /* SleepDisabler.h */; settings = {ATTRIBUTES = (Private, ); }; };
C149D55F242EA7B8003EBB12 /* SleepDisablerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = C149D55B242EA4FA003EBB12 /* SleepDisablerClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
C149D567242EB84A003EBB12 /* SleepDisablerIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = C149D565242EB765003EBB12 /* SleepDisablerIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ C14D304924B4EAB100480387 /* XPCEndpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = C14D304724B4EAA800480387 /* XPCEndpoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ C14D304B24B4F7EF00480387 /* XPCEndpoint.mm in Sources */ = {isa = PBXBuildFile; fileRef = C14D304A24B4EB1E00480387 /* XPCEndpoint.mm */; };
+ C14D304E24B4F8FA00480387 /* XPCEndpointClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = C14D304C24B4F8F600480387 /* XPCEndpointClient.mm */; };
+ C14D304F24B4F8FF00480387 /* XPCEndpointClient.h in Headers */ = {isa = PBXBuildFile; fileRef = C14D304D24B4F8F700480387 /* XPCEndpointClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
C1692DD223D23ABD006E88F7 /* SystemBattery.mm in Sources */ = {isa = PBXBuildFile; fileRef = C1692DD123D23ABD006E88F7 /* SystemBattery.mm */; };
C1692DD523D23E08006E88F7 /* SystemBattery.h in Headers */ = {isa = PBXBuildFile; fileRef = C1692DD423D23AE0006E88F7 /* SystemBattery.h */; settings = {ATTRIBUTES = (Private, ); }; };
C1E1D236203DF15400584665 /* ScreenProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = C1E1D235203DF15400584665 /* ScreenProperties.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -13730,6 +13734,10 @@
C149D55A242EA4F9003EBB12 /* SleepDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SleepDisabler.h; sourceTree = "<group>"; };
C149D55B242EA4FA003EBB12 /* SleepDisablerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SleepDisablerClient.h; sourceTree = "<group>"; };
C149D565242EB765003EBB12 /* SleepDisablerIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SleepDisablerIdentifier.h; sourceTree = "<group>"; };
+ C14D304724B4EAA800480387 /* XPCEndpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPCEndpoint.h; sourceTree = "<group>"; };
+ C14D304A24B4EB1E00480387 /* XPCEndpoint.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = XPCEndpoint.mm; sourceTree = "<group>"; };
+ C14D304C24B4F8F600480387 /* XPCEndpointClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = XPCEndpointClient.mm; sourceTree = "<group>"; };
+ C14D304D24B4F8F700480387 /* XPCEndpointClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPCEndpointClient.h; sourceTree = "<group>"; };
C1692DD123D23ABD006E88F7 /* SystemBattery.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemBattery.mm; sourceTree = "<group>"; };
C1692DD423D23AE0006E88F7 /* SystemBattery.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SystemBattery.h; sourceTree = "<group>"; };
C18FB518242F9382007E9875 /* SleepDisablerClient.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SleepDisablerClient.cpp; sourceTree = "<group>"; };
@@ -23632,6 +23640,10 @@
CDC979F31C498C0900DB50D4 /* WebCoreNSErrorExtras.h */,
CDC979F21C498C0900DB50D4 /* WebCoreNSErrorExtras.mm */,
5DFEBAB618592B6D00C75BEB /* WebKitAvailability.h */,
+ C14D304724B4EAA800480387 /* XPCEndpoint.h */,
+ C14D304A24B4EB1E00480387 /* XPCEndpoint.mm */,
+ C14D304D24B4F8F700480387 /* XPCEndpointClient.h */,
+ C14D304C24B4F8F600480387 /* XPCEndpointClient.mm */,
);
path = cocoa;
sourceTree = "<group>";
@@ -30097,6 +30109,7 @@
C37CDEBD149EF2030042090D /* ColorChooserClient.h in Headers */,
F48D2AA52159740D00C6752B /* ColorCocoa.h in Headers */,
7CAC6AF0247F411000E61D59 /* ColorComponents.h in Headers */,
+ 7C514E0324AF805E0050710F /* ColorConversion.h in Headers */,
3103B7DF1DB01567008BB890 /* ColorHash.h in Headers */,
F55B3DB41251F12D003EF269 /* ColorInputType.h in Headers */,
CE5169E721F1B84700EA4F78 /* ColorIOS.h in Headers */,
@@ -33923,7 +33936,6 @@
91278D6221DEDAF000B57184 /* WorkerAuditAgent.h in Headers */,
41A7D3531F438D16008988DE /* WorkerCacheStorageConnection.h in Headers */,
A5B81CCD1FAA44DE0037D1E6 /* WorkerConsoleAgent.h in Headers */,
- 7C514E0324AF805E0050710F /* ColorConversion.h in Headers */,
A55639D11C6F09E300806D8E /* WorkerConsoleClient.h in Headers */,
A5B81CCE1FAA44DE0037D1E6 /* WorkerDebuggerAgent.h in Headers */,
A52B349E1FA41703008B6246 /* WorkerDebuggerProxy.h in Headers */,
@@ -33990,6 +34002,8 @@
1AB7FC840A8B92EC00D9D37B /* XPathUtil.h in Headers */,
1AB7FC860A8B92EC00D9D37B /* XPathValue.h in Headers */,
1AB7FC880A8B92EC00D9D37B /* XPathVariableReference.h in Headers */,
+ C14D304924B4EAB100480387 /* XPCEndpoint.h in Headers */,
+ C14D304F24B4F8FF00480387 /* XPCEndpointClient.h in Headers */,
E1EE8B9C2413195000E794D6 /* XREnvironmentBlendMode.h in Headers */,
E1EE8B972413195000E794D6 /* XREye.h in Headers */,
E1EE8B8F2413195000E794D6 /* XRFrameRequestCallback.h in Headers */,
@@ -35185,6 +35199,8 @@
A833C7CC0A2CF07400D57664 /* XLinkNames.cpp in Sources */,
A833C80C0A2CF25600D57664 /* XMLNames.cpp in Sources */,
E15A36D91104572700B7B639 /* XMLNSNames.cpp in Sources */,
+ C14D304B24B4F7EF00480387 /* XPCEndpoint.mm in Sources */,
+ C14D304E24B4F8FA00480387 /* XPCEndpointClient.mm in Sources */,
E1EE8B7A2413191F00E794D6 /* XRInputSourceEvent.cpp in Sources */,
E1EE8BA72413196300E794D6 /* XRInputSourcesChangeEvent.cpp in Sources */,
E1EE8B952413195000E794D6 /* XRReferenceSpaceEvent.cpp in Sources */,
Added: trunk/Source/WebCore/platform/cocoa/XPCEndpoint.h (0 => 264128)
--- trunk/Source/WebCore/platform/cocoa/XPCEndpoint.h (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/XPCEndpoint.h 2020-07-08 19:42:08 UTC (rev 264128)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#pragma once
+
+#include <wtf/OSObjectPtr.h>
+#include <wtf/spi/darwin/XPCSPI.h>
+
+namespace WebCore {
+
+class XPCEndpoint {
+public:
+ WEBCORE_EXPORT XPCEndpoint();
+ WEBCORE_EXPORT virtual ~XPCEndpoint() = default;
+
+ WEBCORE_EXPORT void sendEndpointToConnection(xpc_connection_t);
+
+ WEBCORE_EXPORT OSObjectPtr<xpc_endpoint_t> endpoint() const;
+
+ static constexpr auto xpcMessageNameKey = "message-name";
+
+private:
+ virtual const char* xpcEndpointMessageNameKey() const = 0;
+ virtual const char* xpcEndpointMessageName() const = 0;
+ virtual const char* xpcEndpointNameKey() const = 0;
+ virtual void handleEvent(xpc_connection_t, xpc_object_t) = 0;
+
+ OSObjectPtr<xpc_connection_t> m_connection;
+ OSObjectPtr<xpc_endpoint_t> m_endpoint;
+};
+
+}
Added: trunk/Source/WebCore/platform/cocoa/XPCEndpoint.mm (0 => 264128)
--- trunk/Source/WebCore/platform/cocoa/XPCEndpoint.mm (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/XPCEndpoint.mm 2020-07-08 19:42:08 UTC (rev 264128)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2020 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 "XPCEndpoint.h"
+
+#import <wtf/cocoa/Entitlements.h>
+
+namespace WebCore {
+
+XPCEndpoint::XPCEndpoint()
+{
+ m_connection = adoptOSObject(xpc_connection_create(nullptr, nullptr));
+ m_endpoint = adoptOSObject(xpc_endpoint_create(m_connection.get()));
+
+ xpc_connection_set_target_queue(m_connection.get(), dispatch_get_main_queue());
+ xpc_connection_set_event_handler(m_connection.get(), ^(xpc_object_t message) {
+ xpc_type_t type = xpc_get_type(message);
+
+ if (type == XPC_TYPE_CONNECTION) {
+ xpc_connection_t connection = message;
+ audit_token_t auditToken;
+ xpc_connection_get_audit_token(connection, &auditToken);
+
+ if (!WTF::hasEntitlement(auditToken, "com.apple.private.webkit.use-xpc-endpoint")) {
+ // Uncomment before landing; this is commented out because the bots does not seem to update the entitlements on incremental builds.
+ // WTFLogAlways("Audit token does not have required entitlement");
+ // return;
+ }
+ xpc_connection_set_target_queue(connection, dispatch_get_main_queue());
+ xpc_connection_set_event_handler(connection, ^(xpc_object_t event) {
+ handleEvent(connection, event);
+ });
+ xpc_connection_resume(connection);
+ }
+ });
+ xpc_connection_resume(m_connection.get());
+}
+
+void XPCEndpoint::sendEndpointToConnection(xpc_connection_t connection)
+{
+ if (!connection)
+ return;
+
+ auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
+ xpc_dictionary_set_string(message.get(), xpcEndpointMessageNameKey(), xpcEndpointMessageName());
+ xpc_dictionary_set_value(message.get(), xpcEndpointNameKey(), m_endpoint.get());
+
+ xpc_connection_send_message(connection, message.get());
+}
+
+OSObjectPtr<xpc_endpoint_t> XPCEndpoint::endpoint() const
+{
+ return m_endpoint;
+}
+
+}
Added: trunk/Source/WebCore/platform/cocoa/XPCEndpointClient.h (0 => 264128)
--- trunk/Source/WebCore/platform/cocoa/XPCEndpointClient.h (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/XPCEndpointClient.h 2020-07-08 19:42:08 UTC (rev 264128)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#pragma once
+
+#include <wtf/Lock.h>
+#include <wtf/OSObjectPtr.h>
+#include <wtf/spi/darwin/XPCSPI.h>
+
+namespace WebCore {
+
+class XPCEndpointClient {
+public:
+ virtual ~XPCEndpointClient() { }
+
+ WEBCORE_EXPORT void setEndpoint(xpc_endpoint_t);
+
+protected:
+ WEBCORE_EXPORT OSObjectPtr<xpc_connection_t> connection();
+
+private:
+ virtual void handleEvent(xpc_object_t) = 0;
+ virtual void didConnect() = 0;
+
+ OSObjectPtr<xpc_connection_t> m_connection;
+ Lock m_lock;
+};
+
+}
Added: trunk/Source/WebCore/platform/cocoa/XPCEndpointClient.mm (0 => 264128)
--- trunk/Source/WebCore/platform/cocoa/XPCEndpointClient.mm (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/XPCEndpointClient.mm 2020-07-08 19:42:08 UTC (rev 264128)
@@ -0,0 +1,81 @@
+/*
+* Copyright (C) 2020 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 "XPCEndpointClient.h"
+
+#import <wtf/cocoa/Entitlements.h>
+
+namespace WebCore {
+
+void XPCEndpointClient::setEndpoint(xpc_endpoint_t endpoint)
+{
+ {
+ LockHolder locker(m_lock);
+
+ if (m_connection)
+ return;
+
+ m_connection = adoptOSObject(xpc_connection_create_from_endpoint(endpoint));
+
+ xpc_connection_set_target_queue(m_connection.get(), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
+ xpc_connection_set_event_handler(m_connection.get(), ^(xpc_object_t message) {
+ xpc_type_t type = xpc_get_type(message);
+ if (type == XPC_TYPE_ERROR) {
+ if (message == XPC_ERROR_CONNECTION_INVALID || message == XPC_ERROR_TERMINATION_IMMINENT) {
+ LockHolder locker(m_lock);
+ m_connection = nullptr;
+ }
+ return;
+ }
+ if (type != XPC_TYPE_DICTIONARY)
+ return;
+
+ auto connection = xpc_dictionary_get_remote_connection(message);
+ if (!connection)
+ return;
+ audit_token_t auditToken;
+ xpc_connection_get_audit_token(connection, &auditToken);
+ if (!WTF::hasEntitlement(auditToken, "com.apple.private.webkit.use-xpc-endpoint")) {
+ // Uncomment before landing; this is commented out because the bots does not seem to update the entitlements on incremental builds.
+ // WTFLogAlways("Audit token does not have required entitlement");
+ // return;
+ }
+ handleEvent(message);
+ });
+
+ xpc_connection_resume(m_connection.get());
+ }
+
+ didConnect();
+}
+
+OSObjectPtr<xpc_connection_t> XPCEndpointClient::connection()
+{
+ LockHolder locker(m_lock);
+ return m_connection;
+}
+
+}
Modified: trunk/Tools/ChangeLog (264127 => 264128)
--- trunk/Tools/ChangeLog 2020-07-08 19:34:18 UTC (rev 264127)
+++ trunk/Tools/ChangeLog 2020-07-08 19:42:08 UTC (rev 264128)
@@ -1,3 +1,14 @@
+2020-07-08 Per Arne Vollan <[email protected]>
+
+ [Cocoa] Make it possible to establish direct XPC connections between WebKit processes
+ https://bugs.webkit.org/show_bug.cgi?id=214079
+
+ Reviewed by Brent Fulgham.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit/XPCEndpoint.mm: Added.
+ (TEST):
+
2020-07-08 Aakash Jain <[email protected]>
[ews] Limit layout tests failures to display in the status-bubble tooltip and buildbot summary
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (264127 => 264128)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2020-07-08 19:34:18 UTC (rev 264127)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2020-07-08 19:42:08 UTC (rev 264128)
@@ -912,6 +912,7 @@
C0C5D3C61459912900A802A6 /* GetBackingScaleFactor_Bundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */; };
C13D82D92416F13200A62793 /* EnableAccessibility.mm in Sources */ = {isa = PBXBuildFile; fileRef = C13D82D82416F13200A62793 /* EnableAccessibility.mm */; };
C149D550242E98DF003EBB12 /* SleepDisabler.mm in Sources */ = {isa = PBXBuildFile; fileRef = C149D54F242E9844003EBB12 /* SleepDisabler.mm */; };
+ C14D304624B4C3BA00480387 /* XPCEndpoint.mm in Sources */ = {isa = PBXBuildFile; fileRef = C14D304524B4C3BA00480387 /* XPCEndpoint.mm */; };
C15CBB3023F1FF1A00300CC7 /* BacklightLevelNotification.mm in Sources */ = {isa = PBXBuildFile; fileRef = C15CBB2F23F1FF1A00300CC7 /* BacklightLevelNotification.mm */; };
C15CBB3F23FB177A00300CC7 /* PreferenceChanges.mm in Sources */ = {isa = PBXBuildFile; fileRef = C15CBB3E23FB177A00300CC7 /* PreferenceChanges.mm */; };
C1692DCA23D10DAE006E88F7 /* Battery.mm in Sources */ = {isa = PBXBuildFile; fileRef = C1692DC923D10DAE006E88F7 /* Battery.mm */; };
@@ -2559,6 +2560,7 @@
C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor_Bundle.mm; sourceTree = "<group>"; };
C13D82D82416F13200A62793 /* EnableAccessibility.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = EnableAccessibility.mm; sourceTree = "<group>"; };
C149D54F242E9844003EBB12 /* SleepDisabler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SleepDisabler.mm; sourceTree = "<group>"; };
+ C14D304524B4C3BA00480387 /* XPCEndpoint.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = XPCEndpoint.mm; sourceTree = "<group>"; };
C15CBB2F23F1FF1A00300CC7 /* BacklightLevelNotification.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = BacklightLevelNotification.mm; sourceTree = "<group>"; };
C15CBB3E23FB177A00300CC7 /* PreferenceChanges.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PreferenceChanges.mm; sourceTree = "<group>"; };
C1692DC923D10DAE006E88F7 /* Battery.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = Battery.mm; sourceTree = "<group>"; };
@@ -3043,6 +3045,7 @@
C149D54F242E9844003EBB12 /* SleepDisabler.mm */,
0F139E751A423A5300F590F5 /* WeakObjCPtr.mm */,
C1FF9EDA244644F000839AE4 /* WebFilter.mm */,
+ C14D304524B4C3BA00480387 /* XPCEndpoint.mm */,
);
name = cocoa;
sourceTree = "<group>";
@@ -5392,6 +5395,7 @@
CD7F89DC22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm in Sources */,
9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */,
7C74C8FA22DFBA9600DA2DAB /* WTFStringUtilities.cpp in Sources */,
+ C14D304624B4C3BA00480387 /* XPCEndpoint.mm in Sources */,
9C64DC321D76198A004B598E /* YouTubePluginReplacement.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit/XPCEndpoint.mm (0 => 264128)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit/XPCEndpoint.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/XPCEndpoint.mm 2020-07-08 19:42:08 UTC (rev 264128)
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2020 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 "PlatformUtilities.h"
+
+#import <WebCore/XPCEndpoint.h>
+#import <WebCore/XPCEndpointClient.h>
+#import <wtf/text/WTFString.h>
+
+static bool clientConnectedToEndpoint = false;
+static bool endpointReceivedMessageFromClient = false;
+static bool clientReceivedMessageFromEndpoint = false;
+
+static constexpr auto testMessageFromEndpoint = "test-message-from-endpoint";
+static constexpr auto testMessageFromClient = "test-message-from-client";
+
+class XPCEndpoint : public WebCore::XPCEndpoint {
+private:
+ const char* xpcEndpointMessageNameKey() const override
+ {
+ return nullptr;
+ }
+ const char* xpcEndpointMessageName() const override
+ {
+ return nullptr;
+ }
+ const char* xpcEndpointNameKey() const override
+ {
+ return nullptr;
+ }
+ void handleEvent(xpc_connection_t connection, xpc_object_t event) override
+ {
+ String messageName = xpc_dictionary_get_string(event, XPCEndpoint::xpcMessageNameKey);
+ if (messageName == testMessageFromClient) {
+ endpointReceivedMessageFromClient = true;
+
+ auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
+ xpc_dictionary_set_string(message.get(), XPCEndpoint::xpcMessageNameKey, testMessageFromEndpoint);
+ xpc_connection_send_message(connection, message.get());
+ }
+ }
+};
+
+class XPCEndpointClient : public WebCore::XPCEndpointClient {
+private:
+ void handleEvent(xpc_object_t event) override
+ {
+ String messageName = xpc_dictionary_get_string(event, XPCEndpoint::xpcMessageNameKey);
+ if (messageName == testMessageFromEndpoint)
+ clientReceivedMessageFromEndpoint = true;
+ }
+ void didConnect() override
+ {
+ auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
+ xpc_dictionary_set_string(message.get(), XPCEndpoint::xpcMessageNameKey, testMessageFromClient);
+ xpc_connection_send_message(connection().get(), message.get());
+
+ clientConnectedToEndpoint = true;
+ }
+};
+
+TEST(WebKit, XPCEndpoint)
+{
+ XPCEndpoint xpcEndpoint;
+ XPCEndpointClient xpcEndpointClient;
+
+ xpcEndpointClient.setEndpoint(xpcEndpoint.endpoint().get());
+
+ TestWebKitAPI::Util::run(&clientConnectedToEndpoint);
+ TestWebKitAPI::Util::run(&endpointReceivedMessageFromClient);
+ TestWebKitAPI::Util::run(&clientReceivedMessageFromEndpoint);
+}