Use SocketProvider to create WebSocketChannels
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jul 2016 21:09:14 +0000 (21:09 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jul 2016 21:09:14 +0000 (21:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158776

Patch by Alex Christensen <achristensen@webkit.org> on 2016-07-07
Reviewed by Brent Fulgham.

Source/WebCore:

This patch should have no change in behavior except making an InvalidStateError in
conditions where we should not be able to do networking, like in a detached frame.
It just replaces ThreadableWebSocketChannel::create with SocketProvider::createWebSocketChannel
which does the same thing as ThreadableWebSocketChannel::create for Mac and
Windows WebKit1.  The WebKit2 implementation is the same right now, but it will
be replaced by a proxy that will do the WebSocket operations in the NetworkProcess.

* Modules/websockets/ThreadableWebSocketChannel.cpp: Removed.
* Modules/websockets/ThreadableWebSocketChannel.h:
(WebCore::ThreadableWebSocketChannel::ThreadableWebSocketChannel):
* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::connect):
* Modules/websockets/WebSocketChannel.h:
* Modules/websockets/WorkerThreadableWebSocketChannel.h:
* WebCore.xcodeproj/project.pbxproj:
* dom/Document.cpp:
(WebCore::Document::idbConnectionProxy):
(WebCore::Document::socketProvider):
(WebCore::Document::canNavigate):
* dom/Document.h:
(WebCore::Document::notifyRemovePendingSheetIfNeeded):
* dom/ScriptExecutionContext.h:
* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::overlayPage):
* loader/EmptyClients.cpp:
(WebCore::EmptyEditorClient::registerRedoStep):
(WebCore::EmptySocketProvider::createWebSocketChannel):
* loader/EmptyClients.h:
* page/Page.h:
* page/PageConfiguration.cpp:
(WebCore::PageConfiguration::PageConfiguration):
* page/PageConfiguration.h:
* page/SocketProvider.h:
(WebCore::SocketProvider::~SocketProvider):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::dataChanged):
* workers/DedicatedWorkerGlobalScope.cpp:
(WebCore::DedicatedWorkerGlobalScope::create):
(WebCore::DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope):
* workers/DedicatedWorkerGlobalScope.h:
* workers/DedicatedWorkerThread.cpp:
(WebCore::DedicatedWorkerThread::DedicatedWorkerThread):
(WebCore::DedicatedWorkerThread::createWorkerGlobalScope):
(WebCore::DedicatedWorkerThread::runEventLoop):
* workers/DedicatedWorkerThread.h:
* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::WorkerGlobalScope):
(WebCore::WorkerGlobalScope::disableEval):
(WebCore::WorkerGlobalScope::socketProvider):
(WebCore::WorkerGlobalScope::idbConnectionProxy):
* workers/WorkerGlobalScope.h:
(WebCore::WorkerGlobalScope::script):
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::startWorkerGlobalScope):
* workers/WorkerThread.cpp:
(WebCore::WorkerThreadStartupData::WorkerThreadStartupData):
(WebCore::WorkerThread::WorkerThread):
(WebCore::WorkerThread::idbConnectionProxy):
(WebCore::WorkerThread::socketProvider):
* workers/WorkerThread.h:
(WebCore::WorkerThread::workerGlobalScope):

Source/WebKit:

* PlatformMac.cmake:
* PlatformWin.cmake:
* WebKit.xcodeproj/project.pbxproj:

Source/WebKit/mac:

* Misc/WebSocketProvider.mm: Copied from Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp.
(WebSocketProvider::createWebSocketChannel):
(WebCore::ThreadableWebSocketChannel::create): Deleted.
* Misc/WebSocketProvider.h:
* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):

Source/WebKit/win:

* WebSocketProvider.cpp: Copied from Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp.
(WebSocketProvider::createWebSocketChannel):
(WebCore::ThreadableWebSocketChannel::create): Deleted.
* WebSocketProvider.h:

Source/WebKit2:

* CMakeLists.txt:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/Network/WebSocketProvider.cpp: Copied from Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp.
(WebKit::WebSocketProvider::createWebSocketChannel):
(WebCore::ThreadableWebSocketChannel::create): Deleted.
* WebProcess/Network/WebSocketProvider.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_shouldDispatchFakeMouseMoveEvents):

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

45 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.h
Source/WebCore/Modules/websockets/WebSocket.cpp
Source/WebCore/Modules/websockets/WebSocketChannel.h
Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h
Source/WebCore/PlatformWin.cmake
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/ScriptExecutionContext.h
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/loader/EmptyClients.h
Source/WebCore/page/Page.h
Source/WebCore/page/PageConfiguration.cpp
Source/WebCore/page/PageConfiguration.h
Source/WebCore/page/SocketProvider.h
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp
Source/WebCore/workers/DedicatedWorkerGlobalScope.h
Source/WebCore/workers/DedicatedWorkerThread.cpp
Source/WebCore/workers/DedicatedWorkerThread.h
Source/WebCore/workers/WorkerGlobalScope.cpp
Source/WebCore/workers/WorkerGlobalScope.h
Source/WebCore/workers/WorkerMessagingProxy.cpp
Source/WebCore/workers/WorkerThread.cpp
Source/WebCore/workers/WorkerThread.h
Source/WebKit/ChangeLog
Source/WebKit/PlatformMac.cmake
Source/WebKit/PlatformWin.cmake
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Misc/WebSocketProvider.h
Source/WebKit/mac/Misc/WebSocketProvider.mm [new file with mode: 0644]
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebSocketProvider.cpp [moved from Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp with 79% similarity]
Source/WebKit/win/WebSocketProvider.h
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/Network/WebSocketProvider.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/Network/WebSocketProvider.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 0e54568..b626d7c 100644 (file)
@@ -1034,7 +1034,6 @@ set(WebCore_SOURCES
     Modules/webdatabase/SQLTransactionCoordinator.cpp
     Modules/webdatabase/SQLTransactionStateMachine.cpp
 
-    Modules/websockets/ThreadableWebSocketChannel.cpp
     Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp
     Modules/websockets/WebSocket.cpp
     Modules/websockets/WebSocketChannel.cpp
index d904231..f284e84 100644 (file)
@@ -1,3 +1,72 @@
+2016-07-07  Alex Christensen  <achristensen@webkit.org>
+
+        Use SocketProvider to create WebSocketChannels
+        https://bugs.webkit.org/show_bug.cgi?id=158776
+
+        Reviewed by Brent Fulgham.
+
+        This patch should have no change in behavior except making an InvalidStateError in
+        conditions where we should not be able to do networking, like in a detached frame.
+        It just replaces ThreadableWebSocketChannel::create with SocketProvider::createWebSocketChannel
+        which does the same thing as ThreadableWebSocketChannel::create for Mac and 
+        Windows WebKit1.  The WebKit2 implementation is the same right now, but it will
+        be replaced by a proxy that will do the WebSocket operations in the NetworkProcess.
+
+        * Modules/websockets/ThreadableWebSocketChannel.cpp: Removed.
+        * Modules/websockets/ThreadableWebSocketChannel.h:
+        (WebCore::ThreadableWebSocketChannel::ThreadableWebSocketChannel):
+        * Modules/websockets/WebSocket.cpp:
+        (WebCore::WebSocket::connect):
+        * Modules/websockets/WebSocketChannel.h:
+        * Modules/websockets/WorkerThreadableWebSocketChannel.h:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/Document.cpp:
+        (WebCore::Document::idbConnectionProxy):
+        (WebCore::Document::socketProvider):
+        (WebCore::Document::canNavigate):
+        * dom/Document.h:
+        (WebCore::Document::notifyRemovePendingSheetIfNeeded):
+        * dom/ScriptExecutionContext.h:
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::InspectorOverlay::overlayPage):
+        * loader/EmptyClients.cpp:
+        (WebCore::EmptyEditorClient::registerRedoStep):
+        (WebCore::EmptySocketProvider::createWebSocketChannel):
+        * loader/EmptyClients.h:
+        * page/Page.h:
+        * page/PageConfiguration.cpp:
+        (WebCore::PageConfiguration::PageConfiguration):
+        * page/PageConfiguration.h:
+        * page/SocketProvider.h:
+        (WebCore::SocketProvider::~SocketProvider):
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::dataChanged):
+        * workers/DedicatedWorkerGlobalScope.cpp:
+        (WebCore::DedicatedWorkerGlobalScope::create):
+        (WebCore::DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope):
+        * workers/DedicatedWorkerGlobalScope.h:
+        * workers/DedicatedWorkerThread.cpp:
+        (WebCore::DedicatedWorkerThread::DedicatedWorkerThread):
+        (WebCore::DedicatedWorkerThread::createWorkerGlobalScope):
+        (WebCore::DedicatedWorkerThread::runEventLoop):
+        * workers/DedicatedWorkerThread.h:
+        * workers/WorkerGlobalScope.cpp:
+        (WebCore::WorkerGlobalScope::WorkerGlobalScope):
+        (WebCore::WorkerGlobalScope::disableEval):
+        (WebCore::WorkerGlobalScope::socketProvider):
+        (WebCore::WorkerGlobalScope::idbConnectionProxy):
+        * workers/WorkerGlobalScope.h:
+        (WebCore::WorkerGlobalScope::script):
+        * workers/WorkerMessagingProxy.cpp:
+        (WebCore::WorkerMessagingProxy::startWorkerGlobalScope):
+        * workers/WorkerThread.cpp:
+        (WebCore::WorkerThreadStartupData::WorkerThreadStartupData):
+        (WebCore::WorkerThread::WorkerThread):
+        (WebCore::WorkerThread::idbConnectionProxy):
+        (WebCore::WorkerThread::socketProvider):
+        * workers/WorkerThread.h:
+        (WebCore::WorkerThread::workerGlobalScope):
+
 2016-07-07  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r202905 and r202911.
