<!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>[211855] trunk/Source/WebCore</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/211855">211855</a></dd>
<dt>Author</dt> <dd>zandobersek@gmail.com</dd>
<dt>Date</dt> <dd>2017-02-08 01:34:44 -0800 (Wed, 08 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[EME] Alias CDMInstance enums to the specification-defined enums
https://bugs.webkit.org/show_bug.cgi?id=167896

Reviewed by Sam Weinig.

Simplify the enums in the CDMInstance class by simply aliasing them
to the EME specification-defined enums. CDMInstance::KeyStatus and
CDMInstance::MessageType were already direct copies of the
MediaKeyStatus and MediaKeyMessageType enums, while the
CDMInstance::LicenseType had the members as MediaKeySessionType,
but with slightly different names.

No changes in behavior.

* Modules/encryptedmedia/CDMInstance.h:
* Modules/encryptedmedia/MediaKeySession.cpp:
(WebCore::MediaKeySession::generateRequest):
(WebCore::MediaKeySession::update):
* testing/MockCDMFactory.cpp:
(WebCore::MockCDMInstance::requestLicense):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesencryptedmediaCDMInstanceh">trunk/Source/WebCore/Modules/encryptedmedia/CDMInstance.h</a></li>
<li><a href="#trunkSourceWebCoreModulesencryptedmediaMediaKeySessioncpp">trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingMockCDMFactorycpp">trunk/Source/WebCore/testing/MockCDMFactory.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (211854 => 211855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-02-08 06:54:01 UTC (rev 211854)
+++ trunk/Source/WebCore/ChangeLog        2017-02-08 09:34:44 UTC (rev 211855)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2017-02-08  Zan Dobersek  &lt;zdobersek@igalia.com&gt;
+
+        [EME] Alias CDMInstance enums to the specification-defined enums
+        https://bugs.webkit.org/show_bug.cgi?id=167896
+
+        Reviewed by Sam Weinig.
+
+        Simplify the enums in the CDMInstance class by simply aliasing them
+        to the EME specification-defined enums. CDMInstance::KeyStatus and
+        CDMInstance::MessageType were already direct copies of the
+        MediaKeyStatus and MediaKeyMessageType enums, while the
+        CDMInstance::LicenseType had the members as MediaKeySessionType,
+        but with slightly different names.
+
+        No changes in behavior.
+
+        * Modules/encryptedmedia/CDMInstance.h:
+        * Modules/encryptedmedia/MediaKeySession.cpp:
+        (WebCore::MediaKeySession::generateRequest):
+        (WebCore::MediaKeySession::update):
+        * testing/MockCDMFactory.cpp:
+        (WebCore::MockCDMInstance::requestLicense):
+
</ins><span class="cx"> 2017-02-07  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r210740): [GTK] 2.15 broke embedded videos in GNOME's yelp app
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesencryptedmediaCDMInstanceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/encryptedmedia/CDMInstance.h (211854 => 211855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/encryptedmedia/CDMInstance.h        2017-02-08 06:54:01 UTC (rev 211854)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDMInstance.h        2017-02-08 09:34:44 UTC (rev 211855)
</span><span class="lines">@@ -27,6 +27,9 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(ENCRYPTED_MEDIA)
</span><span class="cx"> 
</span><ins>+#include &quot;MediaKeyMessageType.h&quot;
+#include &quot;MediaKeySessionType.h&quot;
+#include &quot;MediaKeyStatus.h&quot;
</ins><span class="cx"> #include &lt;utility&gt;
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="cx"> #include &lt;wtf/Optional.h&gt;
</span><span class="lines">@@ -47,37 +50,18 @@
</span><span class="cx">         Succeeded,
</span><span class="cx">     };
</span><span class="cx"> 
</span><ins>+    using LicenseType = MediaKeySessionType;
+    using KeyStatus = MediaKeyStatus;
+    using MessageType = MediaKeyMessageType;
+
</ins><span class="cx">     virtual SuccessValue initializeWithConfiguration(const MediaKeySystemConfiguration&amp;) = 0;
</span><span class="cx">     virtual SuccessValue setDistinctiveIdentifiersAllowed(bool) = 0;
</span><span class="cx">     virtual SuccessValue setPersistentStateAllowed(bool) = 0;
</span><span class="cx">     virtual SuccessValue setServerCertificate(Ref&lt;SharedBuffer&gt;&amp;&amp;) = 0;
</span><span class="cx"> 
</span><del>-    enum class LicenseType {
-        Temporary,
-        Persistable,
-        UsageRecord,
-    };
-
</del><span class="cx">     using LicenseCallback = Function&lt;void(Ref&lt;SharedBuffer&gt;&amp;&amp; message, const String&amp; sessionId, bool needsIndividualization, SuccessValue succeeded)&gt;;
</span><span class="cx">     virtual void requestLicense(LicenseType, const AtomicString&amp; initDataType, Ref&lt;SharedBuffer&gt;&amp;&amp; initData, LicenseCallback) = 0;
</span><span class="cx"> 
</span><del>-    enum class KeyStatus {
-        Usable,
-        Expired,
-        Released,
-        OutputRestricted,
-        OutputDownscaled,
-        StatusPending,
-        InternalError,
-    };
-
-    enum class MessageType {
-        LicenseRequest,
-        LicenseRenewal,
-        LicenseRelease,
-        IndividualizationRequest,
-    };
-
</del><span class="cx">     using KeyStatusVector = Vector&lt;std::pair&lt;Ref&lt;SharedBuffer&gt;, KeyStatus&gt;&gt;;
</span><span class="cx">     using Message = std::pair&lt;MessageType, Ref&lt;SharedBuffer&gt;&gt;;
</span><span class="cx">     using LicenseUpdateCallback = Function&lt;void(bool sessionWasClosed, std::optional&lt;KeyStatusVector&gt;&amp;&amp; changedKeys, std::optional&lt;double&gt;&amp;&amp; changedExpiration, std::optional&lt;Message&gt;&amp;&amp; message, SuccessValue succeeded)&gt;;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesencryptedmediaMediaKeySessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp (211854 => 211855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp        2017-02-08 06:54:01 UTC (rev 211854)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp        2017-02-08 09:34:44 UTC (rev 211855)
</span><span class="lines">@@ -165,37 +165,25 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // 10.9.2 Follow the steps for the value of session type from the following list:
</span><del>-        CDMInstance::LicenseType requestedLicenseType;
-        switch (m_sessionType) {
-        case MediaKeySessionType::Temporary:
-            // ↳ &quot;temporary&quot;
-            // Let requested license type be a temporary non-persistable license.
-            requestedLicenseType = CDMInstance::LicenseType::Temporary;
-            break;
-        case MediaKeySessionType::PersistentLicense:
-            // ↳ &quot;persistent-license&quot;
-            // Let requested license type be a persistable license.
-            requestedLicenseType = CDMInstance::LicenseType::Persistable;
-            break;
-        case MediaKeySessionType::PersistentUsageRecord:
-            // ↳ &quot;persistent-usage-record&quot;
-            // 1. Initialize this object's record of key usage as follows.
-            //    Set the list of key IDs known to the session to an empty list.
</del><ins>+        //   ↳ &quot;temporary&quot;
+        //     Let requested license type be a temporary non-persistable license.
+        //   ↳ &quot;persistent-license&quot;
+        //     Let requested license type be a persistable license.
+        //   ↳ &quot;persistent-usage-record&quot;
+        //     1. Initialize this object's record of key usage as follows.
+        //        Set the list of key IDs known to the session to an empty list.
+        //        Set the first decrypt time to null.
+        //        Set the latest decrypt time to null.
+        //     2. Let requested license type be a non-persistable license that will
+        //        persist a record of key usage.
+
+        if (m_sessionType == MediaKeySessionType::PersistentUsageRecord) {
</ins><span class="cx">             m_recordOfKeyUsage.clear();
</span><del>-
-            //    Set the first decrypt time to null.
</del><span class="cx">             m_firstDecryptTime = 0;
</span><del>-
-            //    Set the latest decrypt time to null.
</del><span class="cx">             m_latestDecryptTime = 0;
</span><del>-
-            // 2. Let requested license type be a non-persistable license that will
-            //    persist a record of key usage.
-            requestedLicenseType = CDMInstance::LicenseType::UsageRecord;
-            break;
</del><span class="cx">         }
</span><span class="cx"> 
</span><del>-        m_instance-&gt;requestLicense(requestedLicenseType, initDataType, WTFMove(initData), [this, weakThis = m_weakPtrFactory.createWeakPtr(), promise = WTFMove(promise)] (Ref&lt;SharedBuffer&gt;&amp;&amp; message, const String&amp; sessionId, bool needsIndividualization, CDMInstance::SuccessValue succeeded) mutable {
</del><ins>+        m_instance-&gt;requestLicense(m_sessionType, initDataType, WTFMove(initData), [this, weakThis = m_weakPtrFactory.createWeakPtr(), promise = WTFMove(promise)] (Ref&lt;SharedBuffer&gt;&amp;&amp; message, const String&amp; sessionId, bool needsIndividualization, CDMInstance::SuccessValue succeeded) mutable {
</ins><span class="cx">             if (!weakThis)
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><span class="lines">@@ -277,25 +265,12 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        CDMInstance::LicenseType licenseType;
-        switch (m_sessionType) {
-        case MediaKeySessionType::Temporary:
-            licenseType = CDMInstance::LicenseType::Temporary;
-            break;
-        case MediaKeySessionType::PersistentLicense:
-            licenseType = CDMInstance::LicenseType::Persistable;
-            break;
-        case MediaKeySessionType::PersistentUsageRecord:
-            licenseType = CDMInstance::LicenseType::UsageRecord;
-            break;
-        };
-
</del><span class="cx">         // 6.3. Let message be null.
</span><span class="cx">         // 6.4. Let message type be null.
</span><span class="cx">         // 6.5. Let session closed be false.
</span><span class="cx">         // 6.6. Let cdm be the CDM instance represented by this object's cdm instance value.
</span><span class="cx">         // 6.7. Use the cdm to execute the following steps:
</span><del>-        m_instance-&gt;updateLicense(licenseType, *sanitizedResponse, [this, weakThis = m_weakPtrFactory.createWeakPtr(), promise = WTFMove(promise)] (bool sessionWasClosed, std::optional&lt;CDMInstance::KeyStatusVector&gt;&amp;&amp; changedKeys, std::optional&lt;double&gt;&amp;&amp; changedExpiration, std::optional&lt;CDMInstance::Message&gt;&amp;&amp; message, CDMInstance::SuccessValue succeeded) mutable {
</del><ins>+        m_instance-&gt;updateLicense(m_sessionType, *sanitizedResponse, [this, weakThis = m_weakPtrFactory.createWeakPtr(), promise = WTFMove(promise)] (bool sessionWasClosed, std::optional&lt;CDMInstance::KeyStatusVector&gt;&amp;&amp; changedKeys, std::optional&lt;double&gt;&amp;&amp; changedExpiration, std::optional&lt;CDMInstance::Message&gt;&amp;&amp; message, CDMInstance::SuccessValue succeeded) mutable {
</ins><span class="cx">             if (!weakThis)
</span><span class="cx">                 return;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoretestingMockCDMFactorycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/MockCDMFactory.cpp (211854 => 211855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/MockCDMFactory.cpp        2017-02-08 06:54:01 UTC (rev 211854)
+++ trunk/Source/WebCore/testing/MockCDMFactory.cpp        2017-02-08 09:34:44 UTC (rev 211855)
</span><span class="lines">@@ -249,10 +249,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if ((licenseType == LicenseType::Temporary &amp;&amp; !factory-&gt;supportedSessionTypes().contains(MediaKeySessionType::Temporary))
-        || (licenseType == LicenseType::Persistable &amp;&amp; !factory-&gt;supportedSessionTypes().contains(MediaKeySessionType::PersistentLicense))
-        || (licenseType == LicenseType::UsageRecord &amp;&amp; !factory-&gt;supportedSessionTypes().contains(MediaKeySessionType::PersistentUsageRecord))
-        || !factory-&gt;supportedDataTypes().contains(initDataType)) {
</del><ins>+    if (!factory-&gt;supportedSessionTypes().contains(licenseType) || !factory-&gt;supportedDataTypes().contains(initDataType)) {
</ins><span class="cx">         callback(SharedBuffer::create(), emptyString(), false, SuccessValue::Failed);
</span><span class="cx">         return;
</span><span class="cx">     }
</span></span></pre>
</div>
</div>

</body>
</html>