Title: [227397] branches/safari-605-branch/Source
Revision
227397
Author
jmarc...@apple.com
Date
2018-01-22 22:42:29 -0800 (Mon, 22 Jan 2018)

Log Message

Cherry-pick r227340. rdar://problem/36746140

Modified Paths

Added Paths

Diff

Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (227396 => 227397)


--- branches/safari-605-branch/Source/WebCore/ChangeLog	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog	2018-01-23 06:42:29 UTC (rev 227397)
@@ -1,5 +1,35 @@
 2018-01-22  Jason Marcell  <jmarc...@apple.com>
 
+        Cherry-pick r227340. rdar://problem/36746140
+
+    2018-01-22  Brady Eidson  <beid...@apple.com>
+
+            In WebKit2, make the MessagePortChannelRegistry live in the UI process.
+            https://bugs.webkit.org/show_bug.cgi?id=181922
+
+            Reviewed by Andy Estes.
+
+            No new tests (Refactor, no behavior change)
+
+            Add encoder/decoders and EXPORT a whole bunch of stuff.
+
+            * WebCore.xcodeproj/project.pbxproj:
+
+            * dom/MessagePort.h:
+
+            * dom/messageports/MessagePortChannel.cpp:
+            (WebCore::MessagePortChannel::processForPort):
+            * dom/messageports/MessagePortChannel.h:
+
+            * dom/messageports/MessagePortChannelProvider.h:
+            * dom/messageports/MessagePortChannelRegistry.h:
+
+            * dom/messageports/MessageWithMessagePorts.h:
+            (WebCore::MessageWithMessagePorts::encode const):
+            (WebCore::MessageWithMessagePorts::decode):
+
+2018-01-22  Jason Marcell  <jmarc...@apple.com>
+
         Cherry-pick r227275. rdar://problem/36745983
 
     2018-01-20  Brady Eidson  <beid...@apple.com>

Modified: branches/safari-605-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj (227396 => 227397)


--- branches/safari-605-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-01-23 06:42:29 UTC (rev 227397)
@@ -1405,7 +1405,7 @@
 		51A052561058874000CC9E95 /* ProtectionSpaceHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A052551058874000CC9E95 /* ProtectionSpaceHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		51A4BB0A1954D61600FA5C2E /* Gamepad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51A4BB071954D61600FA5C2E /* Gamepad.cpp */; };
 		51A4BB101954D62700FA5C2E /* NavigatorGamepad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51A4BB0D1954D62700FA5C2E /* NavigatorGamepad.cpp */; };
-		51A748E32005D0E80075BA68 /* MessageWithMessagePorts.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A748E02005D0E00075BA68 /* MessageWithMessagePorts.h */; };
+		51A748E32005D0E80075BA68 /* MessageWithMessagePorts.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A748E02005D0E00075BA68 /* MessageWithMessagePorts.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		51A748E62006004F0075BA68 /* MessagePortChannelProviderImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A748E5200600210075BA68 /* MessagePortChannelProviderImpl.h */; };
 		51A9D9E9195B931F001B2B5C /* GamepadManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51A9D9E7195B931F001B2B5C /* GamepadManager.cpp */; };
 		51A9D9EA195B931F001B2B5C /* GamepadManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A9D9E8195B931F001B2B5C /* GamepadManager.h */; };
@@ -1438,9 +1438,9 @@
 		51E399021D6E4750009C8831 /* GameControllerGamepadProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E398FE1D6E474B009C8831 /* GameControllerGamepadProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		51E3AA0B1B98BCAB0036AD81 /* SecurityOriginData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E3AA091B98BC9A0036AD81 /* SecurityOriginData.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		51E6821016387302003BBF3C /* LoaderStrategy.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E6820F16387302003BBF3C /* LoaderStrategy.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		51ECC3F6200587BF00483EAE /* MessagePortChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 51ECC3F4200587B700483EAE /* MessagePortChannel.h */; };
-		51ECC3F8200587BF00483EAE /* MessagePortChannelRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 51ECC3F1200587B500483EAE /* MessagePortChannelRegistry.h */; };
-		51ECC3FD2005930D00483EAE /* MessagePortChannelProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 51ECC3FB2005930100483EAE /* MessagePortChannelProvider.h */; };
+		51ECC3F6200587BF00483EAE /* MessagePortChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 51ECC3F4200587B700483EAE /* MessagePortChannel.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		51ECC3F8200587BF00483EAE /* MessagePortChannelRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 51ECC3F1200587B500483EAE /* MessagePortChannelRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		51ECC3FD2005930D00483EAE /* MessagePortChannelProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 51ECC3FB2005930100483EAE /* MessagePortChannelProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		51EE7B381AA50B0500F92B21 /* ResourceLoadInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 51EE7B371AA50B0500F92B21 /* ResourceLoadInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		51EEAA741BEFFAB100218008 /* IndexValueEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 51EEAA721BEFFA7900218008 /* IndexValueEntry.h */; };
 		51F174FE1F35899200C74950 /* WorkerType.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F174FC1F35898800C74950 /* WorkerType.h */; settings = {ATTRIBUTES = (Private, ); }; };

Modified: branches/safari-605-branch/Source/WebCore/dom/MessagePort.h (227396 => 227397)


--- branches/safari-605-branch/Source/WebCore/dom/MessagePort.h	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebCore/dom/MessagePort.h	2018-01-23 06:42:29 UTC (rev 227397)
@@ -57,9 +57,9 @@
     // Returns nullptr if the passed-in vector is empty.
     static ExceptionOr<TransferredMessagePortArray> disentanglePorts(Vector<RefPtr<MessagePort>>&&);
     static Vector<RefPtr<MessagePort>> entanglePorts(ScriptExecutionContext&, TransferredMessagePortArray&&);
-    static RefPtr<MessagePort> existingMessagePortForIdentifier(const MessagePortIdentifier&);
+    WEBCORE_EXPORT static RefPtr<MessagePort> existingMessagePortForIdentifier(const MessagePortIdentifier&);
 
-    void messageAvailable();
+    WEBCORE_EXPORT void messageAvailable();
     bool started() const { return m_started; }
     bool closed() const { return m_closed; }
 
@@ -73,8 +73,8 @@
     const MessagePortIdentifier& identifier() const { return m_identifier; }
     const MessagePortIdentifier& remoteIdentifier() const { return m_remoteIdentifier; }
 
-    void ref() const;
-    void deref() const;
+    WEBCORE_EXPORT void ref() const;
+    WEBCORE_EXPORT void deref() const;
 
     // ActiveDOMObject
     const char* activeDOMObjectName() const final;
@@ -83,7 +83,7 @@
     void stop() final { close(); }
     bool hasPendingActivity() const final;
 
-    bool isLocallyReachable() const;
+    WEBCORE_EXPORT bool isLocallyReachable() const;
 
     // EventTargetWithInlineData.
     EventTargetInterface eventTargetInterface() const final { return MessagePortEventTargetInterfaceType; }

Modified: branches/safari-605-branch/Source/WebCore/dom/messageports/MessagePortChannel.cpp (227396 => 227397)


--- branches/safari-605-branch/Source/WebCore/dom/messageports/MessagePortChannel.cpp	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebCore/dom/messageports/MessagePortChannel.cpp	2018-01-23 06:42:29 UTC (rev 227397)
@@ -60,6 +60,14 @@
     m_registry.messagePortChannelDestroyed(*this);
 }
 