index 50170cf..9d4c562 100644 (file)
@@ -51,7 +51,6 @@ class ThreadableWebSocketChannel {
     WTF_MAKE_NONCOPYABLE(ThreadableWebSocketChannel);
 public:
     ThreadableWebSocketChannel() { }
-    static Ref<ThreadableWebSocketChannel> create(ScriptExecutionContext&, WebSocketChannelClient&);
 
     enum SendResult {
         SendSuccess,
index 16e5cc3..a8f061d 100644 (file)
@@ -50,6 +50,7 @@
 #include "ScriptController.h"
 #include "ScriptExecutionContext.h"
 #include "SecurityOrigin.h"
+#include "SocketProvider.h"
 #include "ThreadableWebSocketChannel.h"
 #include "WebSocketChannel.h"
 #include <inspector/ScriptCallStack.h>
@@ -250,7 +251,11 @@ void WebSocket::connect(const String& url, const Vector<String>& protocols, Exce
         return;
     }
 
-    m_channel = ThreadableWebSocketChannel::create(*scriptExecutionContext(), *this);
+    if (auto socketProvider = scriptExecutionContext()->socketProvider())
+        m_channel = socketProvider->createWebSocketChannel(*scriptExecutionContext(), *this);
+
+    // Only an EmptySocketProvider can return nullptr, and every ScriptExecutionContext should have a SocketProvider.
+    RELEASE_ASSERT(m_channel);
 
     // FIXME: There is a disagreement about restriction of subprotocols between WebSocket API and hybi-10 protocol
     // draft. The former simply says "only characters in the range U+0021 to U+007E are allowed," while the latter
index 33edac3..383fbc4 100644 (file)
@@ -119,7 +119,7 @@ protected:
     void derefThreadableWebSocketChannel() override { deref(); }
 
 private:
-    WebSocketChannel(Document&, WebSocketChannelClient&);
+    WEBCORE_EXPORT WebSocketChannel(Document&, WebSocketChannelClient&);
 
     bool appendToBuffer(const char* data, size_t len);
     void skipBuffer(size_t len);
index 1b9f94a..c685a49 100644 (file)
@@ -160,7 +160,7 @@ private:
         Peer* m_peer;
     };
 
-    WorkerThreadableWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient&, const String& taskMode);
+    WEBCORE_EXPORT WorkerThreadableWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient&, const String& taskMode);
 
     class WorkerGlobalScopeDidInitializeTask;
 
index 0c34e97..ccb1a57 100644 (file)
@@ -167,6 +167,7 @@ set(WebCore_FORWARDING_HEADERS_DIRECTORIES
     css
     dom
     editing
+    fileapi
     history
     html
     inspector
@@ -184,6 +185,7 @@ set(WebCore_FORWARDING_HEADERS_DIRECTORIES
 
     Modules/geolocation
     Modules/indexeddb
+    Modules/websockets
 
     Modules/indexeddb/client
     Modules/indexeddb/legacy
index b2927f0..d85e164 100644 (file)
                2E4346450F546A8200B0F1BA /* Worker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E4346330F546A8200B0F1BA /* Worker.cpp */; };
                2E4346460F546A8200B0F1BA /* Worker.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E4346340F546A8200B0F1BA /* Worker.h */; };
                2E4346480F546A8200B0F1BA /* WorkerGlobalScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E4346360F546A8200B0F1BA /* WorkerGlobalScope.cpp */; };
-               2E4346490F546A8200B0F1BA /* WorkerGlobalScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E4346370F546A8200B0F1BA /* WorkerGlobalScope.h */; };
+               2E4346490F546A8200B0F1BA /* WorkerGlobalScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E4346370F546A8200B0F1BA /* WorkerGlobalScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2E43464B0F546A8200B0F1BA /* WorkerGlobalScopeProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E4346390F546A8200B0F1BA /* WorkerGlobalScopeProxy.h */; };
                2E43464C0F546A8200B0F1BA /* WorkerLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E43463A0F546A8200B0F1BA /* WorkerLocation.cpp */; };
                2E43464D0F546A8200B0F1BA /* WorkerLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E43463B0F546A8200B0F1BA /* WorkerLocation.h */; };
                2E7582EE12764F260062628B /* JSFileReaderCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E7582ED12764F260062628B /* JSFileReaderCustom.cpp */; };
                2E75841D12779ADA0062628B /* FileReaderLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E75841A12779ADA0062628B /* FileReaderLoader.cpp */; };
                2E75841E12779ADA0062628B /* FileReaderLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E75841B12779ADA0062628B /* FileReaderLoader.h */; };
-               2E75841F12779ADA0062628B /* FileReaderLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E75841C12779ADA0062628B /* FileReaderLoaderClient.h */; };
+               2E75841F12779ADA0062628B /* FileReaderLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E75841C12779ADA0062628B /* FileReaderLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2E94F43B119207DA00B7F75D /* JSFileReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E94F439119207DA00B7F75D /* JSFileReader.cpp */; };
                2E94F43C119207DA00B7F75D /* JSFileReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E94F43A119207DA00B7F75D /* JSFileReader.h */; };
                2E9B5D8F1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E9B5D8E1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4A0FFAA51AAF5EF60062803B /* RealtimeMediaSourceCenterMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A0FFAA31AAF5EF60062803B /* RealtimeMediaSourceCenterMac.cpp */; };
                4A0FFAA61AAF5EF60062803B /* RealtimeMediaSourceCenterMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A0FFAA41AAF5EF60062803B /* RealtimeMediaSourceCenterMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4A38BF5014FE1C0900612512 /* WebSocketDeflateFramer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A38BF4E14FE1C0900612512 /* WebSocketDeflateFramer.cpp */; };
-               4A38BF5114FE1C0900612512 /* WebSocketDeflateFramer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A38BF4F14FE1C0900612512 /* WebSocketDeflateFramer.h */; };
+               4A38BF5114FE1C0900612512 /* WebSocketDeflateFramer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A38BF4F14FE1C0900612512 /* WebSocketDeflateFramer.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4A4F48A916B0DFC000EDBB29 /* DocumentRuleSets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A4F48A716B0DFC000EDBB29 /* DocumentRuleSets.cpp */; };
                4A4F48AA16B0DFC000EDBB29 /* DocumentRuleSets.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A4F48A816B0DFC000EDBB29 /* DocumentRuleSets.h */; };
                4A4F65701AA997F100E38CDD /* RealtimeMediaSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A4F656B1AA997F100E38CDD /* RealtimeMediaSource.cpp */; };
                510D4A34103165EE0049EA54 /* SocketStreamErrorBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 510D4A2E103165EE0049EA54 /* SocketStreamErrorBase.h */; };
                510D4A36103165EE0049EA54 /* SocketStreamHandleBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510D4A30103165EE0049EA54 /* SocketStreamHandleBase.cpp */; };
                510D4A37103165EE0049EA54 /* SocketStreamHandleBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 510D4A31103165EE0049EA54 /* SocketStreamHandleBase.h */; };
