Skip to content

Commit f230e86

Browse files
Introduce RemotePagePlaybackSessionManagerProxy
https://bugs.webkit.org/show_bug.cgi?id=294646 rdar://153691151 Reviewed by Eric Carlson. This is a little message forwarding object like RemotePageDrawingAreaProxy, which also doesn't need to receive synchronous IPC messages and can become even simpler! * Source/WebKit/Sources.txt: * Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.h: * Source/WebKit/UIProcess/RemotePagePlaybackSessionManagerProxy.cpp: Added. (WebKit::RemotePagePlaybackSessionManagerProxy::create): (WebKit::RemotePagePlaybackSessionManagerProxy::RemotePagePlaybackSessionManagerProxy): (WebKit::RemotePagePlaybackSessionManagerProxy::~RemotePagePlaybackSessionManagerProxy): (WebKit::RemotePagePlaybackSessionManagerProxy::didReceiveMessage): * Source/WebKit/UIProcess/RemotePagePlaybackSessionManagerProxy.h: Added. * Source/WebKit/UIProcess/RemotePageProxy.cpp: (WebKit::RemotePageProxy::injectPageIntoNewProcess): * Source/WebKit/UIProcess/RemotePageProxy.h: * Source/WebKit/WebKit.xcodeproj/project.pbxproj: Canonical link: https://commits.webkit.org/296381@main
1 parent 90d028c commit f230e86

10 files changed

Lines changed: 138 additions & 9 deletions

Source/WebKit/Sources.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ UIProcess/ProvisionalFrameProxy.cpp
413413
UIProcess/ProvisionalPageProxy.cpp
414414
UIProcess/RemotePageDrawingAreaProxy.cpp
415415
UIProcess/RemotePageFullscreenManagerProxy.cpp
416+
UIProcess/RemotePagePlaybackSessionManagerProxy.cpp
416417
UIProcess/RemotePageProxy.cpp
417418
UIProcess/RemotePageVideoPresentationManagerProxy.cpp
418419
UIProcess/ResponsivenessTimer.cpp

Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ namespace WebKit {
4949

5050
class WebPageProxy;
5151
class PlaybackSessionManagerProxy;
52+
class RemotePagePlaybackSessionManagerProxy;
5253
class VideoReceiverEndpointMessage;
5354
class VideoReceiverSwapEndpointMessage;
5455
struct SharedPreferencesForWebProcess;
@@ -268,6 +269,7 @@ class PlaybackSessionManagerProxy
268269

269270
private:
270271
friend class PlaybackSessionModelContext;
272+
friend class RemotePagePlaybackSessionManagerProxy;
271273
friend class VideoPresentationManagerProxy;
272274

273275
explicit PlaybackSessionManagerProxy(WebPageProxy&);

Source/WebKit/UIProcess/Gamepad/wpe/GamepadProviderWPE.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include <WebCore/GamepadProviderClient.h>
3232
#include <WebCore/NotImplemented.h>
3333
#include <wpe/wpe-platform.h>
34+
#include <wtf/NeverDestroyed.h>
35+
#include <wtf/glib/GUniquePtr.h>
3436

3537
namespace WebKit {
3638
using namespace WebCore;

Source/WebKit/UIProcess/RemotePageDrawingAreaProxy.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,4 @@ void RemotePageDrawingAreaProxy::didReceiveMessage(IPC::Connection& connection,
6565
drawingArea->didReceiveMessage(connection, decoder);
6666
}
6767

68-
bool RemotePageDrawingAreaProxy::didReceiveSyncMessage(IPC::Connection& connection, IPC::Decoder& decoder, UniqueRef<IPC::Encoder>& encoder)
69-
{
70-
if (RefPtr drawingArea = m_drawingArea.get())
71-
return drawingArea->didReceiveSyncMessage(connection, decoder, encoder);
72-
ASSERT_NOT_REACHED();
73-
return false;
74-
}
75-
7668
}

Source/WebKit/UIProcess/RemotePageDrawingAreaProxy.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class RemotePageDrawingAreaProxy : public IPC::MessageReceiver, public RefCounte
5252
RemotePageDrawingAreaProxy(DrawingAreaProxy&, WebProcessProxy&);
5353

5454
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
55-
bool didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, UniqueRef<IPC::Encoder>&) final;
5655