+std::optional<ProcessIdentifier> MessagePortChannel::processForPort(const MessagePortIdentifier& port)
+{
+    ASSERT(isMainThread());
+    ASSERT(port == m_ports[0] || port == m_ports[1]);
+    size_t i = port == m_ports[0] ? 0 : 1;
+    return m_processes[i];
+}
+
 bool MessagePortChannel::includesPort(const MessagePortIdentifier& port)
 {
     ASSERT(isMainThread());

Modified: branches/safari-605-branch/Source/WebCore/dom/messageports/MessagePortChannel.h (227396 => 227397)


--- branches/safari-605-branch/Source/WebCore/dom/messageports/MessagePortChannel.h	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebCore/dom/messageports/MessagePortChannel.h	2018-01-23 06:42:29 UTC (rev 227397)
@@ -46,6 +46,7 @@
     const MessagePortIdentifier& port1() const { return m_ports[0]; }
     const MessagePortIdentifier& port2() const { return m_ports[1]; }
 
+    WEBCORE_EXPORT std::optional<ProcessIdentifier> processForPort(const MessagePortIdentifier&);
     bool includesPort(const MessagePortIdentifier&);
     void entanglePortWithProcess(const MessagePortIdentifier&, ProcessIdentifier);
     void disentanglePort(const MessagePortIdentifier&);

Modified: branches/safari-605-branch/Source/WebCore/dom/messageports/MessagePortChannelProvider.h (227396 => 227397)


--- branches/safari-605-branch/Source/WebCore/dom/messageports/MessagePortChannelProvider.h	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebCore/dom/messageports/MessagePortChannelProvider.h	2018-01-23 06:42:29 UTC (rev 227397)
@@ -37,7 +37,7 @@
 class MessagePortChannelProvider {
 public:
     static MessagePortChannelProvider& singleton();
-    static void setSharedProvider(MessagePortChannelProvider&);
+    WEBCORE_EXPORT static void setSharedProvider(MessagePortChannelProvider&);
 
     virtual ~MessagePortChannelProvider() { }
 

Modified: branches/safari-605-branch/Source/WebCore/dom/messageports/MessagePortChannelRegistry.h (227396 => 227397)


--- branches/safari-605-branch/Source/WebCore/dom/messageports/MessagePortChannelRegistry.h	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebCore/dom/messageports/MessagePortChannelRegistry.h	2018-01-23 06:42:29 UTC (rev 227397)
@@ -35,20 +35,20 @@
 
 class MessagePortChannelRegistry {
 public:
-    ~MessagePortChannelRegistry();
+    WEBCORE_EXPORT ~MessagePortChannelRegistry();
     
-    void didCreateMessagePortChannel(const MessagePortIdentifier& port1, const MessagePortIdentifier& port2);
-    void didEntangleLocalToRemote(const MessagePortIdentifier& local, const MessagePortIdentifier& remote, ProcessIdentifier);
-    void didDisentangleMessagePort(const MessagePortIdentifier& local);
-    void didCloseMessagePort(const MessagePortIdentifier& local);
-    bool didPostMessageToRemote(MessageWithMessagePorts&&, const MessagePortIdentifier& remoteTarget);
-    void takeAllMessagesForPort(const MessagePortIdentifier&, Function<void(Vector<MessageWithMessagePorts>&&, Function<void()>&&)>&&);
-    void checkRemotePortForActivity(const MessagePortIdentifier& remoteTarget, CompletionHandler<void(MessagePortChannelProvider::HasActivity)>&& callback);
+    WEBCORE_EXPORT void didCreateMessagePortChannel(const MessagePortIdentifier& port1, const MessagePortIdentifier& port2);
+    WEBCORE_EXPORT void didEntangleLocalToRemote(const MessagePortIdentifier& local, const MessagePortIdentifier& remote, ProcessIdentifier);
+    WEBCORE_EXPORT void didDisentangleMessagePort(const MessagePortIdentifier& local);
+    WEBCORE_EXPORT void didCloseMessagePort(const MessagePortIdentifier& local);
+    WEBCORE_EXPORT bool didPostMessageToRemote(MessageWithMessagePorts&&, const MessagePortIdentifier& remoteTarget);
+    WEBCORE_EXPORT void takeAllMessagesForPort(const MessagePortIdentifier&, Function<void(Vector<MessageWithMessagePorts>&&, Function<void()>&&)>&&);
+    WEBCORE_EXPORT void checkRemotePortForActivity(const MessagePortIdentifier& remoteTarget, CompletionHandler<void(MessagePortChannelProvider::HasActivity)>&& callback);
 
-    MessagePortChannel* existingChannelContainingPort(const MessagePortIdentifier&);
+    WEBCORE_EXPORT MessagePortChannel* existingChannelContainingPort(const MessagePortIdentifier&);
 
-    void messagePortChannelCreated(MessagePortChannel&);
-    void messagePortChannelDestroyed(MessagePortChannel&);
+    WEBCORE_EXPORT void messagePortChannelCreated(MessagePortChannel&);
+    WEBCORE_EXPORT void messagePortChannelDestroyed(MessagePortChannel&);
 
 private:
     HashMap<MessagePortIdentifier, MessagePortChannel*> m_openChannels;

Modified: branches/safari-605-branch/Source/WebCore/dom/messageports/MessageWithMessagePorts.h (227396 => 227397)


--- branches/safari-605-branch/Source/WebCore/dom/messageports/MessageWithMessagePorts.h	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebCore/dom/messageports/MessageWithMessagePorts.h	2018-01-23 06:42:29 UTC (rev 227397)
@@ -25,13 +25,12 @@
 
 #pragma once
 
+#include "MessagePortIdentifier.h"
 #include "SerializedScriptValue.h"
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
 
-struct MessagePortIdentifier;
-
 // When a message port is transferred, it is represented by a pair of identifiers.
 // The first identifier is the port being transferred and the second is its remote port.
 typedef Vector<std::pair<WebCore::MessagePortIdentifier, WebCore::MessagePortIdentifier>> TransferredMessagePortArray;
@@ -39,6 +38,33 @@
 struct MessageWithMessagePorts {
     RefPtr<SerializedScriptValue> message;
     TransferredMessagePortArray transferredPorts;
+
+    template<class Encoder> void encode(Encoder&) const;
+    template<class Decoder> static std::optional<MessageWithMessagePorts> decode(Decoder&);
 };
 
+
+template<class Encoder>
+void MessageWithMessagePorts::encode(Encoder& encoder) const
+{
+    ASSERT(message);
+    encoder << message->toWireBytes() << transferredPorts;
+}
+
+template<class Decoder>
+std::optional<MessageWithMessagePorts> MessageWithMessagePorts::decode(Decoder& decoder)
+{
+    MessageWithMessagePorts result;
+
+    Vector<uint8_t> wireBytes;
+    if (!decoder.decode(wireBytes))
+        return std::nullopt;
+
+    if (!decoder.decode(result.transferredPorts))
+        return std::nullopt;
+
+    result.message = SerializedScriptValue::createFromWireBytes(WTFMove(wireBytes));
+    return result;
+}
+
 } // namespace WebCore

Modified: branches/safari-605-branch/Source/WebKit/CMakeLists.txt (227396 => 227397)


--- branches/safari-605-branch/Source/WebKit/CMakeLists.txt	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebKit/CMakeLists.txt	2018-01-23 06:42:29 UTC (rev 227397)
@@ -300,6 +300,7 @@
     UIProcess/ResponsivenessTimer.cpp
     UIProcess/StatisticsRequest.cpp
     UIProcess/TextCheckerCompletion.cpp
+    UIProcess/UIMessagePortChannelProvider.cpp
     UIProcess/UserMediaPermissionCheckProxy.cpp
     UIProcess/UserMediaPermissionRequestManagerProxy.cpp
     UIProcess/UserMediaPermissionRequestProxy.cpp
@@ -558,6 +559,7 @@
     WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
     WebProcess/WebCoreSupport/WebGeolocationClient.cpp
     WebProcess/WebCoreSupport/WebInspectorClient.cpp
+    WebProcess/WebCoreSupport/WebMessagePortChannelProvider.cpp
     WebProcess/WebCoreSupport/WebNotificationClient.cpp
     WebProcess/WebCoreSupport/WebPerformanceLoggingClient.cpp
     WebProcess/WebCoreSupport/WebPlatformStrategies.cpp

Modified: branches/safari-605-branch/Source/WebKit/ChangeLog (227396 => 227397)


--- branches/safari-605-branch/Source/WebKit/ChangeLog	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebKit/ChangeLog	2018-01-23 06:42:29 UTC (rev 227397)
@@ -1,5 +1,87 @@
 2018-01-22  Jason Marcell  <jmarc...@apple.com>
 
+        Cherry-pick r227340. rdar://problem/36746140
+
+    2018-01-22  Brady Eidson  <beid...@apple.com>
+
+            In WebKit2, make the MessagePortChannelRegistry live in the UI process.
+            https://bugs.webkit.org/show_bug.cgi?id=181922
+
+            Reviewed by Andy Estes.
+
+            With all of the work that went into making MessagePorts be fully asynchronous
+            and to be process-aware, formally moving them out-of-process is just a matter
+            of adding WebKit IPC layers.
+
+            The basic unit of asynchronicity is "MessagePortChannelProvider", and this patch
+            adds both a WebMessagePortChannelProvider and UIMessagePortChannelProvider for
+            each side of the process divide.
+
+            * UIProcess/UIMessagePortChannelProvider.cpp: Added.
+            (WebKit::UIMessagePortChannelProvider::singleton):
+            (WebKit::UIMessagePortChannelProvider::UIMessagePortChannelProvider):
+            (WebKit::UIMessagePortChannelProvider::~UIMessagePortChannelProvider):
+            (WebKit::UIMessagePortChannelProvider::createNewMessagePortChannel):
+            (WebKit::UIMessagePortChannelProvider::entangleLocalPortInThisProcessToRemote):
+            (WebKit::UIMessagePortChannelProvider::messagePortDisentangled):
+            (WebKit::UIMessagePortChannelProvider::messagePortClosed):
+            (WebKit::UIMessagePortChannelProvider::takeAllMessagesForPort):
+            (WebKit::UIMessagePortChannelProvider::postMessageToRemote):
+            (WebKit::UIMessagePortChannelProvider::checkRemotePortForActivity):
+            (WebKit::UIMessagePortChannelProvider::checkProcessLocalPortForActivity):
+            * UIProcess/UIMessagePortChannelProvider.h: Added.
+            (WebKit::UIMessagePortChannelProvider::registry):
+
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::m_configurationPreferenceValues):
+
+            * UIProcess/WebProcessProxy.cpp:
+            (WebKit::WebProcessProxy::processForIdentifier):
+            (WebKit::m_userMediaCaptureManagerProxy):
+            (WebKit::WebProcessProxy::~WebProcessProxy):
+            (WebKit::WebProcessProxy::shutDown):
+            (WebKit::WebProcessProxy::createNewMessagePortChannel):
+            (WebKit::WebProcessProxy::entangleLocalPortInThisProcessToRemote):
+            (WebKit::WebProcessProxy::messagePortDisentangled):
+            (WebKit::WebProcessProxy::messagePortClosed):
+            (WebKit::WebProcessProxy::takeAllMessagesForPort):
+            (WebKit::WebProcessProxy::didDeliverMessagePortMessages):
+            (WebKit::WebProcessProxy::postMessageToRemote):
+            (WebKit::WebProcessProxy::checkRemotePortForActivity):
+            (WebKit::WebProcessProxy::checkProcessLocalPortForActivity):
+            (WebKit::WebProcessProxy::didCheckProcessLocalPortForActivity):
+            * UIProcess/WebProcessProxy.h:
+            * UIProcess/WebProcessProxy.messages.in:
+
+            * WebKit.xcodeproj/project.pbxproj:
+
+            * WebProcess/WebCoreSupport/WebMessagePortChannelProvider.cpp: Added.
+            (WebKit::WebMessagePortChannelProvider::singleton):
+            (WebKit::WebMessagePortChannelProvider::WebMessagePortChannelProvider):
+            (WebKit::WebMessagePortChannelProvider::~WebMessagePortChannelProvider):
+            (WebKit::WebMessagePortChannelProvider::createNewMessagePortChannel):
+            (WebKit::WebMessagePortChannelProvider::entangleLocalPortInThisProcessToRemote):
+            (WebKit::WebMessagePortChannelProvider::messagePortDisentangled):
+            (WebKit::WebMessagePortChannelProvider::messagePortClosed):
+            (WebKit::WebMessagePortChannelProvider::takeAllMessagesForPort):
+            (WebKit::WebMessagePortChannelProvider::didTakeAllMessagesForPort):
+            (WebKit::WebMessagePortChannelProvider::didCheckRemotePortForActivity):
+            (WebKit::WebMessagePortChannelProvider::postMessageToRemote):
+            (WebKit::WebMessagePortChannelProvider::checkProcessLocalPortForActivity):
+            (WebKit::WebMessagePortChannelProvider::checkRemotePortForActivity):
+            * WebProcess/WebCoreSupport/WebMessagePortChannelProvider.h: Added.
+
+            * WebProcess/WebProcess.cpp:
+            (WebKit::WebProcess::initializeProcess):
+            (WebKit::WebProcess::didTakeAllMessagesForPort):
+            (WebKit::WebProcess::checkProcessLocalPortForActivity):
+            (WebKit::WebProcess::didCheckRemotePortForActivity):
+            (WebKit::WebProcess::messagesAvailableForPort):
+            * WebProcess/WebProcess.h:
+            * WebProcess/WebProcess.messages.in:
+
+2018-01-22  Jason Marcell  <jmarc...@apple.com>
+
         Cherry-pick r227218. rdar://problem/36746114
 
     2018-01-19  Daniel Bates  <daba...@apple.com>

Added: branches/safari-605-branch/Source/WebKit/UIProcess/UIMessagePortChannelProvider.cpp (0 => 227397)


--- branches/safari-605-branch/Source/WebKit/UIProcess/UIMessagePortChannelProvider.cpp	                        (rev 0)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/UIMessagePortChannelProvider.cpp	2018-01-23 06:42:29 UTC (rev 227397)
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2018 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 "config.h"
+#include "UIMessagePortChannelProvider.h"
+
+#include "WebProcessMessages.h"
+#include "WebProcessProxy.h"
+#include <wtf/CompletionHandler.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+UIMessagePortChannelProvider& UIMessagePortChannelProvider::singleton()
+{
+    static UIMessagePortChannelProvider* provider = new UIMessagePortChannelProvider;
+    return *provider;
+}
+
+UIMessagePortChannelProvider::UIMessagePortChannelProvider()
+{
+}
+
+UIMessagePortChannelProvider::~UIMessagePortChannelProvider()
+{
+    ASSERT_NOT_REACHED();
+}
+
+void UIMessagePortChannelProvider::createNewMessagePortChannel(const MessagePortIdentifier&, const MessagePortIdentifier&)
+{
+    // Should never be called in the UI process provider.
+    ASSERT_NOT_REACHED();
+}
+
+void UIMessagePortChannelProvider::entangleLocalPortInThisProcessToRemote(const MessagePortIdentifier&, const MessagePortIdentifier&)
+{
+    // Should never be called in the UI process provider.
+    ASSERT_NOT_REACHED();
+}
+
+void UIMessagePortChannelProvider::messagePortDisentangled(const MessagePortIdentifier&)
+{
+    // Should never be called in the UI process provider.
+    ASSERT_NOT_REACHED();
+}
+
+void UIMessagePortChannelProvider::messagePortClosed(const MessagePortIdentifier&)
+{
+    // Should never be called in the UI process provider.
+    ASSERT_NOT_REACHED();
+}
+
+void UIMessagePortChannelProvider::takeAllMessagesForPort(const MessagePortIdentifier&, Function<void(Vector<MessageWithMessagePorts>&&, Function<void()>&&)>&&)
+{
+    // Should never be called in the UI process provider.
+    ASSERT_NOT_REACHED();
+}
+
+void UIMessagePortChannelProvider::postMessageToRemote(MessageWithMessagePorts&&, const MessagePortIdentifier&)
+{
+    // Should never be called in the UI process provider.
+    ASSERT_NOT_REACHED();
+}
+
+void UIMessagePortChannelProvider::checkRemotePortForActivity(const MessagePortIdentifier&, CompletionHandler<void(HasActivity)>&&)
+{
+    // Should never be called in the UI process provider.
+    ASSERT_NOT_REACHED();
+}
+
+void UIMessagePortChannelProvider::checkProcessLocalPortForActivity(const MessagePortIdentifier& port, ProcessIdentifier processIdentifier, CompletionHandler<void(HasActivity)>&& completionHandler)
+{
+    auto* process = WebProcessProxy::processForIdentifier(processIdentifier);
+    if (!process) {
+        completionHandler(HasActivity::No);
+        return;
+    }
+
+    process->checkProcessLocalPortForActivity(port, WTFMove(completionHandler));
+}
+
+} // namespace WebKit