-               510D4A38103165EE0049EA54 /* SocketStreamHandleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 510D4A32103165EE0049EA54 /* SocketStreamHandleClient.h */; };
+               510D4A38103165EE0049EA54 /* SocketStreamHandleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 510D4A32103165EE0049EA54 /* SocketStreamHandleClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                511EC1271C50AACA0032F983 /* IDBSerialization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 511EC1251C50AA570032F983 /* IDBSerialization.cpp */; };
                511EC1281C50AACA0032F983 /* IDBSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 511EC1261C50AA570032F983 /* IDBSerialization.h */; };
                511EC12B1C50ABBF0032F983 /* SQLiteIDBTransaction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 511EC1291C50ABBA0032F983 /* SQLiteIDBTransaction.cpp */; };
                97AA3CA5145237CC003E1DA6 /* EventTargetHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AA3CA3145237CC003E1DA6 /* EventTargetHeaders.h */; };
                97AA3CA6145237CC003E1DA6 /* EventTargetInterfaces.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AA3CA4145237CC003E1DA6 /* EventTargetInterfaces.h */; settings = {ATTRIBUTES = (Private, ); }; };
                97AABD1314FA09D5007457AE /* CloseEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABCF814FA09D5007457AE /* CloseEvent.h */; };
-               97AABD1614FA09D5007457AE /* ThreadableWebSocketChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97AABCFB14FA09D5007457AE /* ThreadableWebSocketChannel.cpp */; };
-               97AABD1714FA09D5007457AE /* ThreadableWebSocketChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABCFC14FA09D5007457AE /* ThreadableWebSocketChannel.h */; };
+               97AABD1714FA09D5007457AE /* ThreadableWebSocketChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABCFC14FA09D5007457AE /* ThreadableWebSocketChannel.h */; settings = {ATTRIBUTES = (Private, ); }; };
                97AABD1814FA09D5007457AE /* ThreadableWebSocketChannelClientWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97AABCFD14FA09D5007457AE /* ThreadableWebSocketChannelClientWrapper.cpp */; };
-               97AABD1914FA09D5007457AE /* ThreadableWebSocketChannelClientWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABCFE14FA09D5007457AE /* ThreadableWebSocketChannelClientWrapper.h */; };
+               97AABD1914FA09D5007457AE /* ThreadableWebSocketChannelClientWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABCFE14FA09D5007457AE /* ThreadableWebSocketChannelClientWrapper.h */; settings = {ATTRIBUTES = (Private, ); }; };
                97AABD1A14FA09D5007457AE /* WebSocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97AABCFF14FA09D5007457AE /* WebSocket.cpp */; };
                97AABD1B14FA09D5007457AE /* WebSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0014FA09D5007457AE /* WebSocket.h */; };
                97AABD1D14FA09D5007457AE /* WebSocketChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97AABD0214FA09D5007457AE /* WebSocketChannel.cpp */; };
-               97AABD1E14FA09D5007457AE /* WebSocketChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0314FA09D5007457AE /* WebSocketChannel.h */; };
-               97AABD1F14FA09D5007457AE /* WebSocketChannelClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0414FA09D5007457AE /* WebSocketChannelClient.h */; };
+               97AABD1E14FA09D5007457AE /* WebSocketChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0314FA09D5007457AE /* WebSocketChannel.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               97AABD1F14FA09D5007457AE /* WebSocketChannelClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0414FA09D5007457AE /* WebSocketChannelClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                97AABD2014FA09D5007457AE /* WebSocketDeflater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97AABD0514FA09D5007457AE /* WebSocketDeflater.cpp */; };
-               97AABD2114FA09D5007457AE /* WebSocketDeflater.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0614FA09D5007457AE /* WebSocketDeflater.h */; };
+               97AABD2114FA09D5007457AE /* WebSocketDeflater.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0614FA09D5007457AE /* WebSocketDeflater.h */; settings = {ATTRIBUTES = (Private, ); }; };
                97AABD2214FA09D5007457AE /* WebSocketExtensionDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97AABD0714FA09D5007457AE /* WebSocketExtensionDispatcher.cpp */; };
                97AABD2314FA09D5007457AE /* WebSocketExtensionDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0814FA09D5007457AE /* WebSocketExtensionDispatcher.h */; };
-               97AABD2414FA09D5007457AE /* WebSocketExtensionProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0914FA09D5007457AE /* WebSocketExtensionProcessor.h */; };
-               97AABD2514FA09D5007457AE /* WebSocketFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0A14FA09D5007457AE /* WebSocketFrame.h */; };
+               97AABD2414FA09D5007457AE /* WebSocketExtensionProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0914FA09D5007457AE /* WebSocketExtensionProcessor.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               97AABD2514FA09D5007457AE /* WebSocketFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0A14FA09D5007457AE /* WebSocketFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
                97AABD2614FA09D5007457AE /* WebSocketHandshake.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97AABD0B14FA09D5007457AE /* WebSocketHandshake.cpp */; };
                97AABD2714FA09D5007457AE /* WebSocketHandshake.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0C14FA09D5007457AE /* WebSocketHandshake.h */; };
                97AABD2C14FA09D5007457AE /* WorkerThreadableWebSocketChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97AABD1114FA09D5007457AE /* WorkerThreadableWebSocketChannel.cpp */; };
-               97AABD2D14FA09D5007457AE /* WorkerThreadableWebSocketChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD1214FA09D5007457AE /* WorkerThreadableWebSocketChannel.h */; };
+               97AABD2D14FA09D5007457AE /* WorkerThreadableWebSocketChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD1214FA09D5007457AE /* WorkerThreadableWebSocketChannel.h */; settings = {ATTRIBUTES = (Private, ); }; };
                97B1F02E13B025CA00F5103F /* SharedBufferChunkReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37569E0013AF172C00CDBA8E /* SharedBufferChunkReader.cpp */; };
                97B1F02F13B025D200F5103F /* SharedBufferChunkReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 37569E0213AF172C00CDBA8E /* SharedBufferChunkReader.h */; };
                97B38E27151C4271004622E9 /* DOMWindowNotifications.h in Headers */ = {isa = PBXBuildFile; fileRef = 97B38E24151C4264004622E9 /* DOMWindowNotifications.h */; };
                A3BB59F31457A40D00AC56FE /* DocumentEventQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3BB59F11457A40D00AC56FE /* DocumentEventQueue.cpp */; };
                A3BB59F41457A40D00AC56FE /* DocumentEventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = A3BB59F21457A40D00AC56FE /* DocumentEventQueue.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A3E2643014748991005A8588 /* WorkerEventQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3E2642E14748991005A8588 /* WorkerEventQueue.cpp */; };
-               A3E2643114748991005A8588 /* WorkerEventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = A3E2642F14748991005A8588 /* WorkerEventQueue.h */; };
+               A3E2643114748991005A8588 /* WorkerEventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = A3E2642F14748991005A8588 /* WorkerEventQueue.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A409C985116D0DDD007197BD /* AccessibilityProgressIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = A409C983116D0DDD007197BD /* AccessibilityProgressIndicator.h */; };
                A4226E5A1163D667008B8397 /* JSHTMLProgressElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A4226E591163D667008B8397 /* JSHTMLProgressElement.cpp */; };
                A4226E5C1163D695008B8397 /* JSHTMLProgressElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A4226E5B1163D695008B8397 /* JSHTMLProgressElement.h */; };
                E1A3162D134BC32D007C9A4F /* WebNSAttributedStringExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A3162B134BC32D007C9A4F /* WebNSAttributedStringExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E1A3162E134BC32D007C9A4F /* WebNSAttributedStringExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1A3162C134BC32D007C9A4F /* WebNSAttributedStringExtras.mm */; };
                E1A5F99B0E7EAA2500AF85EA /* JSMessageChannelCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1A5F99A0E7EAA2500AF85EA /* JSMessageChannelCustom.cpp */; };
-               E1A643F20EC0972500779668 /* WorkerScriptController.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A643F10EC0972500779668 /* WorkerScriptController.h */; };
+               E1A643F20EC0972500779668 /* WorkerScriptController.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A643F10EC0972500779668 /* WorkerScriptController.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E1A643FD0EC097A000779668 /* WorkerScriptController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1A643FC0EC097A000779668 /* WorkerScriptController.cpp */; };
                E1A8E56617552B2A007488E7 /* CFURLExtras.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1A8E56417552B2A007488E7 /* CFURLExtras.cpp */; };
                E1A8E56717552B2A007488E7 /* CFURLExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A8E56517552B2A007488E7 /* CFURLExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
                97AA3CA4145237CC003E1DA6 /* EventTargetInterfaces.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventTargetInterfaces.h; sourceTree = "<group>"; };
                97AABCF814FA09D5007457AE /* CloseEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CloseEvent.h; sourceTree = "<group>"; };
                97AABCF914FA09D5007457AE /* CloseEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CloseEvent.idl; sourceTree = "<group>"; };
-               97AABCFB14FA09D5007457AE /* ThreadableWebSocketChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadableWebSocketChannel.cpp; sourceTree = "<group>"; };
                97AABCFC14FA09D5007457AE /* ThreadableWebSocketChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadableWebSocketChannel.h; sourceTree = "<group>"; };
                97AABCFD14FA09D5007457AE /* ThreadableWebSocketChannelClientWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadableWebSocketChannelClientWrapper.cpp; sourceTree = "<group>"; };
                97AABCFE14FA09D5007457AE /* ThreadableWebSocketChannelClientWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadableWebSocketChannelClientWrapper.h; sourceTree = "<group>"; };
                        children = (
                                97AABCF814FA09D5007457AE /* CloseEvent.h */,
                                97AABCF914FA09D5007457AE /* CloseEvent.idl */,
