Simplify UserMediaPermissionRequestManager management of UserMediaRequest
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Sep 2019 14:16:44 +0000 (14:16 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Sep 2019 14:16:44 +0000 (14:16 +0000)
commit80f1d182be32b284723405c5199204f557f2edaa
treeae64c0e474e6582a17c430e68400cb5bdbac4639
parent6248cdacc2ce0d9a10aa1520a6bc4b7abcf1f43c
Simplify UserMediaPermissionRequestManager management of UserMediaRequest
https://bugs.webkit.org/show_bug.cgi?id=201688

Reviewed by Eric Carlson.

Source/WebCore:

Covered by existing tests and modified test.

* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::UserMediaRequest):
* Modules/mediastream/UserMediaRequest.h:
(WebCore::UserMediaRequest::identifier const):
Add an identifier generated for each request.

Source/WebKit:

Instead of having two maps to go from ID to request and request to ID,
Make request own its ID and keep a single ID to request map.
Rename it to m_ongoingUserMediaRequests.

Rename requests that are not processed because the document cannot start media as m_pendingUserMediaRequests.
In case the request is cancelled following the stopping of active dom objects, we just remove it from m_pendingUserMediaRequests
instead of denying the request. This matches Chrome and Firefox behavior.

* WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
(WebKit::UserMediaPermissionRequestManager::startUserMediaRequest):
(WebKit::UserMediaPermissionRequestManager::sendUserMediaRequest):
(WebKit::UserMediaPermissionRequestManager::cancelUserMediaRequest):
(WebKit::UserMediaPermissionRequestManager::mediaCanStart):
(WebKit::UserMediaPermissionRequestManager::userMediaAccessWasGranted):
(WebKit::UserMediaPermissionRequestManager::userMediaAccessWasDenied):
(WebKit::UserMediaPermissionRequestManager::addDeviceChangeObserver):
(WebKit::generateRequestID): Deleted.
(WebKit::UserMediaPermissionRequestManager::removeMediaRequestFromMaps): Deleted.
* WebProcess/MediaStream/UserMediaPermissionRequestManager.h:

LayoutTests:

* http/tests/media/media-stream/disconnected-frame-permission-denied-expected.txt:
* http/tests/media/media-stream/disconnected-frame-permission-denied.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250233 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/http/tests/media/media-stream/disconnected-frame-permission-denied-expected.txt
LayoutTests/http/tests/media/media-stream/disconnected-frame-permission-denied.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/UserMediaRequest.cpp
Source/WebCore/Modules/mediastream/UserMediaRequest.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp
Source/WebKit/WebProcess/MediaStream/UserMediaPermissionRequestManager.h