Added: branches/safari-605-branch/Source/WebKit/UIProcess/UIMessagePortChannelProvider.h (0 => 227397)


--- branches/safari-605-branch/Source/WebKit/UIProcess/UIMessagePortChannelProvider.h	                        (rev 0)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/UIMessagePortChannelProvider.h	2018-01-23 06:42:29 UTC (rev 227397)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2018 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 <WebCore/MessagePortChannelProvider.h>
+#include <WebCore/MessagePortChannelRegistry.h>
+
+namespace WebKit {
+
+class UIMessagePortChannelProvider : public WebCore::MessagePortChannelProvider {
+public:
+    static UIMessagePortChannelProvider& singleton();
+    WebCore::MessagePortChannelRegistry& registry() { return m_registry; }
+
+private:
+    UIMessagePortChannelProvider();
+    ~UIMessagePortChannelProvider() final;
+
+    void createNewMessagePortChannel(const WebCore::MessagePortIdentifier& local, const WebCore::MessagePortIdentifier& remote) final;
+    void entangleLocalPortInThisProcessToRemote(const WebCore::MessagePortIdentifier& local, const WebCore::MessagePortIdentifier& remote) final;
+    void messagePortDisentangled(const WebCore::MessagePortIdentifier& local) final;
+    void messagePortClosed(const WebCore::MessagePortIdentifier& local) final;
+    void takeAllMessagesForPort(const WebCore::MessagePortIdentifier&, Function<void(Vector<WebCore::MessageWithMessagePorts>&&, Function<void()>&&)>&&) final;
+    void postMessageToRemote(WebCore::MessageWithMessagePorts&&, const WebCore::MessagePortIdentifier& remoteTarget) final;
+    void checkRemotePortForActivity(const WebCore::MessagePortIdentifier& remoteTarget, CompletionHandler<void(HasActivity)>&& callback) final;
+    void checkProcessLocalPortForActivity(const WebCore::MessagePortIdentifier&, WebCore::ProcessIdentifier, CompletionHandler<void(HasActivity)>&&) final;
+
+    WebCore::MessagePortChannelRegistry m_registry;
+};
+
+} // namespace WebKit