-                               97AABCFB14FA09D5007457AE /* ThreadableWebSocketChannel.cpp */,
                                97AABCFC14FA09D5007457AE /* ThreadableWebSocketChannel.h */,
                                97AABCFD14FA09D5007457AE /* ThreadableWebSocketChannelClientWrapper.cpp */,
                                97AABCFE14FA09D5007457AE /* ThreadableWebSocketChannelClientWrapper.h */,
                                BCE659E90EA92FFA007E4533 /* ThemeMac.mm in Sources */,
                                976D6C94122B8A3D001FD1F7 /* ThreadableBlobRegistry.cpp in Sources */,
                                0B90561E0F257E930095FF6A /* ThreadableLoader.cpp in Sources */,
-                               97AABD1614FA09D5007457AE /* ThreadableWebSocketChannel.cpp in Sources */,
                                97AABD1814FA09D5007457AE /* ThreadableWebSocketChannelClientWrapper.cpp in Sources */,
                                51DF6D800B92A18E00C2DC85 /* ThreadCheck.mm in Sources */,
                                0F6383DD18615B29003E5DB5 /* ThreadedScrollingTree.cpp in Sources */,
index 50b8753..6d277ac 100644 (file)
 #include "SelectorQuery.h"
 #include "Settings.h"
 #include "ShadowRoot.h"
+#include "SocketProvider.h"
 #include "StorageEvent.h"
 #include "StyleProperties.h"
 #include "StyleResolveForDocument.h"
@@ -541,6 +542,9 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsig
     , m_disabledFieldsetElementsCount(0)
     , m_hasInjectedPlugInsScript(false)
     , m_hasStyleWithViewportUnits(false)
+#if ENABLE(WEB_SOCKETS)
+    , m_socketProvider(page() ? &page()->socketProvider() : nullptr)
+#endif
 {
     allDocuments().add(this);
 
@@ -3087,6 +3091,13 @@ IDBClient::IDBConnectionProxy* Document::idbConnectionProxy()
 }
 #endif // ENABLE(INDEXED_DATABASE)
 
+#if ENABLE(WEB_SOCKETS)
+SocketProvider* Document::socketProvider()
+{
+    return m_socketProvider.get();
+}
+#endif
+    
 bool Document::canNavigate(Frame* targetFrame)
 {
     if (!m_frame)
index b764227..4382925 100644 (file)
@@ -665,6 +665,9 @@ public:
 #if ENABLE(INDEXED_DATABASE)
     IDBClient::IDBConnectionProxy* idbConnectionProxy() final;
 #endif
+#if ENABLE(WEB_SOCKETS)
+    SocketProvider* socketProvider() final;
+#endif
 
     bool canNavigate(Frame* targetFrame);
     Frame* findUnsafeParentScrollPropagationBoundary();
@@ -1794,6 +1797,9 @@ private:
 #if ENABLE(INDEXED_DATABASE)
     RefPtr<IDBClient::IDBConnectionProxy> m_idbConnectionProxy;
 #endif
+#if ENABLE(WEB_SOCKETS)
+    RefPtr<SocketProvider> m_socketProvider;
+#endif
 };
 
 inline void Document::notifyRemovePendingSheetIfNeeded()
index cb2e6e8..f196bb8 100644 (file)
@@ -60,6 +60,7 @@ class MessagePort;
 class PublicURLManager;
 class ResourceRequest;
 class SecurityOrigin;
+class SocketProvider;
 class URL;
 
 namespace IDBClient {
@@ -87,6 +88,9 @@ public:
 #if ENABLE(INDEXED_DATABASE)
     virtual IDBClient::IDBConnectionProxy* idbConnectionProxy() = 0;
 #endif
+#if ENABLE(WEB_SOCKETS)
+    virtual SocketProvider* socketProvider() = 0;
+#endif
 
     bool sanitizeScriptError(String& errorMessage, int& lineNumber, int& columnNumber, String& sourceURL, Deprecated::ScriptValue& error, CachedScript* = nullptr);
     void reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, JSC::Exception*, RefPtr<Inspector::ScriptCallStack>&&, CachedScript* = nullptr);
index 8ce3c10..bb76902 100644 (file)
@@ -864,7 +864,7 @@ Page* InspectorOverlay::overlayPage()
     if (m_overlayPage)
         return m_overlayPage.get();
 
-    PageConfiguration pageConfiguration(makeUniqueRef<EmptyEditorClient>(), makeUniqueRef<EmptySocketProvider>());
+    PageConfiguration pageConfiguration(makeUniqueRef<EmptyEditorClient>(), EmptySocketProvider::create());
     fillWithEmptyClients(pageConfiguration);
     m_overlayPage = std::make_unique<Page>(WTFMove(pageConfiguration));
 
index ebfce81..1a8ea19 100644 (file)
@@ -45,6 +45,7 @@
 #include "StorageArea.h"
 #include "StorageNamespace.h"
 #include "StorageNamespaceProvider.h"
+#include "ThreadableWebSocketChannel.h"
 #include "UserContentProvider.h"
 #include <wtf/NeverDestroyed.h>
 
@@ -263,5 +264,10 @@ void EmptyEditorClient::registerUndoStep(PassRefPtr<UndoStep>)
 void EmptyEditorClient::registerRedoStep(PassRefPtr<UndoStep>)
 {
 }
+    
+RefPtr<ThreadableWebSocketChannel> EmptySocketProvider::createWebSocketChannel(ScriptExecutionContext&, WebSocketChannelClient&)
+{
+    return nullptr;
+}
 
 }
index 307f19d..b078ff8 100644 (file)
@@ -644,8 +644,12 @@ class EmptyDiagnosticLoggingClient final : public DiagnosticLoggingClient {
 };
 
 class EmptySocketProvider final : public SocketProvider {
+public:
+    virtual ~EmptySocketProvider() { }
+    static Ref<EmptySocketProvider> create() { return adoptRef(*new EmptySocketProvider); }
+    RefPtr<ThreadableWebSocketChannel> createWebSocketChannel(ScriptExecutionContext&, WebSocketChannelClient&) override;
 };
-    
+
 void fillWithEmptyClients(PageConfiguration&);
 
 }
index 920849c..c0cfa48 100644 (file)
@@ -696,7 +696,7 @@ private:
     unsigned m_lastSpatialNavigationCandidatesCount;
     unsigned m_forbidPromptsDepth;
 
-    UniqueRef<SocketProvider> m_socketProvider;
+    Ref<SocketProvider> m_socketProvider;
     Ref<ApplicationCacheStorage> m_applicationCacheStorage;
     Ref<DatabaseProvider> m_databaseProvider;
     Ref<StorageNamespaceProvider> m_storageNamespaceProvider;
