Skip to content
Permalink
Browse files
Remove UserMediaProcessManager processState map
https://bugs.webkit.org/show_bug.cgi?id=195056

Reviewed by Eric Carlson.

Before the patch, the WebProcessProxy->ProcessState map was storing the list of manager proxies and process state.
To improve on this model, this patch does the following:
- Move the process state to WebProcessProxy.
- Remove the map and replace it by a set of all manager proxies.

This simplifies the handling.
On WebProcess side, instead of storing the sandbox extensions in each WebPage, we handle them in WebProcess directly.
This mirrors what is being done in UIProcess and reduces the risk of inconsistencies between the two, the risk being that capture would fail.

* UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
(WebKit::UserMediaPermissionRequestManagerProxy::forEach):
(WebKit::UserMediaPermissionRequestManagerProxy::UserMediaPermissionRequestManagerProxy):
(WebKit::UserMediaPermissionRequestManagerProxy::~UserMediaPermissionRequestManagerProxy):
(WebKit::UserMediaPermissionRequestManagerProxy::captureStateChanged):
* UIProcess/UserMediaPermissionRequestManagerProxy.h:
* UIProcess/UserMediaProcessManager.cpp:
(WebKit::UserMediaProcessManager::muteCaptureMediaStreamsExceptIn):
(WebKit::UserMediaProcessManager::willCreateMediaStream):
(WebKit::UserMediaProcessManager::endedCaptureSession):
(WebKit::UserMediaProcessManager::setCaptureEnabled):
(WebKit::UserMediaProcessManager::captureDevicesChanged):
(WebKit::ProcessState::ProcessState): Deleted.
(WebKit::ProcessState::hasVideoExtension const): Deleted.
(WebKit::ProcessState::grantVideoExtension): Deleted.
(WebKit::ProcessState::revokeVideoExtension): Deleted.
(WebKit::ProcessState::hasAudioExtension const): Deleted.
(WebKit::ProcessState::grantAudioExtension): Deleted.
(WebKit::ProcessState::revokeAudioExtension): Deleted.
(WebKit::stateMap): Deleted.
(WebKit::processState): Deleted.
(WebKit::ProcessState::addRequestManager): Deleted.
(WebKit::ProcessState::removeRequestManager): Deleted.
(WebKit::UserMediaProcessManager::addUserMediaPermissionRequestManagerProxy): Deleted.
(WebKit::UserMediaProcessManager::removeUserMediaPermissionRequestManagerProxy): Deleted.
(WebKit::UserMediaProcessManager::startedCaptureSession): Deleted.
* UIProcess/UserMediaProcessManager.h:
* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::mediaCaptureSandboxExtensions const):
(WebKit::WebProcessProxy::hasVideoCaptureExtension const):
(WebKit::WebProcessProxy::grantVideoCaptureExtension):
(WebKit::WebProcessProxy::revokeVideoCaptureExtension):
(WebKit::WebProcessProxy::hasAudioCaptureExtension const):
(WebKit::WebProcessProxy::grantAudioCaptureExtension):
(WebKit::WebProcessProxy::revokeAudioCaptureExtension):
* WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
(WebKit::UserMediaPermissionRequestManager::~UserMediaPermissionRequestManager): Deleted.
(WebKit::UserMediaPermissionRequestManager::clear): Deleted.
(WebKit::UserMediaPermissionRequestManager::grantUserMediaDeviceSandboxExtensions): Deleted.
(WebKit::UserMediaPermissionRequestManager::revokeUserMediaDeviceSandboxExtensions): Deleted.
* WebProcess/MediaStream/UserMediaPermissionRequestManager.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::close):
(WebKit::WebPage::grantUserMediaDeviceSandboxExtensions): Deleted.
(WebKit::WebPage::revokeUserMediaDeviceSandboxExtensions): Deleted.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::grantUserMediaDeviceSandboxExtensions):
(WebKit::WebProcess::revokeUserMediaDeviceSandboxExtensions):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:


Canonical link: https://commits.webkit.org/209457@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242142 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
youennf committed Feb 27, 2019
1 parent 5aeb4d6 commit 8c5eb6e483d9ce6454ab03e54d83890e51d0e5ee
Showing 14 changed files with 209 additions and 225 deletions.
@@ -1,3 +1,72 @@
2019-02-27 Youenn Fablet <youenn@apple.com>

Remove UserMediaProcessManager processState map
https://bugs.webkit.org/show_bug.cgi?id=195056

Reviewed by Eric Carlson.

Before the patch, the WebProcessProxy->ProcessState map was storing the list of manager proxies and process state.
To improve on this model, this patch does the following:
- Move the process state to WebProcessProxy.
- Remove the map and replace it by a set of all manager proxies.

This simplifies the handling.
On WebProcess side, instead of storing the sandbox extensions in each WebPage, we handle them in WebProcess directly.
This mirrors what is being done in UIProcess and reduces the risk of inconsistencies between the two, the risk being that capture would fail.

* UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
(WebKit::UserMediaPermissionRequestManagerProxy::forEach):
(WebKit::UserMediaPermissionRequestManagerProxy::UserMediaPermissionRequestManagerProxy):
(WebKit::UserMediaPermissionRequestManagerProxy::~UserMediaPermissionRequestManagerProxy):
(WebKit::UserMediaPermissionRequestManagerProxy::captureStateChanged):
* UIProcess/UserMediaPermissionRequestManagerProxy.h:
* UIProcess/UserMediaProcessManager.cpp:
(WebKit::UserMediaProcessManager::muteCaptureMediaStreamsExceptIn):
(WebKit::UserMediaProcessManager::willCreateMediaStream):
(WebKit::UserMediaProcessManager::endedCaptureSession):
(WebKit::UserMediaProcessManager::setCaptureEnabled):
(WebKit::UserMediaProcessManager::captureDevicesChanged):
(WebKit::ProcessState::ProcessState): Deleted.
(WebKit::ProcessState::hasVideoExtension const): Deleted.
(WebKit::ProcessState::grantVideoExtension): Deleted.
(WebKit::ProcessState::revokeVideoExtension): Deleted.
(WebKit::ProcessState::hasAudioExtension const): Deleted.
(WebKit::ProcessState::grantAudioExtension): Deleted.
(WebKit::ProcessState::revokeAudioExtension): Deleted.
(WebKit::stateMap): Deleted.
(WebKit::processState): Deleted.
(WebKit::ProcessState::addRequestManager): Deleted.
(WebKit::ProcessState::removeRequestManager): Deleted.
(WebKit::UserMediaProcessManager::addUserMediaPermissionRequestManagerProxy): Deleted.
(WebKit::UserMediaProcessManager::removeUserMediaPermissionRequestManagerProxy): Deleted.
(WebKit::UserMediaProcessManager::startedCaptureSession): Deleted.
* UIProcess/UserMediaProcessManager.h:
* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::mediaCaptureSandboxExtensions const):
(WebKit::WebProcessProxy::hasVideoCaptureExtension const):
(WebKit::WebProcessProxy::grantVideoCaptureExtension):
(WebKit::WebProcessProxy::revokeVideoCaptureExtension):
(WebKit::WebProcessProxy::hasAudioCaptureExtension const):
(WebKit::WebProcessProxy::grantAudioCaptureExtension):
(WebKit::WebProcessProxy::revokeAudioCaptureExtension):
* WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
(WebKit::UserMediaPermissionRequestManager::~UserMediaPermissionRequestManager): Deleted.
(WebKit::UserMediaPermissionRequestManager::clear): Deleted.
(WebKit::UserMediaPermissionRequestManager::grantUserMediaDeviceSandboxExtensions): Deleted.
(WebKit::UserMediaPermissionRequestManager::revokeUserMediaDeviceSandboxExtensions): Deleted.
* WebProcess/MediaStream/UserMediaPermissionRequestManager.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::close):
(WebKit::WebPage::grantUserMediaDeviceSandboxExtensions): Deleted.
(WebKit::WebPage::revokeUserMediaDeviceSandboxExtensions): Deleted.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::grantUserMediaDeviceSandboxExtensions):
(WebKit::WebProcess::revokeUserMediaDeviceSandboxExtensions):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

2019-02-27 Per Arne Vollan <pvollan@apple.com>

[macOS] Disable permissive call logging in sandbox
@@ -51,20 +51,35 @@ static uint64_t generateRequestID()
}
#endif

#if ENABLE(MEDIA_STREAM)
static HashSet<UserMediaPermissionRequestManagerProxy*>& proxies()
{
static NeverDestroyed<HashSet<UserMediaPermissionRequestManagerProxy*>> set;
return set;
}

void UserMediaPermissionRequestManagerProxy::forEach(const WTF::Function<void(UserMediaPermissionRequestManagerProxy&)>& function)
{
for (auto* proxy : proxies())
function(*proxy);
}
#endif

UserMediaPermissionRequestManagerProxy::UserMediaPermissionRequestManagerProxy(WebPageProxy& page)
: m_page(page)
, m_rejectionTimer(RunLoop::main(), this, &UserMediaPermissionRequestManagerProxy::rejectionTimerFired)
, m_watchdogTimer(RunLoop::main(), this, &UserMediaPermissionRequestManagerProxy::watchdogTimerFired)
{
#if ENABLE(MEDIA_STREAM)
UserMediaProcessManager::singleton().addUserMediaPermissionRequestManagerProxy(*this);
proxies().add(this);
#endif
}

UserMediaPermissionRequestManagerProxy::~UserMediaPermissionRequestManagerProxy()
{
#if ENABLE(MEDIA_STREAM)
UserMediaProcessManager::singleton().removeUserMediaPermissionRequestManagerProxy(*this);
UserMediaProcessManager::singleton().endedCaptureSession(*this);
proxies().remove(this);
#endif
invalidatePendingRequests();
}
@@ -592,8 +607,6 @@ void UserMediaPermissionRequestManagerProxy::captureStateChanged(MediaProducer::

if ((wasCapturingAudio && !isCapturingAudio) || (wasCapturingVideo && !isCapturingVideo))
UserMediaProcessManager::singleton().endedCaptureSession(*this);
if ((!wasCapturingAudio && isCapturingAudio) || (!wasCapturingVideo && isCapturingVideo))
UserMediaProcessManager::singleton().startedCaptureSession(*this);

if (m_captureState == (newState & activeCaptureMask))
return;
@@ -47,6 +47,10 @@ class UserMediaPermissionRequestManagerProxy : public CanMakeWeakPtr<UserMediaPe

WebPageProxy& page() const { return m_page; }

#if ENABLE(MEDIA_STREAM)
static void forEach(const WTF::Function<void(UserMediaPermissionRequestManagerProxy&)>&);
#endif

void invalidatePendingRequests();

void requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, Ref<WebCore::SecurityOrigin>&& userMediaDocumentOrigin, Ref<WebCore::SecurityOrigin>&& topLevelDocumentOrigin, WebCore::MediaStreamRequest&&);

0 comments on commit 8c5eb6e

Please sign in to comment.