<!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>[210445] 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/210445">210445</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2017-01-06 10:48:29 -0800 (Fri, 06 Jan 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add support for MediaKeySystemAccess.createMediaKeys()
https://bugs.webkit.org/show_bug.cgi?id=166749
Reviewed by Eric Carlson.
Source/WebCore:
Test: media/encrypted-media/mock-MediaKeySystemAccess.html
Implement MediaKeySystemAccess::createMediaKeys(). This requires some
additions to CDM, CDMPrivate, and a new interface CDMInstance to support
eventual platform adoption and to implement mock support for testing.
* Modules/encryptedmedia/CDM.cpp:
(WebCore::CDM::loadAndInitialize):
(WebCore::CDM::createInstance):
* Modules/encryptedmedia/CDM.h:
* Modules/encryptedmedia/CDMInstance.h:
(WebCore::CDMInstance::~CDMInstance):
* Modules/encryptedmedia/CDMPrivate.h:
* Modules/encryptedmedia/MediaKeySystemAccess.cpp:
(WebCore::MediaKeySystemAccess::createMediaKeys):
* Modules/encryptedmedia/MediaKeySystemAccess.h:
* Modules/encryptedmedia/MediaKeys.cpp:
(WebCore::MediaKeys::MediaKeys):
* Modules/encryptedmedia/MediaKeys.h:
(WebCore::MediaKeys::create):
* Modules/encryptedmedia/MediaKeys.idl:
* Modules/encryptedmedia/NavigatorEME.cpp:
(WebCore::tryNextSupportedConfiguration):
* WebCore.xcodeproj/project.pbxproj:
* testing/MockCDMFactory.cpp:
(WebCore::MockCDM::MockCDM):
(WebCore::MockCDM::createInstance):
(WebCore::MockCDM::loadAndInitialize):
(WebCore::MockCDMInstance::MockCDMInstance):
(WebCore::MockCDMInstance::initializeWithConfiguration):
(WebCore::MockCDMInstance::setDistinctiveIdentifiersAllowed):
(WebCore::MockCDMInstance::setPersistentStateAllowed):
* testing/MockCDMFactory.h:
(WebCore::MockCDMFactory::canCreateInstances):
(WebCore::MockCDMFactory::setCanCreateInstances):
(WebCore::MockCDM::factory):
* testing/MockCDMFactory.idl:
LayoutTests:
* media/encrypted-media/mock-MediaKeySystemAccess-expected.txt: Added.
* media/encrypted-media/mock-MediaKeySystemAccess.html: Added.
* platform/mac/TestExpectations:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacTestExpectations">trunk/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesencryptedmediaCDMcpp">trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesencryptedmediaCDMh">trunk/Source/WebCore/Modules/encryptedmedia/CDM.h</a></li>
<li><a href="#trunkSourceWebCoreModulesencryptedmediaCDMPrivateh">trunk/Source/WebCore/Modules/encryptedmedia/CDMPrivate.h</a></li>
<li><a href="#trunkSourceWebCoreModulesencryptedmediaMediaKeySystemAccesscpp">trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesencryptedmediaMediaKeySystemAccessh">trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.h</a></li>
<li><a href="#trunkSourceWebCoreModulesencryptedmediaMediaKeyscpp">trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesencryptedmediaMediaKeysh">trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.h</a></li>
<li><a href="#trunkSourceWebCoreModulesencryptedmediaMediaKeysidl">trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.idl</a></li>
<li><a href="#trunkSourceWebCoreModulesencryptedmediaNavigatorEMEcpp">trunk/Source/WebCore/Modules/encryptedmedia/NavigatorEME.cpp</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoretestingMockCDMFactorycpp">trunk/Source/WebCore/testing/MockCDMFactory.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingMockCDMFactoryh">trunk/Source/WebCore/testing/MockCDMFactory.h</a></li>
<li><a href="#trunkSourceWebCoretestingMockCDMFactoryidl">trunk/Source/WebCore/testing/MockCDMFactory.idl</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsmediaencryptedmediamockMediaKeySystemAccessexpectedtxt">trunk/LayoutTests/media/encrypted-media/mock-MediaKeySystemAccess-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediaencryptedmediamockMediaKeySystemAccesshtml">trunk/LayoutTests/media/encrypted-media/mock-MediaKeySystemAccess.html</a></li>
<li><a href="#trunkSourceWebCoreModulesencryptedmediaCDMInstanceh">trunk/Source/WebCore/Modules/encryptedmedia/CDMInstance.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/LayoutTests/ChangeLog        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-01-06 Jer Noble <jer.noble@apple.com>
+
+ Add support for MediaKeySystemAccess.createMediaKeys()
+ https://bugs.webkit.org/show_bug.cgi?id=166749
+
+ Reviewed by Eric Carlson.
+
+ * media/encrypted-media/mock-MediaKeySystemAccess-expected.txt: Added.
+ * media/encrypted-media/mock-MediaKeySystemAccess.html: Added.
+ * platform/mac/TestExpectations:
+
</ins><span class="cx"> 2017-01-06 Ryan Haddad <ryanhaddad@apple.com>
</span><span class="cx">
</span><span class="cx"> Add pass expectation for fast/text/emoji-num-glyphs.html on Sierra.
</span></span></pre></div>
<a id="trunkLayoutTestsmediaencryptedmediamockMediaKeySystemAccessexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/encrypted-media/mock-MediaKeySystemAccess-expected.txt (0 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/encrypted-media/mock-MediaKeySystemAccess-expected.txt         (rev 0)
+++ trunk/LayoutTests/media/encrypted-media/mock-MediaKeySystemAccess-expected.txt        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+RUN(internals.initializeMockMediaSource())
+RUN(mock = internals.registerMockCDM())
+RUN(mock.supportedDataTypes = ["mock"])
+
+RUN(capabilities.initDataTypes = ["mock"])
+RUN(capabilities.videoCapabilities = [{ contentType: 'video/mock; codecs="mock"' }] )
+RUN(promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", [capabilities]))
+Promise resolved OK
+
+RUN(promise = mediaKeySystemAccess.createMediaKeys())
+Promise resolved OK
+
+RUN(mock.canCreateInstances = false)
+RUN(promise = mediaKeySystemAccess.createMediaKeys())
+Promise rejected correctly OK
+
+RUN(mock.canCreateInstances = true)
+RUN(capabilities.distinctiveIdentifier = "not-allowed")
+RUN(promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", [capabilities]))
+Promise resolved OK
+
+RUN(promise = mediaKeySystemAccess.createMediaKeys())
+Promise resolved OK
+
+RUN(mock.distinctiveIdentifiersRequirement = "required")
+RUN(promise = mediaKeySystemAccess.createMediaKeys())
+Promise rejected correctly OK
+
+RUN(mock.distinctiveIdentifiersRequirement = "optional")
+RUN(capabilities.persistentState = "not-allowed")
+RUN(promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", [capabilities]))
+Promise resolved OK
+
+RUN(promise = mediaKeySystemAccess.createMediaKeys())
+Promise resolved OK
+
+RUN(mock.persistentStateRequirement = "required")
+RUN(promise = mediaKeySystemAccess.createMediaKeys())
+Promise rejected correctly OK
+END OF TEST
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediaencryptedmediamockMediaKeySystemAccesshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/encrypted-media/mock-MediaKeySystemAccess.html (0 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/encrypted-media/mock-MediaKeySystemAccess.html         (rev 0)
+++ trunk/LayoutTests/media/encrypted-media/mock-MediaKeySystemAccess.html        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -0,0 +1,122 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+ <script src=../video-test.js></script>
+ <script type="text/javascript">
+ var mock;
+ var promise;
+ var mediaKeySystemAccess;
+ var capabilities = {};
+
+ function doTest()
+ {
+ if (!window.internals) {
+ // failTest("Internals is required for this test.")
+ // return;
+ }
+
+ run('internals.initializeMockMediaSource()');
+ run('mock = internals.registerMockCDM()');
+ run('mock.supportedDataTypes = ["mock"]');
+
+ next();
+ }
+
+ function next() {
+ if (!tests.length) {
+ mock.unregister();
+ endTest()
+ return;
+ }
+
+ var nextTest = tests.shift();
+ consoleWrite('');
+ nextTest();
+ }
+
+ function shouldResolve(promise) {
+ promise.then(mediaKeySystemAccess => {
+ logResult(Success, 'Promise resolved');
+ next();
+ }, () => {
+ logResult(Failed, 'Promise rejected');
+ next();
+ });
+ }
+
+ function shouldReject(promise) {
+ promise.then(() => {
+ logResult(Failed, 'Promise resolved incorrectly');
+ next();
+ }, exceptionCode => {
+ logResult(Success, 'Promise rejected correctly');
+ next();
+ });
+ }
+
+ function gotMediaKeySystemAccess(result) {
+ logResult(Success, 'Promise resolved');
+ mediaKeySystemAccess = result;
+ next();
+ }
+
+ tests = [
+ function() {
+ run('capabilities.initDataTypes = ["mock"]');
+ run(`capabilities.videoCapabilities = [{ contentType: 'video/mock; codecs="mock"' }] `);
+ run('promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", [capabilities])');
+ promise.then(gotMediaKeySystemAccess).catch(failTest);
+ },
+
+ function() {
+ run('promise = mediaKeySystemAccess.createMediaKeys()');
+ shouldResolve(promise);
+ },
+
+ function() {
+ run('mock.canCreateInstances = false');
+ run('promise = mediaKeySystemAccess.createMediaKeys()');
+ shouldReject(promise);
+ },
+
+ function() {
+ run('mock.canCreateInstances = true');
+ run('capabilities.distinctiveIdentifier = "not-allowed"');
+ run('promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", [capabilities])');
+ promise.then(gotMediaKeySystemAccess).catch(failTest);
+ },
+
+ function() {
+ run('promise = mediaKeySystemAccess.createMediaKeys()');
+ shouldResolve(promise);
+ },
+
+ function() {
+ run('mock.distinctiveIdentifiersRequirement = "required"');
+ run('promise = mediaKeySystemAccess.createMediaKeys()');
+ shouldReject(promise);
+ },
+
+ function() {
+ run('mock.distinctiveIdentifiersRequirement = "optional"');
+ run('capabilities.persistentState = "not-allowed"');
+ run('promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", [capabilities])');
+ promise.then(gotMediaKeySystemAccess).catch(failTest);
+ },
+
+ function() {
+ run('promise = mediaKeySystemAccess.createMediaKeys()');
+ shouldResolve(promise);
+ },
+
+ function() {
+ run('mock.persistentStateRequirement = "required"');
+ run('promise = mediaKeySystemAccess.createMediaKeys()');
+ shouldReject(promise);
+ },
+ ];
+ </script>
+</head>
+<body onload="doTest()">
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/TestExpectations        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/LayoutTests/platform/mac/TestExpectations        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -1465,5 +1465,6 @@
</span><span class="cx">
</span><span class="cx"> # New Encrypted Media API not enabled on Mac
</span><span class="cx"> media/encrypted-media/mock-navigator-requestMediaKeySystemAccess.html [ Skip ]
</span><ins>+media/encrypted-media/mock-MediaKeySystemAccess.html [ Skip ]
</ins><span class="cx">
</span><span class="cx"> webkit.org/b/166025 http/tests/fetch/fetching-same-resource-with-diffferent-options.html [ Pass Failure ]
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/ChangeLog        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -1,3 +1,48 @@
</span><ins>+2017-01-06 Jer Noble <jer.noble@apple.com>
+
+ Add support for MediaKeySystemAccess.createMediaKeys()
+ https://bugs.webkit.org/show_bug.cgi?id=166749
+
+ Reviewed by Eric Carlson.
+
+ Test: media/encrypted-media/mock-MediaKeySystemAccess.html
+
+ Implement MediaKeySystemAccess::createMediaKeys(). This requires some
+ additions to CDM, CDMPrivate, and a new interface CDMInstance to support
+ eventual platform adoption and to implement mock support for testing.
+
+ * Modules/encryptedmedia/CDM.cpp:
+ (WebCore::CDM::loadAndInitialize):
+ (WebCore::CDM::createInstance):
+ * Modules/encryptedmedia/CDM.h:
+ * Modules/encryptedmedia/CDMInstance.h:
+ (WebCore::CDMInstance::~CDMInstance):
+ * Modules/encryptedmedia/CDMPrivate.h:
+ * Modules/encryptedmedia/MediaKeySystemAccess.cpp:
+ (WebCore::MediaKeySystemAccess::createMediaKeys):
+ * Modules/encryptedmedia/MediaKeySystemAccess.h:
+ * Modules/encryptedmedia/MediaKeys.cpp:
+ (WebCore::MediaKeys::MediaKeys):
+ * Modules/encryptedmedia/MediaKeys.h:
+ (WebCore::MediaKeys::create):
+ * Modules/encryptedmedia/MediaKeys.idl:
+ * Modules/encryptedmedia/NavigatorEME.cpp:
+ (WebCore::tryNextSupportedConfiguration):
+ * WebCore.xcodeproj/project.pbxproj:
+ * testing/MockCDMFactory.cpp:
+ (WebCore::MockCDM::MockCDM):
+ (WebCore::MockCDM::createInstance):
+ (WebCore::MockCDM::loadAndInitialize):
+ (WebCore::MockCDMInstance::MockCDMInstance):
+ (WebCore::MockCDMInstance::initializeWithConfiguration):
+ (WebCore::MockCDMInstance::setDistinctiveIdentifiersAllowed):
+ (WebCore::MockCDMInstance::setPersistentStateAllowed):
+ * testing/MockCDMFactory.h:
+ (WebCore::MockCDMFactory::canCreateInstances):
+ (WebCore::MockCDMFactory::setCanCreateInstances):
+ (WebCore::MockCDM::factory):
+ * testing/MockCDMFactory.idl:
+
</ins><span class="cx"> 2017-01-06 Andreas Kling <akling@apple.com>
</span><span class="cx">
</span><span class="cx"> Give RenderObject a Page& getter.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesencryptedmediaCDMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -611,6 +611,19 @@
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CDM::loadAndInitialize()
+{
+ if (m_private)
+ m_private->loadAndInitialize();
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+std::unique_ptr<CDMInstance> CDM::createInstance()
+{
+ if (!m_private)
+ return nullptr;
+ return m_private->createInstance();
+}
+
+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesencryptedmediaCDMh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/encryptedmedia/CDM.h (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/encryptedmedia/CDM.h        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDM.h        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> class CDM;
</span><ins>+class CDMInstance;
</ins><span class="cx"> class CDMPrivate;
</span><span class="cx"> class Document;
</span><span class="cx"> class ScriptExecutionContext;
</span><span class="lines">@@ -68,6 +69,9 @@
</span><span class="cx">
</span><span class="cx"> const String& keySystem() const { return m_keySystem; }
</span><span class="cx">
</span><ins>+ void loadAndInitialize();
+ std::unique_ptr<CDMInstance> createInstance();
+
</ins><span class="cx"> private:
</span><span class="cx"> CDM(Document&, const String& keySystem);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesencryptedmediaCDMInstancehfromrev210443trunkSourceWebCoretestingMockCDMFactoryidl"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/encryptedmedia/CDMInstance.h (from rev 210443, trunk/Source/WebCore/testing/MockCDMFactory.idl) (0 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/encryptedmedia/CDMInstance.h         (rev 0)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDMInstance.h        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(ENCRYPTED_MEDIA)
+
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+struct MediaKeySystemConfiguration;
+
+class CDMInstance {
+public:
+ virtual ~CDMInstance() { }
+
+ enum SuccessValue {
+ Failed,
+ Succeeded,
+ };
+
+ virtual SuccessValue initializeWithConfiguration(const MediaKeySystemConfiguration&) = 0;
+ virtual SuccessValue setDistinctiveIdentifiersAllowed(bool) = 0;
+ virtual SuccessValue setPersistentStateAllowed(bool) = 0;
+};
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesencryptedmediaCDMPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/encryptedmedia/CDMPrivate.h (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/encryptedmedia/CDMPrivate.h        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDMPrivate.h        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(ENCRYPTED_MEDIA)
</span><span class="cx">
</span><ins>+#include "CDMInstance.h"
</ins><span class="cx"> #include "MediaKeySessionType.h"
</span><span class="cx"> #include "MediaKeysRequirement.h"
</span><span class="cx"> #include <wtf/Forward.h>
</span><span class="lines">@@ -39,6 +40,7 @@
</span><span class="cx"> class CDMPrivate {
</span><span class="cx"> public:
</span><span class="cx"> virtual ~CDMPrivate() { }
</span><ins>+
</ins><span class="cx"> virtual bool supportsInitDataType(const String&) = 0;
</span><span class="cx"> virtual bool supportsConfiguration(const MediaKeySystemConfiguration&) = 0;
</span><span class="cx"> virtual bool supportsConfigurationWithRestrictions(const MediaKeySystemConfiguration&, const MediaKeysRestrictions&) = 0;
</span><span class="lines">@@ -47,6 +49,8 @@
</span><span class="cx"> virtual MediaKeysRequirement distinctiveIdentifiersRequirement(const MediaKeySystemConfiguration&, const MediaKeysRestrictions&) = 0;
</span><span class="cx"> virtual MediaKeysRequirement persistentStateRequirement(const MediaKeySystemConfiguration&, const MediaKeysRestrictions&) = 0;
</span><span class="cx"> virtual bool distinctiveIdentifiersAreUniquePerOriginAndClearable(const MediaKeySystemConfiguration&) = 0;
</span><ins>+ virtual std::unique_ptr<CDMInstance> createInstance() = 0;
+ virtual void loadAndInitialize() = 0;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesencryptedmediaMediaKeySystemAccesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.cpp (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.cpp        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.cpp        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -32,7 +32,10 @@
</span><span class="cx"> #if ENABLE(ENCRYPTED_MEDIA)
</span><span class="cx">
</span><span class="cx"> #include "CDM.h"
</span><ins>+#include "CDMInstance.h"
+#include "JSMediaKeys.h"
</ins><span class="cx"> #include "MediaKeySystemConfiguration.h"
</span><ins>+#include "MediaKeys.h"
</ins><span class="cx"> #include "NotImplemented.h"
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -51,9 +54,64 @@
</span><span class="cx">
</span><span class="cx"> MediaKeySystemAccess::~MediaKeySystemAccess() = default;
</span><span class="cx">
</span><del>-void MediaKeySystemAccess::createMediaKeys(Ref<DeferredPromise>&&)
</del><ins>+void MediaKeySystemAccess::createMediaKeys(Ref<DeferredPromise>&& promise)
</ins><span class="cx"> {
</span><del>- notImplemented();
</del><ins>+ // https://w3c.github.io/encrypted-media/#dom-mediakeysystemaccess-createmediakeys
+ // W3C Editor's Draft 09 November 2016
+
+ // When this method is invoked, the user agent must run the following steps:
+ // 1. Let promise be a new promise.
+ // 2. Run the following steps in parallel:
+ m_taskQueue.enqueueTask([this, promise = WTFMove(promise)] () mutable {
+ // 2.1. Let configuration be the value of this object's configuration value.
+ // 2.2. Let use distinctive identifier be true if the value of configuration's distinctiveIdentifier member is "required" and false otherwise.
+ bool useDistinctiveIdentifier = m_configuration->distinctiveIdentifier == MediaKeysRequirement::Required;
+
+ // 2.3. Let persistent state allowed be true if the value of configuration's persistentState member is "required" and false otherwise.
+ bool persistentStateAllowed = m_configuration->persistentState == MediaKeysRequirement::Required;
+
+ // 2.4. Load and initialize the Key System implementation represented by this object's cdm implementation value if necessary.
+ m_implementation->loadAndInitialize();
+
+ // 2.5. Let instance be a new instance of the Key System implementation represented by this object's cdm implementation value.
+ std::unique_ptr<CDMInstance> instance = m_implementation->createInstance();
+ if (!instance) {
+ promise->reject(INVALID_STATE_ERR);
+ return;
+ }
+
+ // 2.6. Initialize instance to enable, disable and/or select Key System features using configuration.
+ if (instance->initializeWithConfiguration(*m_configuration) == CDMInstance::Failed) {
+ promise->reject(NotAllowedError);
+ return;
+ }
+
+ // 2.7. If use distinctive identifier is false, prevent instance from using Distinctive Identifier(s) and Distinctive Permanent Identifier(s).
+ if (!useDistinctiveIdentifier && instance->setDistinctiveIdentifiersAllowed(false) == CDMInstance::Failed) {
+ promise->reject(NotAllowedError);
+ return;
+ }
+
+ // 2.8. If persistent state allowed is false, prevent instance from persisting any state related to the application or origin of this object's Document.
+ if (!persistentStateAllowed && instance->setPersistentStateAllowed(false) == CDMInstance::Failed) {
+ promise->reject(NotAllowedError);
+ return;
+ }
+
+ // 2.9. If any of the preceding steps failed, reject promise with a new DOMException whose name is the appropriate error name.
+ // 2.10. Let media keys be a new MediaKeys object, and initialize it as follows:
+ // 2.10.1. Let the use distinctive identifier value be use distinctive identifier.
+ // 2.10.2. Let the persistent state allowed value be persistent state allowed.
+ // 2.10.3. Let the supported session types value be be the value of configuration's sessionTypes member.
+ // 2.10.4. Let the cdm implementation value be this object's cdm implementation value.
+ // 2.10.5. Let the cdm instance value be instance.
+ auto mediaKeys = MediaKeys::create(useDistinctiveIdentifier, persistentStateAllowed, m_configuration->sessionTypes, m_implementation.copyRef(), WTFMove(instance));
+
+ // 2.11. Resolve promise with media keys.
+ promise->resolveWithNewlyCreated<IDLInterface<MediaKeys>>(WTFMove(mediaKeys));
+ });
+
+ // 3. Return promise.
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesencryptedmediaMediaKeySystemAccessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.h (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.h        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.h        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(ENCRYPTED_MEDIA)
</span><span class="cx">
</span><ins>+#include "GenericTaskQueue.h"
</ins><span class="cx"> #include "JSDOMPromise.h"
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="lines">@@ -56,6 +57,7 @@
</span><span class="cx"> String m_keySystem;
</span><span class="cx"> std::unique_ptr<MediaKeySystemConfiguration> m_configuration;
</span><span class="cx"> Ref<CDM> m_implementation;
</span><ins>+ GenericTaskQueue<Timer> m_taskQueue;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesencryptedmediaMediaKeyscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -31,12 +31,21 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(ENCRYPTED_MEDIA)
</span><span class="cx">
</span><ins>+#include "CDM.h"
+#include "CDMInstance.h"
</ins><span class="cx"> #include "MediaKeySession.h"
</span><span class="cx"> #include "NotImplemented.h"
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-MediaKeys::MediaKeys() = default;
</del><ins>+MediaKeys::MediaKeys(bool useDistinctiveIdentifier, bool persistentStateAllowed, const Vector<MediaKeySessionType>& supportedSessionTypes, Ref<CDM>&& implementation, std::unique_ptr<CDMInstance>&& instance)
+ : m_useDistinctiveIdentifier(useDistinctiveIdentifier)
+ , m_persistentStateAllowed(persistentStateAllowed)
+ , m_supportedSessionTypes(supportedSessionTypes)
+ , m_implementation(WTFMove(implementation))
+ , m_instance(WTFMove(instance))
+{
+}
</ins><span class="cx">
</span><span class="cx"> MediaKeys::~MediaKeys() = default;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesencryptedmediaMediaKeysh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.h (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.h        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.h        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -38,6 +38,8 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+class CDM;
+class CDMInstance;
</ins><span class="cx"> class BufferSource;
</span><span class="cx"> class MediaKeySession;
</span><span class="cx">
</span><span class="lines">@@ -45,12 +47,12 @@
</span><span class="cx"> public:
</span><span class="cx"> using KeySessionType = MediaKeySessionType;
</span><span class="cx">
</span><del>- static Ref<MediaKeys> create()
</del><ins>+ static Ref<MediaKeys> create(bool useDistinctiveIdentifier, bool persistentStateAllowed, const Vector<MediaKeySessionType>& supportedSessionTypes, Ref<CDM>&& implementation, std::unique_ptr<CDMInstance>&& instance)
</ins><span class="cx"> {
</span><del>- return adoptRef(*new MediaKeys);
</del><ins>+ return adoptRef(*new MediaKeys(useDistinctiveIdentifier, persistentStateAllowed, supportedSessionTypes, WTFMove(implementation), WTFMove(instance)));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- virtual ~MediaKeys();
</del><ins>+ ~MediaKeys();
</ins><span class="cx">
</span><span class="cx"> ExceptionOr<Ref<MediaKeySession>> createSession(MediaKeySessionType);
</span><span class="cx">
</span><span class="lines">@@ -57,7 +59,13 @@
</span><span class="cx"> void setServerCertificate(const BufferSource&, Ref<DeferredPromise>&&);
</span><span class="cx">
</span><span class="cx"> protected:
</span><del>- MediaKeys();
</del><ins>+ MediaKeys(bool useDistinctiveIdentifier, bool persistentStateAllowed, const Vector<MediaKeySessionType>&, Ref<CDM>&&, std::unique_ptr<CDMInstance>&&);
+
+ bool m_useDistinctiveIdentifier;
+ bool m_persistentStateAllowed;
+ Vector<MediaKeySessionType> m_supportedSessionTypes;
+ Ref<CDM> m_implementation;
+ std::unique_ptr<CDMInstance> m_instance;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesencryptedmediaMediaKeysidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.idl (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.idl        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.idl        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -28,7 +28,8 @@
</span><span class="cx">
</span><span class="cx"> [
</span><span class="cx"> Conditional=ENCRYPTED_MEDIA,
</span><del>- EnabledAtRuntime=EncryptedMediaAPI
</del><ins>+ EnabledAtRuntime=EncryptedMediaAPI,
+ ImplementationLacksVTable,
</ins><span class="cx"> ] interface MediaKeys {
</span><span class="cx"> [MayThrowException] MediaKeySession createSession(optional MediaKeySessionType sessionType = "temporary");
</span><span class="cx"> Promise<bool> setServerCertificate(BufferSource serverCertificate);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesencryptedmediaNavigatorEMEcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/encryptedmedia/NavigatorEME.cpp (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/encryptedmedia/NavigatorEME.cpp        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/NavigatorEME.cpp        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -90,7 +90,7 @@
</span><span class="cx"> // 6.3.3.1.3. Let the cdm implementation value be implementation.
</span><span class="cx"> auto access = MediaKeySystemAccess::create(implementation->keySystem(), WTFMove(supportedConfiguration.value()), implementation.releaseNonNull());
</span><span class="cx"> // 6.3.3.2. Resolve promise with access and abort the parallel steps of this algorithm.
</span><del>- promise->resolve<IDLInterface<MediaKeySystemAccess>>(access.get());
</del><ins>+ promise->resolveWithNewlyCreated<IDLInterface<MediaKeySystemAccess>>(WTFMove(access));
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -13738,6 +13738,7 @@
</span><span class="cx">                 CD8B5A48180E138B008B8E65 /* TextTrackMediaSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackMediaSource.h; sourceTree = "<group>"; };
</span><span class="cx">                 CD8B5A4A180E17A3008B8E65 /* AudioTrackMediaSource.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AudioTrackMediaSource.idl; sourceTree = "<group>"; };
</span><span class="cx">                 CD8B5A4B180E17C0008B8E65 /* AudioTrackMediaSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioTrackMediaSource.h; sourceTree = "<group>"; };
</span><ins>+                CD9D05421E1EFA12003B4C4F /* CDMInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDMInstance.h; sourceTree = "<group>"; };
</ins><span class="cx">                 CD9D82731C7AE535006FF066 /* TextureCacheCV.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TextureCacheCV.mm; path = ../cv/TextureCacheCV.mm; sourceTree = "<group>"; };
</span><span class="cx">                 CD9D82741C7AE535006FF066 /* TextureCacheCV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextureCacheCV.h; path = ../cv/TextureCacheCV.h; sourceTree = "<group>"; };
</span><span class="cx">                 CD9D82771C7B8EE1006FF066 /* VideoTextureCopierCV.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VideoTextureCopierCV.cpp; path = ../cv/VideoTextureCopierCV.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -22754,6 +22755,7 @@
</span><span class="cx">                                 2D0621461DA639EC00A7FB26 /* legacy */,
</span><span class="cx">                                 CDF4B7131E00B7E500E235A2 /* CDM.cpp */,
</span><span class="cx">                                 CDF4B7141E00B7E500E235A2 /* CDM.h */,
</span><ins>+                                CD9D05421E1EFA12003B4C4F /* CDMInstance.h */,
</ins><span class="cx">                                 CDF4B7251E03C15B00E235A2 /* CDMPrivate.h */,
</span><span class="cx">                                 2D9BF72F1DBFDC0F007A7D99 /* MediaKeyMessageEvent.cpp */,
</span><span class="cx">                                 2D9BF7301DBFDC0F007A7D99 /* MediaKeyMessageEvent.h */,
</span></span></pre></div>
<a id="trunkSourceWebCoretestingMockCDMFactorycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/MockCDMFactory.cpp (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/MockCDMFactory.cpp        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/testing/MockCDMFactory.cpp        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -63,6 +63,7 @@
</span><span class="cx">
</span><span class="cx"> MockCDM::MockCDM(WeakPtr<MockCDMFactory> factory)
</span><span class="cx"> : m_factory(WTFMove(factory))
</span><ins>+ , m_weakPtrFactory(this)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -119,6 +120,59 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+std::unique_ptr<CDMInstance> MockCDM::createInstance()
+{
+ if (m_factory && !m_factory->canCreateInstances())
+ return nullptr;
+ return std::unique_ptr<CDMInstance>(new MockCDMInstance(m_weakPtrFactory.createWeakPtr()));
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+void MockCDM::loadAndInitialize()
+{
+ // No-op.
+}
+
+MockCDMInstance::MockCDMInstance(WeakPtr<MockCDM> cdm)
+ : m_cdm(cdm)
+{
+}
+
+CDMInstance::SuccessValue MockCDMInstance::initializeWithConfiguration(const MediaKeySystemConfiguration& configuration)
+{
+ if (!m_cdm || !m_cdm->supportsConfiguration(configuration))
+ return Failed;
+
+ return Succeeded;
+}
+
+CDMInstance::SuccessValue MockCDMInstance::setDistinctiveIdentifiersAllowed(bool distinctiveIdentifiersAllowed)
+{
+ if (m_distinctiveIdentifiersAllowed == distinctiveIdentifiersAllowed)
+ return Succeeded;
+
+ MockCDMFactory* factory = m_cdm ? m_cdm->factory() : nullptr;
+
+ if (!factory || (!distinctiveIdentifiersAllowed && factory->distinctiveIdentifiersRequirement() == MediaKeysRequirement::Required))
+ return Failed;
+
+ m_distinctiveIdentifiersAllowed = distinctiveIdentifiersAllowed;
+ return Succeeded;
+}
+
+CDMInstance::SuccessValue MockCDMInstance::setPersistentStateAllowed(bool persistentStateAllowed)
+{
+ if (m_persistentStateAllowed == persistentStateAllowed)
+ return Succeeded;
+
+ MockCDMFactory* factory = m_cdm ? m_cdm->factory() : nullptr;
+
+ if (!factory || (!persistentStateAllowed && factory->persistentStateRequirement() == MediaKeysRequirement::Required))
+ return Failed;
+
+ m_persistentStateAllowed = persistentStateAllowed;
+ return Succeeded;
+}
+
+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoretestingMockCDMFactoryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/MockCDMFactory.h (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/MockCDMFactory.h        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/testing/MockCDMFactory.h        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #if ENABLE(ENCRYPTED_MEDIA)
</span><span class="cx">
</span><span class="cx"> #include "CDM.h"
</span><ins>+#include "CDMInstance.h"
</ins><span class="cx"> #include "CDMPrivate.h"
</span><span class="cx"> #include "MediaKeysRequirement.h"
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="lines">@@ -53,6 +54,9 @@
</span><span class="cx"> MediaKeysRequirement persistentStateRequirement() const { return m_persistentStateRequirement; }
</span><span class="cx"> void setPersistentStateRequirement(MediaKeysRequirement requirement) { m_persistentStateRequirement = requirement; }
</span><span class="cx">
</span><ins>+ bool canCreateInstances() const { return m_canCreateInstances; }
+ void setCanCreateInstances(bool flag) { m_canCreateInstances = flag; }
+
</ins><span class="cx"> void unregister();
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="lines">@@ -65,6 +69,7 @@
</span><span class="cx"> Vector<String> m_supportedDataTypes;
</span><span class="cx"> Vector<String> m_supportedRobustness;
</span><span class="cx"> bool m_registered { true };
</span><ins>+ bool m_canCreateInstances { true };
</ins><span class="cx"> WeakPtrFactory<MockCDMFactory> m_weakPtrFactory;
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -72,7 +77,11 @@
</span><span class="cx"> public:
</span><span class="cx"> MockCDM(WeakPtr<MockCDMFactory>);
</span><span class="cx">
</span><ins>+ MockCDMFactory* factory() { return m_factory.get(); }
+
</ins><span class="cx"> private:
</span><ins>+ friend class MockCDMInstance;
+
</ins><span class="cx"> bool supportsInitDataType(const String&) final;
</span><span class="cx"> bool supportsConfiguration(const MediaKeySystemConfiguration&) final;
</span><span class="cx"> bool supportsConfigurationWithRestrictions(const MediaKeySystemConfiguration&, const MediaKeysRestrictions&) final;
</span><span class="lines">@@ -81,10 +90,27 @@
</span><span class="cx"> MediaKeysRequirement distinctiveIdentifiersRequirement(const MediaKeySystemConfiguration&, const MediaKeysRestrictions&) final;
</span><span class="cx"> MediaKeysRequirement persistentStateRequirement(const MediaKeySystemConfiguration&, const MediaKeysRestrictions&) final;
</span><span class="cx"> bool distinctiveIdentifiersAreUniquePerOriginAndClearable(const MediaKeySystemConfiguration&) final;
</span><ins>+ std::unique_ptr<CDMInstance> createInstance() final;
+ void loadAndInitialize() final;
</ins><span class="cx">
</span><span class="cx"> WeakPtr<MockCDMFactory> m_factory;
</span><ins>+ WeakPtrFactory<MockCDM> m_weakPtrFactory;
</ins><span class="cx"> };
</span><span class="cx">
</span><ins>+class MockCDMInstance : public CDMInstance {
+public:
+ MockCDMInstance(WeakPtr<MockCDM>);
+
+private:
+ SuccessValue initializeWithConfiguration(const MediaKeySystemConfiguration&) final;
+ SuccessValue setDistinctiveIdentifiersAllowed(bool) final;
+ SuccessValue setPersistentStateAllowed(bool) final;
+
+ WeakPtr<MockCDM> m_cdm;
+ bool m_distinctiveIdentifiersAllowed { true };
+ bool m_persistentStateAllowed { true };
+};
+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoretestingMockCDMFactoryidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/MockCDMFactory.idl (210444 => 210445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/MockCDMFactory.idl        2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/testing/MockCDMFactory.idl        2017-01-06 18:48:29 UTC (rev 210445)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> attribute sequence<DOMString> supportedRobustness;
</span><span class="cx"> attribute MediaKeysRequirement distinctiveIdentifiersRequirement;
</span><span class="cx"> attribute MediaKeysRequirement persistentStateRequirement;
</span><ins>+ attribute boolean canCreateInstances;
</ins><span class="cx">
</span><span class="cx"> void unregister();
</span><span class="cx"> };
</span></span></pre>
</div>
</div>
</body>
</html>