index 9cec846..eef30af 100644 (file)
@@ -38,7 +38,7 @@
 
 namespace WebCore {
 
-PageConfiguration::PageConfiguration(UniqueRef<EditorClient>&& editorClient, UniqueRef<SocketProvider>&& socketProvider)
+PageConfiguration::PageConfiguration(UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider)
     : editorClient(WTFMove(editorClient))
     , socketProvider(WTFMove(socketProvider))
 {
index 7284131..dac2e96 100644 (file)
@@ -57,7 +57,7 @@ class ContextMenuClient;
 class PageConfiguration {
     WTF_MAKE_NONCOPYABLE(PageConfiguration); WTF_MAKE_FAST_ALLOCATED;
 public:
-    WEBCORE_EXPORT PageConfiguration(UniqueRef<EditorClient>&&, UniqueRef<SocketProvider>&&);
+    WEBCORE_EXPORT PageConfiguration(UniqueRef<EditorClient>&&, Ref<SocketProvider>&&);
     WEBCORE_EXPORT ~PageConfiguration();
 
     AlternativeTextClient* alternativeTextClient { nullptr };
@@ -66,7 +66,7 @@ public:
     ContextMenuClient* contextMenuClient { nullptr };
 #endif
     UniqueRef<EditorClient> editorClient;
-    UniqueRef<SocketProvider> socketProvider;
+    Ref<SocketProvider> socketProvider;
     DragClient* dragClient { nullptr };
     InspectorClient* inspectorClient { nullptr };
 #if ENABLE(APPLE_PAY)
index 7116821..6111aba 100644 (file)
 
 #pragma once
 
+#include <wtf/RefPtr.h>
+#include <wtf/ThreadSafeRefCounted.h>
+
 namespace WebCore {
 
-class SocketProvider {
+class ScriptExecutionContext;
+class ThreadableWebSocketChannel;
+class WebSocketChannelClient;
+
+class SocketProvider : public ThreadSafeRefCounted<SocketProvider> {
 public:
+    virtual RefPtr<ThreadableWebSocketChannel> createWebSocketChannel(ScriptExecutionContext&, WebSocketChannelClient&) = 0;
     virtual ~SocketProvider() { };
 };
 
index 51d9e00..99a2b1f 100644 (file)
@@ -380,7 +380,7 @@ bool SVGImage::dataChanged(bool allDataReceived)
         return true;
 
     if (allDataReceived) {
-        PageConfiguration pageConfiguration(makeUniqueRef<EmptyEditorClient>(), makeUniqueRef<EmptySocketProvider>());
+        PageConfiguration pageConfiguration(makeUniqueRef<EmptyEditorClient>(), EmptySocketProvider::create());
         fillWithEmptyClients(pageConfiguration);
         m_chromeClient = std::make_unique<SVGImageChromeClient>(this);
         pageConfiguration.chromeClient = m_chromeClient.get();
index d494d52..2922bb6 100644 (file)
 
 namespace WebCore {
 
-Ref<DedicatedWorkerGlobalScope> DedicatedWorkerGlobalScope::create(const URL& url, const String& userAgent, DedicatedWorkerThread& thread, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy* connectionProxy)
+Ref<DedicatedWorkerGlobalScope> DedicatedWorkerGlobalScope::create(const URL& url, const String& userAgent, DedicatedWorkerThread& thread, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider)
 {
-    Ref<DedicatedWorkerGlobalScope> context = adoptRef(*new DedicatedWorkerGlobalScope(url, userAgent, thread, shouldBypassMainWorldContentSecurityPolicy, topOrigin, connectionProxy));
+    Ref<DedicatedWorkerGlobalScope> context = adoptRef(*new DedicatedWorkerGlobalScope(url, userAgent, thread, shouldBypassMainWorldContentSecurityPolicy, topOrigin, connectionProxy, socketProvider));
     if (!shouldBypassMainWorldContentSecurityPolicy)
         context->applyContentSecurityPolicyResponseHeaders(contentSecurityPolicyResponseHeaders);
     return context;
 }
 
-DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(const URL& url, const String& userAgent, DedicatedWorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy* connectionProxy)
-    : WorkerGlobalScope(url, userAgent, thread, shouldBypassMainWorldContentSecurityPolicy, topOrigin, connectionProxy)
+DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(const URL& url, const String& userAgent, DedicatedWorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider)
+    : WorkerGlobalScope(url, userAgent, thread, shouldBypassMainWorldContentSecurityPolicy, topOrigin, connectionProxy, socketProvider)
 {
 }
 
index 5dd8fb0..6f4d774 100644 (file)
@@ -42,7 +42,7 @@ namespace WebCore {
     class DedicatedWorkerGlobalScope : public WorkerGlobalScope {
     public:
         typedef WorkerGlobalScope Base;
-        static Ref<DedicatedWorkerGlobalScope> create(const URL&, const String& userAgent, DedicatedWorkerThread&, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy*);
+        static Ref<DedicatedWorkerGlobalScope> create(const URL&, const String& userAgent, DedicatedWorkerThread&, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*);
         virtual ~DedicatedWorkerGlobalScope();
 
         bool isDedicatedWorkerGlobalScope() const override { return true; }
@@ -60,7 +60,7 @@ namespace WebCore {
         DedicatedWorkerThread& thread();
 
     private:
-        DedicatedWorkerGlobalScope(const URL&, const String& userAgent, DedicatedWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy*);
+        DedicatedWorkerGlobalScope(const URL&, const String& userAgent, DedicatedWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*);
     };
 
 } // namespace WebCore
index 63fb8de..a750abe 100644 (file)
@@ -38,8 +38,8 @@
 
 namespace WebCore {
 
-DedicatedWorkerThread::DedicatedWorkerThread(const URL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin, IDBClient::IDBConnectionProxy* connectionProxy)
-    : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, connectionProxy)
+DedicatedWorkerThread::DedicatedWorkerThread(const URL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider)
+    : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, connectionProxy, socketProvider)
     , m_workerObjectProxy(workerObjectProxy)
 {
 }
@@ -50,7 +50,7 @@ DedicatedWorkerThread::~DedicatedWorkerThread()
 
 Ref<WorkerGlobalScope> DedicatedWorkerThread::createWorkerGlobalScope(const URL& url, const String& userAgent, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin)
 {
-    return DedicatedWorkerGlobalScope::create(url, userAgent, *this, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, idbConnectionProxy());
+    return DedicatedWorkerGlobalScope::create(url, userAgent, *this, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, idbConnectionProxy(), socketProvider());
 }
 
 void DedicatedWorkerThread::runEventLoop()
index a782b30..80a4a63 100644 (file)
@@ -53,7 +53,7 @@ protected:
     void runEventLoop() override;
 
 private:
-    DedicatedWorkerThread(const URL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin, IDBClient::IDBConnectionProxy*);
+    DedicatedWorkerThread(const URL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*);
 
     WorkerObjectProxy& m_workerObjectProxy;
 };
index 6ae96a4..0fbd994 100644 (file)
@@ -43,6 +43,7 @@
 #include "ScriptSourceCode.h"
 #include "SecurityOrigin.h"
 #include "SecurityOriginPolicy.h"
+#include "SocketProvider.h"
 #include "URL.h"
 #include "WorkerLocation.h"
 #include "WorkerNavigator.h"
@@ -63,7 +64,7 @@ using namespace Inspector;
 
 namespace WebCore {
 
-WorkerGlobalScope::WorkerGlobalScope(const URL& url, const String& userAgent, WorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy* connectionProxy)
+WorkerGlobalScope::WorkerGlobalScope(const URL& url, const String& userAgent, WorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, RefPtr<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider)
     : m_url(url)
     , m_userAgent(userAgent)
     , m_script(std::make_unique<WorkerScriptController>(this))
@@ -75,6 +76,9 @@ WorkerGlobalScope::WorkerGlobalScope(const URL& url, const String& userAgent, Wo
 #if ENABLE(INDEXED_DATABASE)
     , m_connectionProxy(connectionProxy)
 #endif
+#if ENABLE(WEB_SOCKETS)
+    , m_socketProvider(socketProvider)
+#endif
 {
 #if !ENABLE(INDEXED_DATABASE)
     UNUSED_PARAM(connectionProxy);
@@ -123,6 +127,13 @@ void WorkerGlobalScope::disableEval(const String& errorMessage)
     m_script->disableEval(errorMessage);
 }
 
+#if ENABLE(WEB_SOCKETS)
+SocketProvider* WorkerGlobalScope::socketProvider()
+{
+    return m_socketProvider.get();
+}
+#endif
+
 #if ENABLE(INDEXED_DATABASE)
 IDBClient::IDBConnectionProxy* WorkerGlobalScope::idbConnectionProxy()
 {
index bba9096..a626777 100644 (file)
@@ -36,7 +36,6 @@
 #include <memory>
 #include <wtf/Assertions.h>
 #include <wtf/HashMap.h>
-#include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 #include <wtf/TypeCasts.h>
@@ -81,6 +80,10 @@ public:
     void stopIndexedDatabase();
 #endif
 
+#if ENABLE(WEB_SOCKETS)
+    SocketProvider* socketProvider() final;
+#endif
+
     bool shouldBypassMainWorldContentSecurityPolicy() const final { return m_shouldBypassMainWorldContentSecurityPolicy; }
 
     WorkerScriptController* script() { return m_script.get(); }
@@ -147,7 +150,7 @@ public:
 #endif
 
 protected:
-    WorkerGlobalScope(const URL&, const String& userAgent, WorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin, IDBClient::IDBConnectionProxy*);
+    WorkerGlobalScope(const URL&, const String& userAgent, WorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, RefPtr<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*);
     void applyContentSecurityPolicyResponseHeaders(const ContentSecurityPolicyResponseHeaders&);
 
     void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, RefPtr<Inspector::ScriptCallStack>&&) override;
@@ -188,6 +191,9 @@ private:
 #if ENABLE(INDEXED_DATABASE)
     RefPtr<IDBClient::IDBConnectionProxy> m_connectionProxy;
 #endif
+#if ENABLE(WEB_SOCKETS)
+    RefPtr<SocketProvider> m_socketProvider;
+#endif
 };
 
 } // namespace WebCore
index 89c335f..177fd18 100644 (file)
@@ -79,11 +79,19 @@ void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const St
     Document& document = downcast<Document>(*m_scriptExecutionContext);
 
 #if ENABLE(INDEXED_DATABASE)
-    RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, sourceCode, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin(), document.idbConnectionProxy());
+    IDBClient::IDBConnectionProxy* proxy = document.idbConnectionProxy();
 #else
-    RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, sourceCode, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin(), nullptr);
+    IDBClient::IDBConnectionProxy* proxy = nullptr;
 #endif
 
+#if ENABLE(WEB_SOCKETS)
+    SocketProvider* socketProvider = document.socketProvider();
+#else
+    SocketProvider* socketProvider = nullptr;
+#endif
+
+    RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, sourceCode, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin(), proxy, socketProvider);
+
     workerThreadCreated(thread);
     thread->start();
 }
index f6f5a4d..f4cd8e7 100644 (file)
@@ -33,6 +33,7 @@
 #include "IDBConnectionProxy.h"
 #include "ScriptSourceCode.h"
 #include "SecurityOrigin.h"
+#include "SocketProvider.h"
 #include "ThreadGlobalData.h"
 #include "URL.h"
 #include <utility>
@@ -93,7 +94,7 @@ WorkerThreadStartupData::WorkerThreadStartupData(const URL& scriptURL, const Str
 {
 }
 
-WorkerThread::WorkerThread(const URL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin, IDBClient::IDBConnectionProxy* connectionProxy)
+WorkerThread::WorkerThread(const URL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider)
     : m_threadID(0)
     , m_workerLoaderProxy(workerLoaderProxy)
     , m_workerReportingProxy(workerReportingProxy)
@@ -104,6 +105,9 @@ WorkerThread::WorkerThread(const URL& scriptURL, const String& userAgent, const
 #if ENABLE(INDEXED_DATABASE)
     , m_idbConnectionProxy(connectionProxy)
 #endif
+#if ENABLE(WEB_SOCKETS)
+    , m_socketProvider(socketProvider)
+#endif
 {
 #if !ENABLE(INDEXED_DATABASE)
     UNUSED_PARAM(connectionProxy);
@@ -253,4 +257,13 @@ IDBClient::IDBConnectionProxy* WorkerThread::idbConnectionProxy()
 #endif
 }
 
+SocketProvider* WorkerThread::socketProvider()
+{
+#if ENABLE(WEB_SOCKETS)
+    return m_socketProvider.get();
+#else
+    return nullptr;
+#endif
+}
+
 } // namespace WebCore
index 0bccb43..7d4ee55 100644 (file)
@@ -38,6 +38,7 @@ class ContentSecurityPolicyResponseHeaders;
 class URL;
 class NotificationClient;
 class SecurityOrigin;
+class SocketProvider;
 class WorkerGlobalScope;
 class WorkerLoaderProxy;
 class WorkerReportingProxy;
@@ -72,7 +73,7 @@ public:
 #endif
 
 protected:
-    WorkerThread(const URL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin, IDBClient::IDBConnectionProxy*);
+    WorkerThread(const URL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin* topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*);
 
     // Factory method for creating a new worker context for the thread.
     virtual Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, const String& userAgent, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, PassRefPtr<SecurityOrigin> topOrigin) = 0;
@@ -83,6 +84,7 @@ protected:
     WorkerGlobalScope* workerGlobalScope() { return m_workerGlobalScope.get(); }
 
     IDBClient::IDBConnectionProxy* idbConnectionProxy();
+    SocketProvider* socketProvider();
 
 private:
     // Static function executed as the core routine on the new thread. Passed a pointer to a WorkerThread object.
@@ -106,6 +108,9 @@ private:
 #if ENABLE(INDEXED_DATABASE)
     RefPtr<IDBClient::IDBConnectionProxy> m_idbConnectionProxy;
 #endif
+#if ENABLE(WEB_SOCKETS)
+    RefPtr<SocketProvider> m_socketProvider;
+#endif
 };
 
 } // namespace WebCore
