<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[248847] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/248847">248847</a></dd>
<dt>Author</dt> <dd>youenn@apple.com</dd>
<dt>Date</dt> <dd>2019-08-19 00:40:52 -0700 (Mon, 19 Aug 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>enumerateDevices should return the same JS objects if called twice
https://bugs.webkit.org/show_bug.cgi?id=200767

Reviewed by Eric Carlson.

Source/WebCore:

Make MediaDevices store the last list of enumerated MediaDeviceInfo objects.
Reuse them for the next enumerateDevices call if needed.
In case of a device change event, make sure the next enumerateDevices call will fetch the new list of devices.
When constructing the new list of devices, reuse any preexisting device in the old list as specified by
https://w3c.github.io/mediacapture-main/#dom-mediadevices-enumeratedevices.

Update enumerateDevices to use a completion handler.
Remove MediaDevicesRequest and MediaDevicesEnumerationRequest.
Covered by updated test and existing tests.

* Modules/mediastream/MediaDeviceInfo.cpp:
(WebCore::MediaDeviceInfo::MediaDeviceInfo):
(WebCore::MediaDeviceInfo::create):
* Modules/mediastream/MediaDeviceInfo.h:
* Modules/mediastream/MediaDeviceInfo.idl:
* Modules/mediastream/MediaDevices.cpp:
(WebCore::MediaDevices::MediaDevices):
(WebCore::MediaDevices::stop):
(WebCore::MediaDevices::refreshDevices):
(WebCore::MediaDevices::enumerateDevices):
(WebCore::MediaDevices::scheduledEventTimerFired):
(WebCore::MediaDevices::listenForDeviceChanges):
(WebCore::MediaDevices::addEventListener):
* Modules/mediastream/MediaDevices.h:
* Modules/mediastream/MediaDevices.idl:
* Modules/mediastream/MediaDevicesEnumerationRequest.cpp: Removed.
* Modules/mediastream/MediaDevicesEnumerationRequest.h: Removed.
* Modules/mediastream/MediaDevicesRequest.cpp: Removed.
* Modules/mediastream/MediaDevicesRequest.h: Removed.
* Modules/mediastream/RTCRtpSender.cpp:
* Modules/mediastream/UserMediaClient.h:
* Modules/mediastream/UserMediaController.cpp:
(WebCore::isAllowedToUse):
(WebCore::UserMediaController::canCallGetUserMedia const):
* Modules/mediastream/UserMediaController.h:
(WebCore::UserMediaController::enumerateMediaDevices):
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:

Source/WebKit:

Update code as enumerate device request is now gone.
Make use of async IPC to simplify code since we are now passing a completion handler directly.

* UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
(WebKit::UserMediaPermissionRequestManagerProxy::captureDevicesChanged):
(WebKit::UserMediaPermissionRequestManagerProxy::finishGrantingRequest):
(WebKit::UserMediaPermissionRequestManagerProxy::enumerateMediaDevicesForFrame):
* UIProcess/UserMediaPermissionRequestManagerProxy.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
(WebKit::UserMediaPermissionRequestManager::enumerateMediaDevices):
* WebProcess/MediaStream/UserMediaPermissionRequestManager.h:
* WebProcess/WebCoreSupport/WebUserMediaClient.cpp:
(WebKit::WebUserMediaClient::enumerateMediaDevices):
* WebProcess/WebCoreSupport/WebUserMediaClient.h:
* WebProcess/WebPage/WebPage.cpp:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

LayoutTests:

* fast/mediastream/device-change-event-2.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamdevicechangeevent2html">trunk/LayoutTests/fast/mediastream/device-change-event-2.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreHeaderscmake">trunk/Source/WebCore/Headers.cmake</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamMediaDeviceInfocpp">trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamMediaDeviceInfoh">trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.h</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamMediaDeviceInfoidl">trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.idl</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamMediaDevicescpp">trunk/Source/WebCore/Modules/mediastream/MediaDevices.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamMediaDevicesh">trunk/Source/WebCore/Modules/mediastream/MediaDevices.h</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamRTCRtpSendercpp">trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamUserMediaClienth">trunk/Source/WebCore/Modules/mediastream/UserMediaClient.h</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamUserMediaControllercpp">trunk/Source/WebCore/Modules/mediastream/UserMediaController.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamUserMediaControllerh">trunk/Source/WebCore/Modules/mediastream/UserMediaController.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWebGPUDevicecpp">trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp</a></li>
<li><a href="#trunkSourceWebCoreSourcestxt">trunk/Source/WebCore/Sources.txt</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessUserMediaPermissionRequestManagerProxycpp">trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessUserMediaPermissionRequestManagerProxyh">trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxycpp">trunk/Source/WebKit/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxyh">trunk/Source/WebKit/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxymessagesin">trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKitWebProcessMediaStreamUserMediaPermissionRequestManagercpp">trunk/Source/WebKit/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessMediaStreamUserMediaPermissionRequestManagerh">trunk/Source/WebKit/WebProcess/MediaStream/UserMediaPermissionRequestManager.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebUserMediaClientcpp">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebUserMediaClient.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebUserMediaClienth">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebUserMediaClient.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagecpp">trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPageh">trunk/Source/WebKit/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagemessagesin">trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreModulesmediastreamMediaDevicesEnumerationRequestcpp">trunk/Source/WebCore/Modules/mediastream/MediaDevicesEnumerationRequest.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamMediaDevicesEnumerationRequesth">trunk/Source/WebCore/Modules/mediastream/MediaDevicesEnumerationRequest.h</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamMediaDevicesRequestcpp">trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamMediaDevicesRequesth">trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/LayoutTests/ChangeLog 2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2019-08-19  Youenn Fablet  <youenn@apple.com>
+
+        enumerateDevices should return the same JS objects if called twice
+        https://bugs.webkit.org/show_bug.cgi?id=200767
+
+        Reviewed by Eric Carlson.
+
+        * fast/mediastream/device-change-event-2.html:
+
</ins><span class="cx"> 2019-08-18  Cathie Chen  <cathiechen@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         Crash in Document::deliverResizeObservations
</span></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamdevicechangeevent2html"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/mediastream/device-change-event-2.html (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/device-change-event-2.html    2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/LayoutTests/fast/mediastream/device-change-event-2.html       2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -27,33 +27,39 @@
</span><span class="cx">             .then(s => stream = s)
</span><span class="cx"> 
</span><span class="cx">         let devices = await navigator.mediaDevices.enumerateDevices();
</span><ins>+        let devices2 = await navigator.mediaDevices.enumerateDevices();
</ins><span class="cx"> 
</span><span class="cx">         assert_true(!!devices.length, "check there are some devices");
</span><ins>+        assert_array_equals(devices, devices2);
</ins><span class="cx"> 
</span><span class="cx">         testRunner.clearMockMediaDevices();
</span><del>-
</del><ins>+        await new Promise((resolve, reject) => {
+            navigator.mediaDevices.ondevicechange = resolve;
+            setTimeout(() => {
+                reject("event 1 took too long");
+            }, 5000);
+        });
</ins><span class="cx">         devices = await navigator.mediaDevices.enumerateDevices();
</span><span class="cx">         assert_false(!!devices.length, "check there are no more devices");
</span><span class="cx"> 
</span><ins>+        testRunner.addMockCameraDevice("id1", "my camera");
</ins><span class="cx">         await new Promise((resolve, reject) => {
</span><span class="cx">             navigator.mediaDevices.ondevicechange = resolve;
</span><span class="cx">             setTimeout(() => {
</span><del>-                console.log("event 1 took too long");
-                resolve();
</del><ins>+                reject("event 2 took too long");
</ins><span class="cx">             }, 5000);
</span><del>-            testRunner.addMockCameraDevice("id1", "my camera");
</del><span class="cx">         });
</span><ins>+
</ins><span class="cx">         devices = await navigator.mediaDevices.enumerateDevices();
</span><span class="cx">         assert_equals(devices[0].kind, "videoinput");
</span><span class="cx">         assert_equals(devices[0].label, "my camera");
</span><span class="cx"> 
</span><ins>+        testRunner.addMockMicrophoneDevice("id2", "my mic");
</ins><span class="cx">         await new Promise((resolve, reject) => {
</span><span class="cx">             navigator.mediaDevices.ondevicechange = resolve;
</span><span class="cx">             setTimeout(() => {
</span><del>-                console.log("event 2 took too long");
-                resolve();
</del><ins>+                reject("event 3 took too long");
</ins><span class="cx">             }, 5000);
</span><del>-            testRunner.addMockMicrophoneDevice("id2", "my mic");
</del><span class="cx">         });
</span><span class="cx">         devices = await navigator.mediaDevices.enumerateDevices();
</span><span class="cx">         assert_equals(devices[0].kind, "audioinput");
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/ChangeLog      2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -1,3 +1,49 @@
</span><ins>+2019-08-19  Youenn Fablet  <youenn@apple.com>
+
+        enumerateDevices should return the same JS objects if called twice
+        https://bugs.webkit.org/show_bug.cgi?id=200767
+
+        Reviewed by Eric Carlson.
+
+        Make MediaDevices store the last list of enumerated MediaDeviceInfo objects.
+        Reuse them for the next enumerateDevices call if needed.
+        In case of a device change event, make sure the next enumerateDevices call will fetch the new list of devices.
+        When constructing the new list of devices, reuse any preexisting device in the old list as specified by
+        https://w3c.github.io/mediacapture-main/#dom-mediadevices-enumeratedevices.
+
+        Update enumerateDevices to use a completion handler.
+        Remove MediaDevicesRequest and MediaDevicesEnumerationRequest.
+        Covered by updated test and existing tests.
+
+        * Modules/mediastream/MediaDeviceInfo.cpp:
+        (WebCore::MediaDeviceInfo::MediaDeviceInfo):
+        (WebCore::MediaDeviceInfo::create):
+        * Modules/mediastream/MediaDeviceInfo.h:
+        * Modules/mediastream/MediaDeviceInfo.idl:
+        * Modules/mediastream/MediaDevices.cpp:
+        (WebCore::MediaDevices::MediaDevices):
+        (WebCore::MediaDevices::stop):
+        (WebCore::MediaDevices::refreshDevices):
+        (WebCore::MediaDevices::enumerateDevices):
+        (WebCore::MediaDevices::scheduledEventTimerFired):
+        (WebCore::MediaDevices::listenForDeviceChanges):
+        (WebCore::MediaDevices::addEventListener):
+        * Modules/mediastream/MediaDevices.h:
+        * Modules/mediastream/MediaDevices.idl:
+        * Modules/mediastream/MediaDevicesEnumerationRequest.cpp: Removed.
+        * Modules/mediastream/MediaDevicesEnumerationRequest.h: Removed.
+        * Modules/mediastream/MediaDevicesRequest.cpp: Removed.
+        * Modules/mediastream/MediaDevicesRequest.h: Removed.
+        * Modules/mediastream/RTCRtpSender.cpp:
+        * Modules/mediastream/UserMediaClient.h:
+        * Modules/mediastream/UserMediaController.cpp:
+        (WebCore::isAllowedToUse):
+        (WebCore::UserMediaController::canCallGetUserMedia const):
+        * Modules/mediastream/UserMediaController.h:
+        (WebCore::UserMediaController::enumerateMediaDevices):
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2019-08-18  Yusuke Suzuki  <ysuzuki@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [WTF] Add makeUnique<T>, which ensures T is fast-allocated, makeUnique / makeUniqueWithoutFastMallocCheck part
</span></span></pre></div>
<a id="trunkSourceWebCoreHeaderscmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Headers.cmake (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Headers.cmake       2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Headers.cmake  2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -90,7 +90,6 @@
</span><span class="cx"> 
</span><span class="cx">     Modules/mediastream/DoubleRange.h
</span><span class="cx">     Modules/mediastream/LongRange.h
</span><del>-    Modules/mediastream/MediaDevicesEnumerationRequest.h
</del><span class="cx">     Modules/mediastream/MediaStreamTrack.h
</span><span class="cx">     Modules/mediastream/MediaTrackConstraints.h
</span><span class="cx">     Modules/mediastream/RTCController.h
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamMediaDeviceInfocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.cpp (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.cpp     2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.cpp        2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -34,9 +34,13 @@
</span><span class="cx"> 
</span><span class="cx"> WTF_MAKE_ISO_ALLOCATED_IMPL(MediaDeviceInfo);
</span><span class="cx"> 
</span><del>-inline MediaDeviceInfo::MediaDeviceInfo(ScriptExecutionContext* context, const String& label, const String& deviceId, const String& groupId, Kind kind)
-    : ContextDestructionObserver(context)
-    , m_label(label)
</del><ins>+Ref<MediaDeviceInfo> MediaDeviceInfo::create(const String& label, const String& deviceId, const String& groupId, Kind kind)
+{
+    return adoptRef(*new MediaDeviceInfo(label, deviceId, groupId, kind));
+}
+
+MediaDeviceInfo::MediaDeviceInfo(const String& label, const String& deviceId, const String& groupId, Kind kind)
+    : m_label(label)
</ins><span class="cx">     , m_deviceId(deviceId)
</span><span class="cx">     , m_groupId(groupId)
</span><span class="cx">     , m_kind(kind)
</span><span class="lines">@@ -43,11 +47,6 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Ref<MediaDeviceInfo> MediaDeviceInfo::create(ScriptExecutionContext* context, const String& label, const String& deviceId, const String& groupId, Kind kind)
-{
-    return adoptRef(*new MediaDeviceInfo(context, label, deviceId, groupId, kind));
-}
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamMediaDeviceInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.h (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.h       2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.h  2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -33,12 +33,12 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class MediaDeviceInfo final : public RefCounted<MediaDeviceInfo>, public ScriptWrappable, private ContextDestructionObserver {
</del><ins>+class MediaDeviceInfo final : public RefCounted<MediaDeviceInfo>, public ScriptWrappable {
</ins><span class="cx">     WTF_MAKE_ISO_ALLOCATED(MediaDeviceInfo);
</span><span class="cx"> public:
</span><span class="cx">     enum class Kind { Audioinput, Audiooutput, Videoinput };
</span><span class="cx"> 
</span><del>-    static Ref<MediaDeviceInfo> create(ScriptExecutionContext*, const String&, const String&, const String&, Kind);
</del><ins>+    static Ref<MediaDeviceInfo> create(const String&, const String&, const String&, Kind);
</ins><span class="cx"> 
</span><span class="cx">     const String& label() const { return m_label; }
</span><span class="cx">     const String& deviceId() const { return m_deviceId; }
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx">     Kind kind() const { return m_kind; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    MediaDeviceInfo(ScriptExecutionContext*, const String&, const String&, const String&, Kind);
</del><ins>+    MediaDeviceInfo(const String&, const String&, const String&, Kind);
</ins><span class="cx"> 
</span><span class="cx">     const String m_label;
</span><span class="cx">     const String m_deviceId;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamMediaDeviceInfoidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.idl (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.idl     2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDeviceInfo.idl        2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> [
</span><span class="cx">     Conditional=MEDIA_STREAM,
</span><span class="cx">     JSGenerateToJSObject,
</span><ins>+    SkipVTableValidation,
</ins><span class="cx"> ] interface MediaDeviceInfo {
</span><span class="cx">     readonly attribute DOMString deviceId;
</span><span class="cx">     readonly attribute MediaDeviceKind kind;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamMediaDevicescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/MediaDevices.cpp (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/MediaDevices.cpp        2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevices.cpp   2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2015 Ericsson AB. All rights reserved.
</span><del>- * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx"> #include "Document.h"
</span><span class="cx"> #include "Event.h"
</span><span class="cx"> #include "EventNames.h"
</span><del>-#include "MediaDevicesRequest.h"
</del><ins>+#include "JSMediaDeviceInfo.h"
</ins><span class="cx"> #include "MediaTrackSupportedConstraints.h"
</span><span class="cx"> #include "RealtimeMediaSourceSettings.h"
</span><span class="cx"> #include "RuntimeEnabledFeatures.h"
</span><span class="lines">@@ -61,6 +61,11 @@
</span><span class="cx">     static_assert(static_cast<size_t>(MediaDevices::DisplayCaptureSurfaceType::Window) == static_cast<size_t>(RealtimeMediaSourceSettings::DisplaySurfaceType::Window), "MediaDevices::DisplayCaptureSurfaceType::Window is not RealtimeMediaSourceSettings::DisplaySurfaceType::Window as expected");
</span><span class="cx">     static_assert(static_cast<size_t>(MediaDevices::DisplayCaptureSurfaceType::Application) == static_cast<size_t>(RealtimeMediaSourceSettings::DisplaySurfaceType::Application), "MediaDevices::DisplayCaptureSurfaceType::Application is not RealtimeMediaSourceSettings::DisplaySurfaceType::Application as expected");
</span><span class="cx">     static_assert(static_cast<size_t>(MediaDevices::DisplayCaptureSurfaceType::Browser) == static_cast<size_t>(RealtimeMediaSourceSettings::DisplaySurfaceType::Browser), "MediaDevices::DisplayCaptureSurfaceType::Browser is not RealtimeMediaSourceSettings::DisplaySurfaceType::Browser as expected");
</span><ins>+
+    if (auto* controller = UserMediaController::from(document.page())) {
+        m_canAccessCamera = controller->canCallGetUserMedia(document, { UserMediaController::CaptureType::Camera }) == UserMediaController::GetUserMediaAccess::CanCall;
+        m_canAccessMicrophone = controller->canCallGetUserMedia(document, { UserMediaController::CaptureType::Microphone }) == UserMediaController::GetUserMediaAccess::CanCall;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> MediaDevices::~MediaDevices() = default;
</span><span class="lines">@@ -73,6 +78,7 @@
</span><span class="cx">         if (document && controller)
</span><span class="cx">             controller->removeDeviceChangeObserver(m_deviceChangeToken);
</span><span class="cx">     }
</span><ins>+    m_devices.clear();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Ref<MediaDevices> MediaDevices::create(Document& document)
</span><span class="lines">@@ -129,12 +135,54 @@
</span><span class="cx">     request->start();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MediaDevices::enumerateDevices(EnumerateDevicesPromise&& promise) const
</del><ins>+void MediaDevices::refreshDevices(const Vector<CaptureDevice>& newDevices)
</ins><span class="cx"> {
</span><ins>+    Vector<Ref<MediaDeviceInfo>> devices;
+    for (auto& newDevice : newDevices) {
+        if (!m_canAccessMicrophone && newDevice.type() == CaptureDevice::DeviceType::Microphone)
+            continue;
+        if (!m_canAccessCamera && newDevice.type() == CaptureDevice::DeviceType::Camera)
+            continue;
+
+        auto index = m_devices.findMatching([&newDevice](auto& oldDevice) {
+            return oldDevice->deviceId() == newDevice.persistentId();
+        });
+        if (index != notFound) {
+            devices.append(m_devices[index].copyRef());
+            continue;
+        }
+
+        auto deviceType = newDevice.type() == CaptureDevice::DeviceType::Microphone ? MediaDeviceInfo::Kind::Audioinput : MediaDeviceInfo::Kind::Videoinput;
+        devices.append(MediaDeviceInfo::create(newDevice.label(), newDevice.persistentId(), newDevice.groupId(), deviceType));
+    }
+    m_devices = WTFMove(devices);
+}
+
+void MediaDevices::enumerateDevices(EnumerateDevicesPromise&& promise)
+{
</ins><span class="cx">     auto* document = this->document();
</span><span class="cx">     if (!document)
</span><span class="cx">         return;
</span><del>-    MediaDevicesRequest::create(*document, WTFMove(promise))->start();
</del><ins>+
+    auto* controller = UserMediaController::from(document->page());
+    if (!controller) {
+        promise.resolve({ });
+        return;
+    }
+    if (!m_canAccessCamera && !m_canAccessMicrophone) {
+        controller->logGetUserMediaDenial(*document, UserMediaController::GetUserMediaAccess::BlockedByFeaturePolicy, UserMediaController::BlockedCaller::EnumerateDevices);
+        promise.resolve({ });
+        return;
+    }
+
+    controller->enumerateMediaDevices(*document, [this, weakThis = makeWeakPtr(this), promise = WTFMove(promise)](const auto& newDevices, const auto& deviceIDHashSalt) mutable {
+        if (!weakThis || isContextStopped())
+            return;
+
+        this->document()->setDeviceIDHashSalt(deviceIDHashSalt);
+        refreshDevices(newDevices);
+        promise.resolve(m_devices);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> MediaTrackSupportedConstraints MediaDevices::getSupportedConstraints()
</span><span class="lines">@@ -158,8 +206,10 @@
</span><span class="cx"> 
</span><span class="cx"> void MediaDevices::scheduledEventTimerFired()
</span><span class="cx"> {
</span><del>-    if (scriptExecutionContext())
-        dispatchEvent(Event::create(eventNames().devicechangeEvent, Event::CanBubble::No, Event::IsCancelable::No));
</del><ins>+    if (isContextStopped())
+        return;
+
+    dispatchEvent(Event::create(eventNames().devicechangeEvent, Event::CanBubble::No, Event::IsCancelable::No));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool MediaDevices::hasPendingActivity() const
</span><span class="lines">@@ -177,33 +227,30 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool MediaDevices::addEventListener(const AtomString& eventType, Ref<EventListener>&& listener, const AddEventListenerOptions& options)
</del><ins>+void MediaDevices::listenForDeviceChanges()
</ins><span class="cx"> {
</span><del>-    if (!m_listeningForDeviceChanges && eventType == eventNames().devicechangeEvent) {
-        auto* document = this->document();
-        auto* controller = document ? UserMediaController::from(document->page()) : nullptr;
-        if (document && controller) {
-            m_listeningForDeviceChanges = true;
</del><ins>+    if (m_listeningForDeviceChanges || (!m_canAccessCamera && !m_canAccessMicrophone))
+        return;
</ins><span class="cx"> 
</span><del>-            m_deviceChangeToken = controller->addDeviceChangeObserver([weakThis = makeWeakPtr(*this), this]() {
</del><ins>+    m_listeningForDeviceChanges = true;
</ins><span class="cx"> 
</span><del>-                if (!weakThis || m_scheduledEventTimer.isActive())
-                    return;
</del><ins>+    auto* document = this->document();
+    auto* controller = document ? UserMediaController::from(document->page()) : nullptr;
+    if (!controller)
+        return;
</ins><span class="cx"> 
</span><del>-                auto* document = this->document();
-                auto* controller = document ? UserMediaController::from(document->page()) : nullptr;
-                if (!controller)
-                    return;
</del><ins>+    m_deviceChangeToken = controller->addDeviceChangeObserver([weakThis = makeWeakPtr(*this), this]() {
+        if (!weakThis || m_scheduledEventTimer.isActive())
+            return;
</ins><span class="cx"> 
</span><del>-                bool canAccessMicrophone = controller->canCallGetUserMedia(*document, { UserMediaController::CaptureType::Microphone }) == UserMediaController::GetUserMediaAccess::CanCall;
-                bool canAccessCamera = controller->canCallGetUserMedia(*document, { UserMediaController::CaptureType::Camera }) == UserMediaController::GetUserMediaAccess::CanCall;
-                if (!canAccessMicrophone && !canAccessCamera)
-                    return;
</del><ins>+        m_scheduledEventTimer.startOneShot(Seconds(randomNumber() / 2));
+    });
+}
</ins><span class="cx"> 
</span><del>-                m_scheduledEventTimer.startOneShot(Seconds(randomNumber() / 2));
-            });
-        }
-    }
</del><ins>+bool MediaDevices::addEventListener(const AtomString& eventType, Ref<EventListener>&& listener, const AddEventListenerOptions& options)
+{
+    if (eventType == eventNames().devicechangeEvent)
+        listenForDeviceChanges();
</ins><span class="cx"> 
</span><span class="cx">     return EventTargetWithInlineData::addEventListener(eventType, WTFMove(listener), options);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamMediaDevicesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/MediaDevices.h (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/MediaDevices.h  2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevices.h     2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -77,7 +77,7 @@
</span><span class="cx">     };
</span><span class="cx">     void getUserMedia(const StreamConstraints&, Promise&&) const;
</span><span class="cx">     void getDisplayMedia(const StreamConstraints&, Promise&&) const;
</span><del>-    void enumerateDevices(EnumerateDevicesPromise&&) const;
</del><ins>+    void enumerateDevices(EnumerateDevicesPromise&&);
</ins><span class="cx">     MediaTrackSupportedConstraints getSupportedConstraints();
</span><span class="cx"> 
</span><span class="cx">     using RefCounted<MediaDevices>::ref;
</span><span class="lines">@@ -91,6 +91,9 @@
</span><span class="cx">     void scheduledEventTimerFired();
</span><span class="cx">     bool addEventListener(const AtomString& eventType, Ref<EventListener>&&, const AddEventListenerOptions&) override;
</span><span class="cx"> 
</span><ins>+    void refreshDevices(const Vector<CaptureDevice>&);
+    void listenForDeviceChanges();
+
</ins><span class="cx">     friend class JSMediaDevicesOwner;
</span><span class="cx"> 
</span><span class="cx">     // ActiveDOMObject
</span><span class="lines">@@ -110,6 +113,10 @@
</span><span class="cx">     const EventNames& m_eventNames; // Need to cache this so we can use it from GC threads.
</span><span class="cx">     bool m_listeningForDeviceChanges { false };
</span><span class="cx">     bool m_disableGetDisplayMediaUserGestureConstraint { false };
</span><ins>+
+    Vector<Ref<MediaDeviceInfo>> m_devices;
+    bool m_canAccessCamera { false };
+    bool m_canAccessMicrophone { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamMediaDevicesEnumerationRequestcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/Modules/mediastream/MediaDevicesEnumerationRequest.cpp (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/MediaDevicesEnumerationRequest.cpp      2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevicesEnumerationRequest.cpp 2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -1,105 +0,0 @@
</span><del>-/*
- * Copyright (C) 2016 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. ``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
- * 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 "MediaDevicesEnumerationRequest.h"
-
-#if ENABLE(MEDIA_STREAM)
-
-#include "CaptureDevice.h"
-#include "Document.h"
-#include "Frame.h"
-#include "SecurityOrigin.h"
-#include "UserMediaController.h"
-
-namespace WebCore {
-
-Ref<MediaDevicesEnumerationRequest> MediaDevicesEnumerationRequest::create(Document& document, CompletionHandler&& completionHandler)
-{
-    return adoptRef(*new MediaDevicesEnumerationRequest(document, WTFMove(completionHandler)));
-}
-
-MediaDevicesEnumerationRequest::MediaDevicesEnumerationRequest(ScriptExecutionContext& context, CompletionHandler&& completionHandler)
-    : ContextDestructionObserver(&context)
-    , m_completionHandler(WTFMove(completionHandler))
-{
-}
-
-MediaDevicesEnumerationRequest::~MediaDevicesEnumerationRequest() = default;
-
-SecurityOrigin* MediaDevicesEnumerationRequest::userMediaDocumentOrigin() const
-{
-    if (!scriptExecutionContext())
-        return nullptr;
-
-    return scriptExecutionContext()->securityOrigin();
-}
-
-SecurityOrigin* MediaDevicesEnumerationRequest::topLevelDocumentOrigin() const
-{
-    if (!scriptExecutionContext())
-        return nullptr;
-
-    return &scriptExecutionContext()->topOrigin();
-}
-
-void MediaDevicesEnumerationRequest::contextDestroyed()
-{
-    // Calling cancel() may destroy ourselves.
-    Ref<MediaDevicesEnumerationRequest> protectedThis(*this);
-
-    cancel();
-    ContextDestructionObserver::contextDestroyed();
-}
-
-void MediaDevicesEnumerationRequest::start()
-{
-    ASSERT(scriptExecutionContext());
-
-    auto& document = downcast<Document>(*scriptExecutionContext());
-    auto* controller = UserMediaController::from(document.page());
-    if (!controller)
-        return;
-
-    Ref<MediaDevicesEnumerationRequest> protectedThis(*this);
-    controller->enumerateMediaDevices(*this);
-}
-
-void MediaDevicesEnumerationRequest::cancel()
-{
-    m_completionHandler = nullptr;
-}
-
-void MediaDevicesEnumerationRequest::setDeviceInfo(const Vector<CaptureDevice>& deviceList, const String& deviceIdentifierHashSalt, bool originHasPersistentAccess)
-{
-    if (m_completionHandler)
-        m_completionHandler(deviceList, deviceIdentifierHashSalt, originHasPersistentAccess);
-    m_completionHandler = nullptr;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM)
</del></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamMediaDevicesEnumerationRequesth"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/Modules/mediastream/MediaDevicesEnumerationRequest.h (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/MediaDevicesEnumerationRequest.h        2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevicesEnumerationRequest.h   2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -1,70 +0,0 @@
</span><del>-/*
- * Copyright (C) 2016 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. ``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
- * 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(MEDIA_STREAM)
-
-#include "ActiveDOMObject.h"
-#include <wtf/Function.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-class CaptureDevice;
-class Document;
-class SecurityOrigin;
-
-class MediaDevicesEnumerationRequest final : public ContextDestructionObserver, public RefCounted<MediaDevicesEnumerationRequest> {
-public:
-    using CompletionHandler = WTF::Function<void(const Vector<CaptureDevice>&, const String& deviceIdentifierHashSalt, bool originHasPersistentAccess)>;
-
-    static Ref<MediaDevicesEnumerationRequest> create(Document&, CompletionHandler&&);
-
-    virtual ~MediaDevicesEnumerationRequest();
-
-    void start();
-    void cancel();
-
-    bool wasCanceled() const { return !m_completionHandler; }
-
-    WEBCORE_EXPORT void setDeviceInfo(const Vector<CaptureDevice>&, const String& deviceIdentifierHashSalt, bool originHasPersistentAccess);
-
-    WEBCORE_EXPORT SecurityOrigin* userMediaDocumentOrigin() const;
-    WEBCORE_EXPORT SecurityOrigin* topLevelDocumentOrigin() const;
-
-private:
-    MediaDevicesEnumerationRequest(ScriptExecutionContext&, CompletionHandler&&);
-
-    // ContextDestructionObserver
-    void contextDestroyed() final;
-
-    CompletionHandler m_completionHandler;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM)
</del></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamMediaDevicesRequestcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp 2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp    2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -1,140 +0,0 @@
</span><del>-/*
- * Copyright (C) 2015-2016 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. ``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
- * 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 "MediaDevicesRequest.h"
-
-#if ENABLE(MEDIA_STREAM)
-
-#include "CaptureDevice.h"
-#include "Document.h"
-#include "Frame.h"
-#include "JSMediaDeviceInfo.h"
-#include "MediaDevicesEnumerationRequest.h"
-#include "RealtimeMediaSourceCenter.h"
-#include "SecurityOrigin.h"
-#include "UserMediaController.h"
-#include <wtf/MainThread.h>
-#include <wtf/SHA1.h>
-
-namespace WebCore {
-
-inline MediaDevicesRequest::MediaDevicesRequest(Document& document, MediaDevices::EnumerateDevicesPromise&& promise)
-    : ContextDestructionObserver(&document)
-    , m_promise(WTFMove(promise))
-{
-}
-
-Ref<MediaDevicesRequest> MediaDevicesRequest::create(Document& document, MediaDevices::EnumerateDevicesPromise&& promise)
-{
-    return adoptRef(*new MediaDevicesRequest(document, WTFMove(promise)));
-}
-
-MediaDevicesRequest::~MediaDevicesRequest()
-{
-    // This should only get destroyed after the enumeration request has completed or has been canceled.
-    ASSERT(!m_enumerationRequest || m_enumerationRequest->wasCanceled());
-}
-
-SecurityOrigin* MediaDevicesRequest::securityOrigin() const
-{
-    if (scriptExecutionContext())
-        return scriptExecutionContext()->securityOrigin();
-
-    return nullptr;
-}
-
-void MediaDevicesRequest::contextDestroyed()
-{
-    // The call to m_enumerationRequest->cancel() might delete this.
-    auto protectedThis = makeRef(*this);
-
-    if (m_enumerationRequest) {
-        m_enumerationRequest->cancel();
-        m_enumerationRequest = nullptr;
-    }
-    ContextDestructionObserver::contextDestroyed();
-}
-
-void MediaDevicesRequest::start()
-{
-    auto& document = downcast<Document>(*scriptExecutionContext());
-    auto* controller = UserMediaController::from(document.page());
-    if (!controller) {
-        callOnMainThread([protectedThis = makeRef(*this)]() {
-            protectedThis->m_promise.resolve({ });
-        });
-
-        return;
-    }
-
-    auto microphoneAccess = controller->canCallGetUserMedia(document, { UserMediaController::CaptureType::Microphone });
-    auto cameraAccess = controller->canCallGetUserMedia(document, { UserMediaController::CaptureType::Camera });
-    bool canAccessMicrophone = microphoneAccess == UserMediaController::GetUserMediaAccess::CanCall;
-    bool canAccessCamera = cameraAccess == UserMediaController::GetUserMediaAccess::CanCall;
-    if (!canAccessMicrophone && !canAccessCamera) {
-        controller->logGetUserMediaDenial(document, !canAccessMicrophone ? microphoneAccess : cameraAccess, UserMediaController::BlockedCaller::EnumerateDevices);
-        callOnMainThread([protectedThis = makeRef(*this)]() {
-            protectedThis->m_promise.resolve({ });
-        });
-
-        return;
-    }
-
-    // This lambda keeps |this| alive until the request completes or is canceled.
-    auto completion = [this, protectedThis = makeRef(*this), canAccessMicrophone, canAccessCamera] (const Vector<CaptureDevice>& captureDevices, const String& deviceIdentifierHashSalt, bool) mutable {
-
-        m_enumerationRequest = nullptr;
-
-        if (!scriptExecutionContext())
-            return;
-
-        auto& document = downcast<Document>(*scriptExecutionContext());
-        document.setDeviceIDHashSalt(deviceIdentifierHashSalt);
-
-        Vector<Ref<MediaDeviceInfo>> devices;
-        for (auto& deviceInfo : captureDevices) {
-            if (!canAccessMicrophone && deviceInfo.type() == CaptureDevice::DeviceType::Microphone)
-                continue;
-            if (!canAccessCamera && deviceInfo.type() == CaptureDevice::DeviceType::Camera)
-                continue;
-
-            auto deviceType = deviceInfo.type() == CaptureDevice::DeviceType::Microphone ? MediaDeviceInfo::Kind::Audioinput : MediaDeviceInfo::Kind::Videoinput;
-            devices.append(MediaDeviceInfo::create(scriptExecutionContext(), deviceInfo.label(), deviceInfo.persistentId(), deviceInfo.groupId(), deviceType));
-        }
-
-        callOnMainThread([protectedThis = makeRef(*this), devices = WTFMove(devices)]() mutable {
-            protectedThis->m_promise.resolve(devices);
-        });
-    };
-
-    m_enumerationRequest = MediaDevicesEnumerationRequest::create(document, WTFMove(completion));
-    m_enumerationRequest->start();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM)
</del></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamMediaDevicesRequesth"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.h (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.h   2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.h      2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -1,61 +0,0 @@
</span><del>-/*
- * Copyright (C) 2015-2016 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. ``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
- * 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(MEDIA_STREAM)
-
-#include "MediaDevices.h"
-
-namespace WebCore {
-
-class Document;
-class MediaDevicesEnumerationRequest;
-class SecurityOrigin;
-
-class MediaDevicesRequest : public RefCounted<MediaDevicesRequest>, private ContextDestructionObserver {
-public:
-    static Ref<MediaDevicesRequest> create(Document&, MediaDevices::EnumerateDevicesPromise&&);
-
-    virtual ~MediaDevicesRequest();
-
-    void start();
-
-    SecurityOrigin* securityOrigin() const;
-
-private:
-    MediaDevicesRequest(Document&, MediaDevices::EnumerateDevicesPromise&&);
-
-    void contextDestroyed() final;
-
-    MediaDevices::EnumerateDevicesPromise m_promise;
-    RefPtr<MediaDevicesRequest> m_protector;
-    RefPtr<MediaDevicesEnumerationRequest> m_enumerationRequest;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM)
</del></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamRTCRtpSendercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.cpp (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.cpp        2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.cpp   2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include "RTCDTMFSender.h"
</span><span class="cx"> #include "RTCDTMFSenderBackend.h"
</span><span class="cx"> #include "RTCRtpCapabilities.h"
</span><ins>+#include "RTCRtpTransceiver.h"
</ins><span class="cx"> #include "RuntimeEnabledFeatures.h"
</span><span class="cx"> #include <wtf/IsoMallocInlines.h>
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamUserMediaClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/UserMediaClient.h (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/UserMediaClient.h       2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Modules/mediastream/UserMediaClient.h  2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -33,11 +33,12 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><span class="cx"> 
</span><ins>+#include <wtf/CompletionHandler.h>
</ins><span class="cx"> #include <wtf/ObjectIdentifier.h>
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class MediaDevicesEnumerationRequest;
</del><ins>+class CaptureDevice;
</ins><span class="cx"> class Page;
</span><span class="cx"> class UserMediaRequest;
</span><span class="cx"> 
</span><span class="lines">@@ -48,8 +49,7 @@
</span><span class="cx">     virtual void requestUserMediaAccess(UserMediaRequest&) = 0;
</span><span class="cx">     virtual void cancelUserMediaAccessRequest(UserMediaRequest&) = 0;
</span><span class="cx"> 
</span><del>-    virtual void enumerateMediaDevices(MediaDevicesEnumerationRequest&) = 0;
-    virtual void cancelMediaDevicesEnumerationRequest(MediaDevicesEnumerationRequest&) = 0;
</del><ins>+    virtual void enumerateMediaDevices(Document&, CompletionHandler<void(const Vector<CaptureDevice>&, const String&)>&&) = 0;
</ins><span class="cx"> 
</span><span class="cx">     enum DeviceChangeObserverTokenType { };
</span><span class="cx">     using DeviceChangeObserverToken = ObjectIdentifier<DeviceChangeObserverTokenType>;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamUserMediaControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/UserMediaController.cpp (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/UserMediaController.cpp 2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Modules/mediastream/UserMediaController.cpp    2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static UserMediaController::GetUserMediaAccess isAllowedToUse(Document& document, Document& topDocument, OptionSet<UserMediaController::CaptureType> types)
</del><ins>+static UserMediaController::GetUserMediaAccess isAllowedToUse(const Document& document, const Document& topDocument, OptionSet<UserMediaController::CaptureType> types)
</ins><span class="cx"> {
</span><span class="cx">     if (&document == &topDocument)
</span><span class="cx">         return UserMediaController::GetUserMediaAccess::CanCall;
</span><span class="lines">@@ -106,7 +106,7 @@
</span><span class="cx">     return UserMediaController::GetUserMediaAccess::BlockedByFeaturePolicy;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-UserMediaController::GetUserMediaAccess UserMediaController::canCallGetUserMedia(Document& document, OptionSet<UserMediaController::CaptureType> types)
</del><ins>+UserMediaController::GetUserMediaAccess UserMediaController::canCallGetUserMedia(const Document& document, OptionSet<UserMediaController::CaptureType> types) const
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!types.isEmpty());
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamUserMediaControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/UserMediaController.h (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/UserMediaController.h   2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Modules/mediastream/UserMediaController.h      2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include "Page.h"
</span><span class="cx"> #include "UserMediaClient.h"
</span><ins>+#include <wtf/CompletionHandler.h>
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -45,8 +46,7 @@
</span><span class="cx">     void requestUserMediaAccess(UserMediaRequest&);
</span><span class="cx">     void cancelUserMediaAccessRequest(UserMediaRequest&);
</span><span class="cx"> 
</span><del>-    void enumerateMediaDevices(MediaDevicesEnumerationRequest&);
-    void cancelMediaDevicesEnumerationRequest(MediaDevicesEnumerationRequest&);
</del><ins>+    void enumerateMediaDevices(Document&, CompletionHandler<void(const Vector<CaptureDevice>&, const String&)>&&);
</ins><span class="cx"> 
</span><span class="cx">     UserMediaClient::DeviceChangeObserverToken addDeviceChangeObserver(WTF::Function<void()>&&);
</span><span class="cx">     void removeDeviceChangeObserver(UserMediaClient::DeviceChangeObserverToken);
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx">         Camera = 1 << 1,
</span><span class="cx">         Display = 1 << 3
</span><span class="cx">     };
</span><del>-    GetUserMediaAccess canCallGetUserMedia(Document&, OptionSet<CaptureType>);
</del><ins>+    GetUserMediaAccess canCallGetUserMedia(const Document&, OptionSet<CaptureType>) const;
</ins><span class="cx"> 
</span><span class="cx">     enum class BlockedCaller {
</span><span class="cx">         GetUserMedia,
</span><span class="lines">@@ -89,15 +89,11 @@
</span><span class="cx">     m_client->cancelUserMediaAccessRequest(request);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void UserMediaController::enumerateMediaDevices(MediaDevicesEnumerationRequest& request)
</del><ins>+inline void UserMediaController::enumerateMediaDevices(Document& document, CompletionHandler<void(const Vector<CaptureDevice>&, const String&)>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    m_client->enumerateMediaDevices(request);
</del><ins>+    m_client->enumerateMediaDevices(document, WTFMove(completionHandler));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void UserMediaController::cancelMediaDevicesEnumerationRequest(MediaDevicesEnumerationRequest& request)
-{
-    m_client->cancelMediaDevicesEnumerationRequest(request);
-}
</del><span class="cx"> 
</span><span class="cx"> inline UserMediaClient::DeviceChangeObserverToken UserMediaController::addDeviceChangeObserver(WTF::Function<void()>&& observer)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWebGPUDevicecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp     2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp        2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include "GPUBufferBinding.h"
</span><span class="cx"> #include "GPUBufferDescriptor.h"
</span><span class="cx"> #include "GPUCommandBuffer.h"
</span><ins>+#include "GPUComputePipelineDescriptor.h"
</ins><span class="cx"> #include "GPUPipelineStageDescriptor.h"
</span><span class="cx"> #include "GPURenderPipelineDescriptor.h"
</span><span class="cx"> #include "GPUSampler.h"
</span></span></pre></div>
<a id="trunkSourceWebCoreSourcestxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Sources.txt (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Sources.txt 2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/Sources.txt    2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -160,8 +160,6 @@
</span><span class="cx"> Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp
</span><span class="cx"> Modules/mediastream/MediaDeviceInfo.cpp
</span><span class="cx"> Modules/mediastream/MediaDevices.cpp
</span><del>-Modules/mediastream/MediaDevicesEnumerationRequest.cpp
-Modules/mediastream/MediaDevicesRequest.cpp
</del><span class="cx"> Modules/mediastream/MediaStream.cpp
</span><span class="cx"> Modules/mediastream/MediaStreamTrack.cpp
</span><span class="cx"> Modules/mediastream/MediaStreamTrackEvent.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -121,7 +121,6 @@
</span><span class="cx">          073794EC19EE341E00E5A045 /* JSRTCIceServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 073794EA19EE341E00E5A045 /* JSRTCIceServer.h */; };
</span><span class="cx">          073794FA19F5864E00E5A045 /* RTCDataChannelHandlerMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 073794F419F5864E00E5A045 /* RTCDataChannelHandlerMock.h */; };
</span><span class="cx">          073794FE19F5864E00E5A045 /* RTCNotifiersMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 073794F819F5864E00E5A045 /* RTCNotifiersMock.h */; };
</span><del>-               07394ECA1BAB2CD700BE99CD /* MediaDevicesRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 07394EC91BAB2CD700BE99CD /* MediaDevicesRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
</del><span class="cx">           073A15542177A42600EA08F2 /* RemoteVideoSample.h in Headers */ = {isa = PBXBuildFile; fileRef = 073A15532177A39A00EA08F2 /* RemoteVideoSample.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          073B87671E4385AC0071C0EC /* AudioSampleBufferList.h in Headers */ = {isa = PBXBuildFile; fileRef = 073B87631E43859D0071C0EC /* AudioSampleBufferList.h */; };
</span><span class="cx">          073B87691E4385AC0071C0EC /* AudioSampleDataSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 073B87651E43859D0071C0EC /* AudioSampleDataSource.h */; };
</span><span class="lines">@@ -196,7 +195,6 @@
</span><span class="cx">          07AA6B6C166D2C1300D45671 /* InbandTextTrackPrivateAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = 07AA6B69166D019500D45671 /* InbandTextTrackPrivateAVFObjC.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          07AB996918DA3C010018771E /* RTCConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 07AB996518DA3C010018771E /* RTCConfiguration.h */; };
</span><span class="cx">          07AB996B18DA3C010018771E /* RTCIceServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 07AB996718DA3C010018771E /* RTCIceServer.h */; };
</span><del>-               07ABEF6E1D8A1C7600F21972 /* MediaDevicesEnumerationRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 07ABEF6D1D8A1C7600F21972 /* MediaDevicesEnumerationRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
</del><span class="cx">           07AFF4221EFB144900B545B3 /* CoreAudioCaptureSourceIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 07AFF4201EFB144700B545B3 /* CoreAudioCaptureSourceIOS.h */; };
</span><span class="cx">          07AFF4231EFB144900B545B3 /* CoreAudioCaptureSourceIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07AFF4211EFB144700B545B3 /* CoreAudioCaptureSourceIOS.mm */; };
</span><span class="cx">          07B0113F1032242200FBDC33 /* AccessibilityMediaControls.h in Headers */ = {isa = PBXBuildFile; fileRef = 07B0113E1032242200FBDC33 /* AccessibilityMediaControls.h */; };
</span><span class="lines">@@ -5351,8 +5349,6 @@
</span><span class="cx">          073794F419F5864E00E5A045 /* RTCDataChannelHandlerMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCDataChannelHandlerMock.h; sourceTree = "<group>"; };
</span><span class="cx">          073794F719F5864E00E5A045 /* RTCNotifiersMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCNotifiersMock.cpp; sourceTree = "<group>"; };
</span><span class="cx">          073794F819F5864E00E5A045 /* RTCNotifiersMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCNotifiersMock.h; sourceTree = "<group>"; };
</span><del>-               07394EC71BAB2CCD00BE99CD /* MediaDevicesRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaDevicesRequest.cpp; sourceTree = "<group>"; };
-               07394EC91BAB2CD700BE99CD /* MediaDevicesRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaDevicesRequest.h; sourceTree = "<group>"; };
</del><span class="cx">           073A15512177A39800EA08F2 /* RemoteVideoSample.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteVideoSample.cpp; sourceTree = "<group>"; };
</span><span class="cx">          073A15532177A39A00EA08F2 /* RemoteVideoSample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteVideoSample.h; sourceTree = "<group>"; };
</span><span class="cx">          073B87561E40DCE50071C0EC /* AudioStreamDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioStreamDescription.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -5444,8 +5440,6 @@
</span><span class="cx">          07AB996618DA3C010018771E /* RTCConfiguration.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCConfiguration.idl; sourceTree = "<group>"; };
</span><span class="cx">          07AB996718DA3C010018771E /* RTCIceServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCIceServer.h; sourceTree = "<group>"; };
</span><span class="cx">          07AB996818DA3C010018771E /* RTCIceServer.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCIceServer.idl; sourceTree = "<group>"; };
</span><del>-               07ABEF6B1D8A1C5800F21972 /* MediaDevicesEnumerationRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaDevicesEnumerationRequest.cpp; sourceTree = "<group>"; };
-               07ABEF6D1D8A1C7600F21972 /* MediaDevicesEnumerationRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaDevicesEnumerationRequest.h; sourceTree = "<group>"; };
</del><span class="cx">           07AFF4201EFB144700B545B3 /* CoreAudioCaptureSourceIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreAudioCaptureSourceIOS.h; sourceTree = "<group>"; };
</span><span class="cx">          07AFF4211EFB144700B545B3 /* CoreAudioCaptureSourceIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreAudioCaptureSourceIOS.mm; sourceTree = "<group>"; };
</span><span class="cx">          07B0113E1032242200FBDC33 /* AccessibilityMediaControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityMediaControls.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -15673,10 +15667,6 @@
</span><span class="cx">                          5EA725CD1ACABCD900EAD17B /* MediaDevices.cpp */,
</span><span class="cx">                          5EA725CE1ACABCD900EAD17B /* MediaDevices.h */,
</span><span class="cx">                          5EA725CF1ACABCD900EAD17B /* MediaDevices.idl */,
</span><del>-                               07ABEF6B1D8A1C5800F21972 /* MediaDevicesEnumerationRequest.cpp */,
-                               07ABEF6D1D8A1C7600F21972 /* MediaDevicesEnumerationRequest.h */,
-                               07394EC71BAB2CCD00BE99CD /* MediaDevicesRequest.cpp */,
-                               07394EC91BAB2CD700BE99CD /* MediaDevicesRequest.h */,
</del><span class="cx">                           07221B4C17CEC32700848E51 /* MediaStream.cpp */,
</span><span class="cx">                          07221B4D17CEC32700848E51 /* MediaStream.h */,
</span><span class="cx">                          07221B4E17CEC32700848E51 /* MediaStream.idl */,
</span><span class="lines">@@ -30674,8 +30664,6 @@
</span><span class="cx">                          CDF2B004181F059C00F2B424 /* MediaDescription.h in Headers */,
</span><span class="cx">                          15145B901B3A1CE000662BF7 /* MediaDeviceInfo.h in Headers */,
</span><span class="cx">                          5EA725D31ACABD4700EAD17B /* MediaDevices.h in Headers */,
</span><del>-                               07ABEF6E1D8A1C7600F21972 /* MediaDevicesEnumerationRequest.h in Headers */,
-                               07394ECA1BAB2CD700BE99CD /* MediaDevicesRequest.h in Headers */,
</del><span class="cx">                           97205AB81239291000B17380 /* MediaDocument.h in Headers */,
</span><span class="cx">                          FD6F252D13F5EF0E0065165F /* MediaElementAudioSourceNode.h in Headers */,
</span><span class="cx">                          07FE99DD18807A7D00256648 /* MediaElementSession.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebKit/ChangeLog       2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2019-08-19  Youenn Fablet  <youenn@apple.com>
+
+        enumerateDevices should return the same JS objects if called twice
+        https://bugs.webkit.org/show_bug.cgi?id=200767
+
+        Reviewed by Eric Carlson.
+
+        Update code as enumerate device request is now gone.
+        Make use of async IPC to simplify code since we are now passing a completion handler directly.
+
+        * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
+        (WebKit::UserMediaPermissionRequestManagerProxy::captureDevicesChanged):
+        (WebKit::UserMediaPermissionRequestManagerProxy::finishGrantingRequest):
+        (WebKit::UserMediaPermissionRequestManagerProxy::enumerateMediaDevicesForFrame):
+        * UIProcess/UserMediaPermissionRequestManagerProxy.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
+        (WebKit::UserMediaPermissionRequestManager::enumerateMediaDevices):
+        * WebProcess/MediaStream/UserMediaPermissionRequestManager.h:
+        * WebProcess/WebCoreSupport/WebUserMediaClient.cpp:
+        (WebKit::WebUserMediaClient::enumerateMediaDevices):
+        * WebProcess/WebCoreSupport/WebUserMediaClient.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
</ins><span class="cx"> 2019-08-18  Yusuke Suzuki  <ysuzuki@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [WTF] Add makeUnique<T>, which ensures T is fast-allocated, makeUnique / makeUniqueWithoutFastMallocCheck part
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessUserMediaPermissionRequestManagerProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp 2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp    2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> #include <WebCore/RealtimeMediaSource.h>
</span><span class="cx"> #include <WebCore/SecurityOriginData.h>
</span><span class="cx"> #include <WebCore/UserMediaRequest.h>
</span><ins>+#include <wtf/Scope.h>
</ins><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> using namespace WebCore;
</span><span class="lines">@@ -121,28 +122,33 @@
</span><span class="cx">     if (!m_page.hasRunningProcess() || !m_page.mainFrame())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    auto handler = [this](PermissionInfo permissionInfo) mutable {
-        switch (permissionInfo) {
-        case PermissionInfo::Error:
-            return;
-        case PermissionInfo::Unknown:
-            if (m_grantedRequests.isEmpty())
-                return;
-            break;
-        case PermissionInfo::Granted:
-            break;
-        }
-        if (!m_page.hasRunningProcess())
-            return;
-
-        m_page.process().send(Messages::WebPage::CaptureDevicesChanged(), m_page.pageID());
-    };
-
</del><span class="cx">     auto origin = WebCore::SecurityOrigin::create(m_page.mainFrame()->url());
</span><del>-    getUserMediaPermissionInfo(m_page.mainFrame()->frameID(), origin.get(), WTFMove(origin), WTFMove(handler));
</del><ins>+    getUserMediaPermissionInfo(m_page.mainFrame()->frameID(), origin.get(), WTFMove(origin), [this](PermissionInfo permissionInfo) {
+        captureDevicesChanged(permissionInfo);
+    });
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(MEDIA_STREAM)
+void UserMediaPermissionRequestManagerProxy::captureDevicesChanged(PermissionInfo permissionInfo)
+{
+    switch (permissionInfo) {
+    case PermissionInfo::Error:
+        return;
+    case PermissionInfo::Unknown:
+        if (m_grantedRequests.isEmpty())
+            return;
+        break;
+    case PermissionInfo::Granted:
+        break;
+    }
+    if (!m_page.hasRunningProcess())
+        return;
+
+    m_page.process().send(Messages::WebPage::CaptureDevicesChanged(), m_page.pageID());
+}
+#endif
+
</ins><span class="cx"> void UserMediaPermissionRequestManagerProxy::clearCachedState()
</span><span class="cx"> {
</span><span class="cx">     ALWAYS_LOG(LOGIDENTIFIER);
</span><span class="lines">@@ -226,8 +232,9 @@
</span><span class="cx">     if (request.requestType() == MediaStreamRequest::Type::UserMedia)
</span><span class="cx">         m_grantedRequests.append(makeRef(request));
</span><span class="cx"> 
</span><ins>+    // FIXME: m_hasFilteredDeviceList will trigger ondevicechange events for various documents from different origins.
</ins><span class="cx">     if (m_hasFilteredDeviceList)
</span><del>-        captureDevicesChanged();
</del><ins>+        captureDevicesChanged(PermissionInfo::Granted);
</ins><span class="cx">     m_hasFilteredDeviceList = false;
</span><span class="cx"> 
</span><span class="cx">     ++m_hasPendingCapture;
</span><span class="lines">@@ -604,12 +611,15 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void UserMediaPermissionRequestManagerProxy::enumerateMediaDevicesForFrame(uint64_t userMediaID, FrameIdentifier frameID, Ref<SecurityOrigin>&& userMediaDocumentOrigin, Ref<SecurityOrigin>&& topLevelDocumentOrigin)
</del><ins>+void UserMediaPermissionRequestManagerProxy::enumerateMediaDevicesForFrame(FrameIdentifier frameID, Ref<SecurityOrigin>&& userMediaDocumentOrigin, Ref<SecurityOrigin>&& topLevelDocumentOrigin, CompletionHandler<void(const Vector<CaptureDevice>&, const String&)>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><del>-    ALWAYS_LOG(LOGIDENTIFIER, userMediaID);
</del><ins>+    ALWAYS_LOG(LOGIDENTIFIER);
</ins><span class="cx"> 
</span><del>-    auto completionHandler = [this, userMediaID, frameID, userMediaDocumentOrigin = userMediaDocumentOrigin.copyRef(), topLevelDocumentOrigin = topLevelDocumentOrigin.copyRef()](PermissionInfo permissionInfo) mutable {
</del><ins>+    auto callback = [this, frameID, userMediaDocumentOrigin = userMediaDocumentOrigin.copyRef(), topLevelDocumentOrigin = topLevelDocumentOrigin.copyRef(), completionHandler = WTFMove(completionHandler)](PermissionInfo permissionInfo) mutable {
+        auto callCompletionHandler = makeScopeExit([&completionHandler] {
+            completionHandler({ }, { });
+        });
</ins><span class="cx"> 
</span><span class="cx">         bool originHasPersistentAccess;
</span><span class="cx">         switch (permissionInfo) {
</span><span class="lines">@@ -631,7 +641,13 @@
</span><span class="cx"> 
</span><span class="cx">         auto& requestOrigin = userMediaDocumentOrigin.get();
</span><span class="cx">         auto& topOrigin = topLevelDocumentOrigin.get();
</span><del>-        m_page.websiteDataStore().deviceIdHashSaltStorage().deviceIdHashSaltForOrigin(requestOrigin, topOrigin, [this, weakThis = makeWeakPtr(*this), requestID, frameID, userMediaID, userMediaDocumentOrigin = WTFMove(userMediaDocumentOrigin), topLevelDocumentOrigin = WTFMove(topLevelDocumentOrigin), originHasPersistentAccess] (String&& deviceIDHashSalt) {
</del><ins>+
+        callCompletionHandler.release();
+        m_page.websiteDataStore().deviceIdHashSaltStorage().deviceIdHashSaltForOrigin(requestOrigin, topOrigin, [this, weakThis = makeWeakPtr(*this), requestID, frameID, userMediaDocumentOrigin = WTFMove(userMediaDocumentOrigin), topLevelDocumentOrigin = WTFMove(topLevelDocumentOrigin), originHasPersistentAccess, completionHandler = WTFMove(completionHandler)](String&& deviceIDHashSalt) mutable {
+            auto callCompletionHandler = makeScopeExit([&completionHandler] {
+                completionHandler({ }, { });
+            });
+
</ins><span class="cx">             if (!weakThis || !m_pendingDeviceRequests.remove(requestID))
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><span class="lines">@@ -642,16 +658,17 @@
</span><span class="cx"> 
</span><span class="cx">             bool revealIdsAndLabels = originHasPersistentAccess || wasGrantedVideoOrAudioAccess(frameID, userMediaDocumentOrigin.get(), topLevelDocumentOrigin.get());
</span><span class="cx"> 
</span><del>-            m_page.process().send(Messages::WebPage::DidCompleteMediaDeviceEnumeration { userMediaID, computeFilteredDeviceList(revealIdsAndLabels, deviceIDHashSalt), deviceIDHashSalt, originHasPersistentAccess }, m_page.pageID());
</del><ins>+            callCompletionHandler.release();
+            completionHandler(computeFilteredDeviceList(revealIdsAndLabels, deviceIDHashSalt), deviceIDHashSalt);
</ins><span class="cx">         });
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    getUserMediaPermissionInfo(frameID, WTFMove(userMediaDocumentOrigin), WTFMove(topLevelDocumentOrigin), WTFMove(completionHandler));
</del><ins>+    getUserMediaPermissionInfo(frameID, WTFMove(userMediaDocumentOrigin), WTFMove(topLevelDocumentOrigin), WTFMove(callback));
</ins><span class="cx"> #else
</span><del>-    UNUSED_PARAM(userMediaID);
</del><span class="cx">     UNUSED_PARAM(frameID);
</span><span class="cx">     UNUSED_PARAM(userMediaDocumentOrigin);
</span><span class="cx">     UNUSED_PARAM(topLevelDocumentOrigin);
</span><ins>+    completionHandler({ }, { });
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessUserMediaPermissionRequestManagerProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.h (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.h   2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.h      2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx">     void grantRequest(UserMediaPermissionRequestProxy&);
</span><span class="cx">     void denyRequest(UserMediaPermissionRequestProxy&, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason, const String& invalidConstraint = { });
</span><span class="cx"> 
</span><del>-    void enumerateMediaDevicesForFrame(uint64_t userMediaID, WebCore::FrameIdentifier, Ref<WebCore::SecurityOrigin>&& userMediaDocumentOrigin, Ref<WebCore::SecurityOrigin>&& topLevelDocumentOrigin);
</del><ins>+    void enumerateMediaDevicesForFrame(WebCore::FrameIdentifier, Ref<WebCore::SecurityOrigin>&& userMediaDocumentOrigin, Ref<WebCore::SecurityOrigin>&& topLevelDocumentOrigin, CompletionHandler<void(const Vector<WebCore::CaptureDevice>&, const String&)>&&);
</ins><span class="cx"> 
</span><span class="cx">     void stopCapture();
</span><span class="cx">     void scheduleNextRejection();
</span><span class="lines">@@ -105,6 +105,7 @@
</span><span class="cx"> 
</span><span class="cx">     using PermissionInfo = UserMediaPermissionCheckProxy::PermissionInfo;
</span><span class="cx">     void getUserMediaPermissionInfo(WebCore::FrameIdentifier, Ref<WebCore::SecurityOrigin>&& userMediaDocumentOrigin, Ref<WebCore::SecurityOrigin>&& topLevelDocumentOrigin, CompletionHandler<void(PermissionInfo)>&&);
</span><ins>+    void captureDevicesChanged(PermissionInfo);
</ins><span class="cx"> 
</span><span class="cx">     RequestAction getRequestAction(const UserMediaPermissionRequestProxy&);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp   2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp      2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -7462,13 +7462,13 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::enumerateMediaDevicesForFrame(uint64_t userMediaID, FrameIdentifier frameID, const WebCore::SecurityOriginData& userMediaDocumentOriginData, const WebCore::SecurityOriginData& topLevelDocumentOriginData)
</del><ins>+void WebPageProxy::enumerateMediaDevicesForFrame(FrameIdentifier frameID, const WebCore::SecurityOriginData& userMediaDocumentOriginData, const WebCore::SecurityOriginData& topLevelDocumentOriginData, CompletionHandler<void(const Vector<CaptureDevice>&, const String&)>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><span class="cx">     WebFrameProxy* frame = m_process->webFrame(frameID);
</span><span class="cx">     MESSAGE_CHECK(m_process, frame);
</span><span class="cx"> 
</span><del>-    userMediaPermissionRequestManager().enumerateMediaDevicesForFrame(userMediaID, frameID, userMediaDocumentOriginData.securityOrigin(), topLevelDocumentOriginData.securityOrigin());
</del><ins>+    userMediaPermissionRequestManager().enumerateMediaDevicesForFrame(frameID, userMediaDocumentOriginData.securityOrigin(), topLevelDocumentOriginData.securityOrigin(), WTFMove(completionHandler));
</ins><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(userMediaID);
</span><span class="cx">     UNUSED_PARAM(frameID);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.h     2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h        2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -1714,7 +1714,7 @@
</span><span class="cx">     UserMediaPermissionRequestManagerProxy& userMediaPermissionRequestManager();
</span><span class="cx"> #endif
</span><span class="cx">     void requestUserMediaPermissionForFrame(uint64_t userMediaID, WebCore::FrameIdentifier, const WebCore::SecurityOriginData& userMediaDocumentOriginIdentifier, const WebCore::SecurityOriginData& topLevelDocumentOriginIdentifier, WebCore::MediaStreamRequest&&);
</span><del>-    void enumerateMediaDevicesForFrame(uint64_t userMediaID, WebCore::FrameIdentifier, const WebCore::SecurityOriginData& userMediaDocumentOriginData, const WebCore::SecurityOriginData& topLevelDocumentOriginData);
</del><ins>+    void enumerateMediaDevicesForFrame(WebCore::FrameIdentifier, const WebCore::SecurityOriginData& userMediaDocumentOriginData, const WebCore::SecurityOriginData& topLevelDocumentOriginData, CompletionHandler<void(const Vector<WebCore::CaptureDevice>&, const String&)>&&);
</ins><span class="cx">     void beginMonitoringCaptureDevices();
</span><span class="cx"> 
</span><span class="cx">     void runModal();
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in   2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in      2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -282,11 +282,11 @@
</span><span class="cx"> 
</span><span class="cx">     # Geolocation messages
</span><span class="cx">     RequestGeolocationPermissionForFrame(uint64_t geolocationID, WebCore::FrameIdentifier frameID, String originIdentifier)
</span><del>-    
</del><ins>+
</ins><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><span class="cx">     # MediaSteam messages
</span><span class="cx">     RequestUserMediaPermissionForFrame(uint64_t userMediaID, WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData userMediaDocumentOriginIdentifier, struct WebCore::SecurityOriginData topLevelDocumentOriginIdentifier, struct WebCore::MediaStreamRequest request)
</span><del>-    EnumerateMediaDevicesForFrame(uint64_t userMediaID, WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData userMediaDocumentOriginIdentifier, struct WebCore::SecurityOriginData topLevelDocumentOriginIdentifier)
</del><ins>+    EnumerateMediaDevicesForFrame(WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData userMediaDocumentOriginIdentifier, struct WebCore::SecurityOriginData topLevelDocumentOriginIdentifier) -> (Vector<WebCore::CaptureDevice> devices, String mediaDeviceIdentifierHashSalt) Async
</ins><span class="cx">     BeginMonitoringCaptureDevices()
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -298,7 +298,7 @@
</span><span class="cx">     DidDestroyNotification(uint64_t notificationID)
</span><span class="cx"> 
</span><span class="cx">     # Spelling and grammar messages
</span><del>-#if USE(UNIFIED_TEXT_CHECKING)  
</del><ins>+#if USE(UNIFIED_TEXT_CHECKING)
</ins><span class="cx">     CheckTextOfParagraph(String text, OptionSet<WebCore::TextCheckingType> checkingTypes, int32_t insertionPoint) -> (Vector<WebCore::TextCheckingResult> results) Synchronous
</span><span class="cx"> #endif
</span><span class="cx">     CheckSpellingOfString(String text) -> (int32_t misspellingLocation, int32_t misspellingLength) Synchronous
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessMediaStreamUserMediaPermissionRequestManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp 2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebKit/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp    2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -159,47 +159,17 @@
</span><span class="cx">     request->deny(reason, WTFMove(invalidConstraint));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void UserMediaPermissionRequestManager::enumerateMediaDevices(MediaDevicesEnumerationRequest& request)
</del><ins>+void UserMediaPermissionRequestManager::enumerateMediaDevices(Document& document, CompletionHandler<void(const Vector<CaptureDevice>&, const String&)>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    auto* document = downcast<Document>(request.scriptExecutionContext());
-    auto* frame = document ? document->frame() : nullptr;
-
</del><ins>+    auto* frame = document.frame();
</ins><span class="cx">     if (!frame) {
</span><del>-        request.setDeviceInfo(Vector<CaptureDevice>(), emptyString(), false);
</del><ins>+        completionHandler({ }, emptyString());
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    uint64_t requestID = generateRequestID();
-    m_idToMediaDevicesEnumerationRequestMap.add(requestID, &request);
-    m_mediaDevicesEnumerationRequestToIDMap.add(&request, requestID);
-
-    WebFrame* webFrame = WebFrame::fromCoreFrame(*frame);
-    ASSERT(webFrame);
-
-    SecurityOrigin* topLevelDocumentOrigin = request.topLevelDocumentOrigin();
-    ASSERT(topLevelDocumentOrigin);
-    m_page.send(Messages::WebPageProxy::EnumerateMediaDevicesForFrame(requestID, webFrame->frameID(), request.userMediaDocumentOrigin()->data(), topLevelDocumentOrigin->data()));
</del><ins>+    m_page.sendWithAsyncReply(Messages::WebPageProxy::EnumerateMediaDevicesForFrame { WebFrame::fromCoreFrame(*frame)->frameID(), document.securityOrigin().data(), document.topOrigin().data() }, WTFMove(completionHandler));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void UserMediaPermissionRequestManager::cancelMediaDevicesEnumeration(WebCore::MediaDevicesEnumerationRequest& request)
-{
-    uint64_t requestID = m_mediaDevicesEnumerationRequestToIDMap.take(&request);
-    if (!requestID)
-        return;
-    request.setDeviceInfo(Vector<CaptureDevice>(), emptyString(), false);
-    m_idToMediaDevicesEnumerationRequestMap.remove(requestID);
-}
-
-void UserMediaPermissionRequestManager::didCompleteMediaDeviceEnumeration(uint64_t requestID, const Vector<CaptureDevice>& deviceList, String&& mediaDeviceIdentifierHashSalt, bool hasPersistentAccess)
-{
-    RefPtr<MediaDevicesEnumerationRequest> request = m_idToMediaDevicesEnumerationRequestMap.take(requestID);
-    if (!request)
-        return;
-    m_mediaDevicesEnumerationRequestToIDMap.remove(request);
-    
-    request->setDeviceInfo(deviceList, WTFMove(mediaDeviceIdentifierHashSalt), hasPersistentAccess);
-}
-
</del><span class="cx"> UserMediaClient::DeviceChangeObserverToken UserMediaPermissionRequestManager::addDeviceChangeObserver(WTF::Function<void()>&& observer)
</span><span class="cx"> {
</span><span class="cx">     auto identifier = WebCore::UserMediaClient::DeviceChangeObserverToken::generate();
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessMediaStreamUserMediaPermissionRequestManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/MediaStream/UserMediaPermissionRequestManager.h (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/MediaStream/UserMediaPermissionRequestManager.h   2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebKit/WebProcess/MediaStream/UserMediaPermissionRequestManager.h      2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -24,7 +24,6 @@
</span><span class="cx"> #include "SandboxExtension.h"
</span><span class="cx"> #include <WebCore/MediaCanStartListener.h>
</span><span class="cx"> #include <WebCore/MediaConstraints.h>
</span><del>-#include <WebCore/MediaDevicesEnumerationRequest.h>
</del><span class="cx"> #include <WebCore/UserMediaClient.h>
</span><span class="cx"> #include <WebCore/UserMediaRequest.h>
</span><span class="cx"> #include <wtf/HashMap.h>
</span><span class="lines">@@ -46,9 +45,7 @@
</span><span class="cx">     void userMediaAccessWasGranted(uint64_t, WebCore::CaptureDevice&& audioDevice, WebCore::CaptureDevice&& videoDevice, String&& deviceIdentifierHashSalt, CompletionHandler<void()>&&);
</span><span class="cx">     void userMediaAccessWasDenied(uint64_t, WebCore::UserMediaRequest::MediaAccessDenialReason, String&&);
</span><span class="cx"> 
</span><del>-    void enumerateMediaDevices(WebCore::MediaDevicesEnumerationRequest&);
-    void cancelMediaDevicesEnumeration(WebCore::MediaDevicesEnumerationRequest&);
-    void didCompleteMediaDeviceEnumeration(uint64_t, const Vector<WebCore::CaptureDevice>& deviceList, String&& deviceIdentifierHashSalt, bool originHasPersistentAccess);
</del><ins>+    void enumerateMediaDevices(WebCore::Document&, CompletionHandler<void(const Vector<WebCore::CaptureDevice>&, const String&)>&&);
</ins><span class="cx"> 
</span><span class="cx">     WebCore::UserMediaClient::DeviceChangeObserverToken addDeviceChangeObserver(WTF::Function<void()>&&);
</span><span class="cx">     void removeDeviceChangeObserver(WebCore::UserMediaClient::DeviceChangeObserverToken);
</span><span class="lines">@@ -69,9 +66,6 @@
</span><span class="cx">     HashMap<RefPtr<WebCore::UserMediaRequest>, uint64_t> m_userMediaRequestToIDMap;
</span><span class="cx">     HashMap<RefPtr<WebCore::Document>, Vector<RefPtr<WebCore::UserMediaRequest>>> m_blockedUserMediaRequests;
</span><span class="cx"> 
</span><del>-    HashMap<uint64_t, RefPtr<WebCore::MediaDevicesEnumerationRequest>> m_idToMediaDevicesEnumerationRequestMap;
-    HashMap<RefPtr<WebCore::MediaDevicesEnumerationRequest>, uint64_t> m_mediaDevicesEnumerationRequestToIDMap;
-
</del><span class="cx">     HashMap<WebCore::UserMediaClient::DeviceChangeObserverToken, WTF::Function<void()>> m_deviceChangeObserverMap;
</span><span class="cx">     bool m_monitoringDeviceChange { false };
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebUserMediaClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebUserMediaClient.cpp (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebUserMediaClient.cpp     2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebUserMediaClient.cpp        2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -50,16 +50,11 @@
</span><span class="cx">     m_page.userMediaPermissionRequestManager().cancelUserMediaRequest(request);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebUserMediaClient::enumerateMediaDevices(MediaDevicesEnumerationRequest& request)
</del><ins>+void WebUserMediaClient::enumerateMediaDevices(Document& document, CompletionHandler<void(const Vector<CaptureDevice>&, const String&)>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    m_page.userMediaPermissionRequestManager().enumerateMediaDevices(request);
</del><ins>+    m_page.userMediaPermissionRequestManager().enumerateMediaDevices(document, WTFMove(completionHandler));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebUserMediaClient::cancelMediaDevicesEnumerationRequest(MediaDevicesEnumerationRequest& request)
-{
-    m_page.userMediaPermissionRequestManager().cancelMediaDevicesEnumeration(request);
-}
-
</del><span class="cx"> WebUserMediaClient::DeviceChangeObserverToken WebUserMediaClient::addDeviceChangeObserver(WTF::Function<void()>&& observer)
</span><span class="cx"> {
</span><span class="cx">     return m_page.userMediaPermissionRequestManager().addDeviceChangeObserver(WTFMove(observer));
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebUserMediaClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebUserMediaClient.h (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebUserMediaClient.h       2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebUserMediaClient.h  2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -40,8 +40,7 @@
</span><span class="cx">     void requestUserMediaAccess(WebCore::UserMediaRequest&) override;
</span><span class="cx">     void cancelUserMediaAccessRequest(WebCore::UserMediaRequest&) override;
</span><span class="cx"> 
</span><del>-    void enumerateMediaDevices(WebCore::MediaDevicesEnumerationRequest&) final;
-    void cancelMediaDevicesEnumerationRequest(WebCore::MediaDevicesEnumerationRequest&) final;
</del><ins>+    void enumerateMediaDevices(WebCore::Document&, CompletionHandler<void(const Vector<WebCore::CaptureDevice>&, const String&)>&&) final;
</ins><span class="cx"> 
</span><span class="cx">     DeviceChangeObserverToken addDeviceChangeObserver(WTF::Function<void()>&&) final;
</span><span class="cx">     void removeDeviceChangeObserver(DeviceChangeObserverToken) final;
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp       2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp  2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -4200,11 +4200,6 @@
</span><span class="cx">     m_userMediaPermissionRequestManager->userMediaAccessWasDenied(userMediaID, static_cast<UserMediaRequest::MediaAccessDenialReason>(reason), WTFMove(invalidConstraint));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPage::didCompleteMediaDeviceEnumeration(uint64_t userMediaID, const Vector<CaptureDevice>& devices, String&& deviceIdentifierHashSalt, bool originHasPersistentAccess)
-{
-    m_userMediaPermissionRequestManager->didCompleteMediaDeviceEnumeration(userMediaID, devices, WTFMove(deviceIdentifierHashSalt), originHasPersistentAccess);
-}
-
</del><span class="cx"> void WebPage::captureDevicesChanged()
</span><span class="cx"> {
</span><span class="cx">     m_userMediaPermissionRequestManager->captureDevicesChanged();
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h    2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -1482,7 +1482,6 @@
</span><span class="cx">     void userMediaAccessWasGranted(uint64_t userMediaID, WebCore::CaptureDevice&& audioDeviceUID, WebCore::CaptureDevice&& videoDeviceUID, String&& mediaDeviceIdentifierHashSalt, CompletionHandler<void()>&&);
</span><span class="cx">     void userMediaAccessWasDenied(uint64_t userMediaID, uint64_t reason, String&& invalidConstraint);
</span><span class="cx"> 
</span><del>-    void didCompleteMediaDeviceEnumeration(uint64_t userMediaID, const Vector<WebCore::CaptureDevice>& devices, String&& deviceIdentifierHashSalt, bool originHasPersistentAccess);
</del><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEB_RTC)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (248846 => 248847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in       2019-08-19 06:59:40 UTC (rev 248846)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in  2019-08-19 07:40:52 UTC (rev 248847)
</span><span class="lines">@@ -359,7 +359,6 @@
</span><span class="cx">     # MediaSteam
</span><span class="cx">     UserMediaAccessWasGranted(uint64_t userMediaID, WebCore::CaptureDevice audioDevice, WebCore::CaptureDevice videoDevice, String mediaDeviceIdentifierHashSalt) -> () Async
</span><span class="cx">     UserMediaAccessWasDenied(uint64_t userMediaID, uint64_t reason, String invalidConstraint)
</span><del>-    DidCompleteMediaDeviceEnumeration(uint64_t userMediaID, Vector<WebCore::CaptureDevice> devices, String mediaDeviceIdentifierHashSalt, bool hasPersistentAccess)
</del><span class="cx">     CaptureDevicesChanged()
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>