Modified: branches/safari-605-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (227396 => 227397)


--- branches/safari-605-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-01-23 06:42:29 UTC (rev 227397)
@@ -77,6 +77,7 @@
 #include "PrintInfo.h"
 #include "TextChecker.h"
 #include "TextCheckerState.h"
+#include "UIMessagePortChannelProvider.h"
 #include "URLSchemeTaskParameters.h"
 #include "UserMediaPermissionRequestProxy.h"
 #include "UserMediaProcessManager.h"
@@ -414,6 +415,11 @@
         this->dispatchActivityStateChange();
     });
 #endif
+
+    static std::once_flag once;
+    std::call_once(once, [] {
+        MessagePortChannelProvider::setSharedProvider(UIMessagePortChannelProvider::singleton());
+    });
 }
 
 WebPageProxy::~WebPageProxy()

Modified: branches/safari-605-branch/Source/WebKit/UIProcess/WebProcessProxy.cpp (227396 => 227397)


--- branches/safari-605-branch/Source/WebKit/UIProcess/WebProcessProxy.cpp	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/WebProcessProxy.cpp	2018-01-23 06:42:29 UTC (rev 227397)
@@ -36,6 +36,7 @@
 #include "PluginProcessManager.h"
 #include "TextChecker.h"
 #include "TextCheckerState.h"
+#include "UIMessagePortChannelProvider.h"
 #include "UserData.h"
 #include "WebBackForwardListItem.h"
 #include "WebInspectorUtilities.h"
@@ -78,6 +79,18 @@
 
 namespace WebKit {
 
+static HashMap<ProcessIdentifier, WebProcessProxy*>& allProcesses()
+{
+    ASSERT(isMainThread());
+    static NeverDestroyed<HashMap<ProcessIdentifier, WebProcessProxy*>> map;
+    return map;
+}
+
+WebProcessProxy* WebProcessProxy::processForIdentifier(ProcessIdentifier identifier)
+{
+    return allProcesses().get(identifier);
+}
+
 uint64_t WebProcessProxy::generatePageID()
 {
     static uint64_t uniquePageID;
@@ -113,6 +126,9 @@
     , m_userMediaCaptureManagerProxy(std::make_unique<UserMediaCaptureManagerProxy>(*this))
 #endif
 {
+    auto result = allProcesses().add(coreProcessIdentifier(), this);
+    ASSERT_UNUSED(result, result.isNewEntry);
+
     WebPasteboardProxy::singleton().addWebProcessProxy(*this);
 }
 
@@ -119,7 +135,10 @@
 WebProcessProxy::~WebProcessProxy()
 {
     ASSERT(m_pageURLRetainCountMap.isEmpty());
-    
+
+    auto result = allProcesses().remove(coreProcessIdentifier());
+    ASSERT_UNUSED(result, result);
+
     WebPasteboardProxy::singleton().removeWebProcessProxy(*this);
 
     if (m_webConnection)
@@ -197,6 +216,9 @@
 
     m_userInitiatedActionMap.clear();
 
+    for (auto& port : m_processEntangledPorts)
+        UIMessagePortChannelProvider::singleton().registry().didCloseMessagePort(port);
+
     m_processPool->disconnectProcess(this);
 }
 
@@ -1229,4 +1251,90 @@
 }
 #endif
 
+void WebProcessProxy::createNewMessagePortChannel(const MessagePortIdentifier& port1, const MessagePortIdentifier& port2)
+{
+    m_processEntangledPorts.add(port1);
+    m_processEntangledPorts.add(port2);
+    UIMessagePortChannelProvider::singleton().registry().didCreateMessagePortChannel(port1, port2);
+}
+
+void WebProcessProxy::entangleLocalPortInThisProcessToRemote(const MessagePortIdentifier& local, const MessagePortIdentifier& remote)
+{
+    m_processEntangledPorts.add(local);
+    UIMessagePortChannelProvider::singleton().registry().didEntangleLocalToRemote(local, remote, coreProcessIdentifier());
+}
+
+void WebProcessProxy::messagePortDisentangled(const MessagePortIdentifier& port)
+{
+    auto result = m_processEntangledPorts.remove(port);
+    ASSERT_UNUSED(result, result);
+
+    UIMessagePortChannelProvider::singleton().registry().didDisentangleMessagePort(port);
+}
+
+void WebProcessProxy::messagePortClosed(const MessagePortIdentifier& port)
+{
+    UIMessagePortChannelProvider::singleton().registry().didCloseMessagePort(port);
+}
+
+void WebProcessProxy::takeAllMessagesForPort(const MessagePortIdentifier& port, uint64_t messagesCallbackIdentifier)
+{
+    UIMessagePortChannelProvider::singleton().registry().takeAllMessagesForPort(port, [this, protectedThis = makeRef(*this), messagesCallbackIdentifier](Vector<MessageWithMessagePorts>&& messages, Function<void()>&& deliveryCallback) {
+
+        static uint64_t currentMessageBatchIdentifier;
+        auto result = m_messageBatchDeliveryCompletionHandlers.ensure(++currentMessageBatchIdentifier, [deliveryCallback = WTFMove(deliveryCallback)]() mutable {
+            return WTFMove(deliveryCallback);
+        });
+        ASSERT_UNUSED(result, result.isNewEntry);
+
+        send(Messages::WebProcess::DidTakeAllMessagesForPort(WTFMove(messages), messagesCallbackIdentifier, currentMessageBatchIdentifier), 0);
+    });
+}
+
+void WebProcessProxy::didDeliverMessagePortMessages(uint64_t messageBatchIdentifier)
+{
+    auto callback = m_messageBatchDeliveryCompletionHandlers.take(messageBatchIdentifier);
+    ASSERT(callback);
+    callback();
+}
+
+void WebProcessProxy::postMessageToRemote(MessageWithMessagePorts&& message, const MessagePortIdentifier& port)
+{
+    if (UIMessagePortChannelProvider::singleton().registry().didPostMessageToRemote(WTFMove(message), port)) {
+        // Look up the process for that port
+        auto* channel = UIMessagePortChannelProvider::singleton().registry().existingChannelContainingPort(port);
+        ASSERT(channel);
+        auto process = channel->processForPort(port);
+        if (process)
+            send(Messages::WebProcess::MessagesAvailableForPort(port), 0);
+    }
+}
+
+void WebProcessProxy::checkRemotePortForActivity(const WebCore::MessagePortIdentifier port, uint64_t callbackIdentifier)
+{
+    UIMessagePortChannelProvider::singleton().registry().checkRemotePortForActivity(port, [this, protectedThis = makeRef(*this), callbackIdentifier](MessagePortChannelProvider::HasActivity hasActivity) {
+        send(Messages::WebProcess::DidCheckRemotePortForActivity(callbackIdentifier, hasActivity == MessagePortChannelProvider::HasActivity::Yes), 0);
+    });
+}
+
+void WebProcessProxy::checkProcessLocalPortForActivity(const MessagePortIdentifier& port, CompletionHandler<void(MessagePortChannelProvider::HasActivity)>&& callback)
+{
+    static uint64_t currentCallbackIdentifier;
+    auto result = m_localPortActivityCompletionHandlers.ensure(++currentCallbackIdentifier, [callback = WTFMove(callback)]() mutable {
+        return WTFMove(callback);
+    });
+    ASSERT_UNUSED(result, result.isNewEntry);
+
+    send(Messages::WebProcess::CheckProcessLocalPortForActivity(port, currentCallbackIdentifier), 0);
+}
+
+void WebProcessProxy::didCheckProcessLocalPortForActivity(uint64_t callbackIdentifier, bool isLocallyReachable)
+{
+    auto callback = m_localPortActivityCompletionHandlers.take(callbackIdentifier);
+    if (!callback)
+        return;
+
+    callback(isLocallyReachable ? MessagePortChannelProvider::HasActivity::Yes : MessagePortChannelProvider::HasActivity::No);
+}
+
 } // namespace WebKit