index 6440b0e..123504c 100644 (file)
@@ -1,3 +1,14 @@
+2016-07-07  Alex Christensen  <achristensen@webkit.org>
+
+        Use SocketProvider to create WebSocketChannels
+        https://bugs.webkit.org/show_bug.cgi?id=158776
+
+        Reviewed by Brent Fulgham.
+
+        * PlatformMac.cmake:
+        * PlatformWin.cmake:
+        * WebKit.xcodeproj/project.pbxproj:
+
 2016-07-03  Per Arne Vollan  <pvollan@apple.com>
 
         [Win] DLLs are missing version information.
index c4e8443..c603264 100644 (file)
@@ -114,6 +114,7 @@ list(APPEND WebKit_SOURCES
     mac/Misc/WebNSViewExtras.m
     mac/Misc/WebNSWindowExtras.m
     mac/Misc/WebSharingServicePickerController.mm
+    mac/Misc/WebSocketProvider.mm
     mac/Misc/WebStringTruncator.mm
     mac/Misc/WebUserContentURLPattern.mm
 
index 3f6e594..26e4268 100644 (file)
@@ -195,6 +195,7 @@ list(APPEND WebKit_SOURCES_Classes
     win/WebScriptWorld.cpp
     win/WebSecurityOrigin.cpp
     win/WebSerializedJSValue.cpp
+    win/WebSocketProvider.cpp
     win/WebTextRenderer.cpp
     win/WebURLAuthenticationChallenge.cpp
     win/WebURLAuthenticationChallengeSender.cpp
index a70a77b..2effad9 100644 (file)
                598AD9281201CF3200ABAE4E /* WebDeviceOrientationProviderMock.mm in Sources */ = {isa = PBXBuildFile; fileRef = 598AD9271201CF3200ABAE4E /* WebDeviceOrientationProviderMock.mm */; };
                598AD92A1201CF3B00ABAE4E /* WebDeviceOrientationProviderMockInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 598AD9291201CF3B00ABAE4E /* WebDeviceOrientationProviderMockInternal.h */; };
                598ADA461202275000ABAE4E /* WebDeviceOrientationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 598ADA451202275000ABAE4E /* WebDeviceOrientationProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               5C7706701D111B020012700F /* WebSocketProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C77066F1D111B020012700F /* WebSocketProvider.mm */; };