5756
WeakPtr<DrawingAreaProxy> m_drawingArea;
5857
DrawingAreaIdentifier m_identifier;
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (C) 2025 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#include "config.h"
27+
#include "RemotePagePlaybackSessionManagerProxy.h"
28+
29+
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
30+
31+
#include "PlaybackSessionManagerProxy.h"
32+
#include "PlaybackSessionManagerProxyMessages.h"
33+
#include "WebProcessProxy.h"
34+
35+
namespace WebKit {
36+
37+
Ref<RemotePagePlaybackSessionManagerProxy> RemotePagePlaybackSessionManagerProxy::create(WebCore::PageIdentifier identifier, PlaybackSessionManagerProxy* manager, WebProcessProxy& process)
38+
{
39+
return adoptRef(*new RemotePagePlaybackSessionManagerProxy(identifier, manager, process));
40+
}
41+
42+
RemotePagePlaybackSessionManagerProxy::RemotePagePlaybackSessionManagerProxy(WebCore::PageIdentifier identifier, PlaybackSessionManagerProxy* manager, WebProcessProxy& process)
43+
: m_identifier(identifier)
44+
, m_manager(manager)
45+
, m_process(process)
46+
{
47+
process.addMessageReceiver(Messages::PlaybackSessionManagerProxy::messageReceiverName(), m_identifier, *this);
48+
}
49+
50+
RemotePagePlaybackSessionManagerProxy::~RemotePagePlaybackSessionManagerProxy()
51+
{
52+
m_process->removeMessageReceiver(Messages::PlaybackSessionManagerProxy::messageReceiverName(), m_identifier);
53+
}
54+
55+
void RemotePagePlaybackSessionManagerProxy::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder)
56+
{
57+
if (RefPtr manager = m_manager.get())
58+
manager->didReceiveMessage(connection, decoder);
59+
}
60+
61+
}
62+
63+
#endif
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (C) 2025 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#pragma once
27+
28+
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
29+
30+
#include "MessageReceiver.h"
31+
#include <WebCore/PageIdentifier.h>
32+
33+
namespace WebKit {
34+
35+
class PlaybackSessionManagerProxy;
36+
class WebProcessProxy;
37+
38+
class RemotePagePlaybackSessionManagerProxy : public IPC::MessageReceiver, public RefCounted<RemotePagePlaybackSessionManagerProxy> {
39+
public:
40+
static Ref<RemotePagePlaybackSessionManagerProxy> create(WebCore::PageIdentifier, PlaybackSessionManagerProxy*, WebProcessProxy&);
41+
42+
~RemotePagePlaybackSessionManagerProxy();
43+
44+
void ref() const final { RefCounted::ref(); }
45+
void deref() const final { RefCounted::deref(); }
46+
47+
private:
48+
RemotePagePlaybackSessionManagerProxy(WebCore::PageIdentifier, PlaybackSessionManagerProxy*, WebProcessProxy&);
49+
50+
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
51+
52+
const WebCore::PageIdentifier m_identifier;
53+
const WeakPtr<PlaybackSessionManagerProxy> m_manager;
54+
const Ref<WebProcessProxy> m_process;
55+
};
56+
57+
}
58+
59+
#endif