Modified: branches/safari-605-branch/Source/WebKit/UIProcess/WebProcessProxy.h (227396 => 227397)


--- branches/safari-605-branch/Source/WebKit/UIProcess/WebProcessProxy.h	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/WebProcessProxy.h	2018-01-23 06:42:29 UTC (rev 227397)
@@ -38,6 +38,9 @@
 #include "VisibleWebPageCounter.h"
 #include "WebConnectionToWebProcess.h"
 #include "WebProcessProxyMessages.h"
+#include <WebCore/MessagePortChannelProvider.h>
+#include <WebCore/MessagePortIdentifier.h>
+#include <WebCore/Process.h>
 #include <WebCore/SharedStringHash.h>
 #include <memory>
 #include <pal/SessionID.h>
@@ -103,6 +106,7 @@
     // FIXME: WebsiteDataStores should be made per-WebPageProxy throughout WebKit2
     WebsiteDataStore& websiteDataStore() const { return m_websiteDataStore.get(); }
 
+    static WebProcessProxy* processForIdentifier(WebCore::ProcessIdentifier);
     static WebPageProxy* webPage(uint64_t pageID);
     Ref<WebPageProxy> createWebPage(PageClient&, Ref<API::PageConfiguration>&&);
     void addExistingWebPage(WebPageProxy&, uint64_t pageID);
@@ -197,6 +201,8 @@
     void didExceedActiveMemoryLimit();
     void didExceedInactiveMemoryLimit();
 
+    void checkProcessLocalPortForActivity(const WebCore::MessagePortIdentifier&, CompletionHandler<void(WebCore::MessagePortChannelProvider::HasActivity)>&&);
+
 protected:
     static uint64_t generatePageID();
     WebProcessProxy(WebProcessPool&, WebsiteDataStore&);
@@ -219,6 +225,16 @@
     void shouldTerminate(bool& shouldTerminate);
     void testIncomingSyncIPCMessageWhileWaitingForSyncReply(bool& handled);
 
+    void createNewMessagePortChannel(const WebCore::MessagePortIdentifier& port1, const WebCore::MessagePortIdentifier& port2);
+    void entangleLocalPortInThisProcessToRemote(const WebCore::MessagePortIdentifier& local, const WebCore::MessagePortIdentifier& remote);
+    void messagePortDisentangled(const WebCore::MessagePortIdentifier&);
+    void messagePortClosed(const WebCore::MessagePortIdentifier&);
+    void takeAllMessagesForPort(const WebCore::MessagePortIdentifier&, uint64_t messagesCallbackIdentifier);
+    void postMessageToRemote(WebCore::MessageWithMessagePorts&&, const WebCore::MessagePortIdentifier&);
+    void checkRemotePortForActivity(const WebCore::MessagePortIdentifier, uint64_t callbackIdentifier);
+    void didDeliverMessagePortMessages(uint64_t messageBatchIdentifier);
+    void didCheckProcessLocalPortForActivity(uint64_t callbackIdentifier, bool isLocallyReachable);
+
     // Plugins
 #if ENABLE(NETSCAPE_PLUGIN_API)
     void getPlugins(bool refresh, Vector<WebCore::PluginInfo>& plugins, Vector<WebCore::PluginInfo>& applicationPlugins);
@@ -307,6 +323,10 @@
 #if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
     std::unique_ptr<UserMediaCaptureManagerProxy> m_userMediaCaptureManagerProxy;
 #endif
+
+    HashSet<WebCore::MessagePortIdentifier> m_processEntangledPorts;
+    HashMap<uint64_t, CompletionHandler<void()>> m_messageBatchDeliveryCompletionHandlers;
+    HashMap<uint64_t, CompletionHandler<void(WebCore::MessagePortChannelProvider::HasActivity)>> m_localPortActivityCompletionHandlers;
 };
 
 } // namespace WebKit

Modified: branches/safari-605-branch/Source/WebKit/UIProcess/WebProcessProxy.messages.in (227396 => 227397)


--- branches/safari-605-branch/Source/WebKit/UIProcess/WebProcessProxy.messages.in	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/WebProcessProxy.messages.in	2018-01-23 06:42:29 UTC (rev 227397)
@@ -56,4 +56,14 @@
     DidExceedInactiveMemoryLimitWhileActive()
 
     TestIncomingSyncIPCMessageWhileWaitingForSyncReply() -> (bool handled)
+
+    CreateNewMessagePortChannel(struct WebCore::MessagePortIdentifier port1, struct WebCore::MessagePortIdentifier port2)
+    EntangleLocalPortInThisProcessToRemote(struct WebCore::MessagePortIdentifier local, struct WebCore::MessagePortIdentifier remote)
+    MessagePortDisentangled(struct WebCore::MessagePortIdentifier local)
+    MessagePortClosed(struct WebCore::MessagePortIdentifier local)
+    TakeAllMessagesForPort(struct WebCore::MessagePortIdentifier port, uint64_t messagesCallbackIdentifier)
+    PostMessageToRemote(struct WebCore::MessageWithMessagePorts message, struct WebCore::MessagePortIdentifier remote)
+    CheckRemotePortForActivity(struct WebCore::MessagePortIdentifier port, uint64_t callbackIdentifier)
+    DidDeliverMessagePortMessages(uint64_t messageBatchIdentifier)
+    DidCheckProcessLocalPortForActivity(uint64_t callbackIdentifier, bool isLocallyReachable)
 }

Modified: branches/safari-605-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj (227396 => 227397)


--- branches/safari-605-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2018-01-23 06:42:29 UTC (rev 227397)
@@ -64,6 +64,7 @@
 		076E884E1A13CADF005E90FC /* APIContextMenuClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 076E884D1A13CADF005E90FC /* APIContextMenuClient.h */; };
 		07A5EBBB1C7BA43E00B9CA69 /* WKFrameHandleRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A5EBB91C7BA43E00B9CA69 /* WKFrameHandleRef.cpp */; };
 		07A5EBBC1C7BA43E00B9CA69 /* WKFrameHandleRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 07A5EBBA1C7BA43E00B9CA69 /* WKFrameHandleRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		0EDE85032004E75D00030560 /* WebsitePopUpPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 0EDE85022004E74900030560 /* WebsitePopUpPolicy.h */; };
 		0F08CF521D63C13A00B48DF1 /* WKFormSelectPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F08CF511D63C13A00B48DF1 /* WKFormSelectPicker.h */; };
 		0F08CF541D63C14000B48DF1 /* WKFormSelectPopover.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F08CF531D63C14000B48DF1 /* WKFormSelectPopover.h */; };
 		0F0C365818C051BA00F607D7 /* RemoteLayerTreeHostIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F0C365718C051BA00F607D7 /* RemoteLayerTreeHostIOS.mm */; };