+               5C7706721D111B220012700F /* QuickDrawCompatibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C7706711D111B220012700F /* QuickDrawCompatibility.h */; };
                5C7C88DA1D0F3BF2009D2F6D /* WebSocketProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C7C88D91D0F3BF2009D2F6D /* WebSocketProvider.h */; };
                5D7BF8140C2A1D90008CE06D /* WebInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D7BF8120C2A1D90008CE06D /* WebInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5D7BF8150C2A1D90008CE06D /* WebInspector.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5D7BF8130C2A1D90008CE06D /* WebInspector.mm */; };
                598AD9271201CF3200ABAE4E /* WebDeviceOrientationProviderMock.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebDeviceOrientationProviderMock.mm; sourceTree = "<group>"; };
                598AD9291201CF3B00ABAE4E /* WebDeviceOrientationProviderMockInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDeviceOrientationProviderMockInternal.h; sourceTree = "<group>"; };
                598ADA451202275000ABAE4E /* WebDeviceOrientationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDeviceOrientationProvider.h; sourceTree = "<group>"; };
+               5C77066F1D111B020012700F /* WebSocketProvider.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSocketProvider.mm; sourceTree = "<group>"; };
+               5C7706711D111B220012700F /* QuickDrawCompatibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuickDrawCompatibility.h; sourceTree = "<group>"; };
                5C7C88D91D0F3BF2009D2F6D /* WebSocketProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocketProvider.h; sourceTree = "<group>"; };
                5D7BF8120C2A1D90008CE06D /* WebInspector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebInspector.h; sourceTree = "<group>"; };
                5D7BF8130C2A1D90008CE06D /* WebInspector.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebInspector.mm; sourceTree = "<group>"; };
                254DC334016E1D3F0ECA149E /* Misc */ = {
                        isa = PBXGroup;
                        children = (
+                               5C7706711D111B220012700F /* QuickDrawCompatibility.h */,
+                               5C77066F1D111B020012700F /* WebSocketProvider.mm */,
                                5C7C88D91D0F3BF2009D2F6D /* WebSocketProvider.h */,
                                A10C1D2018202FAF0036883A /* ios */,
                                1CCFFD120B1F81F2002EE926 /* OldWebAssertions.c */,
                                939810150824BF01008DF038 /* WebURLsWithTitles.h in Headers */,
                                C0C5B3EE1177A4A0002B0AEF /* WebUserContentURLPattern.h in Headers */,
                                070F549B17F1E42B00169E04 /* WebUserMediaClient.h in Headers */,
+                               5C7706721D111B220012700F /* QuickDrawCompatibility.h in Headers */,
                                939810700824BF01008DF038 /* WebView.h in Headers */,
                                BC2E464D0FD8A96800A9D9DE /* WebViewData.h in Headers */,
                                1430C12D1B2C5DF700DEA01D /* WebViewGroup.h in Headers */,
                                1C0D40880AC1C8F40009C113 /* WebKitVersionChecks.m in Sources */,
                                ED5B9524111B725A00472298 /* WebLocalizableStrings.mm in Sources */,
                                BC42D34D131ED3880075FA4B /* WebLocalizableStringsInternal.mm in Sources */,
+                               5C7706701D111B020012700F /* WebSocketProvider.mm in Sources */,
                                072E5F461ABF88750003B164 /* WebMediaPlaybackTargetPicker.mm in Sources */,
                                A10C1D731820300E0036883A /* WebMIMETypeRegistry.mm in Sources */,
                                5185F62810712B97007AA393 /* WebNavigationData.mm in Sources */,
index 1238efd..88ef96b 100644 (file)
@@ -1,3 +1,18 @@
+2016-07-07  Alex Christensen  <achristensen@webkit.org>
+
+        Use SocketProvider to create WebSocketChannels
+        https://bugs.webkit.org/show_bug.cgi?id=158776
+
+        Reviewed by Brent Fulgham.
+
+        * Misc/WebSocketProvider.mm: Copied from Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp.
+        (WebSocketProvider::createWebSocketChannel):
+        (WebCore::ThreadableWebSocketChannel::create): Deleted.
+        * Misc/WebSocketProvider.h:
+        * WebView/WebView.mm:
+        (-[WebView _commonInitializationWithFrameName:groupName:]):
+        (-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):
+
 2016-07-06  Benjamin Poulain  <bpoulain@apple.com>
 
         [JSC] Unify how we throw TypeError from C++
index c6c087f..47301e4 100644 (file)
 
 #pragma once
 
-#include <WebCore/SocketProvider.h>
+#import <WebCore/SocketProvider.h>
 
 class WebSocketProvider final : public WebCore::SocketProvider {
+public:
+    static Ref<WebSocketProvider> create() { return adoptRef(*new WebSocketProvider); }
+    RefPtr<WebCore::ThreadableWebSocketChannel> createWebSocketChannel(WebCore::ScriptExecutionContext&, WebCore::WebSocketChannelClient&) override;
+    virtual ~WebSocketProvider() { }
 };
diff --git a/Source/WebKit/mac/Misc/WebSocketProvider.mm b/Source/WebKit/mac/Misc/WebSocketProvider.mm
new file mode 100644 (file)
index 0000000..6981e27
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2009, 2012 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 "WebSocketProvider.h"
+
+#if ENABLE(WEB_SOCKETS)
+
+#import <WebCore/Document.h>
+#import <WebCore/ScriptExecutionContext.h>
+#import <WebCore/ThreadableWebSocketChannelClientWrapper.h>
+#import <WebCore/WebSocketChannel.h>
+#import <WebCore/WebSocketChannelClient.h>
+#import <WebCore/WorkerGlobalScope.h>
+#import <WebCore/WorkerRunLoop.h>
+#import <WebCore/WorkerThread.h>
+#import <WebCore/WorkerThreadableWebSocketChannel.h>
+#import <wtf/text/StringBuilder.h>
+
+using namespace WebCore;
+
+static const char webSocketChannelMode[] = "webSocketChannelMode";
+
+RefPtr<ThreadableWebSocketChannel> WebSocketProvider::createWebSocketChannel(ScriptExecutionContext& context, WebSocketChannelClient& client)
+{
+    if (is<WorkerGlobalScope>(context)) {
+        WorkerGlobalScope& workerGlobalScope = downcast<WorkerGlobalScope>(context);
+        WorkerRunLoop& runLoop = workerGlobalScope.thread().runLoop();
+        StringBuilder mode;
+        mode.appendLiteral(webSocketChannelMode);
+        mode.appendNumber(runLoop.createUniqueId());
+        return WorkerThreadableWebSocketChannel::create(workerGlobalScope, client, mode.toString());
+    }
+
+    return WebSocketChannel::create(downcast<Document>(context), client);
+}
+
+#endif // ENABLE(WEB_SOCKETS)
index 7b52c33..8add540 100644 (file)
@@ -996,7 +996,7 @@ static void WebKitInitializeGamepadProviderIfNecessary()
     _private->group = WebViewGroup::getOrCreate(groupName, _private->preferences._localStorageDatabasePath);
     _private->group->addWebView(self);
 
-    PageConfiguration pageConfiguration(makeUniqueRef<WebEditorClient>(self), makeUniqueRef<WebSocketProvider>());
+    PageConfiguration pageConfiguration(makeUniqueRef<WebEditorClient>(self), WebSocketProvider::create());
 #if !PLATFORM(IOS)
     pageConfiguration.chromeClient = new WebChromeClient(self);
     pageConfiguration.contextMenuClient = new WebContextMenuClient(self);
@@ -1246,7 +1246,7 @@ static void WebKitInitializeGamepadProviderIfNecessary()
     _private->group = WebViewGroup::getOrCreate(groupName, _private->preferences._localStorageDatabasePath);
     _private->group->addWebView(self);
 
-    PageConfiguration pageConfiguration(makeUniqueRef<WebEditorClient>(self), makeUniqueRef<WebSocketProvider>());
+    PageConfiguration pageConfiguration(makeUniqueRef<WebEditorClient>(self), WebSocketProvider::create());
     pageConfiguration.chromeClient = new WebChromeClientIOS(self);
 #if ENABLE(DRAG_SUPPORT)
     pageConfiguration.dragClient = new WebDragClient(self);
index ab6190c..82b1281 100644 (file)
@@ -1,3 +1,15 @@
+2016-07-07  Alex Christensen  <achristensen@webkit.org>
+
+        Use SocketProvider to create WebSocketChannels
+        https://bugs.webkit.org/show_bug.cgi?id=158776
+
+        Reviewed by Brent Fulgham.
+
+        * WebSocketProvider.cpp: Copied from Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp.
+        (WebSocketProvider::createWebSocketChannel):
+        (WebCore::ThreadableWebSocketChannel::create): Deleted.
+        * WebSocketProvider.h:
+
 2016-07-06  Per Arne Vollan  <pvollan@apple.com>
 
         [Win] Add null pointer check in gesture handling.
  */
 
 #include "config.h"
+#include "WebSocketProvider.h"
 
 #if ENABLE(WEB_SOCKETS)
 
-#include "ThreadableWebSocketChannel.h"
-
-#include "Document.h"
-#include "ScriptExecutionContext.h"
-#include "ThreadableWebSocketChannelClientWrapper.h"
-#include "WebSocketChannel.h"
-#include "WebSocketChannelClient.h"
-#include "WorkerGlobalScope.h"
-#include "WorkerRunLoop.h"
-#include "WorkerThread.h"
-#include "WorkerThreadableWebSocketChannel.h"
+#include <WebCore/Document.h>
+#include <WebCore/ScriptExecutionContext.h>
+#include <WebCore/ThreadableWebSocketChannelClientWrapper.h>
+#include <WebCore/WebSocketChannel.h>
+#include <WebCore/WebSocketChannelClient.h>
+#include <WebCore/WorkerGlobalScope.h>
+#include <WebCore/WorkerRunLoop.h>
+#include <WebCore/WorkerThread.h>
+#include <WebCore/WorkerThreadableWebSocketChannel.h>
 #include <wtf/text/StringBuilder.h>
 
-namespace WebCore {
+using namespace WebCore;
 
 static const char webSocketChannelMode[] = "webSocketChannelMode";
 
-Ref<ThreadableWebSocketChannel> ThreadableWebSocketChannel::create(ScriptExecutionContext& context, WebSocketChannelClient& client)
+RefPtr<ThreadableWebSocketChannel> WebSocketProvider::createWebSocketChannel(ScriptExecutionContext& context, WebSocketChannelClient& client)
 {
     if (is<WorkerGlobalScope>(context)) {
         WorkerGlobalScope& workerGlobalScope = downcast<WorkerGlobalScope>(context);
@@ -63,6 +62,4 @@ Ref<ThreadableWebSocketChannel> ThreadableWebSocketChannel::create(ScriptExecuti
     return WebSocketChannel::create(downcast<Document>(context), client);
 }
 
-} // namespace WebCore
-
 #endif // ENABLE(WEB_SOCKETS)
index c6c087f..d6c324a 100644 (file)
@@ -28,4 +28,8 @@
 #include <WebCore/SocketProvider.h>
 
 class WebSocketProvider final : public WebCore::SocketProvider {
+public:
+    static Ref<WebSocketProvider> create() { return adoptRef(*new WebSocketProvider); }
+    RefPtr<WebCore::ThreadableWebSocketChannel> createWebSocketChannel(WebCore::ScriptExecutionContext&, WebCore::WebSocketChannelClient&) override;
+    virtual ~WebSocketProvider() { }
 };
index 54620b7..03ecc91 100644 (file)
@@ -133,6 +133,7 @@ set(WebKit2_INCLUDE_DIRECTORIES
     "${WEBCORE_DIR}/svg"
     "${WEBCORE_DIR}/svg/graphics"
     "${WEBCORE_DIR}/svg/properties"
+    "${WEBCORE_DIR}/workers"
     "${JAVASCRIPTCORE_DIR}"
     "${JAVASCRIPTCORE_DIR}/ForwardingHeaders"
     "${JAVASCRIPTCORE_DIR}/API"
@@ -573,6 +574,7 @@ set(WebKit2_SOURCES
     WebProcess/Network/NetworkProcessConnection.cpp
     WebProcess/Network/WebLoaderStrategy.cpp
     WebProcess/Network/WebResourceLoader.cpp
+    WebProcess/Network/WebSocketProvider.cpp
 
     WebProcess/Notifications/NotificationPermissionRequestManager.cpp
     WebProcess/Notifications/WebNotificationManager.cpp
index 7ee6fda..72a27b2 100644 (file)
@@ -1,3 +1,19 @@
+2016-07-07  Alex Christensen  <achristensen@webkit.org>
+
+        Use SocketProvider to create WebSocketChannels
+        https://bugs.webkit.org/show_bug.cgi?id=158776
+
+        Reviewed by Brent Fulgham.
+
+        * CMakeLists.txt:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/Network/WebSocketProvider.cpp: Copied from Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp.
+        (WebKit::WebSocketProvider::createWebSocketChannel):
+        (WebCore::ThreadableWebSocketChannel::create): Deleted.
+        * WebProcess/Network/WebSocketProvider.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_shouldDispatchFakeMouseMoveEvents):
+
 2016-07-07  Antoine Quint  <graouts@apple.com>
 
         <img> with a wide gamut PDF does not display using a wide gamut color space
index ff4a87b..9ff63a2 100644 (file)
                5C20CB9D1BB0DCFA00895BB1 /* NetworkSessionCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C20CB9B1BB0DCD200895BB1 /* NetworkSessionCocoa.mm */; };
                5C20CBA01BB1ECD800895BB1 /* NetworkSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C20CB9E1BB0DD1800895BB1 /* NetworkSession.h */; };
                5C298DA01C3DF02100470AFE /* PendingDownload.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C298D9E1C3DEF2900470AFE /* PendingDownload.h */; };
+               5C7706741D1138380012700F /* WebSocketProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C7706731D111D8B0012700F /* WebSocketProvider.cpp */; };
                5C85C7881C3F23CE0061A4FA /* PendingDownload.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C85C7861C3F23C50061A4FA /* PendingDownload.cpp */; };
                5CBC9B8D1C65279C00A8FDCF /* NetworkDataTaskCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CBC9B8B1C65257300A8FDCF /* NetworkDataTaskCocoa.mm */; };
                5CBC9B8E1C652CA000A8FDCF /* NetworkDataTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */; };
                5C20CB9B1BB0DCD200895BB1 /* NetworkSessionCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NetworkSessionCocoa.mm; path = NetworkProcess/cocoa/NetworkSessionCocoa.mm; sourceTree = "<group>"; };
                5C20CB9E1BB0DD1800895BB1 /* NetworkSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkSession.h; path = NetworkProcess/NetworkSession.h; sourceTree = "<group>"; };
                5C298D9E1C3DEF2900470AFE /* PendingDownload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PendingDownload.h; path = NetworkProcess/Downloads/PendingDownload.h; sourceTree = "<group>"; };
+               5C7706731D111D8B0012700F /* WebSocketProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebSocketProvider.cpp; path = Network/WebSocketProvider.cpp; sourceTree = "<group>"; };
                5C7C88DC1D0F41A0009D2F6D /* WebSocketProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocketProvider.h; path = Network/WebSocketProvider.h; sourceTree = "<group>"; };
                5C85C7861C3F23C50061A4FA /* PendingDownload.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PendingDownload.cpp; path = NetworkProcess/Downloads/PendingDownload.cpp; sourceTree = "<group>"; };
                5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkDataTask.h; path = NetworkProcess/NetworkDataTask.h; sourceTree = "<group>"; };
                5105B0D2162F7A5E00E27709 /* Network */ = {
                        isa = PBXGroup;
                        children = (
+                               5C7706731D111D8B0012700F /* WebSocketProvider.cpp */,
                                5C7C88DC1D0F41A0009D2F6D /* WebSocketProvider.h */,
                                5105B0D4162F7A7A00E27709 /* NetworkProcessConnection.cpp */,
                                5105B0D5162F7A7A00E27709 /* NetworkProcessConnection.h */,
                                1AA83F6C1A5B63FF00026EC6 /* WebDatabaseProvider.cpp in Sources */,
                                CD19A26D1A13E82A008D650E /* WebDiagnosticLoggingClient.cpp in Sources */,
                                1A5B1C5418987EDF004FCF9B /* WebDocumentLoader.cpp in Sources */,
+                               5C7706741D1138380012700F /* WebSocketProvider.cpp in Sources */,
                                BC111A5D112F4FBB00337BAB /* WebDragClient.cpp in Sources */,
                                C574A37712E6099D002DFE98 /* WebDragClientMac.mm in Sources */,
                                BCA0EFA012332642007D3CFB /* WebEditCommandProxy.cpp in Sources */,
diff --git a/Source/WebKit2/WebProcess/Network/WebSocketProvider.cpp b/Source/WebKit2/WebProcess/Network/WebSocketProvider.cpp
new file mode 100644 (file)
index 0000000..1b4101c
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2009, 2012 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 "WebSocketProvider.h"
+
+#if ENABLE(WEB_SOCKETS)
+
+#include <WebCore/Document.h>
+#include <WebCore/ScriptExecutionContext.h>
+#include <WebCore/ThreadableWebSocketChannelClientWrapper.h>
+#include <WebCore/WebSocketChannel.h>
+#include <WebCore/WebSocketChannelClient.h>
+#include <WebCore/WorkerGlobalScope.h>
+#include <WebCore/WorkerRunLoop.h>
+#include <WebCore/WorkerThread.h>
+#include <WebCore/WorkerThreadableWebSocketChannel.h>
+#include <wtf/text/StringBuilder.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static const char webSocketChannelMode[] = "webSocketChannelMode";
+
+RefPtr<ThreadableWebSocketChannel> WebSocketProvider::createWebSocketChannel(ScriptExecutionContext& context, WebSocketChannelClient& client)
+{
+    // FIXME: This should return a proxy so we can do the actual network interactions in the NetworkProcess.
+    if (is<WorkerGlobalScope>(context)) {
+        WorkerGlobalScope& workerGlobalScope = downcast<WorkerGlobalScope>(context);
+        WorkerRunLoop& runLoop = workerGlobalScope.thread().runLoop();
+        StringBuilder mode;
+        mode.appendLiteral(webSocketChannelMode);
+        mode.appendNumber(runLoop.createUniqueId());
+        return WorkerThreadableWebSocketChannel::create(workerGlobalScope, client, mode.toString());
+    }
+
+    return WebSocketChannel::create(downcast<Document>(context), client);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(WEB_SOCKETS)
index 8947ee8..8cc4dfe 100644 (file)
 namespace WebKit {
 
 class WebSocketProvider final : public WebCore::SocketProvider {
+public:
+    static Ref<WebSocketProvider> create() { return adoptRef(*new WebSocketProvider); }
+    RefPtr<WebCore::ThreadableWebSocketChannel> createWebSocketChannel(WebCore::ScriptExecutionContext&, WebCore::WebSocketChannelClient&) override;
+    virtual ~WebSocketProvider() { }
 };
 
 }
index 70b12ad..414d3d8 100644 (file)
@@ -388,7 +388,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
     Settings::setShouldManageAudioSessionCategory(true);
 #endif
 
-    PageConfiguration pageConfiguration(makeUniqueRef<WebEditorClient>(this), makeUniqueRef<WebSocketProvider>());
+    PageConfiguration pageConfiguration(makeUniqueRef<WebEditorClient>(this), WebSocketProvider::create());
     pageConfiguration.chromeClient = new WebChromeClient(this);
 #if ENABLE(CONTEXT_MENUS)
     pageConfiguration.contextMenuClient = new WebContextMenuClient(this);