Source/WebKit/UIProcess/RemotePageProxy.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ void RemotePageProxy::injectPageIntoNewProcess()
102102
#endif
103103
#if ENABLE(VIDEO_PRESENTATION_MODE)
104104
m_videoPresentationManager = RemotePageVideoPresentationManagerProxy::create(pageID(), m_process, page->protectedVideoPresentationManager().get());
105+
#endif
106+
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
107+
m_playbackSessionManager = RemotePagePlaybackSessionManagerProxy::create(pageID(), page->protectedPlaybackSessionManager().get(), m_process);
105108
#endif
106109
m_visitedLinkStoreRegistration = makeUnique<RemotePageVisitedLinkStoreRegistration>(*page, m_process);
107110

Source/WebKit/UIProcess/RemotePageProxy.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class DrawingAreaProxy;
6363
class NativeWebMouseEvent;
6464
class RemotePageDrawingAreaProxy;
6565
class RemotePageFullscreenManagerProxy;
66+
class RemotePagePlaybackSessionManagerProxy;
6667
class RemotePageVideoPresentationManagerProxy;
6768
class RemotePageVisitedLinkStoreRegistration;
6869
class UserData;
@@ -122,6 +123,9 @@ class RemotePageProxy : public IPC::MessageReceiver, public RefCounted<RemotePag
122123
#endif
123124
#if ENABLE(VIDEO_PRESENTATION_MODE)
124125
RefPtr<RemotePageVideoPresentationManagerProxy> m_videoPresentationManager;
126+
#endif
127+
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
128+
RefPtr<RemotePagePlaybackSessionManagerProxy> m_playbackSessionManager;
125129
#endif
126130
std::unique_ptr<RemotePageVisitedLinkStoreRegistration> m_visitedLinkStoreRegistration;
127131
WebPageProxyMessageReceiverRegistration m_messageReceiverRegistration;

Source/WebKit/WebKit.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8624,6 +8624,8 @@
86248624
FA4066DF2D4472CE00A2E622 /* WKPageFullScreenClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKPageFullScreenClient.h; sourceTree = "<group>"; };
86258625
FA4368C62B811BA3001B993D /* CoreIPCNSURLCredential.serialization.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CoreIPCNSURLCredential.serialization.in; sourceTree = "<group>"; };
86268626
FA4899BD2C5C56E800B04660 /* APISerializedScriptValue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = APISerializedScriptValue.cpp; sourceTree = "<group>"; };
8627+
FA4EFC4E2E024493005DADAF /* RemotePagePlaybackSessionManagerProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemotePagePlaybackSessionManagerProxy.h; sourceTree = "<group>"; };
8628+
FA4EFC4F2E024493005DADAF /* RemotePagePlaybackSessionManagerProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemotePagePlaybackSessionManagerProxy.cpp; sourceTree = "<group>"; };
86278629
FA4FE2642B75EAFF0016E671 /* CoreIPCNull.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreIPCNull.mm; sourceTree = "<group>"; };
86288630
FA580AFF2DA64085005E4965 /* UnifiedSource141.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = UnifiedSource141.cpp; sourceTree = "<group>"; };
86298631
FA580B002DA64085005E4965 /* UnifiedSource142.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = UnifiedSource142.cpp; sourceTree = "<group>"; };
@@ -14831,6 +14833,8 @@
1483114833
5CCB54DB2A4FEA6A0005FAA8 /* RemotePageDrawingAreaProxy.h */,
1483214834
FABBBC802D35AC6800820017 /* RemotePageFullscreenManagerProxy.cpp */,
1483314835
FABBBC7F2D35AC6800820017 /* RemotePageFullscreenManagerProxy.h */,
14836+
FA4EFC4F2E024493005DADAF /* RemotePagePlaybackSessionManagerProxy.cpp */,
14837+
FA4EFC4E2E024493005DADAF /* RemotePagePlaybackSessionManagerProxy.h */,
1483414838
5C907E9A294D507100B3402D /* RemotePageProxy.cpp */,
1483514839
5C907E99294D507100B3402D /* RemotePageProxy.h */,
1483614840
FA1A7DE52E012DB3005E394B /* RemotePageVideoPresentationManagerProxy.cpp */,

0 commit comments

Comments
 (0)