@@ -1018,6 +1019,10 @@
 		513A164D1630A9BF005D7D22 /* NetworkConnectionToWebProcess.h in Headers */ = {isa = PBXBuildFile; fileRef = 513A164A1630A9BF005D7D22 /* NetworkConnectionToWebProcess.h */; };
 		513E462D1AD837560016234A /* WKSharingServicePickerDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 513E462B1AD837560016234A /* WKSharingServicePickerDelegate.h */; };
 		513E462E1AD837560016234A /* WKSharingServicePickerDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 513E462C1AD837560016234A /* WKSharingServicePickerDelegate.mm */; };
+		513FFB8C201459B0002596EA /* UIMessagePortChannelProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 513FFB8A201459A7002596EA /* UIMessagePortChannelProvider.cpp */; };
+		513FFB8D201459B0002596EA /* UIMessagePortChannelProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 513FFB8B201459A7002596EA /* UIMessagePortChannelProvider.h */; };
+		513FFB90201459C6002596EA /* WebMessagePortChannelProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 513FFB8E201459C2002596EA /* WebMessagePortChannelProvider.cpp */; };
+		513FFB91201459C6002596EA /* WebMessagePortChannelProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 513FFB8F201459C2002596EA /* WebMessagePortChannelProvider.h */; };
 		514129941C6428BB0059E714 /* WebIDBConnectionToServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 514129921C6428100059E714 /* WebIDBConnectionToServer.h */; };
 		514129951C6428C20059E714 /* WebIDBConnectionToServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514129911C6428100059E714 /* WebIDBConnectionToServer.cpp */; };
 		514BDED316C98EDD00E4E25E /* StatisticsRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 514BDED216C98EDD00E4E25E /* StatisticsRequest.h */; };
@@ -2319,6 +2324,7 @@
 		07A8F3861E64A8F900B668E8 /* CelestialSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CelestialSPI.h; sourceTree = "<group>"; };
 		0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
 		089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		0EDE85022004E74900030560 /* WebsitePopUpPolicy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebsitePopUpPolicy.h; sourceTree = "<group>"; };
 		0F08CF511D63C13A00B48DF1 /* WKFormSelectPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKFormSelectPicker.h; path = ios/forms/WKFormSelectPicker.h; sourceTree = "<group>"; };
 		0F08CF531D63C14000B48DF1 /* WKFormSelectPopover.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKFormSelectPopover.h; path = ios/forms/WKFormSelectPopover.h; sourceTree = "<group>"; };
 		0F0C365718C051BA00F607D7 /* RemoteLayerTreeHostIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerTreeHostIOS.mm; sourceTree = "<group>"; };
@@ -3371,6 +3377,10 @@
 		513A164B1630A9BF005D7D22 /* NetworkConnectionToWebProcess.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = NetworkConnectionToWebProcess.messages.in; path = NetworkProcess/NetworkConnectionToWebProcess.messages.in; sourceTree = "<group>"; };
 		513E462B1AD837560016234A /* WKSharingServicePickerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKSharingServicePickerDelegate.h; sourceTree = "<group>"; };
 		513E462C1AD837560016234A /* WKSharingServicePickerDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKSharingServicePickerDelegate.mm; sourceTree = "<group>"; };
+		513FFB8A201459A7002596EA /* UIMessagePortChannelProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIMessagePortChannelProvider.cpp; sourceTree = "<group>"; };
+		513FFB8B201459A7002596EA /* UIMessagePortChannelProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIMessagePortChannelProvider.h; sourceTree = "<group>"; };
+		513FFB8E201459C2002596EA /* WebMessagePortChannelProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebMessagePortChannelProvider.cpp; sourceTree = "<group>"; };
+		513FFB8F201459C2002596EA /* WebMessagePortChannelProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebMessagePortChannelProvider.h; sourceTree = "<group>"; };
 		514129911C6428100059E714 /* WebIDBConnectionToServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebIDBConnectionToServer.cpp; sourceTree = "<group>"; };
 		514129921C6428100059E714 /* WebIDBConnectionToServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebIDBConnectionToServer.h; sourceTree = "<group>"; };
 		5143B25E1DDCDFD10014FAC6 /* _WKIconLoadingDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKIconLoadingDelegate.h; sourceTree = "<group>"; };
@@ -5811,6 +5821,7 @@
 				A1FB68261F6E51C100C43F9F /* CrashReporterClientSPI.h */,
 				3754D5441B3A29FD003A4C7F /* NSInvocationSPI.h */,
 				37B47E2C1D64DB76005F4EFF /* objcSPI.h */,
+				0E97D74C200E8FF300BF6643 /* SafeBrowsingSPI.h */,
 			);
 			path = Cocoa;
 			sourceTree = "<group>";
@@ -6947,6 +6958,8 @@
 				BC1BE1DE12D54A410004A228 /* WebGeolocationClient.h */,
 				BC111A59112F4FBB00337BAB /* WebInspectorClient.cpp */,
 				BC032D6D10F4378D0058C15A /* WebInspectorClient.h */,
+				513FFB8E201459C2002596EA /* WebMessagePortChannelProvider.cpp */,
+				513FFB8F201459C2002596EA /* WebMessagePortChannelProvider.h */,
 				31099971146C759B0029DEB9 /* WebNotificationClient.cpp */,
 				31099968146C71F50029DEB9 /* WebNotificationClient.h */,
 				512127C11908239A00DAF35C /* WebPasteboardOverrides.cpp */,
@@ -7102,6 +7115,8 @@
 				1AA417C912C00CCA002BE67B /* TextChecker.h */,
 				1BB417C912C00CCA002BE67B /* TextCheckerCompletion.cpp */,
 				1CC417C912C00CCA002BE67B /* TextCheckerCompletion.h */,
+				513FFB8A201459A7002596EA /* UIMessagePortChannelProvider.cpp */,
+				513FFB8B201459A7002596EA /* UIMessagePortChannelProvider.h */,
 				07297F9C1C17BBEA003F0735 /* UserMediaPermissionCheckProxy.cpp */,
 				07297F9D1C17BBEA003F0735 /* UserMediaPermissionCheckProxy.h */,
 				4A410F3919AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.cpp */,
@@ -8924,6 +8939,7 @@
 				51E6C1641F2935DD00FD3437 /* ResourceLoadStatisticsPersistentStorage.h in Headers */,
 				1A30066E1110F4F70031937C /* ResponsivenessTimer.h in Headers */,
 				410482CE1DDD324F00F006D0 /* RTCNetwork.h in Headers */,
+				0E97D74D200E900400BF6643 /* SafeBrowsingSPI.h in Headers */,
 				BC2D021712AC41CB00E732A3 /* SameDocumentNavigationType.h in Headers */,
 				1AAB4A8D1296F0A20023952F /* SandboxExtension.h in Headers */,
 				E1E552C516AE065F004ED653 /* SandboxInitializationParameters.h in Headers */,
@@ -8975,6 +8991,7 @@
 				515BE1B51D5917FF00DD7C68 /* UIGamepad.h in Headers */,
 				515BE1A91D55293400DD7C68 /* UIGamepadProvider.h in Headers */,
 				CEE4AE2B1A5DCF430002F49B /* UIKitSPI.h in Headers */,
+				513FFB8D201459B0002596EA /* UIMessagePortChannelProvider.h in Headers */,
 				1A64245E12DE29A100CAAE2C /* UpdateInfo.h in Headers */,
 				5C19A5201FD0B29500EEA323 /* URLSchemeTaskParameters.h in Headers */,
 				1AC1336818565B5700F3EC05 /* UserData.h in Headers */,
