Add remote media resource loader for the GPU process
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jan 2020 02:27:01 +0000 (02:27 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jan 2020 02:27:01 +0000 (02:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=205379

Patch by Peng Liu <peng.liu6@apple.com> on 2019-12-31
Reviewed by Youenn Fablet.

Source/WebCore:

There are two definitions of ShouldContinue: WebCore::ScriptExecutionContext::ShouldContinue
and WebCore::ShouldContinue. This patch moves WebCore::ShouldContinue to
WebCore::PolicyChecker::ShouldContinue in order to support transmitting it in XPC messages.

Tests: media/audio-play-with-video-element.html
       media/audio-play.html

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadURL):
(WebCore::FrameLoader::load):
(WebCore::FrameLoader::loadPostRequest):
(WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
* loader/FrameLoader.h:
* loader/MediaResourceLoader.cpp:
(WebCore::MediaResource::responseReceived):
* loader/PolicyChecker.h:
* platform/graphics/PlatformMediaResourceLoader.h:
(WebCore::PlatformMediaResourceClient::responseReceived):
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(CachedResourceStreamingClient::responseReceived):
* platform/network/cocoa/WebCoreNSURLSession.mm:
(WebCore::WebCoreNSURLSessionDataTaskClient::responseReceived):
(-[WebCoreNSURLSessionDataTask resource:receivedResponse:completionHandler:]):

Source/WebKit:

In the GPU process, the RemoteMediaResourceLoader creates RemoteMediaResource(s),
which will notify the media resource clients (WebCoreNSURLSessionDataTaskClient).
Then the data will be forwarded to AVFoundation.

In the Web process, MeidaResourceLoader creates MediaResource(s), which take care of
downloading media data through the network process. The received data will be forwarded to
RemoteMediaResourceProxy, which will forward the data to the corresponding RemoteMediaResource
through XPC messages.

(WebKit::GPUConnectionToWebProcess::remoteMediaResourceManager):
(WebKit::GPUConnectionToWebProcess::didReceiveMessage):
* GPUProcess/GPUConnectionToWebProcess.h:
* GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp:
* GPUProcess/media/RemoteMediaPlayerManagerProxy.h:
* GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::~RemoteMediaPlayerProxy):
(WebKit::RemoteMediaPlayerProxy::requestResource):
(WebKit::RemoteMediaPlayerProxy::removeResource):
(WebKit::RemoteMediaPlayerProxy::mediaPlayerCreateResourceLoader):
* GPUProcess/media/RemoteMediaPlayerProxy.h:
(WebKit::RemoteMediaPlayerProxy::~RemoteMediaPlayerProxy): Deleted.
(WebKit::RemoteMediaPlayerProxy::mediaPlayerLogIdentifier): Deleted.
* GPUProcess/media/RemoteMediaResource.cpp: Added.
(WebKit::RemoteMediaResource::create):
(WebKit::RemoteMediaResource::RemoteMediaResource):
(WebKit::RemoteMediaResource::~RemoteMediaResource):
(WebKit::RemoteMediaResource::stop):
(WebKit::RemoteMediaResource::didPassAccessControlCheck const):
(WebKit::RemoteMediaResource::responseReceived):
(WebKit::RemoteMediaResource::redirectReceived):
(WebKit::RemoteMediaResource::shouldCacheResponse):
(WebKit::RemoteMediaResource::dataSent):
(WebKit::RemoteMediaResource::dataReceived):
(WebKit::RemoteMediaResource::accessControlCheckFailed):
(WebKit::RemoteMediaResource::loadFailed):
(WebKit::RemoteMediaResource::loadFinished):
* GPUProcess/media/RemoteMediaResource.h: Added.
(WebKit::RemoteMediaResource::ready const):
(WebKit::RemoteMediaResource::setReady):
* GPUProcess/media/RemoteMediaResourceIdentifier.h: Added.
* GPUProcess/media/RemoteMediaResourceLoader.cpp: Added.
(WebKit::RemoteMediaResourceLoader::RemoteMediaResourceLoader):
(WebKit::RemoteMediaResourceLoader::~RemoteMediaResourceLoader):
(WebKit::RemoteMediaResourceLoader::requestResource):
* GPUProcess/media/RemoteMediaResourceLoader.h: Added.
* GPUProcess/media/RemoteMediaResourceManager.cpp: Added.
(WebKit::RemoteMediaResourceManager::RemoteMediaResourceManager):
(WebKit::RemoteMediaResourceManager::~RemoteMediaResourceManager):
(WebKit::RemoteMediaResourceManager::addMediaResource):
(WebKit::RemoteMediaResourceManager::removeMediaResource):
(WebKit::RemoteMediaResourceManager::responseReceived):
(WebKit::RemoteMediaResourceManager::redirectReceived):
(WebKit::RemoteMediaResourceManager::dataSent):
(WebKit::RemoteMediaResourceManager::dataReceived):
(WebKit::RemoteMediaResourceManager::accessControlCheckFailed):
(WebKit::RemoteMediaResourceManager::loadFailed):
(WebKit::RemoteMediaResourceManager::loadFinished):
* GPUProcess/media/RemoteMediaResourceManager.h: Added.
* GPUProcess/media/RemoteMediaResourceManager.messages.in: Added.
* WebProcess/GPU/GPUProcessConnection.h:
* WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
(WebKit::MediaPlayerPrivateRemote::MediaPlayerPrivateRemote):
(WebKit::MediaPlayerPrivateRemote::requestResource):
(WebKit::MediaPlayerPrivateRemote::removeResource):
* WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
* WebProcess/GPU/media/MediaPlayerPrivateRemoteIdentifier.h:
* WebProcess/GPU/media/RemoteMediaPlayerManager.cpp:
(WebKit::RemoteMediaPlayerManager::supportsTypeAndCodecs):
(WebKit::RemoteMediaPlayerManager::originsInMediaCache):
(WebKit::RemoteMediaPlayerManager::clearMediaCacheForOrigins):
(WebKit::RemoteMediaPlayerManager::networkStateChanged):
(WebKit::RemoteMediaPlayerManager::readyStateChanged):
(WebKit::RemoteMediaPlayerManager::volumeChanged):
(WebKit::RemoteMediaPlayerManager::muteChanged):
(WebKit::RemoteMediaPlayerManager::timeChanged):
(WebKit::RemoteMediaPlayerManager::durationChanged):
(WebKit::RemoteMediaPlayerManager::rateChanged):
(WebKit::RemoteMediaPlayerManager::playbackStateChanged):
(WebKit::RemoteMediaPlayerManager::engineFailedToLoad):
(WebKit::RemoteMediaPlayerManager::requestResource):
(WebKit::RemoteMediaPlayerManager::removeResource):
* WebProcess/GPU/media/RemoteMediaPlayerManager.h:
(WebKit::RemoteMediaPlayerManager::didReceiveMessageFromGPUProcess):
(WebKit::RemoteMediaPlayerManager::didReceiveMessageFromWebProcess): Deleted.
* WebProcess/GPU/media/RemoteMediaPlayerManager.messages.in:
* WebProcess/GPU/media/RemoteMediaResourceProxy.cpp: Added.
(WebKit::RemoteMediaResourceProxy::RemoteMediaResourceProxy):
(WebKit::RemoteMediaResourceProxy::~RemoteMediaResourceProxy):
(WebKit::RemoteMediaResourceProxy::responseReceived):
(WebKit::RemoteMediaResourceProxy::redirectReceived):
(WebKit::RemoteMediaResourceProxy::shouldCacheResponse):
(WebKit::RemoteMediaResourceProxy::dataSent):
(WebKit::RemoteMediaResourceProxy::dataReceived):
(WebKit::RemoteMediaResourceProxy::accessControlCheckFailed):
(WebKit::RemoteMediaResourceProxy::loadFailed):
(WebKit::RemoteMediaResourceProxy::loadFinished):
* WebProcess/GPU/media/RemoteMediaResourceProxy.h: Added.

LayoutTests:

* gpu-process/TestExpectations:
* media/audio-play-expected.txt: Added.
* media/audio-play-with-video-element-expected.txt: Added.
* media/audio-play-with-video-element.html: Added.
* media/audio-play.html: Added.

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

46 files changed:
LayoutTests/ChangeLog
LayoutTests/gpu-process/TestExpectations
LayoutTests/media/audio-play-expected.txt [new file with mode: 0644]
LayoutTests/media/audio-play-with-video-element-expected.txt [new file with mode: 0644]
LayoutTests/media/audio-play-with-video-element.html [new file with mode: 0644]
LayoutTests/media/audio-play.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/FrameLoader.h
Source/WebCore/loader/MediaResourceLoader.cpp
Source/WebCore/loader/PolicyChecker.h
Source/WebCore/platform/graphics/PlatformMediaResourceLoader.h
Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm
Source/WebKit/ChangeLog
Source/WebKit/DerivedSources-input.xcfilelist
Source/WebKit/DerivedSources-output.xcfilelist
Source/WebKit/DerivedSources.make
Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp
Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h
Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp
Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.h
Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp
Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h
Source/WebKit/GPUProcess/media/RemoteMediaResource.cpp [new file with mode: 0644]
Source/WebKit/GPUProcess/media/RemoteMediaResource.h [new file with mode: 0644]
Source/WebKit/GPUProcess/media/RemoteMediaResourceIdentifier.h [new file with mode: 0644]
Source/WebKit/GPUProcess/media/RemoteMediaResourceLoader.cpp [new file with mode: 0644]
Source/WebKit/GPUProcess/media/RemoteMediaResourceLoader.h [new file with mode: 0644]
Source/WebKit/GPUProcess/media/RemoteMediaResourceManager.cpp [new file with mode: 0644]
Source/WebKit/GPUProcess/media/RemoteMediaResourceManager.h [new file with mode: 0644]
Source/WebKit/GPUProcess/media/RemoteMediaResourceManager.messages.in [new file with mode: 0644]
Source/WebKit/Scripts/webkit/messages.py
Source/WebKit/Sources.txt
Source/WebKit/SourcesCocoa.txt
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/GPU/GPUProcessConnection.cpp
Source/WebKit/WebProcess/GPU/GPUProcessConnection.h
Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp
Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h
Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemoteIdentifier.h
Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerManager.cpp
Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerManager.h
Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerManager.messages.in
Source/WebKit/WebProcess/GPU/media/RemoteMediaResourceProxy.cpp [new file with mode: 0644]
Source/WebKit/WebProcess/GPU/media/RemoteMediaResourceProxy.h [new file with mode: 0644]

index 6903f56..0387a5c 100644 (file)
@@ -1,3 +1,16 @@
+2019-12-31  Peng Liu  <peng.liu6@apple.com>
+
+        Add remote media resource loader for the GPU process
+        https://bugs.webkit.org/show_bug.cgi?id=205379
+
+        Reviewed by Youenn Fablet.
+
+        * gpu-process/TestExpectations:
+        * media/audio-play-expected.txt: Added.
+        * media/audio-play-with-video-element-expected.txt: Added.
+        * media/audio-play-with-video-element.html: Added.
+        * media/audio-play.html: Added.
+
 2019-12-31  youenn fablet  <youenn@apple.com>
 
         Implement RTC VTB decoders in GPUProcess
index 475fa28..f4cda3d 100644 (file)
@@ -179,6 +179,11 @@ legacy-animation-engine/imported/blink/compositing/squashing/remove-from-grouped
 inspector/layers/layers-compositing-reasons.html [ Skip ]
 
 media [ Skip ]
+media/video-src.html [ Pass ]
+media/media-can-play-mpeg-audio.html [ Pass ]
+media/media-can-play-wav-audio.html [ Pass ]
+media/audio-play-with-video-element.html [ Pass ]
+media/audio-play.html [ Pass ]
 accessibility/media-element.html [ Skip ]
 fast/block/float/list-marker-is-float-crash.html [ Skip ]
 fast/css/relative-position-replaced-in-table-display-crash.html [ Skip ]
diff --git a/LayoutTests/media/audio-play-expected.txt b/LayoutTests/media/audio-play-expected.txt
new file mode 100644 (file)
index 0000000..725d915
--- /dev/null
@@ -0,0 +1,7 @@
+Test that a 'play' event is fired when an audio element plays.
+
+RUN(mediaElement.src = findMediaFile('audio', 'content/test'))
+RUN(mediaElement.play())
+EVENT(play)
+END OF TEST
+
diff --git a/LayoutTests/media/audio-play-with-video-element-expected.txt b/LayoutTests/media/audio-play-with-video-element-expected.txt
new file mode 100644 (file)
index 0000000..95cfd7e
--- /dev/null
@@ -0,0 +1,12 @@
+Test that calling play() and pause() on a video element with audio source triggers play and pause events.
+
+
+RUN(video.src = findMediaFile("audio", "content/silence"))
+RUN(handlePromise(video.play()))
+RUN(video.pause())
+EVENT(play)
+EVENT(waiting)
+EVENT(pause)
+EXPECTED (video.paused == 'true') OK
+END OF TEST
+
diff --git a/LayoutTests/media/audio-play-with-video-element.html b/LayoutTests/media/audio-play-with-video-element.html
new file mode 100644 (file)
index 0000000..dad857b
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=media-file.js></script>
+    <script src=video-test.js></script>
+    <script>
+    function runTest() {
+        findMediaElement();
+        run('video.src = findMediaFile("audio", "content/silence")');
+
+        waitForEvent("loadstart");
+        waitForEvent("ratechange");
+        waitForEvent("waiting");
+        waitForEvent("ratechange");
+        waitForEvent("durationchange");
+        waitForEvent("loadedmetadata");
+        waitForEvent("loadeddata");
+        waitForEvent("canplay");
+        waitForEvent("canplaythrough");
+        waitForEvent("play");
+        waitForEvent("timeupdate");
+        waitForEvent('pause', function () { testExpected("video.paused", true); endTest(); } );
+
+        run("handlePromise(video.play())");
+        run("video.pause()");
+    }
+    </script>
+</head>
+
+<body onload="runTest()">
+    <p>Test that calling play() and pause() on a video element with audio source triggers play and pause events.</p>
+    <video controls></video>
+</body>
+</html>
diff --git a/LayoutTests/media/audio-play.html b/LayoutTests/media/audio-play.html
new file mode 100644 (file)
index 0000000..625cc29
--- /dev/null
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>'play' event</title>
+    <script src=media-file.js></script>
+    <script src=video-test.js></script>
+
+    <script>
+        function start() {
+            mediaElement = new Audio();
+            waitForEvent('loadedmetadata');
+            waitForEvent('play', function() { endTest(); });
+            run("mediaElement.src = findMediaFile('audio', 'content/test')");
+            run("mediaElement.play()");
+        }
+    </script>
+</head>
+
+<body onload="start()">
+    <p>Test that a 'play' event is fired when an audio element plays.</p>
+</body>
+</html>
+
index 88b978d..2a19c0e 100644 (file)
@@ -1,3 +1,34 @@
+2019-12-31  Peng Liu  <peng.liu6@apple.com>
+
+        Add remote media resource loader for the GPU process
+        https://bugs.webkit.org/show_bug.cgi?id=205379
+
+        Reviewed by Youenn Fablet.
+
+        There are two definitions of ShouldContinue: WebCore::ScriptExecutionContext::ShouldContinue
+        and WebCore::ShouldContinue. This patch moves WebCore::ShouldContinue to
+        WebCore::PolicyChecker::ShouldContinue in order to support transmitting it in XPC messages.
+
+        Tests: media/audio-play-with-video-element.html
+               media/audio-play.html
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadURL):
+        (WebCore::FrameLoader::load):
+        (WebCore::FrameLoader::loadPostRequest):
+        (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
+        * loader/FrameLoader.h:
+        * loader/MediaResourceLoader.cpp:
+        (WebCore::MediaResource::responseReceived):
+        * loader/PolicyChecker.h:
+        * platform/graphics/PlatformMediaResourceLoader.h:
+        (WebCore::PlatformMediaResourceClient::responseReceived):
+        * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
+        (CachedResourceStreamingClient::responseReceived):
+        * platform/network/cocoa/WebCoreNSURLSession.mm:
+        (WebCore::WebCoreNSURLSessionDataTaskClient::responseReceived):
+        (-[WebCoreNSURLSessionDataTask resource:receivedResponse:completionHandler:]):
+
 2019-12-20  Darin Adler  <darin@apple.com>
 
         Tidy a bit of StringBuilder usage
index 6375f50..22eb8d0 100644 (file)
@@ -1380,7 +1380,7 @@ void FrameLoader::loadURL(FrameLoadRequest&& frameLoadRequest, const String& ref
 
     if (!targetFrame && !effectiveFrameName.isEmpty()) {
         action = action.copyWithShouldOpenExternalURLsPolicy(shouldOpenExternalURLsPolicyToApply(m_frame, frameLoadRequest));
-        policyChecker().checkNewWindowPolicy(WTFMove(action), WTFMove(request), WTFMove(formState), effectiveFrameName, [this, allowNavigationToInvalidURL, openerPolicy, completionHandler = completionHandlerCaller.release()] (const ResourceRequest& request, WeakPtr<FormState>&& formState, const String& frameName, const NavigationAction& action, ShouldContinue shouldContinue) mutable {
+        policyChecker().checkNewWindowPolicy(WTFMove(action), WTFMove(request), WTFMove(formState), effectiveFrameName, [this, allowNavigationToInvalidURL, openerPolicy, completionHandler = completionHandlerCaller.release()] (const ResourceRequest& request, WeakPtr<FormState>&& formState, const String& frameName, const NavigationAction& action, PolicyChecker::ShouldContinue shouldContinue) mutable {
             continueLoadAfterNewWindowPolicy(request, formState.get(), frameName, action, shouldContinue, allowNavigationToInvalidURL, openerPolicy);
             completionHandler();
         });
@@ -1463,7 +1463,7 @@ void FrameLoader::load(FrameLoadRequest&& request)
 
     if (request.shouldCheckNewWindowPolicy()) {
         NavigationAction action { request.requester(), request.resourceRequest(), InitiatedByMainFrame::Unknown, NavigationType::Other, request.shouldOpenExternalURLsPolicy() };
-        policyChecker().checkNewWindowPolicy(WTFMove(action), WTFMove(request.resourceRequest()), { }, request.frameName(), [this] (const ResourceRequest& request, WeakPtr<FormState>&& formState, const String& frameName, const NavigationAction& action, ShouldContinue shouldContinue) {
+        policyChecker().checkNewWindowPolicy(WTFMove(action), WTFMove(request.resourceRequest()), { }, request.frameName(), [this] (const ResourceRequest& request, WeakPtr<FormState>&& formState, const String& frameName, const NavigationAction& action, PolicyChecker::ShouldContinue shouldContinue) {
             continueLoadAfterNewWindowPolicy(request, formState.get(), frameName, action, shouldContinue, AllowNavigationToInvalidURL::Yes, NewFrameOpenerPolicy::Suppress);
         });
 
@@ -3063,7 +3063,7 @@ void FrameLoader::loadPostRequest(FrameLoadRequest&& request, const String& refe
             return;
         }
 
-        policyChecker().checkNewWindowPolicy(WTFMove(action), WTFMove(workingResourceRequest), WTFMove(formState), frameName, [this, allowNavigationToInvalidURL, openerPolicy, completionHandler = WTFMove(completionHandler)] (const ResourceRequest& request, WeakPtr<FormState>&& formState, const String& frameName, const NavigationAction& action, ShouldContinue shouldContinue) mutable {
+        policyChecker().checkNewWindowPolicy(WTFMove(action), WTFMove(workingResourceRequest), WTFMove(formState), frameName, [this, allowNavigationToInvalidURL, openerPolicy, completionHandler = WTFMove(completionHandler)] (const ResourceRequest& request, WeakPtr<FormState>&& formState, const String& frameName, const NavigationAction& action, PolicyChecker::ShouldContinue shouldContinue) mutable {
             continueLoadAfterNewWindowPolicy(request, formState.get(), frameName, action, shouldContinue, allowNavigationToInvalidURL, openerPolicy);
             completionHandler();
         });
@@ -3541,9 +3541,9 @@ void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest& reque
 }
 
 void FrameLoader::continueLoadAfterNewWindowPolicy(const ResourceRequest& request,
-    FormState* formState, const String& frameName, const NavigationAction& action, ShouldContinue shouldContinue, AllowNavigationToInvalidURL allowNavigationToInvalidURL, NewFrameOpenerPolicy openerPolicy)
+    FormState* formState, const String& frameName, const NavigationAction& action, PolicyChecker::ShouldContinue shouldContinue, AllowNavigationToInvalidURL allowNavigationToInvalidURL, NewFrameOpenerPolicy openerPolicy)
 {
-    if (shouldContinue != ShouldContinue::Yes)
+    if (shouldContinue != PolicyChecker::ShouldContinue::Yes)
         return;
 
     Ref<Frame> frame(m_frame);
index ce3ed6a..71634c8 100644 (file)
@@ -37,6 +37,7 @@
 #include "FrameLoaderTypes.h"
 #include "LayoutMilestone.h"
 #include "MixedContentChecker.h"
+#include "PolicyChecker.h"
 #include "ReferrerPolicy.h"
 #include "ResourceLoadNotifier.h"
 #include "ResourceLoaderOptions.h"
@@ -84,7 +85,6 @@ class SubframeLoader;
 class SubstituteData;
 
 enum class NewLoadInProgress : bool;
-enum class ShouldContinue;
 enum class NavigationPolicyDecision : uint8_t;
 enum class ShouldTreatAsContinuingLoad : bool;
 
@@ -357,7 +357,7 @@ private:
     void dispatchUnloadEvents(UnloadEventPolicy);
 
     void continueLoadAfterNavigationPolicy(const ResourceRequest&, FormState*, NavigationPolicyDecision, AllowNavigationToInvalidURL);
-    void continueLoadAfterNewWindowPolicy(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, ShouldContinue, AllowNavigationToInvalidURL, NewFrameOpenerPolicy);
+    void continueLoadAfterNewWindowPolicy(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, PolicyChecker::ShouldContinue, AllowNavigationToInvalidURL, NewFrameOpenerPolicy);
     void continueFragmentScrollAfterNavigationPolicy(const ResourceRequest&, bool shouldContinue);
 
     bool shouldPerformFragmentNavigation(bool isFormSubmission, const String& httpMethod, FrameLoadType, const URL&);
index 06e847d..7c53189 100644 (file)
@@ -172,10 +172,10 @@ void MediaResource::responseReceived(CachedResource& resource, const ResourceRes
 
     m_didPassAccessControlCheck = m_resource->options().mode == FetchOptions::Mode::Cors;
     if (m_client)
-        m_client->responseReceived(*this, response, [this, protectedThis = makeRef(*this), completionHandler = completionHandlerCaller.release()] (ShouldContinue shouldContinue) mutable {
+        m_client->responseReceived(*this, response, [this, protectedThis = makeRef(*this), completionHandler = completionHandlerCaller.release()] (auto shouldContinue) mutable {
             if (completionHandler)
                 completionHandler();
-            if (shouldContinue == ShouldContinue::No)
+            if (shouldContinue == PolicyChecker::ShouldContinue::No)
                 stop();
         });
 
index 0ef1e6e..c3ce266 100644 (file)
@@ -52,11 +52,6 @@ class NavigationAction;
 class ResourceError;
 class ResourceResponse;
 
-enum class ShouldContinue {
-    Yes,
-    No
-};
-
 enum class NavigationPolicyDecision : uint8_t {
     ContinueLoad,
     IgnoreLoad,
@@ -65,15 +60,20 @@ enum class NavigationPolicyDecision : uint8_t {
 
 enum class PolicyDecisionMode { Synchronous, Asynchronous };
 
-using NewWindowPolicyDecisionFunction = CompletionHandler<void(const ResourceRequest&, WeakPtr<FormState>&&, const String& frameName, const NavigationAction&, ShouldContinue)>;
-using NavigationPolicyDecisionFunction = CompletionHandler<void(ResourceRequest&&, WeakPtr<FormState>&&, NavigationPolicyDecision)>;
-
 class PolicyChecker {
     WTF_MAKE_NONCOPYABLE(PolicyChecker);
     WTF_MAKE_FAST_ALLOCATED;
 public:
     explicit PolicyChecker(Frame&);
 
+    enum class ShouldContinue {
+        Yes,
+        No
+    };
+
+    using NavigationPolicyDecisionFunction = CompletionHandler<void(ResourceRequest&&, WeakPtr<FormState>&&, NavigationPolicyDecision)>;
+    using NewWindowPolicyDecisionFunction = CompletionHandler<void(const ResourceRequest&, WeakPtr<FormState>&&, const String& frameName, const NavigationAction&, ShouldContinue)>;
+
     void checkNavigationPolicy(ResourceRequest&&, const ResourceResponse& redirectResponse, DocumentLoader*, RefPtr<FormState>&&, NavigationPolicyDecisionFunction&&, PolicyDecisionMode = PolicyDecisionMode::Asynchronous);
     void checkNavigationPolicy(ResourceRequest&&, const ResourceResponse& redirectResponse, NavigationPolicyDecisionFunction&&);
     void checkNewWindowPolicy(NavigationAction&&, ResourceRequest&&, RefPtr<FormState>&&, const String& frameName, NewWindowPolicyDecisionFunction&&);
@@ -112,3 +112,16 @@ private:
 };
 
 } // namespace WebCore
+
+// To support encoding WebCore::PolicyChecker::ShouldContinue in XPC messages
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::PolicyChecker::ShouldContinue> {
+    using values = EnumValues<
+        WebCore::PolicyChecker::ShouldContinue,
+        WebCore::PolicyChecker::ShouldContinue::No,
+        WebCore::PolicyChecker::ShouldContinue::Yes
+    >;
+};
+
+}
index 51615ef..a145f16 100644 (file)
@@ -44,7 +44,7 @@ class PlatformMediaResourceClient {
 public:
     virtual ~PlatformMediaResourceClient() = default;
 
-    virtual void responseReceived(PlatformMediaResource&, const ResourceResponse&, CompletionHandler<void(ShouldContinue)>&& completionHandler) { completionHandler(ShouldContinue::Yes); }
+    virtual void responseReceived(PlatformMediaResource&, const ResourceResponse&, CompletionHandler<void(PolicyChecker::ShouldContinue)>&& completionHandler) { completionHandler(PolicyChecker::ShouldContinue::Yes); }
     virtual void redirectReceived(PlatformMediaResource&, ResourceRequest&& request, const ResourceResponse&, CompletionHandler<void(ResourceRequest&&)>&& completionHandler) { completionHandler(WTFMove(request)); }
     virtual bool shouldCacheResponse(PlatformMediaResource&, const ResourceResponse&) { return true; }
     virtual void dataSent(PlatformMediaResource&, unsigned long long, unsigned long long) { }
index aedbf68..6415417 100644 (file)
@@ -28,6 +28,7 @@
 #include "MainThreadNotifier.h"
 #include "MediaPlayer.h"
 #include "PlatformMediaResourceLoader.h"
+#include "PolicyChecker.h"
 #include "ResourceError.h"
 #include "ResourceRequest.h"
 #include "ResourceResponse.h"
@@ -65,7 +66,7 @@ private:
     void checkUpdateBlocksize(unsigned bytesRead);
 
     // PlatformMediaResourceClient virtual methods.
-    void responseReceived(PlatformMediaResource&, const ResourceResponse&, CompletionHandler<void(ShouldContinue)>&&) override;
+    void responseReceived(PlatformMediaResource&, const ResourceResponse&, CompletionHandler<void(PolicyChecker::ShouldContinue)>&&) override;
     void dataReceived(PlatformMediaResource&, const char*, int) override;
     void accessControlCheckFailed(PlatformMediaResource&, const ResourceError&) override;
     void loadFailed(PlatformMediaResource&, const ResourceError&) override;
@@ -944,7 +945,7 @@ void CachedResourceStreamingClient::checkUpdateBlocksize(unsigned bytesRead)
     }
 }
 
-void CachedResourceStreamingClient::responseReceived(PlatformMediaResource&, const ResourceResponse& response, CompletionHandler<void(ShouldContinue)>&& completionHandler)
+void CachedResourceStreamingClient::responseReceived(PlatformMediaResource&, const ResourceResponse& response, CompletionHandler<void(PolicyChecker::ShouldContinue)>&& completionHandler)
 {
     WebKitWebSrc* src = WEBKIT_WEB_SRC(m_src.get());
     WebKitWebSrcPrivate* priv = src->priv;
@@ -998,7 +999,7 @@ void CachedResourceStreamingClient::responseReceived(PlatformMediaResource&, con
         GST_ELEMENT_ERROR(src, RESOURCE, READ, ("Received %d HTTP error code", response.httpStatusCode()), (nullptr));
         priv->doesHaveEOS = true;
         webKitWebSrcStop(GST_BASE_SRC_CAST(src));
-        completionHandler(ShouldContinue::No);
+        completionHandler(PolicyChecker::ShouldContinue::No);
         return;
     }
 
@@ -1012,7 +1013,7 @@ void CachedResourceStreamingClient::responseReceived(PlatformMediaResource&, con
             GST_ELEMENT_ERROR(src, RESOURCE, READ, ("Received unexpected %d HTTP status code", response.httpStatusCode()), (nullptr));
             priv->doesHaveEOS = true;
             webKitWebSrcStop(GST_BASE_SRC_CAST(src));
-            completionHandler(ShouldContinue::No);
+            completionHandler(PolicyChecker::ShouldContinue::No);
             return;
         } else {
             GST_DEBUG_OBJECT(src, "Range request succeeded");
@@ -1058,7 +1059,7 @@ void CachedResourceStreamingClient::responseReceived(PlatformMediaResource&, con
         priv->wereHeadersReceived = true;
         priv->headersCondition.notifyOne();
     }
-    completionHandler(ShouldContinue::Yes);
+    completionHandler(PolicyChecker::ShouldContinue::Yes);
 }
 
 void CachedResourceStreamingClient::dataReceived(PlatformMediaResource&, const char* data, int length)
index ba55f00..78a0279 100644 (file)
@@ -56,7 +56,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (assign) WebCoreNSURLSession * _Nullable session;
 
 - (void)resource:(PlatformMediaResource&)resource sentBytes:(unsigned long long)bytesSent totalBytesToBeSent:(unsigned long long)totalBytesToBeSent;
-- (void)resource:(PlatformMediaResource&)resource receivedResponse:(const ResourceResponse&)response completionHandler:(CompletionHandler<void(ShouldContinue)>&&)completionHandler;
+- (void)resource:(PlatformMediaResource&)resource receivedResponse:(const ResourceResponse&)response completionHandler:(CompletionHandler<void(PolicyChecker::ShouldContinue)>&&)completionHandler;
 - (BOOL)resource:(PlatformMediaResource&)resource shouldCacheResponse:(const ResourceResponse&)response;
 - (void)resource:(PlatformMediaResource&)resource receivedData:(const char*)data length:(int)length;
 - (void)resource:(PlatformMediaResource&)resource receivedRedirect:(const ResourceResponse&)response request:(ResourceRequest&&)request completionHandler:(CompletionHandler<void(ResourceRequest&&)>&&)completionHandler;
@@ -381,7 +381,7 @@ public:
 
     void clearTask();
 
-    void responseReceived(PlatformMediaResource&, const ResourceResponse&, CompletionHandler<void(ShouldContinue)>&&) override;
+    void responseReceived(PlatformMediaResource&, const ResourceResponse&, CompletionHandler<void(PolicyChecker::ShouldContinue)>&&) override;
     void redirectReceived(PlatformMediaResource&, ResourceRequest&&, const ResourceResponse&, CompletionHandler<void(ResourceRequest&&)>&&) override;
     bool shouldCacheResponse(PlatformMediaResource&, const ResourceResponse&) override;
     void dataSent(PlatformMediaResource&, unsigned long long, unsigned long long) override;
@@ -410,11 +410,11 @@ void WebCoreNSURLSessionDataTaskClient::dataSent(PlatformMediaResource& resource
     [m_task resource:resource sentBytes:bytesSent totalBytesToBeSent:totalBytesToBeSent];
 }
 
-void WebCoreNSURLSessionDataTaskClient::responseReceived(PlatformMediaResource& resource, const ResourceResponse& response, CompletionHandler<void(ShouldContinue)>&& completionHandler)
+void WebCoreNSURLSessionDataTaskClient::responseReceived(PlatformMediaResource& resource, const ResourceResponse& response, CompletionHandler<void(PolicyChecker::ShouldContinue)>&& completionHandler)
 {
     LockHolder locker(m_taskLock);
     if (!m_task)
-        return completionHandler(ShouldContinue::No);
+        return completionHandler(PolicyChecker::ShouldContinue::No);
 
     [m_task resource:resource receivedResponse:response completionHandler:WTFMove(completionHandler)];
 }
@@ -627,7 +627,7 @@ void WebCoreNSURLSessionDataTaskClient::loadFinished(PlatformMediaResource& reso
     // No-op.
 }
 
-- (void)resource:(PlatformMediaResource&)resource receivedResponse:(const ResourceResponse&)response completionHandler:(CompletionHandler<void(ShouldContinue)>&&)completionHandler
+- (void)resource:(PlatformMediaResource&)resource receivedResponse:(const ResourceResponse&)response completionHandler:(CompletionHandler<void(PolicyChecker::ShouldContinue)>&&)completionHandler
 {
     ASSERT(response.source() == ResourceResponse::Source::Network || response.source() == ResourceResponse::Source::DiskCache || response.source() == ResourceResponse::Source::DiskCacheAfterValidation || response.source() == ResourceResponse::Source::ServiceWorker);
     ASSERT_UNUSED(resource, &resource == _resource);
@@ -638,14 +638,14 @@ void WebCoreNSURLSessionDataTaskClient::loadFinished(PlatformMediaResource& reso
     RetainPtr<NSURLResponse> strongResponse { response.nsURLResponse() };
     RetainPtr<WebCoreNSURLSessionDataTask> strongSelf { self };
     if (!self.session)
-        return completionHandler(ShouldContinue::No);
+        return completionHandler(PolicyChecker::ShouldContinue::No);
     [self.session addDelegateOperation:[strongSelf, strongResponse, completionHandler = WTFMove(completionHandler)] () mutable {
         strongSelf->_response = strongResponse.get();
 
         id<NSURLSessionDataDelegate> dataDelegate = (id<NSURLSessionDataDelegate>)strongSelf.get().session.delegate;
         if (![dataDelegate respondsToSelector:@selector(URLSession:dataTask:didReceiveResponse:completionHandler:)]) {
             callOnMainThread([strongSelf, completionHandler = WTFMove(completionHandler)] () mutable {
-                completionHandler(ShouldContinue::Yes);
+                completionHandler(PolicyChecker::ShouldContinue::Yes);
             });
             return;
         }
@@ -653,10 +653,10 @@ void WebCoreNSURLSessionDataTaskClient::loadFinished(PlatformMediaResource& reso
         [dataDelegate URLSession:(NSURLSession *)strongSelf.get().session dataTask:(NSURLSessionDataTask *)strongSelf.get() didReceiveResponse:strongResponse.get() completionHandler:makeBlockPtr([strongSelf, completionHandler = WTFMove(completionHandler)] (NSURLSessionResponseDisposition disposition) mutable {
             callOnMainThread([strongSelf, disposition, completionHandler = WTFMove(completionHandler)] () mutable {
                 if (disposition == NSURLSessionResponseCancel)
-                    completionHandler(ShouldContinue::No);
+                    completionHandler(PolicyChecker::ShouldContinue::No);
                 else {
                     ASSERT(disposition == NSURLSessionResponseAllow);
-                    completionHandler(ShouldContinue::Yes);
+                    completionHandler(PolicyChecker::ShouldContinue::Yes);
                 }
             });
         }).get()];
index 7981604..3a8126b 100644 (file)
@@ -1,3 +1,108 @@
+2019-12-31  Peng Liu  <peng.liu6@apple.com>
+
+        Add remote media resource loader for the GPU process
+        https://bugs.webkit.org/show_bug.cgi?id=205379
+
+        Reviewed by Youenn Fablet.
+
+        In the GPU process, the RemoteMediaResourceLoader creates RemoteMediaResource(s),
+        which will notify the media resource clients (WebCoreNSURLSessionDataTaskClient).
+        Then the data will be forwarded to AVFoundation.
+
+        In the Web process, MeidaResourceLoader creates MediaResource(s), which take care of
+        downloading media data through the network process. The received data will be forwarded to
+        RemoteMediaResourceProxy, which will forward the data to the corresponding RemoteMediaResource
+        through XPC messages.
+
+        (WebKit::GPUConnectionToWebProcess::remoteMediaResourceManager):
+        (WebKit::GPUConnectionToWebProcess::didReceiveMessage):
+        * GPUProcess/GPUConnectionToWebProcess.h:
+        * GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp:
+        * GPUProcess/media/RemoteMediaPlayerManagerProxy.h:
+        * GPUProcess/media/RemoteMediaPlayerProxy.cpp:
+        (WebKit::RemoteMediaPlayerProxy::~RemoteMediaPlayerProxy):
+        (WebKit::RemoteMediaPlayerProxy::requestResource):
+        (WebKit::RemoteMediaPlayerProxy::removeResource):
+        (WebKit::RemoteMediaPlayerProxy::mediaPlayerCreateResourceLoader):
+        * GPUProcess/media/RemoteMediaPlayerProxy.h:
+        (WebKit::RemoteMediaPlayerProxy::~RemoteMediaPlayerProxy): Deleted.
+        (WebKit::RemoteMediaPlayerProxy::mediaPlayerLogIdentifier): Deleted.
+        * GPUProcess/media/RemoteMediaResource.cpp: Added.
+        (WebKit::RemoteMediaResource::create):
+        (WebKit::RemoteMediaResource::RemoteMediaResource):
+        (WebKit::RemoteMediaResource::~RemoteMediaResource):
+        (WebKit::RemoteMediaResource::stop):
+        (WebKit::RemoteMediaResource::didPassAccessControlCheck const):
+        (WebKit::RemoteMediaResource::responseReceived):
+        (WebKit::RemoteMediaResource::redirectReceived):
+        (WebKit::RemoteMediaResource::shouldCacheResponse):
+        (WebKit::RemoteMediaResource::dataSent):
+        (WebKit::RemoteMediaResource::dataReceived):
+        (WebKit::RemoteMediaResource::accessControlCheckFailed):
+        (WebKit::RemoteMediaResource::loadFailed):
+        (WebKit::RemoteMediaResource::loadFinished):
+        * GPUProcess/media/RemoteMediaResource.h: Added.
+        (WebKit::RemoteMediaResource::ready const):
+        (WebKit::RemoteMediaResource::setReady):
+        * GPUProcess/media/RemoteMediaResourceIdentifier.h: Added.
+        * GPUProcess/media/RemoteMediaResourceLoader.cpp: Added.
+        (WebKit::RemoteMediaResourceLoader::RemoteMediaResourceLoader):
+        (WebKit::RemoteMediaResourceLoader::~RemoteMediaResourceLoader):
+        (WebKit::RemoteMediaResourceLoader::requestResource):
+        * GPUProcess/media/RemoteMediaResourceLoader.h: Added.
+        * GPUProcess/media/RemoteMediaResourceManager.cpp: Added.
+        (WebKit::RemoteMediaResourceManager::RemoteMediaResourceManager):
+        (WebKit::RemoteMediaResourceManager::~RemoteMediaResourceManager):
+        (WebKit::RemoteMediaResourceManager::addMediaResource):
+        (WebKit::RemoteMediaResourceManager::removeMediaResource):
+        (WebKit::RemoteMediaResourceManager::responseReceived):
+        (WebKit::RemoteMediaResourceManager::redirectReceived):
+        (WebKit::RemoteMediaResourceManager::dataSent):
+        (WebKit::RemoteMediaResourceManager::dataReceived):
+        (WebKit::RemoteMediaResourceManager::accessControlCheckFailed):
+        (WebKit::RemoteMediaResourceManager::loadFailed):
+        (WebKit::RemoteMediaResourceManager::loadFinished):
+        * GPUProcess/media/RemoteMediaResourceManager.h: Added.
+        * GPUProcess/media/RemoteMediaResourceManager.messages.in: Added.
+        * WebProcess/GPU/GPUProcessConnection.h:
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+        (WebKit::MediaPlayerPrivateRemote::MediaPlayerPrivateRemote):
+        (WebKit::MediaPlayerPrivateRemote::requestResource):
+        (WebKit::MediaPlayerPrivateRemote::removeResource):
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
+        * WebProcess/GPU/media/MediaPlayerPrivateRemoteIdentifier.h:
+        * WebProcess/GPU/media/RemoteMediaPlayerManager.cpp:
+        (WebKit::RemoteMediaPlayerManager::supportsTypeAndCodecs):
+        (WebKit::RemoteMediaPlayerManager::originsInMediaCache):
+        (WebKit::RemoteMediaPlayerManager::clearMediaCacheForOrigins):
+        (WebKit::RemoteMediaPlayerManager::networkStateChanged):
+        (WebKit::RemoteMediaPlayerManager::readyStateChanged):
+        (WebKit::RemoteMediaPlayerManager::volumeChanged):
+        (WebKit::RemoteMediaPlayerManager::muteChanged):
+        (WebKit::RemoteMediaPlayerManager::timeChanged):
+        (WebKit::RemoteMediaPlayerManager::durationChanged):
+        (WebKit::RemoteMediaPlayerManager::rateChanged):
+        (WebKit::RemoteMediaPlayerManager::playbackStateChanged):
+        (WebKit::RemoteMediaPlayerManager::engineFailedToLoad):
+        (WebKit::RemoteMediaPlayerManager::requestResource):
+        (WebKit::RemoteMediaPlayerManager::removeResource):
+        * WebProcess/GPU/media/RemoteMediaPlayerManager.h:
+        (WebKit::RemoteMediaPlayerManager::didReceiveMessageFromGPUProcess):
+        (WebKit::RemoteMediaPlayerManager::didReceiveMessageFromWebProcess): Deleted.
+        * WebProcess/GPU/media/RemoteMediaPlayerManager.messages.in:
+        * WebProcess/GPU/media/RemoteMediaResourceProxy.cpp: Added.
+        (WebKit::RemoteMediaResourceProxy::RemoteMediaResourceProxy):
+        (WebKit::RemoteMediaResourceProxy::~RemoteMediaResourceProxy):
+        (WebKit::RemoteMediaResourceProxy::responseReceived):
+        (WebKit::RemoteMediaResourceProxy::redirectReceived):
+        (WebKit::RemoteMediaResourceProxy::shouldCacheResponse):
+        (WebKit::RemoteMediaResourceProxy::dataSent):
+        (WebKit::RemoteMediaResourceProxy::dataReceived):
+        (WebKit::RemoteMediaResourceProxy::accessControlCheckFailed):
+        (WebKit::RemoteMediaResourceProxy::loadFailed):
+        (WebKit::RemoteMediaResourceProxy::loadFinished):
+        * WebProcess/GPU/media/RemoteMediaResourceProxy.h: Added.
+
 2019-12-31  youenn fablet  <youenn@apple.com>
 
         Implement RTC VTB decoders in GPUProcess
index f37f3bd..7994e3c 100644 (file)
@@ -17,6 +17,7 @@ $(PROJECT_DIR)/GPUProcess/GPUConnectionToWebProcess.messages.in
 $(PROJECT_DIR)/GPUProcess/GPUProcess.messages.in
 $(PROJECT_DIR)/GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in
 $(PROJECT_DIR)/GPUProcess/media/RemoteMediaPlayerManagerProxy.messages.in
+$(PROJECT_DIR)/GPUProcess/media/RemoteMediaResourceManager.messages.in
 $(PROJECT_DIR)/GPUProcess/webrtc/LibWebRTCCodecsProxy.messages.in
 $(PROJECT_DIR)/NetworkProcess/Cookies/WebCookieManager.messages.in
 $(PROJECT_DIR)/NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.messages.in
index 70aeb7b..0cd23e0 100644 (file)
@@ -129,6 +129,9 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaPlayerManagerMessagesRep
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaPlayerManagerProxyMessageReceiver.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaPlayerManagerProxyMessages.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaPlayerManagerProxyMessagesReplies.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaResourceManagerMessageReceiver.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaResourceManagerMessages.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteMediaResourceManagerMessagesReplies.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteObjectRegistryMessageReceiver.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteObjectRegistryMessages.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteObjectRegistryMessagesReplies.h
index 3850277..9d3e2a9 100644 (file)
@@ -143,6 +143,7 @@ MESSAGE_RECEIVERS = \
     RemoteLayerTreeDrawingAreaProxy \
     RemoteMediaPlayerManager \
     RemoteMediaPlayerManagerProxy \
+    RemoteMediaResourceManager \
     RemoteObjectRegistry \
     RemoteScrollingCoordinator \
     RemoteWebInspectorProxy \
index 8d6e78f..52a95ce 100644 (file)
@@ -39,6 +39,8 @@
 #include "RemoteLayerTreeDrawingAreaProxyMessages.h"
 #include "RemoteMediaPlayerManagerProxy.h"
 #include "RemoteMediaPlayerManagerProxyMessages.h"
+#include "RemoteMediaResourceManager.h"
+#include "RemoteMediaResourceManagerMessages.h"
 #include "RemoteScrollingCoordinatorTransaction.h"
 #include "UserMediaCaptureManagerProxy.h"
 #include "UserMediaCaptureManagerProxyMessages.h"
@@ -111,6 +113,14 @@ void GPUConnectionToWebProcess::didReceiveInvalidMessage(IPC::Connection& connec
     CRASH();
 }
 
+RemoteMediaResourceManager& GPUConnectionToWebProcess::remoteMediaResourceManager()
+{
+    if (!m_remoteMediaResourceManager)
+        m_remoteMediaResourceManager = makeUnique<RemoteMediaResourceManager>();
+
+    return *m_remoteMediaResourceManager;
+}
+
 RemoteMediaPlayerManagerProxy& GPUConnectionToWebProcess::remoteMediaPlayerManagerProxy()
 {
     if (!m_remoteMediaPlayerManagerProxy)
@@ -144,6 +154,9 @@ void GPUConnectionToWebProcess::didReceiveMessage(IPC::Connection& connection, I
     if (decoder.messageReceiverName() == Messages::RemoteMediaPlayerManagerProxy::messageReceiverName()) {
         remoteMediaPlayerManagerProxy().didReceiveMessageFromWebProcess(connection, decoder);
         return;
+    } else if (decoder.messageReceiverName() == Messages::RemoteMediaResourceManager::messageReceiverName()) {
+        remoteMediaResourceManager().didReceiveMessage(connection, decoder);
+        return;
     }
 #if ENABLE(MEDIA_STREAM)
     if (decoder.messageReceiverName() == Messages::UserMediaCaptureManagerProxy::messageReceiverName()) {
index 8fb20f2..ac7125d 100644 (file)
@@ -42,6 +42,7 @@ class GPUProcess;
 class LibWebRTCCodecsProxy;
 class RemoteMediaPlayerManagerProxy;
 class UserMediaCaptureManagerProxy;
+class RemoteMediaResourceManager;
 
 class GPUConnectionToWebProcess
     : public RefCounted<GPUConnectionToWebProcess>
@@ -57,6 +58,7 @@ public:
     void endSuspension();
 
     WebCore::ProcessIdentifier webProcessIdentifier() const { return m_webProcessIdentifier; }
+    RemoteMediaResourceManager& remoteMediaResourceManager();
 
     Logger& logger();
 
@@ -82,6 +84,7 @@ private:
     Ref<IPC::Connection> m_connection;
     Ref<GPUProcess> m_gpuProcess;
     const WebCore::ProcessIdentifier m_webProcessIdentifier;
+    std::unique_ptr<RemoteMediaResourceManager> m_remoteMediaResourceManager;
     std::unique_ptr<RemoteMediaPlayerManagerProxy> m_remoteMediaPlayerManagerProxy;
     PAL::SessionID m_sessionID;
 #if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
index 834673a..0503404 100644 (file)
 #if ENABLE(GPU_PROCESS)
 
 #include "GPUConnectionToWebProcess.h"
+#include "Logging.h"
 #include "RemoteMediaPlayerConfiguration.h"
 #include "RemoteMediaPlayerManagerMessages.h"
 #include "RemoteMediaPlayerManagerProxyMessages.h"
 #include "RemoteMediaPlayerProxy.h"
+#include "RemoteMediaPlayerProxyConfiguration.h"
 #include "WebCoreArgumentCoders.h"
 #include <WebCore/MediaPlayer.h>
 #include <WebCore/MediaPlayerPrivate.h>
@@ -41,6 +43,7 @@
 #define MESSAGE_CHECK_CONTEXTID(identifier) MESSAGE_CHECK_BASE(m_proxies.isValidKey(identifier), &m_gpuConnectionToWebProcess.connection())
 
 namespace WebKit {
+
 using namespace WebCore;
 
 RemoteMediaPlayerManagerProxy::RemoteMediaPlayerManagerProxy(GPUConnectionToWebProcess& connection)
index 16ed6f2..ae51fc0 100644 (file)
 #include "Connection.h"
 #include "MediaPlayerPrivateRemoteIdentifier.h"
 #include "MessageReceiver.h"
-#include "RemoteMediaPlayerProxyConfiguration.h"
 #include <WebCore/MediaPlayer.h>
 #include <wtf/LoggerHelper.h>
 
 namespace WebKit {
 
 class GPUConnectionToWebProcess;
+class RemoteMediaResourceManager;
 class RemoteMediaPlayerProxy;
 struct RemoteMediaPlayerConfiguration;
+struct RemoteMediaPlayerProxyConfiguration;
 
 class RemoteMediaPlayerManagerProxy
     : private IPC::MessageReceiver
index 6dfa75f..88c7e79 100644 (file)
 
 #if ENABLE(GPU_PROCESS)
 
+#include "GPUConnectionToWebProcess.h"
+#include "RemoteMediaPlayerManagerMessages.h"
 #include "RemoteMediaPlayerManagerProxy.h"
+#include "RemoteMediaPlayerProxyConfiguration.h"
 #include "RemoteMediaPlayerState.h"
+#include "RemoteMediaResource.h"
+#include "RemoteMediaResourceIdentifier.h"
+#include "RemoteMediaResourceLoader.h"
+#include "RemoteMediaResourceManager.h"
+#include "WebCoreArgumentCoders.h"
 #include <WebCore/MediaPlayer.h>
 #include <WebCore/MediaPlayerPrivate.h>
 #include <WebCore/NotImplemented.h>
@@ -53,6 +61,10 @@ RemoteMediaPlayerProxy::RemoteMediaPlayerProxy(RemoteMediaPlayerManagerProxy& ma
     m_player = MediaPlayer::create(*this, m_engineIdentifier);
 }
 
+RemoteMediaPlayerProxy::~RemoteMediaPlayerProxy()
+{
+}
+
 void RemoteMediaPlayerProxy::invalidate()
 {
     m_updateCachedStateMessageTimer.stop();
@@ -143,6 +155,25 @@ void RemoteMediaPlayerProxy::setPreservesPitch(bool preservesPitch)
     m_player->setPreservesPitch(preservesPitch);
 }
 
+Ref<PlatformMediaResource> RemoteMediaPlayerProxy::requestResource(ResourceRequest&& request, PlatformMediaResourceLoader::LoadOptions options)
+{
+    auto& remoteMediaResourceManager = m_manager.gpuConnectionToWebProcess().remoteMediaResourceManager();
+    auto remoteMediaResourceIdentifier = RemoteMediaResourceIdentifier::generate();
+    auto remoteMediaResource = RemoteMediaResource::create(remoteMediaResourceManager, *this, remoteMediaResourceIdentifier);
+    remoteMediaResourceManager.addMediaResource(remoteMediaResourceIdentifier, remoteMediaResource);
+
+    m_webProcessConnection->sendWithAsyncReply(Messages::RemoteMediaPlayerManager::RequestResource(m_id, remoteMediaResourceIdentifier, request, options), [remoteMediaResource = remoteMediaResource.copyRef()]() {
+        remoteMediaResource->setReady(true);
+    });
+
+    return remoteMediaResource;
+}
+
+void RemoteMediaPlayerProxy::removeResource(RemoteMediaResourceIdentifier remoteMediaResourceIdentifier)
+{
+    m_webProcessConnection->send(Messages::RemoteMediaPlayerManager::RemoveResource(m_id, remoteMediaResourceIdentifier), 0);
+}
+
 // MediaPlayerClient
 void RemoteMediaPlayerProxy::mediaPlayerNetworkStateChanged()
 {
@@ -388,8 +419,7 @@ CachedResourceLoader* RemoteMediaPlayerProxy::mediaPlayerCachedResourceLoader()
 
 RefPtr<PlatformMediaResourceLoader> RemoteMediaPlayerProxy::mediaPlayerCreateResourceLoader()
 {
-    notImplemented();
-    return nullptr;
+    return adoptRef(*new RemoteMediaResourceLoader(*this));
 }
 
 bool RemoteMediaPlayerProxy::doesHaveAttribute(const AtomString&, AtomString*) const
index 600dcaf..cafdd75 100644 (file)
 
 #if ENABLE(GPU_PROCESS)
 
+#include "Connection.h"
 #include "MediaPlayerPrivateRemoteIdentifier.h"
+#include "RemoteMediaPlayerConfiguration.h"
 #include "RemoteMediaPlayerProxyConfiguration.h"
 #include "RemoteMediaPlayerState.h"
+#include "RemoteMediaResourceIdentifier.h"
+#include <WebCore/Cookie.h>
+#include <WebCore/MediaPlayer.h>
+#include <WebCore/PlatformMediaResourceLoader.h>
 #include <wtf/LoggerHelper.h>
 #include <wtf/RefPtr.h>
 #include <wtf/RunLoop.h>
 #include <wtf/Vector.h>
-
-namespace IPC {
-class Connection;
-}
-
-namespace WebCore {
-class MediaPlayer;
-}
+#include <wtf/WeakPtr.h>
 
 namespace WebKit {
 
 class RemoteMediaPlayerManagerProxy;
 
-class RemoteMediaPlayerProxy
-    : public MediaPlayerClient {
+class RemoteMediaPlayerProxy final
+    : public CanMakeWeakPtr<RemoteMediaPlayerProxy>
+    , public WebCore::MediaPlayerClient {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    RemoteMediaPlayerProxy(RemoteMediaPlayerManagerProxy&, MediaPlayerPrivateRemoteIdentifier, Ref<IPC::Connection>&&, MediaPlayerEnums::MediaEngineIdentifier, RemoteMediaPlayerProxyConfiguration&&);
-    virtual ~RemoteMediaPlayerProxy()
-    {
-    }
+    RemoteMediaPlayerProxy(RemoteMediaPlayerManagerProxy&, MediaPlayerPrivateRemoteIdentifier, Ref<IPC::Connection>&&, WebCore::MediaPlayerEnums::MediaEngineIdentifier, RemoteMediaPlayerProxyConfiguration&&);
+    ~RemoteMediaPlayerProxy();
 
     void invalidate();
 
@@ -62,7 +60,7 @@ public:
 
     void prepareForPlayback(bool privateMode, WebCore::MediaPlayerEnums::Preload, bool preservesPitch, bool prepareForRendering);
 
-    void load(const URL&, const ContentType&, const String&);
+    void load(const URL&, const WebCore::ContentType&, const String&);
     void cancelLoad();
 
     void prepareToPlay();
@@ -80,6 +78,9 @@ public:
     void setPrivateBrowsingMode(bool);
     void setPreservesPitch(bool);
 
+    Ref<WebCore::PlatformMediaResource> requestResource(WebCore::ResourceRequest&&, WebCore::PlatformMediaResourceLoader::LoadOptions);
+    void removeResource(RemoteMediaResourceIdentifier);
+
 private:
     // MediaPlayerClient
     void mediaPlayerNetworkStateChanged() final;
@@ -124,39 +125,39 @@ private:
     bool mediaPlayerIsFullscreen() const final;
     bool mediaPlayerIsFullscreenPermitted() const final;
     bool mediaPlayerIsVideo() const final;
-    LayoutRect mediaPlayerContentBoxRect() const final;
+    WebCore::LayoutRect mediaPlayerContentBoxRect() const final;
     float mediaPlayerContentsScale() const final;
     void mediaPlayerPause() final;
     void mediaPlayerPlay() final;
     bool mediaPlayerPlatformVolumeConfigurationRequired() const final;
-    CachedResourceLoader* mediaPlayerCachedResourceLoader() final;
-    RefPtr<PlatformMediaResourceLoader> mediaPlayerCreateResourceLoader() final;
+    WebCore::CachedResourceLoader* mediaPlayerCachedResourceLoader() final;
+    RefPtr<WebCore::PlatformMediaResourceLoader> mediaPlayerCreateResourceLoader() final;
     bool doesHaveAttribute(const AtomString&, AtomString* = nullptr) const final;
     bool mediaPlayerShouldUsePersistentCache() const final;
     const String& mediaPlayerMediaCacheDirectory() const final;
 
-    void mediaPlayerDidAddAudioTrack(AudioTrackPrivate&) final;
-    void mediaPlayerDidAddTextTrack(InbandTextTrackPrivate&) final;
-    void mediaPlayerDidAddVideoTrack(VideoTrackPrivate&) final;
-    void mediaPlayerDidRemoveAudioTrack(AudioTrackPrivate&) final;
-    void mediaPlayerDidRemoveTextTrack(InbandTextTrackPrivate&) final;
-    void mediaPlayerDidRemoveVideoTrack(VideoTrackPrivate&) final;
+    void mediaPlayerDidAddAudioTrack(WebCore::AudioTrackPrivate&) final;
+    void mediaPlayerDidAddTextTrack(WebCore::InbandTextTrackPrivate&) final;
+    void mediaPlayerDidAddVideoTrack(WebCore::VideoTrackPrivate&) final;
+    void mediaPlayerDidRemoveAudioTrack(WebCore::AudioTrackPrivate&) final;
+    void mediaPlayerDidRemoveTextTrack(WebCore::InbandTextTrackPrivate&) final;
+    void mediaPlayerDidRemoveVideoTrack(WebCore::VideoTrackPrivate&) final;
 
-    void textTrackRepresentationBoundsChanged(const IntRect&) final;
+    void textTrackRepresentationBoundsChanged(const WebCore::IntRect&) final;
 
 #if ENABLE(VIDEO_TRACK) && ENABLE(AVF_CAPTIONS)
-    Vector<RefPtr<PlatformTextTrack>> outOfBandTrackSources() final;
+    Vector<RefPtr<WebCore::PlatformTextTrack>> outOfBandTrackSources() final;
 #endif
 
 #if PLATFORM(IOS_FAMILY)
     String mediaPlayerNetworkInterfaceName() const final;
-    bool mediaPlayerGetRawCookies(const URL&, Vector<Cookie>&) const final;
+    bool mediaPlayerGetRawCookies(const URL&, Vector<WebCore::Cookie>&) const final;
 #endif
 
     String mediaPlayerSourceApplicationIdentifier() const final;
 
     double mediaPlayerRequestedPlaybackRate() const final;
-    MediaPlayerEnums::VideoFullscreenMode mediaPlayerFullscreenMode() const final;
+    WebCore::MediaPlayerEnums::VideoFullscreenMode mediaPlayerFullscreenMode() const final;
     bool mediaPlayerIsVideoFullscreenStandby() const final;
     Vector<String> mediaPlayerPreferredAudioCharacteristics() const final;
 
@@ -176,9 +177,9 @@ private:
 
     MediaPlayerPrivateRemoteIdentifier m_id;
     Ref<IPC::Connection> m_webProcessConnection;
-    RefPtr<MediaPlayer> m_player;
+    RefPtr<WebCore::MediaPlayer> m_player;
     RemoteMediaPlayerManagerProxy& m_manager;
-    MediaPlayerEnums::MediaEngineIdentifier m_engineIdentifier;
+    WebCore::MediaPlayerEnums::MediaEngineIdentifier m_engineIdentifier;
     Vector<WebCore::ContentType> m_typesRequiringHardwareSupport;
     RunLoop::Timer<RemoteMediaPlayerProxy> m_updateCachedStateMessageTimer;
     RemoteMediaPlayerState m_cachedState;
diff --git a/Source/WebKit/GPUProcess/media/RemoteMediaResource.cpp b/Source/WebKit/GPUProcess/media/RemoteMediaResource.cpp
new file mode 100644 (file)
index 0000000..f793347
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2019 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 "RemoteMediaResource.h"
+
+#if ENABLE(GPU_PROCESS)
+
+#include "RemoteMediaPlayerProxy.h"
+#include "RemoteMediaResourceManager.h"
+#include <WebCore/ResourceResponse.h>
+
+namespace WebKit {
+
+using namespace WebCore;
+
+Ref<RemoteMediaResource> RemoteMediaResource::create(RemoteMediaResourceManager& remoteMediaResourceManager, RemoteMediaPlayerProxy& remoteMediaPlayerProxy, RemoteMediaResourceIdentifier id)
+{
+    return adoptRef(*new RemoteMediaResource(remoteMediaResourceManager, remoteMediaPlayerProxy, id));
+}
+
+RemoteMediaResource::RemoteMediaResource(RemoteMediaResourceManager& remoteMediaResourceManager, RemoteMediaPlayerProxy& remoteMediaPlayerProxy, RemoteMediaResourceIdentifier id)
+    : m_remoteMediaResourceManager(remoteMediaResourceManager)
+    , m_remoteMediaPlayerProxy(makeWeakPtr(remoteMediaPlayerProxy))
+    , m_id(id)
+{
+}
+
+RemoteMediaResource::~RemoteMediaResource()
+{
+    ASSERT(isMainThread());
+    stop();
+    m_remoteMediaResourceManager.removeMediaResource(m_id);
+}
+
+void RemoteMediaResource::stop()
+{
+    if (m_remoteMediaPlayerProxy)
+        m_remoteMediaPlayerProxy->removeResource(m_id);
+}
+
+bool RemoteMediaResource::didPassAccessControlCheck() const
+{
+    return m_didPassAccessControlCheck;
+}
+
+void RemoteMediaResource::responseReceived(const ResourceResponse& response, bool didPassAccessControlCheck, CompletionHandler<void(PolicyChecker::ShouldContinue)>&& completionHandler)
+{
+    if (!m_client)
+        return;
+
+    m_didPassAccessControlCheck = didPassAccessControlCheck;
+    m_client->responseReceived(*this, response, [protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](auto shouldContinue) mutable {
+        ASSERT(isMainThread());
+        if (shouldContinue == PolicyChecker::ShouldContinue::No)
+            protectedThis->stop();
+
+        completionHandler(shouldContinue);
+    });
+}
+
+void RemoteMediaResource::redirectReceived(ResourceRequest&& request, const ResourceResponse& response, CompletionHandler<void(ResourceRequest&&)>&& completionHandler)
+{
+    if (m_client)
+        m_client->redirectReceived(*this, WTFMove(request), response, WTFMove(completionHandler));
+}
+
+void RemoteMediaResource::dataSent(uint64_t bytesSent, uint64_t totalBytesToBeSent)
+{
+    if (m_client)
+        m_client->dataSent(*this, bytesSent, totalBytesToBeSent);
+}
+
+void RemoteMediaResource::dataReceived(const char* data, int64_t length)
+{
+    if (m_client)
+        m_client->dataReceived(*this, data, length);
+}
+
+void RemoteMediaResource::accessControlCheckFailed(const ResourceError& error)
+{
+    m_didPassAccessControlCheck = false;
+    if (m_client)
+        m_client->accessControlCheckFailed(*this, error);
+}
+
+void RemoteMediaResource::loadFailed(const ResourceError& error)
+{
+    if (m_client)
+        m_client->loadFailed(*this, error);
+}
+
+void RemoteMediaResource::loadFinished()
+{
+    if (m_client)
+        m_client->loadFinished(*this);
+}
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/GPUProcess/media/RemoteMediaResource.h b/Source/WebKit/GPUProcess/media/RemoteMediaResource.h
new file mode 100644 (file)
index 0000000..45ba1ca
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2019 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
+
+#if ENABLE(GPU_PROCESS)
+
+#include "RemoteMediaResourceIdentifier.h"
+#include <WebCore/PlatformMediaResourceLoader.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebKit {
+
+class RemoteMediaPlayerProxy;
+class RemoteMediaResourceManager;
+
+class RemoteMediaResource : public WebCore::PlatformMediaResource {
+public:
+    static Ref<RemoteMediaResource> create(RemoteMediaResourceManager&, RemoteMediaPlayerProxy&, RemoteMediaResourceIdentifier);
+    ~RemoteMediaResource();
+
+    bool ready() const { return m_ready; }
+    void setReady(bool ready) { m_ready = ready; }
+
+    // PlatformMediaResource
+    void stop() final;
+    bool didPassAccessControlCheck() const final;
+
+    void responseReceived(const WebCore::ResourceResponse&, bool, CompletionHandler<void(WebCore::PolicyChecker::ShouldContinue)>&&);
+    void redirectReceived(WebCore::ResourceRequest&&, const WebCore::ResourceResponse&, CompletionHandler<void(WebCore::ResourceRequest&&)>&&);
+    void dataSent(uint64_t, uint64_t);
+    void dataReceived(const char*, int64_t);
+    void accessControlCheckFailed(const WebCore::ResourceError&);
+    void loadFailed(const WebCore::ResourceError&);
+    void loadFinished();
+
+private:
+    RemoteMediaResource(RemoteMediaResourceManager&, RemoteMediaPlayerProxy&, RemoteMediaResourceIdentifier);
+
+    RemoteMediaResourceManager& m_remoteMediaResourceManager;
+    WeakPtr<RemoteMediaPlayerProxy> m_remoteMediaPlayerProxy;
+    RemoteMediaResourceIdentifier m_id;
+    bool m_didPassAccessControlCheck { false };
+    bool m_ready { false };
+};
+
+} // namespace WebKit
+
+
+#endif
diff --git a/Source/WebKit/GPUProcess/media/RemoteMediaResourceIdentifier.h b/Source/WebKit/GPUProcess/media/RemoteMediaResourceIdentifier.h
new file mode 100644 (file)
index 0000000..6728a5b
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2019 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
+
+#if ENABLE(GPU_PROCESS)
+
+#include <wtf/ObjectIdentifier.h>
+
+namespace WebKit {
+
+enum RemoteMediaResourceIdentifierType { };
+using RemoteMediaResourceIdentifier = ObjectIdentifier<RemoteMediaResourceIdentifierType>;
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/GPUProcess/media/RemoteMediaResourceLoader.cpp b/Source/WebKit/GPUProcess/media/RemoteMediaResourceLoader.cpp
new file mode 100644 (file)
index 0000000..4eef90a
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2019 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 "RemoteMediaResourceLoader.h"
+
+#if ENABLE(GPU_PROCESS)
+
+#include "RemoteMediaPlayerProxy.h"
+
+namespace WebKit {
+
+using namespace WebCore;
+
+RemoteMediaResourceLoader::RemoteMediaResourceLoader(RemoteMediaPlayerProxy& remoteMediaPlayerProxy)
+    : m_remoteMediaPlayerProxy(makeWeakPtr(remoteMediaPlayerProxy))
+{
+}
+
+RemoteMediaResourceLoader::~RemoteMediaResourceLoader()
+{
+}
+
+RefPtr<PlatformMediaResource> RemoteMediaResourceLoader::requestResource(ResourceRequest&& request, LoadOptions options)
+{
+    if (!m_remoteMediaPlayerProxy)
+        return nullptr;
+
+    return m_remoteMediaPlayerProxy->requestResource(WTFMove(request), options);
+}
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/GPUProcess/media/RemoteMediaResourceLoader.h b/Source/WebKit/GPUProcess/media/RemoteMediaResourceLoader.h
new file mode 100644 (file)
index 0000000..9b2b372
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 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
+
+#if ENABLE(GPU_PROCESS)
+
+#include <WebCore/PlatformMediaResourceLoader.h>
+#include <WebCore/ResourceRequest.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebKit {
+
+class RemoteMediaPlayerProxy;
+
+class RemoteMediaResourceLoader final
+    : public WebCore::PlatformMediaResourceLoader {
+public:
+    explicit RemoteMediaResourceLoader(RemoteMediaPlayerProxy&);
+    ~RemoteMediaResourceLoader();
+
+private:
+    RefPtr<WebCore::PlatformMediaResource> requestResource(WebCore::ResourceRequest&&, LoadOptions) final;
+    WeakPtr<RemoteMediaPlayerProxy> m_remoteMediaPlayerProxy;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/GPUProcess/media/RemoteMediaResourceManager.cpp b/Source/WebKit/GPUProcess/media/RemoteMediaResourceManager.cpp
new file mode 100644 (file)
index 0000000..bb29e33
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2019 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 "RemoteMediaResourceManager.h"
+
+#if ENABLE(GPU_PROCESS)
+
+#include "Connection.h"
+#include "DataReference.h"
+#include "RemoteMediaPlayerManagerMessages.h"
+#include "RemoteMediaResource.h"
+#include "RemoteMediaResourceIdentifier.h"
+#include "WebCoreArgumentCoders.h"
+#include <WebCore/ResourceRequest.h>
+
+namespace WebKit {
+
+using namespace WebCore;
+
+RemoteMediaResourceManager::RemoteMediaResourceManager()
+{
+}
+
+RemoteMediaResourceManager::~RemoteMediaResourceManager()
+{
+}
+
+void RemoteMediaResourceManager::addMediaResource(RemoteMediaResourceIdentifier remoteMediaResourceIdentifier, RemoteMediaResource& remoteMediaResource)
+{
+    ASSERT(!m_remoteMediaResources.contains(remoteMediaResourceIdentifier));
+    m_remoteMediaResources.add(remoteMediaResourceIdentifier, &remoteMediaResource);
+}
+
+void RemoteMediaResourceManager::removeMediaResource(RemoteMediaResourceIdentifier remoteMediaResourceIdentifier)
+{
+    ASSERT(m_remoteMediaResources.contains(remoteMediaResourceIdentifier));
+    m_remoteMediaResources.remove(remoteMediaResourceIdentifier);
+}
+
+void RemoteMediaResourceManager::responseReceived(RemoteMediaResourceIdentifier id, const ResourceResponse& response, bool didPassAccessControlCheck, CompletionHandler<void(PolicyChecker::ShouldContinue)>&& completionHandler)
+{
+    auto* resource = m_remoteMediaResources.get(id);
+    if (!resource || !resource->ready()) {
+        completionHandler(PolicyChecker::ShouldContinue::No);
+        return;
+    }
+
+    m_remoteMediaResources.get(id)->responseReceived(response, didPassAccessControlCheck, WTFMove(completionHandler));
+}
+
+void RemoteMediaResourceManager::redirectReceived(RemoteMediaResourceIdentifier id, ResourceRequest&& request, const ResourceResponse& response, CompletionHandler<void(WebCore::ResourceRequest&&)>&& completionHandler)
+{
+    auto* resource = m_remoteMediaResources.get(id);
+    if (!resource || !resource->ready()) {
+        completionHandler({ });
+        return;
+    }
+
+    m_remoteMediaResources.get(id)->redirectReceived(WTFMove(request), response, WTFMove(completionHandler));
+}
+
+void RemoteMediaResourceManager::dataSent(RemoteMediaResourceIdentifier id, uint64_t bytesSent, uint64_t totalBytesToBeSent)
+{
+    auto* resource = m_remoteMediaResources.get(id);
+    if (!resource || !resource->ready())
+        return;
+
+    m_remoteMediaResources.get(id)->dataSent(bytesSent, totalBytesToBeSent);
+}
+
+void RemoteMediaResourceManager::dataReceived(RemoteMediaResourceIdentifier id, const IPC::DataReference& data)
+{
+    auto* resource = m_remoteMediaResources.get(id);
+    if (!resource || !resource->ready())
+        return;
+
+    m_remoteMediaResources.get(id)->dataReceived(reinterpret_cast<const char*>(data.data()), data.size());
+}
+
+void RemoteMediaResourceManager::accessControlCheckFailed(RemoteMediaResourceIdentifier id, const ResourceError& error)
+{
+    auto* resource = m_remoteMediaResources.get(id);
+    if (!resource || !resource->ready())
+        return;
+
+    m_remoteMediaResources.get(id)->accessControlCheckFailed(error);
+}
+
+void RemoteMediaResourceManager::loadFailed(RemoteMediaResourceIdentifier id, const ResourceError& error)
+{
+    auto* resource = m_remoteMediaResources.get(id);
+    if (!resource || !resource->ready())
+        return;
+
+    m_remoteMediaResources.get(id)->loadFailed(error);
+}
+
+void RemoteMediaResourceManager::loadFinished(RemoteMediaResourceIdentifier id)
+{
+    auto* resource = m_remoteMediaResources.get(id);
+    if (!resource || !resource->ready())
+        return;
+
+    m_remoteMediaResources.get(id)->loadFinished();
+}
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/GPUProcess/media/RemoteMediaResourceManager.h b/Source/WebKit/GPUProcess/media/RemoteMediaResourceManager.h
new file mode 100644 (file)
index 0000000..08fde42
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2019 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
+
+#if ENABLE(GPU_PROCESS)
+
+#include "MessageReceiver.h"
+#include "RemoteMediaResourceIdentifier.h"
+#include <WebCore/PolicyChecker.h>
+#include <wtf/HashMap.h>
+
+namespace IPC {
+class Connection;
+class Decoder;
+class DataReference;
+}
+
+namespace WebCore {
+class ResourceRequest;
+}
+
+namespace WebKit {
+
+class RemoteMediaResource;
+
+class RemoteMediaResourceManager
+    : public IPC::MessageReceiver {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    RemoteMediaResourceManager();
+    ~RemoteMediaResourceManager();
+
+    void addMediaResource(RemoteMediaResourceIdentifier, RemoteMediaResource&);
+    void removeMediaResource(RemoteMediaResourceIdentifier);
+
+    // IPC::MessageReceiver
+    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
+
+private:
+    void responseReceived(RemoteMediaResourceIdentifier, const WebCore::ResourceResponse&, bool, CompletionHandler<void(WebCore::PolicyChecker::ShouldContinue)>&&);
+    void redirectReceived(RemoteMediaResourceIdentifier, WebCore::ResourceRequest&&, const WebCore::ResourceResponse&, CompletionHandler<void(WebCore::ResourceRequest&&)>&&);
+    void dataSent(RemoteMediaResourceIdentifier, uint64_t, uint64_t);
+    void dataReceived(RemoteMediaResourceIdentifier, const IPC::DataReference&);
+    void accessControlCheckFailed(RemoteMediaResourceIdentifier, const WebCore::ResourceError&);
+    void loadFailed(RemoteMediaResourceIdentifier, const WebCore::ResourceError&);
+    void loadFinished(RemoteMediaResourceIdentifier);
+
+    HashMap<RemoteMediaResourceIdentifier, RemoteMediaResource*> m_remoteMediaResources;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit/GPUProcess/media/RemoteMediaResourceManager.messages.in b/Source/WebKit/GPUProcess/media/RemoteMediaResourceManager.messages.in
new file mode 100644 (file)
index 0000000..c04a386
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#if ENABLE(GPU_PROCESS)
+
+messages -> RemoteMediaResourceManager NotRefCounted {
+    ResponseReceived(WebKit::RemoteMediaResourceIdentifier id, WebCore::ResourceResponse response, bool didPassAccessControlCheck) -> (WebCore::PolicyChecker::ShouldContinue shouldContinue) Async
+    RedirectReceived(WebKit::RemoteMediaResourceIdentifier id, WebCore::ResourceRequest request, WebCore::ResourceResponse response) -> (WebCore::ResourceRequest returnRequest) Async
+    DataSent(WebKit::RemoteMediaResourceIdentifier id, uint64_t bytesSent, uint64_t totalBytesToBeSent)
+    DataReceived(WebKit::RemoteMediaResourceIdentifier id, IPC::DataReference data)
+    AccessControlCheckFailed(WebKit::RemoteMediaResourceIdentifier id, WebCore::ResourceError error)
+    LoadFailed(WebKit::RemoteMediaResourceIdentifier id, WebCore::ResourceError error)
+    LoadFinished(WebKit::RemoteMediaResourceIdentifier id)
+}
+
+#endif
index 753ea97..6906310 100644 (file)
@@ -220,6 +220,7 @@ def types_that_cannot_be_forward_declared():
         'WebKit::ActivityStateChangeID',
         'WebKit::LayerHostingContextID',
         'WebKit::MediaPlayerPrivateRemoteIdentifier',
+        'WebKit::RemoteMediaResourceIdentifier',
         'WebKit::RTCDecoderIdentifier',
         'WebKit::StorageAreaIdentifier',
         'WebKit::StorageAreaImplIdentifier',
index acf49c7..b2efd1a 100644 (file)
 GPUProcess/GPUProcess.cpp
 GPUProcess/GPUConnectionToWebProcess.cpp
 GPUProcess/GPUProcessCreationParameters.cpp
+//GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp
+//GPUProcess/media/RemoteMediaPlayerProxy.cpp
+//GPUProcess/media/RemoteMediaResource.cpp
+//GPUProcess/media/RemoteMediaResourceLoader.cpp
+//GPUProcess/media/RemoteMediaResourceManager.cpp
 
 NetworkProcess/AdClickAttributionManager.cpp
 NetworkProcess/NetworkActivityTracker.cpp
@@ -502,8 +507,9 @@ WebProcess/MediaStream/MediaDeviceSandboxExtensions.cpp
 WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp
 
 WebProcess/GPU/GPUProcessConnection.cpp
-WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp
-WebProcess/GPU/media/RemoteMediaPlayerManager.cpp
+//WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp
+//WebProcess/GPU/media/RemoteMediaPlayerManager.cpp
+//WebProcess/GPU/media/RemoteMediaResourceProxy.cpp
 WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp
 
 WebProcess/Network/NetworkProcessConnection.cpp
index c713bae..2ede4de 100644 (file)
@@ -59,8 +59,6 @@ NetworkProcess/webrtc/NetworkRTCSocket.cpp
 
 GPUProcess/ios/GPUProcessIOS.mm
 GPUProcess/mac/GPUProcessMac.mm
-GPUProcess/media/RemoteMediaPlayerProxy.cpp
-GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp
 GPUProcess/webrtc/LibWebRTCCodecsProxy.mm
 GPUProcess/EntryPoint/Cocoa/XPCService/GPUServiceEntryPoint.mm
 
index 7a2e81e..1a78dd8 100644 (file)
                1CA8B946127C882A00576C2B /* WebInspectorProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CA8B944127C882A00576C2B /* WebInspectorProxyMessages.h */; };
                1CBBE4A019B66C53006B7D81 /* WebInspectorUIMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CBBE49E19B66C53006B7D81 /* WebInspectorUIMessageReceiver.cpp */; };
                1CBBE4A119B66C53006B7D81 /* WebInspectorUIMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CBBE49F19B66C53006B7D81 /* WebInspectorUIMessages.h */; };
+               1D32F89C23A84BA600B1EA6A /* RemoteMediaResourceProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D32F89B23A84BA600B1EA6A /* RemoteMediaResourceProxy.h */; };
+               1D32F89E23A84C5B00B1EA6A /* RemoteMediaResourceProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1D32F89D23A84C5B00B1EA6A /* RemoteMediaResourceProxy.cpp */; };
+               1D3AB05023AC01A0005C1FF0 /* RemoteMediaPlayerManagerProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0725EFAD239B024500A538A9 /* RemoteMediaPlayerManagerProxy.cpp */; };
+               1D3AB05123AC01AA005C1FF0 /* RemoteMediaPlayerProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07BAF35723A2CC190044257E /* RemoteMediaPlayerProxy.cpp */; };
+               1D3AB05223AC01AE005C1FF0 /* RemoteMediaResource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1D32F89923A8468000B1EA6A /* RemoteMediaResource.cpp */; };
+               1D3AB05323AC01B3005C1FF0 /* RemoteMediaResourceLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1D3AB04E23AB009B005C1FF0 /* RemoteMediaResourceLoader.cpp */; };
+               1D3AB05423AC01B7005C1FF0 /* RemoteMediaResourceManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1DA4089E23A827780058C950 /* RemoteMediaResourceManager.cpp */; };
+               1D3AB05523AC01F3005C1FF0 /* MediaPlayerPrivateRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07923131239B3B0C009598E2 /* MediaPlayerPrivateRemote.cpp */; };
+               1D3AB05623AC01F6005C1FF0 /* RemoteMediaPlayerManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07923130239B3B0C009598E2 /* RemoteMediaPlayerManager.cpp */; };
+               1D4D737023A9E54700717A25 /* RemoteMediaResourceManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1D4D736B23A9DF5500717A25 /* RemoteMediaResourceManagerMessageReceiver.cpp */; };
+               1D4D737123A9E56200717A25 /* RemoteMediaResourceManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D4D736C23A9DF6000717A25 /* RemoteMediaResourceManagerMessages.h */; };
+               1D4D737623A9ED1800717A25 /* RemoteMediaResourceManagerMessagesReplies.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D4D737523A9EB6800717A25 /* RemoteMediaResourceManagerMessagesReplies.h */; };
                1D67B339212E1F6100FAA786 /* ShareSheetCallbackID.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D67B338212E1F6100FAA786 /* ShareSheetCallbackID.h */; };
+               1DA4089523A80A3E0058C950 /* RemoteMediaResourceManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DA4089423A80A3E0058C950 /* RemoteMediaResourceManager.h */; };
                1DB01943211CF002009FB3E8 /* WKShareSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DE0D095211CC21300439B5F /* WKShareSheet.h */; };
                1DB01944211CF005009FB3E8 /* WKShareSheet.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1DBBB061211CC3CB00502ECC /* WKShareSheet.mm */; };
                1F335BC0185B84F0001A201A /* WKWebProcessPlugInLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F335BBF185B84D8001A201A /* WKWebProcessPlugInLoadDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1CA8B944127C882A00576C2B /* WebInspectorProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebInspectorProxyMessages.h; path = DerivedSources/WebKit2/WebInspectorProxyMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
                1CBBE49E19B66C53006B7D81 /* WebInspectorUIMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebInspectorUIMessageReceiver.cpp; path = DerivedSources/WebKit2/WebInspectorUIMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
                1CBBE49F19B66C53006B7D81 /* WebInspectorUIMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebInspectorUIMessages.h; path = DerivedSources/WebKit2/WebInspectorUIMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
+               1D32F89823A8465A00B1EA6A /* RemoteMediaResource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteMediaResource.h; sourceTree = "<group>"; };
+               1D32F89923A8468000B1EA6A /* RemoteMediaResource.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteMediaResource.cpp; sourceTree = "<group>"; };
+               1D32F89B23A84BA600B1EA6A /* RemoteMediaResourceProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteMediaResourceProxy.h; sourceTree = "<group>"; };
+               1D32F89D23A84C5B00B1EA6A /* RemoteMediaResourceProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteMediaResourceProxy.cpp; sourceTree = "<group>"; };
+               1D32F8A623A8601900B1EA6A /* RemoteMediaResourceManager.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteMediaResourceManager.messages.in; sourceTree = "<group>"; };
+               1D3AB04D23AB0072005C1FF0 /* RemoteMediaResourceLoader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteMediaResourceLoader.h; sourceTree = "<group>"; };
+               1D3AB04E23AB009B005C1FF0 /* RemoteMediaResourceLoader.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteMediaResourceLoader.cpp; sourceTree = "<group>"; };
+               1D4D736B23A9DF5500717A25 /* RemoteMediaResourceManagerMessageReceiver.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; name = RemoteMediaResourceManagerMessageReceiver.cpp; path = DerivedSources/WebKit2/RemoteMediaResourceManagerMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
+               1D4D736C23A9DF6000717A25 /* RemoteMediaResourceManagerMessages.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; name = RemoteMediaResourceManagerMessages.h; path = DerivedSources/WebKit2/RemoteMediaResourceManagerMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
+               1D4D737523A9EB6800717A25 /* RemoteMediaResourceManagerMessagesReplies.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; name = RemoteMediaResourceManagerMessagesReplies.h; path = DerivedSources/WebKit2/RemoteMediaResourceManagerMessagesReplies.h; sourceTree = BUILT_PRODUCTS_DIR; };
                1D67B338212E1F6100FAA786 /* ShareSheetCallbackID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShareSheetCallbackID.h; sourceTree = "<group>"; };
+               1DA4089423A80A3E0058C950 /* RemoteMediaResourceManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteMediaResourceManager.h; sourceTree = "<group>"; };
+               1DA4089E23A827780058C950 /* RemoteMediaResourceManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteMediaResourceManager.cpp; sourceTree = "<group>"; };
                1DBBB061211CC3CB00502ECC /* WKShareSheet.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKShareSheet.mm; sourceTree = "<group>"; };
                1DE0D095211CC21300439B5F /* WKShareSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKShareSheet.h; sourceTree = "<group>"; };
+               1DE2DFAC23A959F8003E013A /* RemoteMediaResourceIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteMediaResourceIdentifier.h; sourceTree = "<group>"; };
                1F0181691858DC1500F92884 /* WKWebProcessPlugInFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInFrame.h; sourceTree = "<group>"; };
                1F01816A1858DC1500F92884 /* WKWebProcessPlugInFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebProcessPlugInFrame.mm; sourceTree = "<group>"; };
                1F01816B1858DC1500F92884 /* WKWebProcessPlugInFrameInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInFrameInternal.h; sourceTree = "<group>"; };
                DF58C6311371AC5800F9A37C /* NativeWebWheelEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeWebWheelEvent.h; sourceTree = "<group>"; };
                DF58C6351371ACA000F9A37C /* NativeWebWheelEventMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NativeWebWheelEventMac.mm; sourceTree = "<group>"; };
                E105FE5318D7B9DE008F57A8 /* EditingRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditingRange.h; sourceTree = "<group>"; };
-               E115C715190F8A2500ECC516 /* com.apple.WebKit.Storage.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file; name = com.apple.WebKit.Storage.sb; path = DerivedSources/WebKit2/com.apple.WebKit.Storage.sb; sourceTree = BUILT_PRODUCTS_DIR; };
+               E115C715190F8A2500ECC516 /* com.apple.WebKit.Storage.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = com.apple.WebKit.Storage.sb; path = DerivedSources/WebKit2/com.apple.WebKit.Storage.sb; sourceTree = BUILT_PRODUCTS_DIR; };
                E133FD891423DD7F00FC7BFB /* WebKit.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = WebKit.icns; path = Resources/WebKit.icns; sourceTree = "<group>"; };
                E14A954716E016A40068DE82 /* NetworkProcessPlatformStrategies.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkProcessPlatformStrategies.cpp; sourceTree = "<group>"; };
                E14A954816E016A40068DE82 /* NetworkProcessPlatformStrategies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkProcessPlatformStrategies.h; sourceTree = "<group>"; };
                                07923134239B3B0C009598E2 /* RemoteMediaPlayerManager.h */,
                                07923133239B3B0C009598E2 /* RemoteMediaPlayerManager.messages.in */,
                                07B3B46F23AB2CB300BA5B12 /* RemoteMediaPlayerState.h */,
+                               1D32F89D23A84C5B00B1EA6A /* RemoteMediaResourceProxy.cpp */,
+                               1D32F89B23A84BA600B1EA6A /* RemoteMediaResourceProxy.h */,
                        );
                        path = media;
                        sourceTree = "<group>";
                                07BAF35723A2CC190044257E /* RemoteMediaPlayerProxy.cpp */,
                                07BAF35623A2CC170044257E /* RemoteMediaPlayerProxy.h */,
                                07B3B47523AD890400BA5B12 /* RemoteMediaPlayerProxyConfiguration.h */,
+                               1D32F89923A8468000B1EA6A /* RemoteMediaResource.cpp */,
+                               1D32F89823A8465A00B1EA6A /* RemoteMediaResource.h */,
+                               1DE2DFAC23A959F8003E013A /* RemoteMediaResourceIdentifier.h */,
+                               1D3AB04E23AB009B005C1FF0 /* RemoteMediaResourceLoader.cpp */,
+                               1D3AB04D23AB0072005C1FF0 /* RemoteMediaResourceLoader.h */,
+                               1DA4089E23A827780058C950 /* RemoteMediaResourceManager.cpp */,
+                               1DA4089423A80A3E0058C950 /* RemoteMediaResourceManager.h */,
+                               1D32F8A623A8601900B1EA6A /* RemoteMediaResourceManager.messages.in */,
                        );
                        path = media;
                        sourceTree = "<group>";
                                07923145239CBCB7009598E2 /* RemoteMediaPlayerManagerProxyMessageReceiver.cpp */,
                                07923146239CBCB7009598E2 /* RemoteMediaPlayerManagerProxyMessages.h */,
                                07923142239CBCB5009598E2 /* RemoteMediaPlayerManagerProxyMessagesReplies.h */,
+                               1D4D736B23A9DF5500717A25 /* RemoteMediaResourceManagerMessageReceiver.cpp */,
+                               1D4D736C23A9DF6000717A25 /* RemoteMediaResourceManagerMessages.h */,
+                               1D4D737523A9EB6800717A25 /* RemoteMediaResourceManagerMessagesReplies.h */,
                                1AC1338318590C4600F3EC05 /* RemoteObjectRegistryMessageReceiver.cpp */,
                                1AC1338418590C4600F3EC05 /* RemoteObjectRegistryMessages.h */,
                                0F5947A5187B517600437857 /* RemoteScrollingCoordinatorMessageReceiver.cpp */,
                                0792314C239CBCB8009598E2 /* RemoteMediaPlayerManagerProxyMessages.h in Headers */,
                                07923148239CBCB8009598E2 /* RemoteMediaPlayerManagerProxyMessagesReplies.h in Headers */,
                                07B3B47023AB302D00BA5B12 /* RemoteMediaPlayerState.h in Headers */,
+                               1DA4089523A80A3E0058C950 /* RemoteMediaResourceManager.h in Headers */,
+                               1D4D737123A9E56200717A25 /* RemoteMediaResourceManagerMessages.h in Headers */,
+                               1D4D737623A9ED1800717A25 /* RemoteMediaResourceManagerMessagesReplies.h in Headers */,
+                               1D32F89C23A84BA600B1EA6A /* RemoteMediaResourceProxy.h in Headers */,
                                E1B78471163F24690007B692 /* RemoteNetworkingContext.h in Headers */,
                                1A5704FC1BE1751100874AF1 /* RemoteObjectInvocation.h in Headers */,
                                1AC1338018590AE400F3EC05 /* RemoteObjectRegistry.h in Headers */,
                                2984F57C164B915F004BC0C6 /* LegacyCustomProtocolManagerProxyMessageReceiver.cpp in Sources */,
                                449D90DA21FDC30B00F677C0 /* LocalAuthenticationSoftLink.mm in Sources */,
                                2D92A779212B6A6100F493FD /* Logging.cpp in Sources */,
+                               1D3AB05523AC01F3005C1FF0 /* MediaPlayerPrivateRemote.cpp in Sources */,
                                2D92A781212B6A7100F493FD /* MessageReceiverMap.cpp in Sources */,
                                2D92A782212B6A7100F493FD /* MessageSender.cpp in Sources */,
                                2D92A77A212B6A6100F493FD /* Module.cpp in Sources */,
                                2D72A1FA212BF46E00517A20 /* RemoteLayerTreeDrawingArea.mm in Sources */,
                                0FF24A2D1879E4BC003ABF0C /* RemoteLayerTreeDrawingAreaProxyMessageReceiver.cpp in Sources */,
                                2DC18FB4218A6E9E0025A88D /* RemoteLayerTreeViews.mm in Sources */,
+                               1D3AB05623AC01F6005C1FF0 /* RemoteMediaPlayerManager.cpp in Sources */,
                                07923149239CBCB8009598E2 /* RemoteMediaPlayerManagerMessageReceiver.cpp in Sources */,
+                               1D3AB05023AC01A0005C1FF0 /* RemoteMediaPlayerManagerProxy.cpp in Sources */,
                                0792314B239CBCB8009598E2 /* RemoteMediaPlayerManagerProxyMessageReceiver.cpp in Sources */,
+                               1D3AB05123AC01AA005C1FF0 /* RemoteMediaPlayerProxy.cpp in Sources */,
+                               1D3AB05223AC01AE005C1FF0 /* RemoteMediaResource.cpp in Sources */,
+                               1D3AB05323AC01B3005C1FF0 /* RemoteMediaResourceLoader.cpp in Sources */,
+                               1D3AB05423AC01B7005C1FF0 /* RemoteMediaResourceManager.cpp in Sources */,
+                               1D4D737023A9E54700717A25 /* RemoteMediaResourceManagerMessageReceiver.cpp in Sources */,
+                               1D32F89E23A84C5B00B1EA6A /* RemoteMediaResourceProxy.cpp in Sources */,
                                1AC1338518590C4600F3EC05 /* RemoteObjectRegistryMessageReceiver.cpp in Sources */,
                                0F5947A7187B517600437857 /* RemoteScrollingCoordinatorMessageReceiver.cpp in Sources */,
                                A55BA8261BA25CFD007CD33D /* RemoteWebInspectorProxyMessageReceiver.cpp in Sources */,
index 64a4b4f..18e936d 100644 (file)
@@ -67,7 +67,7 @@ void GPUProcessConnection::didReceiveInvalidMessage(IPC::Connection&, IPC::Strin
 void GPUProcessConnection::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder)
 {
     if (decoder.messageReceiverName() == Messages::RemoteMediaPlayerManager::messageReceiverName()) {
-        WebProcess::singleton().supplement<RemoteMediaPlayerManager>()->didReceiveMessageFromWebProcess(connection, decoder);
+        WebProcess::singleton().supplement<RemoteMediaPlayerManager>()->didReceiveMessageFromGPUProcess(connection, decoder);
         return;
     }
 #if ENABLE(MEDIA_STREAM)
index 853cc16..31c6104 100644 (file)
@@ -55,7 +55,7 @@ private:
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
     void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
 
-    // The connection from a web process to this GPU process.
+    // The connection from the web process to the GPU process.
     Ref<IPC::Connection> m_connection;
 };
 
index 348a0f5..758d7e2 100644 (file)
@@ -62,6 +62,7 @@ using namespace WebCore;
 
 MediaPlayerPrivateRemote::MediaPlayerPrivateRemote(MediaPlayer* player, MediaPlayerEnums::MediaEngineIdentifier engineIdentifier, MediaPlayerPrivateRemoteIdentifier playerIdentifier, RemoteMediaPlayerManager& manager, const RemoteMediaPlayerConfiguration& configuration)
     : m_player(player)
+    , m_mediaResourceLoader(player->createResourceLoader())
     , m_manager(manager)
     , m_remoteEngineIdentifier(engineIdentifier)
     , m_id(playerIdentifier)
@@ -798,6 +799,21 @@ bool MediaPlayerPrivateRemote::shouldIgnoreIntrinsicSize()
     return false;
 }
 
+void MediaPlayerPrivateRemote::requestResource(RemoteMediaResourceIdentifier remoteMediaResourceIdentifier, WebCore::ResourceRequest&& request, WebCore::PlatformMediaResourceLoader::LoadOptions options)
+{
+    ASSERT(!m_mediaResources.contains(remoteMediaResourceIdentifier));
+    auto resource = m_mediaResourceLoader->requestResource(WTFMove(request), options);
+    // PlatformMediaResource owns the PlatformMediaResourceClient
+    resource->setClient(makeUnique<RemoteMediaResourceProxy>(m_manager.gpuProcessConnection(), *resource, remoteMediaResourceIdentifier));
+    m_mediaResources.add(remoteMediaResourceIdentifier, WTFMove(resource));
+}
+
+void MediaPlayerPrivateRemote::removeResource(RemoteMediaResourceIdentifier remoteMediaResourceIdentifier)
+{
+    // The client(RemoteMediaResourceProxy) will be destroyed as well
+    m_mediaResources.remove(remoteMediaResourceIdentifier);
+}
+
 #if !RELEASE_LOG_DISABLED
 WTFLogChannel& MediaPlayerPrivateRemote::logChannel() const
 {
index 68872ae..faa2ec9 100644 (file)
@@ -30,6 +30,8 @@
 #include "RemoteMediaPlayerConfiguration.h"
 #include "RemoteMediaPlayerManager.h"
 #include "RemoteMediaPlayerState.h"
+#include "RemoteMediaResourceIdentifier.h"
+#include "RemoteMediaResourceProxy.h"
 #include <WebCore/MediaPlayerPrivate.h>
 #include <wtf/LoggerHelper.h>
 #include <wtf/MediaTime.h>
@@ -39,22 +41,23 @@ namespace WebKit {
 
 class MediaPlayerPrivateRemote final
     : public CanMakeWeakPtr<MediaPlayerPrivateRemote>
-    , public MediaPlayerPrivateInterface
+    , public WebCore::MediaPlayerPrivateInterface
 #if !RELEASE_LOG_DISABLED
     , private LoggerHelper
 #endif
 {
 public:
-    static std::unique_ptr<MediaPlayerPrivateRemote> create(MediaPlayer* player, MediaPlayerEnums::MediaEngineIdentifier remoteEngineIdentifier, MediaPlayerPrivateRemoteIdentifier identifier, RemoteMediaPlayerManager& manager, const RemoteMediaPlayerConfiguration& configuration)
+    static std::unique_ptr<MediaPlayerPrivateRemote> create(WebCore::MediaPlayer* player, WebCore::MediaPlayerEnums::MediaEngineIdentifier remoteEngineIdentifier, MediaPlayerPrivateRemoteIdentifier identifier, RemoteMediaPlayerManager& manager, const RemoteMediaPlayerConfiguration& configuration)
     {
         return makeUnique<MediaPlayerPrivateRemote>(player, remoteEngineIdentifier, identifier, manager, configuration);
     }
 
-    explicit MediaPlayerPrivateRemote(MediaPlayer*, MediaPlayerEnums::MediaEngineIdentifier, MediaPlayerPrivateRemoteIdentifier, RemoteMediaPlayerManager&, const RemoteMediaPlayerConfiguration&);
-    virtual ~MediaPlayerPrivateRemote();
+    MediaPlayerPrivateRemote(WebCore::MediaPlayer*, WebCore::MediaPlayerEnums::MediaEngineIdentifier, MediaPlayerPrivateRemoteIdentifier, RemoteMediaPlayerManager&, const RemoteMediaPlayerConfiguration&);
+
+    ~MediaPlayerPrivateRemote();
 
     void invalidate() { m_invalid = true; }
-    MediaPlayerEnums::MediaEngineIdentifier remoteEngineIdentifier() const { return m_remoteEngineIdentifier; }
+    WebCore::MediaPlayerEnums::MediaEngineIdentifier remoteEngineIdentifier() const { return m_remoteEngineIdentifier; }
     MediaPlayerPrivateRemoteIdentifier playerItentifier() const { return m_id; }
 
     void networkStateChanged(RemoteMediaPlayerState&&);
@@ -69,6 +72,9 @@ public:
     void updateCachedState(RemoteMediaPlayerState&&);
     void characteristicChanged(bool hasAudio, bool hasVideo, WebCore::MediaPlayerEnums::MovieLoadType);
 
+    void requestResource(RemoteMediaResourceIdentifier, WebCore::ResourceRequest&&, WebCore::PlatformMediaResourceLoader::LoadOptions);
+    void removeResource(RemoteMediaResourceIdentifier);
+
 #if !RELEASE_LOG_DISABLED
     const Logger& logger() const final { return *m_logger; }
     const char* logClassName() const override { return "MediaPlayerPrivateRemote"; }
@@ -77,14 +83,14 @@ public:
 #endif
 
 private:
-    void load(const URL&, const ContentType&, const String&) final;
-    void prepareForPlayback(bool privateMode, MediaPlayer::Preload, bool preservesPitch, bool prepare) final;
+    void load(const URL&, const WebCore::ContentType&, const String&) final;
+    void prepareForPlayback(bool privateMode, WebCore::MediaPlayer::Preload, bool preservesPitch, bool prepare) final;
 
 #if ENABLE(MEDIA_SOURCE)
-    void load(const String&, MediaSourcePrivateClient*) final;
+    void load(const String&, WebCore::MediaSourcePrivateClient*) final;
 #endif
 #if ENABLE(MEDIA_STREAM)
-    void load(MediaStreamPrivate&) final;
+    void load(WebCore::MediaStreamPrivate&) final;
 #endif
     void cancelLoad() final;
 
@@ -106,9 +112,9 @@ private:
 #if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
     void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler) final;
     void updateVideoFullscreenInlineImage() final;
-    void setVideoFullscreenFrame(FloatRect) final;
-    void setVideoFullscreenGravity(MediaPlayer::VideoGravity) final;
-    void setVideoFullscreenMode(MediaPlayer::VideoFullscreenMode) final;
+    void setVideoFullscreenFrame(WebCore::FloatRect) final;
+    void setVideoFullscreenGravity(WebCore::MediaPlayer::VideoGravity) final;
+    void setVideoFullscreenMode(WebCore::MediaPlayer::VideoFullscreenMode) final;
     void videoFullscreenStandbyChanged() final;
 #endif
 
@@ -118,7 +124,7 @@ private:
     String errorLog() const final;
 #endif
 
-    void setBufferingPolicy(MediaPlayer::BufferingPolicy) final;
+    void setBufferingPolicy(WebCore::MediaPlayer::BufferingPolicy) final;
 
     bool supportsPictureInPicture() const final;
     bool supportsFullscreen() const final;
@@ -126,7 +132,7 @@ private:
 
     bool canSaveMediaData() const final;
 
-    FloatSize naturalSize() const final;
+    WebCore::FloatSize naturalSize() const final;
 
     bool hasVideo() const final;
     bool hasAudio() const final;
@@ -159,29 +165,29 @@ private:
     double maxFastForwardRate() const final;
     double minFastReverseRate() const final;
 
-    MediaPlayer::NetworkState networkState() const final { return m_cachedState.networkState; }
-    MediaPlayer::ReadyState readyState() const final { return m_cachedState.readyState; }
+    WebCore::MediaPlayer::NetworkState networkState() const final { return m_cachedState.networkState; }
+    WebCore::MediaPlayer::ReadyState readyState() const final { return m_cachedState.readyState; }
 
-    std::unique_ptr<PlatformTimeRanges> seekable() const final;
+    std::unique_ptr<WebCore::PlatformTimeRanges> seekable() const final;
 
     MediaTime maxMediaTimeSeekable() const final;
     MediaTime minMediaTimeSeekable() const final;
-    std::unique_ptr<PlatformTimeRanges> buffered() const final;
+    std::unique_ptr<WebCore::PlatformTimeRanges> buffered() const final;
     double seekableTimeRangesLastModifiedTime() const final;
     double liveUpdateInterval() const final;
 
     unsigned long long totalBytes() const final;
     bool didLoadingProgress() const final;
 
-    void setSize(const IntSize&) final;
+    void setSize(const WebCore::IntSize&) final;
 
-    void paint(GraphicsContext&, const FloatRect&) final;
+    void paint(WebCore::GraphicsContext&, const WebCore::FloatRect&) final;
 
-    void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&) final;
-    bool copyVideoTextureToPlatformTexture(GraphicsContext3D*, Platform3DObject, GC3Denum, GC3Dint, GC3Denum, GC3Denum, GC3Denum, bool, bool) final;
-    NativeImagePtr nativeImageForCurrentTime() final;
+    void paintCurrentFrameInContext(WebCore::GraphicsContext&, const WebCore::FloatRect&) final;
+    bool copyVideoTextureToPlatformTexture(WebCore::GraphicsContext3D*, Platform3DObject, GC3Denum, GC3Dint, GC3Denum, GC3Denum, GC3Denum, bool, bool) final;
+    WebCore::NativeImagePtr nativeImageForCurrentTime() final;
 
-    void setPreload(MediaPlayer::Preload) final;
+    void setPreload(WebCore::MediaPlayer::Preload) final;
 
     bool hasAvailableVideoFrame() const final;
 
@@ -192,14 +198,14 @@ private:
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     String wirelessPlaybackTargetName() const final;
-    MediaPlayer::WirelessPlaybackTargetType wirelessPlaybackTargetType() const final;
+    WebCore::MediaPlayer::WirelessPlaybackTargetType wirelessPlaybackTargetType() const final;
 
     bool wirelessVideoPlaybackDisabled() const final;
     void setWirelessVideoPlaybackDisabled(bool) final;
 
     bool canPlayToWirelessPlaybackTarget() const final;
     bool isCurrentPlaybackTargetWireless() const final;
-    void setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&&) final;
+    void setWirelessPlaybackTarget(Ref<WebCore::MediaPlaybackTarget>&&) final;
 
     void setShouldPlayToPlaybackTarget(bool) final;
 #endif
@@ -216,9 +222,9 @@ private:
 
     bool hasSingleSecurityOrigin() const final;
     bool didPassCORSAccessCheck() const final;
-    Optional<bool> wouldTaintOrigin(const SecurityOrigin&) const final;
+    Optional<bool> wouldTaintOrigin(const WebCore::SecurityOrigin&) const final;
 
-    MediaPlayer::MovieLoadType movieLoadType() const final;
+    WebCore::MediaPlayer::MovieLoadType movieLoadType() const final;
 
     void prepareForRendering() final;
 
@@ -234,25 +240,25 @@ private:
     String engineDescription() const final;
 
 #if ENABLE(WEB_AUDIO)
-    AudioSourceProvider* audioSourceProvider() final;
+    WebCore::AudioSourceProvider* audioSourceProvider() final;
 #endif
 
 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
-    std::unique_ptr<LegacyCDMSession> createSession(const String&, LegacyCDMSessionClient*) final;
-    void setCDMSession(LegacyCDMSession*) final;
+    std::unique_ptr<WebCore::LegacyCDMSession> createSession(const String&, WebCore::LegacyCDMSessionClient*) final;
+    void setCDMSession(WebCore::LegacyCDMSession*) final;
     void keyAdded() final;
 #endif
 
 #if ENABLE(ENCRYPTED_MEDIA)
-    void cdmInstanceAttached(CDMInstance&) final;
-    void cdmInstanceDetached(CDMInstance&) final;
-    void attemptToDecryptWithInstance(CDMInstance&) final;
+    void cdmInstanceAttached(WebCore::CDMInstance&) final;
+    void cdmInstanceDetached(WebCore::CDMInstance&) final;
+    void attemptToDecryptWithInstance(WebCore::CDMInstance&) final;
     bool waitingForKey() const final;
 #endif
 
 #if ENABLE(VIDEO_TRACK)
     bool requiresTextTrackRepresentation() const final;
-    void setTextTrackRepresentation(TextTrackRepresentation*) final;
+    void setTextTrackRepresentation(WebCore::TextTrackRepresentation*) final;
     void syncTextTrackBounds() final;
     void tracksChanged() final;
 #endif
@@ -272,7 +278,7 @@ private:
 
     bool ended() const final;
 
-    Optional<VideoPlaybackQualityMetrics> videoPlaybackQualityMetrics() final;
+    Optional<WebCore::VideoPlaybackQualityMetrics> videoPlaybackQualityMetrics() final;
 
 #if ENABLE(AVF_CAPTIONS)
     void notifyTrackModeChanged() final;
@@ -293,19 +299,22 @@ private:
 
     bool shouldIgnoreIntrinsicSize() final;
 
-    MediaPlayer* m_player { nullptr };
-    RemoteMediaPlayerManager m_manager;
-    MediaPlayerEnums::MediaEngineIdentifier m_remoteEngineIdentifier;
+    WebCore::MediaPlayer* m_player { nullptr };
+    RefPtr<WebCore::PlatformMediaResourceLoader> m_mediaResourceLoader;
+    RemoteMediaPlayerManager& m_manager;
+    WebCore::MediaPlayerEnums::MediaEngineIdentifier m_remoteEngineIdentifier;
     MediaPlayerPrivateRemoteIdentifier m_id;
     RemoteMediaPlayerConfiguration m_configuration;
 
     RemoteMediaPlayerState m_cachedState;
-    std::unique_ptr<PlatformTimeRanges> m_cachedBufferedTimeRanges;
+    std::unique_ptr<WebCore::PlatformTimeRanges> m_cachedBufferedTimeRanges;
+
+    HashMap<RemoteMediaResourceIdentifier, RefPtr<WebCore::PlatformMediaResource>> m_mediaResources;
 
     double m_volume { 1 };
     double m_rate { 1 };
     long m_platformErrorCode { 0 };
-    MediaPlayerEnums::MovieLoadType m_movieLoadType { MediaPlayerEnums::MovieLoadType::Unknown };
+    WebCore::MediaPlayerEnums::MovieLoadType m_movieLoadType { WebCore::MediaPlayerEnums::MovieLoadType::Unknown };
     bool m_hasAudio { false };
     bool m_hasVideo { false };
     bool m_muted { false };
index 3d55fda..256b3c5 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(GPU_PROCESS)
+
 #include <wtf/ObjectIdentifier.h>
 
 namespace WebKit {
@@ -33,3 +35,5 @@ enum MediaPlayerPrivateRemoteIdentifierType { };
 using MediaPlayerPrivateRemoteIdentifier = ObjectIdentifier<MediaPlayerPrivateRemoteIdentifierType>;
 
 } // namespace WebKit
+
+#endif
index ae75686..71b71bf 100644 (file)
@@ -28,6 +28,8 @@
 
 #if ENABLE(GPU_PROCESS)
 
+#include "GPUProcessConnection.h"
+#include "MediaPlayerPrivateRemote.h"
 #include "RemoteMediaPlayerConfiguration.h"
 #include "RemoteMediaPlayerManagerMessages.h"
 #include "RemoteMediaPlayerManagerProxyMessages.h"
@@ -41,6 +43,7 @@
 #include <wtf/Assertions.h>
 
 namespace WebKit {
+
 using namespace PAL;
 using namespace WebCore;
 
@@ -165,7 +168,7 @@ void RemoteMediaPlayerManager::getSupportedTypes(MediaPlayerEnums::MediaEngineId
         result.add(type);
 }
 
-MediaPlayer::SupportsType RemoteMediaPlayerManager::supportsTypeAndCodecs(MediaPlayerEnums::MediaEngineIdentifier remoteEngineIdentifier, const WebCore::MediaEngineSupportParameters& parameters)
+MediaPlayer::SupportsType RemoteMediaPlayerManager::supportsTypeAndCodecs(MediaPlayerEnums::MediaEngineIdentifier remoteEngineIdentifier, const MediaEngineSupportParameters& parameters)
 {
     // FIXME: supported types don't change, cache them.
 
@@ -181,9 +184,9 @@ bool RemoteMediaPlayerManager::supportsKeySystem(MediaPlayerEnums::MediaEngineId
     return false;
 }
 
-HashSet<RefPtr<WebCore::SecurityOrigin>> RemoteMediaPlayerManager::originsInMediaCache(MediaPlayerEnums::MediaEngineIdentifier remoteEngineIdentifier, const String& path)
+HashSet<RefPtr<SecurityOrigin>> RemoteMediaPlayerManager::originsInMediaCache(MediaPlayerEnums::MediaEngineIdentifier remoteEngineIdentifier, const String& path)
 {
-    Vector<WebCore::SecurityOriginData> originData;
+    Vector<SecurityOriginData> originData;
     if (!gpuProcessConnection().sendSync(Messages::RemoteMediaPlayerManagerProxy::OriginsInMediaCache(remoteEngineIdentifier, path), Messages::RemoteMediaPlayerManagerProxy::OriginsInMediaCache::Reply(originData), 0))
         return { };
 
@@ -199,7 +202,7 @@ void RemoteMediaPlayerManager::clearMediaCache(MediaPlayerEnums::MediaEngineIden
     gpuProcessConnection().send(Messages::RemoteMediaPlayerManagerProxy::ClearMediaCache(remoteEngineIdentifier, path, modifiedSince), 0);
 }
 
-void RemoteMediaPlayerManager::clearMediaCacheForOrigins(MediaPlayerEnums::MediaEngineIdentifier remoteEngineIdentifier, const String& path, const HashSet<RefPtr<WebCore::SecurityOrigin>>& origins)
+void RemoteMediaPlayerManager::clearMediaCacheForOrigins(MediaPlayerEnums::MediaEngineIdentifier remoteEngineIdentifier, const String& path, const HashSet<RefPtr<SecurityOrigin>>& origins)
 {
     auto originData = WTF::map(origins, [] (auto& origin) {
         return origin->data();
@@ -210,55 +213,55 @@ void RemoteMediaPlayerManager::clearMediaCacheForOrigins(MediaPlayerEnums::Media
 
 void RemoteMediaPlayerManager::networkStateChanged(MediaPlayerPrivateRemoteIdentifier id, RemoteMediaPlayerState&& state)
 {
-    if (auto player = m_players.get(id))
+    if (const auto& player = m_players.get(id))
         player->networkStateChanged(WTFMove(state));
 }
 
 void RemoteMediaPlayerManager::readyStateChanged(MediaPlayerPrivateRemoteIdentifier id, RemoteMediaPlayerState&& state)
 {
-    if (auto player = m_players.get(id))
+    if (const auto& player = m_players.get(id))
         player->readyStateChanged(WTFMove(state));
 }
 
-void RemoteMediaPlayerManager::volumeChanged(WebKit::MediaPlayerPrivateRemoteIdentifier id, double volume)
+void RemoteMediaPlayerManager::volumeChanged(MediaPlayerPrivateRemoteIdentifier id, double volume)
 {
-    if (auto player = m_players.get(id))
+    if (const auto& player = m_players.get(id))
         player->volumeChanged(volume);
 }
 
-void RemoteMediaPlayerManager::muteChanged(WebKit::MediaPlayerPrivateRemoteIdentifier id, bool mute)
+void RemoteMediaPlayerManager::muteChanged(MediaPlayerPrivateRemoteIdentifier id, bool mute)
 {
-    if (auto player = m_players.get(id))
+    if (const auto& player = m_players.get(id))
         player->muteChanged(mute);
 }
 
 void RemoteMediaPlayerManager::timeChanged(WebKit::MediaPlayerPrivateRemoteIdentifier id, RemoteMediaPlayerState&& state)
 {
-    if (auto player = m_players.get(id))
+    if (const auto& player = m_players.get(id))
         player->timeChanged(WTFMove(state));
 }
 
 void RemoteMediaPlayerManager::durationChanged(WebKit::MediaPlayerPrivateRemoteIdentifier id, RemoteMediaPlayerState&& state)
 {
-    if (auto player = m_players.get(id))
+    if (const auto& player = m_players.get(id))
         player->durationChanged(WTFMove(state));
 }
 
-void RemoteMediaPlayerManager::rateChanged(WebKit::MediaPlayerPrivateRemoteIdentifier id, double rate)
+void RemoteMediaPlayerManager::rateChanged(MediaPlayerPrivateRemoteIdentifier id, double rate)
 {
-    if (auto player = m_players.get(id))
+    if (const auto& player = m_players.get(id))
         player->rateChanged(rate);
 }
 
-void RemoteMediaPlayerManager::playbackStateChanged(WebKit::MediaPlayerPrivateRemoteIdentifier id, bool paused)
+void RemoteMediaPlayerManager::playbackStateChanged(MediaPlayerPrivateRemoteIdentifier id, bool paused)
 {
-    if (auto player = m_players.get(id))
+    if (const auto& player = m_players.get(id))
         player->playbackStateChanged(paused);
 }
 
 void RemoteMediaPlayerManager::engineFailedToLoad(WebKit::MediaPlayerPrivateRemoteIdentifier id, long platformErrorCode)
 {
-    if (auto player = m_players.get(id))
+    if (const auto& player = m_players.get(id))
         player->engineFailedToLoad(platformErrorCode);
 }
 
@@ -267,6 +270,20 @@ void RemoteMediaPlayerManager::characteristicChanged(WebKit::MediaPlayerPrivateR
     if (auto player = m_players.get(id))
         player->characteristicChanged(hasAudio, hasVideo, loadType);
 }
+    
+void RemoteMediaPlayerManager::requestResource(MediaPlayerPrivateRemoteIdentifier id, RemoteMediaResourceIdentifier remoteMediaResourceIdentifier, ResourceRequest&& request, PlatformMediaResourceLoader::LoadOptions options, CompletionHandler<void()>&& completionHandler)
+{
+    if (const auto& player = m_players.get(id))
+        player->requestResource(remoteMediaResourceIdentifier, WTFMove(request), options);
+
+    completionHandler();
+}
+
+void RemoteMediaPlayerManager::removeResource(MediaPlayerPrivateRemoteIdentifier id, RemoteMediaResourceIdentifier remoteMediaResourceIdentifier)
+{
+    if (const auto& player = m_players.get(id))
+        player->removeResource(remoteMediaResourceIdentifier);
+}
 
 void RemoteMediaPlayerManager::updatePreferences(const Settings& settings)
 {
index c3c277a..2488144 100644 (file)
@@ -30,6 +30,7 @@
 #include "MediaPlayerPrivateRemoteIdentifier.h"
 #include "MessageReceiver.h"
 #include "RemoteMediaPlayerState.h"
+#include "RemoteMediaResourceIdentifier.h"
 #include "SharedMemory.h"
 #include "WebProcessSupplement.h"
 #include <WebCore/MediaPlayer.h>
@@ -57,7 +58,7 @@ public:
 
     IPC::Connection& gpuProcessConnection() const;
 
-    void didReceiveMessageFromWebProcess(IPC::Connection& connection, IPC::Decoder& decoder) { didReceiveMessage(connection, decoder); }
+    void didReceiveMessageFromGPUProcess(IPC::Connection& connection, IPC::Decoder& decoder) { didReceiveMessage(connection, decoder); }
 
     void deleteRemoteMediaPlayer(MediaPlayerPrivateRemoteIdentifier);
 
@@ -82,6 +83,8 @@ private:
     void engineFailedToLoad(WebKit::MediaPlayerPrivateRemoteIdentifier, long);
     void updateCachedState(WebKit::MediaPlayerPrivateRemoteIdentifier, RemoteMediaPlayerState&&);
     void characteristicChanged(WebKit::MediaPlayerPrivateRemoteIdentifier, bool hasAudio, bool hasVideo, WebCore::MediaPlayerEnums::MovieLoadType);
+    void requestResource(MediaPlayerPrivateRemoteIdentifier, RemoteMediaResourceIdentifier, WebCore::ResourceRequest&&, WebCore::PlatformMediaResourceLoader::LoadOptions, CompletionHandler<void()>&&);
+    void removeResource(MediaPlayerPrivateRemoteIdentifier, RemoteMediaResourceIdentifier);
 
     friend class MediaPlayerRemoteFactory;
     void getSupportedTypes(WebCore::MediaPlayerEnums::MediaEngineIdentifier, HashSet<String, ASCIICaseInsensitiveHash>&);
index d31e05f..180f263 100644 (file)
@@ -21,7 +21,7 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 # THE POSSIBILITY OF SUCH DAMAGE.
 
-#if ENABLE(VIDEO)
+#if ENABLE(GPU_PROCESS)
 
 messages -> RemoteMediaPlayerManager NotRefCounted {
     NetworkStateChanged(WebKit::MediaPlayerPrivateRemoteIdentifier id, struct WebKit::RemoteMediaPlayerState state)
@@ -35,6 +35,9 @@ messages -> RemoteMediaPlayerManager NotRefCounted {
     EngineFailedToLoad(WebKit::MediaPlayerPrivateRemoteIdentifier id, int platformErrorCode)
     UpdateCachedState(WebKit::MediaPlayerPrivateRemoteIdentifier id, struct WebKit::RemoteMediaPlayerState state)
     CharacteristicChanged(WebKit::MediaPlayerPrivateRemoteIdentifier id, bool hasAudio, bool hasVideo, enum:uint8_t WebCore::MediaPlayerEnums::MovieLoadType movieLoadType)
+
+    RequestResource(WebKit::MediaPlayerPrivateRemoteIdentifier mediaPlayerPrivateRemoteIdentifier, WebKit::RemoteMediaResourceIdentifier remoteMediaResourceIdentifier, WebCore::ResourceRequest request, enum:uint8_t WebCore::PlatformMediaResourceLoader::LoadOptions options) -> () Async
+    RemoveResource(WebKit::MediaPlayerPrivateRemoteIdentifier mediaPlayerPrivateRemoteIdentifier, WebKit::RemoteMediaResourceIdentifier remoteMediaResourceIdentifier)
 }
 
 #endif
diff --git a/Source/WebKit/WebProcess/GPU/media/RemoteMediaResourceProxy.cpp b/Source/WebKit/WebProcess/GPU/media/RemoteMediaResourceProxy.cpp
new file mode 100644 (file)
index 0000000..9096e25
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2019 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 "RemoteMediaResourceProxy.h"
+
+#if ENABLE(GPU_PROCESS)
+
+#include "DataReference.h"
+#include "RemoteMediaResourceManagerMessages.h"
+#include "WebCoreArgumentCoders.h"
+#include <wtf/CompletionHandler.h>
+
+namespace WebKit {
+
+RemoteMediaResourceProxy::RemoteMediaResourceProxy(Ref<IPC::Connection>&& connection, WebCore::PlatformMediaResource& platformMediaResource, RemoteMediaResourceIdentifier id)
+    : m_connection(WTFMove(connection))
+    , m_platformMediaResource(platformMediaResource)
+    , m_id(id)
+{
+}
+
+RemoteMediaResourceProxy::~RemoteMediaResourceProxy()
+{
+}
+
+void RemoteMediaResourceProxy::responseReceived(WebCore::PlatformMediaResource&, const WebCore::ResourceResponse& response, CompletionHandler<void(WebCore::PolicyChecker::ShouldContinue)>&& completionHandler)
+{
+    m_connection->sendWithAsyncReply(Messages::RemoteMediaResourceManager::ResponseReceived(m_id, response, m_platformMediaResource.didPassAccessControlCheck()), [completionHandler = WTFMove(completionHandler)](auto shouldContinue) mutable {
+        completionHandler(shouldContinue);
+    });
+}
+
+void RemoteMediaResourceProxy::redirectReceived(WebCore::PlatformMediaResource&, WebCore::ResourceRequest&& request, const WebCore::ResourceResponse& response, CompletionHandler<void(WebCore::ResourceRequest&&)>&& completionHandler)
+{
+    m_connection->sendWithAsyncReply(Messages::RemoteMediaResourceManager::RedirectReceived(m_id, request, response), [completionHandler = WTFMove(completionHandler)](auto&& request) mutable {
+        completionHandler(WTFMove(request));
+    });
+}
+
+bool RemoteMediaResourceProxy::shouldCacheResponse(WebCore::PlatformMediaResource&, const WebCore::ResourceResponse&)
+{
+    // TODO: need to check WebCoreNSURLSessionDataTaskClient::shouldCacheResponse()
+    return false;
+}
+
+void RemoteMediaResourceProxy::dataSent(WebCore::PlatformMediaResource&, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
+{
+    m_connection->send(Messages::RemoteMediaResourceManager::DataSent(m_id, bytesSent, totalBytesToBeSent), 0);
+}
+
+void RemoteMediaResourceProxy::dataReceived(WebCore::PlatformMediaResource&, const char* data, int length)
+{
+    m_connection->send(Messages::RemoteMediaResourceManager::DataReceived(m_id, IPC::DataReference(reinterpret_cast<const uint8_t*>(data), length)), 0);
+}
+
+void RemoteMediaResourceProxy::accessControlCheckFailed(WebCore::PlatformMediaResource&, const WebCore::ResourceError& error)
+{
+    m_connection->send(Messages::RemoteMediaResourceManager::AccessControlCheckFailed(m_id, error), 0);
+}
+
+void RemoteMediaResourceProxy::loadFailed(WebCore::PlatformMediaResource&, const WebCore::ResourceError& error)
+{
+    m_connection->send(Messages::RemoteMediaResourceManager::LoadFailed(m_id, error), 0);
+}
+
+void RemoteMediaResourceProxy::loadFinished(WebCore::PlatformMediaResource&)
+{
+    m_connection->send(Messages::RemoteMediaResourceManager::LoadFinished(m_id), 0);
+}
+
+}
+
+#endif
diff --git a/Source/WebKit/WebProcess/GPU/media/RemoteMediaResourceProxy.h b/Source/WebKit/WebProcess/GPU/media/RemoteMediaResourceProxy.h
new file mode 100644 (file)
index 0000000..d6cdf96
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2019 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
+
+#if ENABLE(GPU_PROCESS)
+
+#include "Connection.h"
+#include "RemoteMediaResourceIdentifier.h"
+#include <WebCore/PlatformMediaResourceLoader.h>
+#include <WebCore/PolicyChecker.h>
+#include <WebCore/ResourceResponse.h>
+
+namespace WebKit {
+
+class RemoteMediaResourceProxy final : public WebCore::PlatformMediaResourceClient {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    RemoteMediaResourceProxy(Ref<IPC::Connection>&&, WebCore::PlatformMediaResource&, RemoteMediaResourceIdentifier);
+    ~RemoteMediaResourceProxy();
+
+private:
+    // PlatformMediaResourceClient
+    void responseReceived(WebCore::PlatformMediaResource&, const WebCore::ResourceResponse&, CompletionHandler<void(WebCore::PolicyChecker::ShouldContinue)>&&) final;
+    void redirectReceived(WebCore::PlatformMediaResource&, WebCore::ResourceRequest&&, const WebCore::ResourceResponse&, CompletionHandler<void(WebCore::ResourceRequest&&)>&&) final;
+    bool shouldCacheResponse(WebCore::PlatformMediaResource&, const WebCore::ResourceResponse&) final;
+    void dataSent(WebCore::PlatformMediaResource&, unsigned long long, unsigned long long) final;
+    void dataReceived(WebCore::PlatformMediaResource&, const char*, int) final;
+    void accessControlCheckFailed(WebCore::PlatformMediaResource&, const WebCore::ResourceError&) final;
+    void loadFailed(WebCore::PlatformMediaResource&, const WebCore::ResourceError&) final;
+    void loadFinished(WebCore::PlatformMediaResource&) final;
+
+    Ref<IPC::Connection> m_connection;
+    WebCore::PlatformMediaResource& m_platformMediaResource;
+    RemoteMediaResourceIdentifier m_id;
+};
+
+} // namespace WebKit
+
+#endif