@@ -9100,6 +9117,7 @@
 				C9CD43981B4B001D00239E33 /* WebMediaSessionMetadata.h in Headers */,
 				2D3EF4431917646300034184 /* WebMemoryPressureHandlerIOS.h in Headers */,
 				909854ED12BC4E18000AD080 /* WebMemorySampler.h in Headers */,
+				513FFB91201459C6002596EA /* WebMessagePortChannelProvider.h in Headers */,
 				BCF69F9A1176CED600471A52 /* WebNavigationDataStore.h in Headers */,
 				7CCCC8FB1A5F50FD008FB0DA /* WebNavigationState.h in Headers */,
 				31A2EC49148997C200810D71 /* WebNotification.h in Headers */,
@@ -10591,6 +10609,7 @@
 				51E399061D6F54C7009C8831 /* UIGamepadProviderCocoa.mm in Sources */,
 				51E949971D76211300EC9EB9 /* UIGamepadProviderIOS.mm in Sources */,
 				515BE1B71D5A94FD00DD7C68 /* UIGamepadProviderMac.mm in Sources */,
+				513FFB8C201459B0002596EA /* UIMessagePortChannelProvider.cpp in Sources */,
 				1A64245F12DE29A100CAAE2C /* UpdateInfo.cpp in Sources */,
 				5C19A5211FD0B29A00EEA323 /* URLSchemeTaskParameters.cpp in Sources */,
 				1AC1336718565B5700F3EC05 /* UserData.cpp in Sources */,
@@ -10743,6 +10762,7 @@
 				2D3EF4421917646300034184 /* WebMemoryPressureHandlerIOS.mm in Sources */,
 				909854EC12BC4E17000AD080 /* WebMemorySampler.cpp in Sources */,
 				909854EE12BC4E18000AD080 /* WebMemorySampler.mac.mm in Sources */,
+				513FFB90201459C6002596EA /* WebMessagePortChannelProvider.cpp in Sources */,
 				C0337DB0127A28D0008FF4F4 /* WebMouseEvent.cpp in Sources */,
 				7CCCC8FA1A5F50FD008FB0DA /* WebNavigationState.cpp in Sources */,
 				31A2EC48148997C200810D71 /* WebNotification.cpp in Sources */,

Added: branches/safari-605-branch/Source/WebKit/WebProcess/WebCoreSupport/WebMessagePortChannelProvider.cpp (0 => 227397)


--- branches/safari-605-branch/Source/WebKit/WebProcess/WebCoreSupport/WebMessagePortChannelProvider.cpp	                        (rev 0)
+++ branches/safari-605-branch/Source/WebKit/WebProcess/WebCoreSupport/WebMessagePortChannelProvider.cpp	2018-01-23 06:42:29 UTC (rev 227397)
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2018 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 "config.h"
+#include "WebMessagePortChannelProvider.h"
+
+#include "WebProcess.h"
+#include "WebProcessProxyMessages.h"
+#include <WebCore/MessagePort.h>
+#include <WebCore/MessagePortIdentifier.h>
+#include <WebCore/MessageWithMessagePorts.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebMessagePortChannelProvider& WebMessagePortChannelProvider::singleton()
+{
+    static WebMessagePortChannelProvider* provider = new WebMessagePortChannelProvider;
+    return *provider;
+}
+
+WebMessagePortChannelProvider::WebMessagePortChannelProvider()
+{
+}
+
+WebMessagePortChannelProvider::~WebMessagePortChannelProvider()
+{
+    ASSERT_NOT_REACHED();
+}
+
+void WebMessagePortChannelProvider::createNewMessagePortChannel(const MessagePortIdentifier& port1, const MessagePortIdentifier& port2)
+{
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::CreateNewMessagePortChannel(port1, port2), 0);
+}
+
+void WebMessagePortChannelProvider::entangleLocalPortInThisProcessToRemote(const MessagePortIdentifier& local, const MessagePortIdentifier& remote)
+{
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::EntangleLocalPortInThisProcessToRemote(local, remote), 0);
+}
+
+void WebMessagePortChannelProvider::messagePortDisentangled(const MessagePortIdentifier& port)
+{
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::MessagePortDisentangled(port), 0);
+}
+
+void WebMessagePortChannelProvider::messagePortClosed(const MessagePortIdentifier& port)
+{
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::MessagePortClosed(port), 0);
+}
+
+void WebMessagePortChannelProvider::takeAllMessagesForPort(const MessagePortIdentifier& port, Function<void(Vector<MessageWithMessagePorts>&&, Function<void()>&&)>&& completionHandler)
+{
+    static std::atomic<uint64_t> currentHandlerIdentifier;
+    uint64_t identifier = ++currentHandlerIdentifier;
+
+    {
+        Locker<Lock> locker(m_takeAllMessagesCallbackLock);
+        auto result = m_takeAllMessagesCallbacks.ensure(identifier, [completionHandler = WTFMove(completionHandler)]() mutable {
+            return WTFMove(completionHandler);
+        });
+        ASSERT_UNUSED(result, result.isNewEntry);
+    }
+
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::TakeAllMessagesForPort(port, identifier), 0);
+}
+
+void WebMessagePortChannelProvider::didTakeAllMessagesForPort(Vector<MessageWithMessagePorts>&& messages, uint64_t messageCallbackIdentifier, uint64_t messageBatchIdentifier)
+{
+    ASSERT(isMainThread());
+
+    Locker<Lock> locker(m_takeAllMessagesCallbackLock);
+    auto callback = m_takeAllMessagesCallbacks.take(messageCallbackIdentifier);
+    locker.unlockEarly();
+
+    ASSERT(callback);
+    callback(WTFMove(messages), [messageBatchIdentifier] {
+        WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::DidDeliverMessagePortMessages(messageBatchIdentifier), 0);
+    });
+}
+
+void WebMessagePortChannelProvider::didCheckRemotePortForActivity(uint64_t callbackIdentifier, bool hasActivity)
+{
+    ASSERT(isMainThread());
+
+    Locker<Lock> locker(m_remoteActivityCallbackLock);
+    auto callback = m_remoteActivityCallbacks.take(callbackIdentifier);
+    locker.unlockEarly();
+
+    ASSERT(callback);
+    callback(hasActivity ? HasActivity::Yes : HasActivity::No);
+}
+
+void WebMessagePortChannelProvider::postMessageToRemote(MessageWithMessagePorts&& message, const MessagePortIdentifier& remoteTarget)
+{
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::PostMessageToRemote(WTFMove(message), remoteTarget), 0);
+}
+
+void WebMessagePortChannelProvider::checkProcessLocalPortForActivity(const MessagePortIdentifier& identifier, uint64_t callbackIdentifier)
+{
+    auto port = MessagePort::existingMessagePortForIdentifier(identifier);
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::DidCheckProcessLocalPortForActivity(callbackIdentifier, port && port->isLocallyReachable()), 0);
+}
+
+void WebMessagePortChannelProvider::checkProcessLocalPortForActivity(const MessagePortIdentifier&, ProcessIdentifier, CompletionHandler<void(HasActivity)>&&)
+{
+    // To be called only in the UI process provider, not the Web process provider.
+    ASSERT_NOT_REACHED();
+}
+
+void WebMessagePortChannelProvider::checkRemotePortForActivity(const MessagePortIdentifier& remoteTarget, CompletionHandler<void(HasActivity)>&& completionHandler)
+{
+    static std::atomic<uint64_t> currentHandlerIdentifier;
+    uint64_t identifier = ++currentHandlerIdentifier;
+
+    {
+        Locker<Lock> locker(m_remoteActivityCallbackLock);
+        auto result = m_remoteActivityCallbacks.ensure(identifier, [completionHandler = WTFMove(completionHandler)]() mutable {
+            return WTFMove(completionHandler);
+        });
+        ASSERT_UNUSED(result, result.isNewEntry);
+    }
+
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::CheckRemotePortForActivity(remoteTarget, identifier), 0);
+}
+
+} // namespace WebKit

Added: branches/safari-605-branch/Source/WebKit/WebProcess/WebCoreSupport/WebMessagePortChannelProvider.h (0 => 227397)


--- branches/safari-605-branch/Source/WebKit/WebProcess/WebCoreSupport/WebMessagePortChannelProvider.h	                        (rev 0)
+++ branches/safari-605-branch/Source/WebKit/WebProcess/WebCoreSupport/WebMessagePortChannelProvider.h	2018-01-23 06:42:29 UTC (rev 227397)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2018 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 <WebCore/MessagePortChannelProvider.h>
+#include <wtf/CompletionHandler.h>
+#include <wtf/HashMap.h>
+
+namespace WebKit {
+
+class WebMessagePortChannelProvider : public WebCore::MessagePortChannelProvider {
+public:
+    static WebMessagePortChannelProvider& singleton();
+
+    void didTakeAllMessagesForPort(Vector<WebCore::MessageWithMessagePorts>&& messages, uint64_t messageCallbackIdentifier, uint64_t messageBatchIdentifier);
+    void checkProcessLocalPortForActivity(const WebCore::MessagePortIdentifier&, uint64_t callbackIdentifier);
+    void didCheckRemotePortForActivity(uint64_t callbackIdentifier, bool hasActivity);
+    
+private:
+    WebMessagePortChannelProvider();
+    ~WebMessagePortChannelProvider() final;
+
+    void createNewMessagePortChannel(const WebCore::MessagePortIdentifier& local, const WebCore::MessagePortIdentifier& remote) final;
+    void entangleLocalPortInThisProcessToRemote(const WebCore::MessagePortIdentifier& local, const WebCore::MessagePortIdentifier& remote) final;
+    void messagePortDisentangled(const WebCore::MessagePortIdentifier& local) final;
+    void messagePortClosed(const WebCore::MessagePortIdentifier& local) final;
+    void takeAllMessagesForPort(const WebCore::MessagePortIdentifier&, Function<void(Vector<WebCore::MessageWithMessagePorts>&&, Function<void()>&&)>&&) final;
+    void postMessageToRemote(WebCore::MessageWithMessagePorts&&, const WebCore::MessagePortIdentifier& remoteTarget) final;
+    void checkProcessLocalPortForActivity(const WebCore::MessagePortIdentifier&, WebCore::ProcessIdentifier, CompletionHandler<void(HasActivity)>&&) final;
+
+    // To be called only in the UI process
+    void checkRemotePortForActivity(const WebCore::MessagePortIdentifier& remoteTarget, CompletionHandler<void(HasActivity)>&& callback) final;
+
+    Lock m_takeAllMessagesCallbackLock;
+    HashMap<uint64_t, CompletionHandler<void(Vector<WebCore::MessageWithMessagePorts>&&, Function<void()>&&)>> m_takeAllMessagesCallbacks;
+    Lock m_remoteActivityCallbackLock;
+    HashMap<uint64_t, CompletionHandler<void(HasActivity)>> m_remoteActivityCallbacks;
+};
+
+} // namespace WebKit

Modified: branches/safari-605-branch/Source/WebKit/WebProcess/WebProcess.cpp (227396 => 227397)


--- branches/safari-605-branch/Source/WebKit/WebProcess/WebProcess.cpp	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebKit/WebProcess/WebProcess.cpp	2018-01-23 06:42:29 UTC (rev 227397)
@@ -57,6 +57,7 @@
 #include "WebLoaderStrategy.h"
 #include "WebMediaKeyStorageManager.h"
 #include "WebMemorySampler.h"
+#include "WebMessagePortChannelProvider.h"
 #include "WebPage.h"
 #include "WebPageGroupProxy.h"
 #include "WebPlatformStrategies.h"
@@ -101,6 +102,7 @@
 #include <WebCore/MainFrame.h>
 #include <WebCore/MemoryCache.h>
 #include <WebCore/MemoryRelease.h>
+#include <WebCore/MessagePort.h>
 #include <WebCore/NetworkStorageSession.h>
 #include <WebCore/Page.h>
 #include <WebCore/PageCache.h>
@@ -216,6 +218,8 @@
 
 void WebProcess::initializeProcess(const ChildProcessInitializationParameters& parameters)
 {
+    MessagePortChannelProvider::setSharedProvider(WebMessagePortChannelProvider::singleton());
+    
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
     // This call is needed when the WebProcess is not running the NSApplication event loop.
     // Otherwise, calling enableSandboxStyleFileQuarantine() will fail.
@@ -1050,6 +1054,28 @@
 {
 }
 
+void WebProcess::didTakeAllMessagesForPort(Vector<MessageWithMessagePorts>&& messages, uint64_t messageCallbackIdentifier, uint64_t messageBatchIdentifier)
+{
+    WebMessagePortChannelProvider::singleton().didTakeAllMessagesForPort(WTFMove(messages), messageCallbackIdentifier, messageBatchIdentifier);
+}
+
+void WebProcess::checkProcessLocalPortForActivity(const MessagePortIdentifier& port, uint64_t callbackIdentifier)
+{
+    WebMessagePortChannelProvider::singleton().checkProcessLocalPortForActivity(port, callbackIdentifier);
+}
+
+void WebProcess::didCheckRemotePortForActivity(uint64_t callbackIdentifier, bool hasActivity)
+{
+    WebMessagePortChannelProvider::singleton().didCheckRemotePortForActivity(callbackIdentifier, hasActivity);
+}
+
+void WebProcess::messagesAvailableForPort(const MessagePortIdentifier& identifier)
+{
+    auto port = MessagePort::existingMessagePortForIdentifier(identifier);
+    if (port)
+        port->messageAvailable();
+}
+
 #if ENABLE(GAMEPAD)
 
 void WebProcess::setInitialGamepads(const Vector<WebKit::GamepadData>& gamepadDatas)

Modified: branches/safari-605-branch/Source/WebKit/WebProcess/WebProcess.h (227396 => 227397)


--- branches/safari-605-branch/Source/WebKit/WebProcess/WebProcess.h	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebKit/WebProcess/WebProcess.h	2018-01-23 06:42:29 UTC (rev 227397)
@@ -68,6 +68,8 @@
 class PageGroup;
 class ResourceRequest;
 class UserGestureToken;
+struct MessagePortIdentifier;
+struct MessageWithMessagePorts;
 struct PluginInfo;
 struct SecurityOriginData;
 struct SoupNetworkProxySettings;
@@ -293,6 +295,10 @@
     void backgroundResponsivenessPing();
 
     void syncIPCMessageWhileWaitingForSyncReplyForTesting();
+    void didTakeAllMessagesForPort(Vector<WebCore::MessageWithMessagePorts>&& messages, uint64_t messageCallbackIdentifier, uint64_t messageBatchIdentifier);
+    void checkProcessLocalPortForActivity(const WebCore::MessagePortIdentifier&, uint64_t callbackIdentifier);
+    void didCheckRemotePortForActivity(uint64_t callbackIdentifier, bool hasActivity);
+    void messagesAvailableForPort(const WebCore::MessagePortIdentifier&);
 
 #if ENABLE(GAMEPAD)
     void setInitialGamepads(const Vector<GamepadData>&);

Modified: branches/safari-605-branch/Source/WebKit/WebProcess/WebProcess.messages.in (227396 => 227397)


--- branches/safari-605-branch/Source/WebKit/WebProcess/WebProcess.messages.in	2018-01-23 05:36:42 UTC (rev 227396)
+++ branches/safari-605-branch/Source/WebKit/WebProcess/WebProcess.messages.in	2018-01-23 06:42:29 UTC (rev 227397)
@@ -119,4 +119,9 @@
     EstablishWorkerContextConnectionToStorageProcess(uint64_t pageID, struct WebKit::WebPreferencesStore store, PAL::SessionID initialSessionID)
     RegisterServiceWorkerClients(PAL::SessionID sessionID)
 #endif
+
+    DidTakeAllMessagesForPort(Vector<WebCore::MessageWithMessagePorts> messages, uint64_t messageCallbackIdentifier, uint64_t messageBatchIdentifier)
+    DidCheckRemotePortForActivity(uint64_t callbackIdentifier, bool hasActivity)
+    CheckProcessLocalPortForActivity(struct WebCore::MessagePortIdentifier port, uint64_t callbackIdentifier)
+    MessagesAvailableForPort(struct WebCore::MessagePortIdentifier port)
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to