[EME] Simplify references to the session object.
authorDavid Dorwin <ddorwin@google.com>
Mon, 24 Mar 2014 15:09:19 -0700
changeset 259 10b205594206
parent 258 6374e2195b04
child 260 e24493b938d9
[EME] Simplify references to the session object.

Use a variable named "session" or "this object" in place of various inconsistent references.

Also, all attributes of the MediaKeySession are now initialized when it is created.
encrypted-media/encrypted-media.html
encrypted-media/encrypted-media.xml
--- a/encrypted-media/encrypted-media.html	Mon Mar 24 15:05:35 2014 -0700
+++ b/encrypted-media/encrypted-media.html	Mon Mar 24 15:09:19 2014 -0700
@@ -356,7 +356,7 @@
       <li><p>If <var title="true">keySystem</var> is not one of the user agent's supported <a href="#key-system">Key Systems</a>, throw a <code><a href="http://www.w3.org/TR/dom/#dom-domexception-not_supported_err">NOT_SUPPORTED_ERR</a></code> and abort these steps. Key system string comparison is case-sensitive.</p></li>
       <li>Create a new <code><a href="#dom-mediakeys">MediaKeys</a></code> object.
         <ol>
-          <li><p>Let the <code><a href="#dom-keysystem">keySystem</a></code> attribute be <var title="true">keySystem</var>.</p></li>
+          <li><p>Set the <code><a href="#dom-keysystem">keySystem</a></code> attribute to <var title="true">keySystem</var>.</p></li>
         </ol>
       </li>
 
@@ -392,23 +392,23 @@
       <li><p>If <var title="true">contentType</var> contains an invalid or unrecognized MIME type, throw a <code><a href="http://www.w3.org/TR/dom/#dom-domexception-not_supported_err">NOT_SUPPORTED_ERR</a></code> exception and abort these steps.</p></li>
       <li><p>Let <var title="true">initDataFormat</var> be the container type specified by <var title="true">contentType</var>.</p></li>
       <li><p>If the <a href="#cdm">content decryption module</a> corresponding to the <code><a href="#dom-keysystem">keySystem</a></code> attribute does not support the <a href="#initialization-data">Initialization Data</a> format <var title="true">initDataFormat</var>, throw a <code><a href="http://www.w3.org/TR/dom/#dom-domexception-not_supported_err">NOT_SUPPORTED_ERR</a></code> exception and abort these steps.</p></li>
-
-      <li>Create a new <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object.
+      <li>Let <var title="true">session</var> be a new <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object, and initialize it as follows:
         <ol>
-          <li><p>Let the <code><a href="#dom-sessionkeysystem">keySystem</a></code> attribute of the new object be <code><a href="#dom-keysystem">keySystem</a></code>.</p></li>
-          <li><p>Let the state of the new object be <code><a href="#dom-statecreated">CREATED</a></code>.</p></li>
+          <li><p>Set the <code><a href="#dom-error">error</a></code> attribute to null.</p></li>
+          <li><p>Set the <code><a href="#dom-sessionkeysystem">keySystem</a></code> attribute to the value of the <code><a href="#dom-mediakeys">MediaKeys</a></code> object's <code><a href="#dom-keysystem">keySystem</a></code> attribute.</p></li>
+          <li><p>Set the <code><a href="#dom-sessionid">sessionId</a></code> attribute to the empty string.</p></li>
+          <li><p>Let the state be <code><a href="#dom-statecreated">CREATED</a></code>.</p></li>
         </ol>
       </li>
-      
       <li>
-<p>Schedule a task to initialize the session, providing <var title="true">initDataFormat</var>, <var title="true">initData</var>, and the new object.</p>
+<p>Schedule a task to process the <var title="true">initData</var>, providing <var title="true">session</var>, <var title="true">initDataFormat</var>, and <var title="true">initData</var>.</p>
         <p>The user agent will asynchronously execute the following steps in the task:</p>
         <ol>
           <li><p>Wait for the <a href="#dom-mediakeys-constructor"><code>MediaKeys</code> constructor</a> task to complete.</p></li>
           <li>
 <p>If error information is stored with the <code><a href="#dom-mediakeys">MediaKeys</a></code> object because of an error during the <a href="#dom-mediakeys-constructor"><code>MediaKeys</code> constructor</a> task:</p>
             <ol>
-              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object, providing the <a href="#mediakeyerror-names">error name</a> and system code that were stored with the <code><a href="#dom-mediakeys">MediaKeys</a></code> object.</p></li>
+              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <var title="true">session</var>, providing the <a href="#mediakeyerror-names">error name</a> and system code that were stored with the <code><a href="#dom-mediakeys">MediaKeys</a></code> object.</p></li>
               <li><p>Clear the error information stored with the <code><a href="#dom-mediakeys">MediaKeys</a></code> object.</p></li>
               <li><p>Abort the task</p></li>
             </ol>
@@ -419,25 +419,25 @@
           <li>
 <p>Use <var title="true">cdm</var> to execute the following steps:</p>
             <ol>
-              <li><p>Process <var title="true">initData</var>, interpreting it per <var title="true">initDataFormat</var>.</p></li>
+              <li><p>Process the <var title="true">initData</var>, interpreting it per <var title="true">initDataFormat</var>.</p></li>
               <li>
 <p>If a message exchange <span class="non-normative">(e.g. a license request)</span> is required:</p>
                 <ol>
                   <li>
-<p>Let <var title="true">request</var> be a request generated by the <a href="#cdm">CDM</a> using <var title="true">initData</var>.</p>
-                    <p><var title="true">cdm</var> must not use any stream-specific data, including <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-data">media data</a>, not provided via <var title="true">initData</var>.</p>
-                    <p class="non-normative">Note: <var title="true">request</var> may be a request for multiple keys, depending on the <var title="true"><a href="#key-system">keySystem</a></var> and/or <var title="true">initData</var>. This is transparent to the application.</p>                
+<p>Let <var title="true">request</var> be a request generated by the <a href="#cdm">CDM</a> using the <var title="true">initData</var>.</p>
+                    <p><var title="true">cdm</var> must not use any stream-specific data, including <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-data">media data</a>, not provided via the <var title="true">initData</var>.</p>
+                    <p class="non-normative">Note: <var title="true">request</var> may be a request for multiple keys, depending on the <var title="true"><a href="#key-system">keySystem</a></var> and/or the <var title="true">initData</var>. This is transparent to the application.</p>                
                   </li>
-                  <li><p>If <var title="true">initData</var> indicates a default URL relevant to <var title="true">keySystem</var>, let <var title="true">default URL</var> be that URL.</p></li>
+                  <li><p>If the <var title="true">initData</var> indicates a default URL relevant to <var title="true">keySystem</var>, let <var title="true">default URL</var> be that URL.</p></li>
                 </ol>
               </li>
             </ol>
           </li>
-          <li><p>Let the <code><a href="#dom-sessionid">sessionId</a></code> attribute be a unique <a href="#session-id">Session ID</a> string. <span class="non-normative">It may be obtained from <var title="true">cdm</var>.</span></p></li>
+          <li><p>Set the <var title="true">session</var>'s <code><a href="#dom-sessionid">sessionId</a></code> attribute to a unique <a href="#session-id">Session ID</a> string. <span class="non-normative">It may be obtained from <var title="true">cdm</var>.</span></p></li>
           <li>
 <p>If any of the preceding steps in the task failed, run the following steps:</p>
             <ol>
-              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object, providing the appropriate <a href="#mediakeyerror-names">error name</a> and system code value, if provided, and 0 otherwise.</p></li>
+              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <var title="true">session</var>, providing the appropriate <a href="#mediakeyerror-names">error name</a> and system code value, if provided, and 0 otherwise.</p></li>
               <li><p>Abort the task</p></li>
             </ol>
           </li>
@@ -451,14 +451,14 @@
             <dl class="switch">
               <dt>If <var title="true">request</var> is not null</dt>
               <dd>
-                <p>Run the <a href="#algorithms-queue-message">Queue a "message" Event</a> algorithm on the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object, providing <var title="true">request</var> and <var title="true">default URL</var>.</p>
+                <p>Run the <a href="#algorithms-queue-message">Queue a "message" Event</a> algorithm on the <var title="true">session</var>, providing <var title="true">request</var> and <var title="true">default URL</var>.</p>
               </dd>
               <dt>Otherwise</dt>
               <dd>
                 <ol>
-                  <li><p>Let the state of the session be <code><a href="#dom-stateready">READY</a></code>.</p></li>
+                  <li><p>Let the state of the <var title="true">session</var> be <code><a href="#dom-stateready">READY</a></code>.</p></li>
                   <li>
-                    <p><a href="http://www.w3.org/TR/html5/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://www.w3.org/TR/html5/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-eventready">ready</a></code> at the new object.</p>
+                    <p><a href="http://www.w3.org/TR/html5/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://www.w3.org/TR/html5/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-eventready">ready</a></code> at the <var title="true">session</var>.</p>
                     <p class="non-normative">Note: this step makes it possible for a MediaKeySession to transition from the CREATED state to the READY state.
                     User agents might do this as an optimization but, even if this is done, all MediaKeySession instances must appear distinct regardless of the underlying implementation.</p>
                   </li>
@@ -480,22 +480,23 @@
     <ol>
       <li><p>If the <a href="#cdm">content decryption module</a> corresponding to the <code><a href="#dom-keysystem">keySystem</a></code> attribute does not support loading previous sessions, throw a <code><a href="http://www.w3.org/TR/dom/#dom-domexception-not_supported_err">NOT_SUPPORTED_ERR</a></code> exception and abort these steps.</p></li>
       <li><p>If <var title="true">sessionId</var> is null or an empty string, throw an <code><a href="http://www.w3.org/TR/dom/#dom-domexception-invalid_access_err">INVALID_ACCESS_ERR</a></code> exception and abort these steps.</p></li>
-      <li>Create a new <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object.
+      <li>Let <var title="true">session</var> be a new <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object, and initialize it as follows:
         <ol>
-          <li><p>Let the <code><a href="#dom-sessionkeysystem">keySystem</a></code> attribute of the new object be <code><a href="#dom-keysystem">keySystem</a></code>.</p></li>
-          <li><p>Let the state of the new object be <code><a href="#dom-statecreated">CREATED</a></code>.</p></li>
+          <li><p>Set the <code><a href="#dom-error">error</a></code> attribute to null.</p></li>
+          <li><p>Set the <code><a href="#dom-sessionkeysystem">keySystem</a></code> attribute to the value of the <code><a href="#dom-mediakeys">MediaKeys</a></code> object's <code><a href="#dom-keysystem">keySystem</a></code> attribute.</p></li>
+          <li><p>Set the <code><a href="#dom-sessionid">sessionId</a></code> attribute to the empty string.</p></li>
+          <li><p>Let the state be <code><a href="#dom-statecreated">CREATED</a></code>.</p></li>
         </ol>
       </li>
-      
       <li>
-<p>Schedule a task to initialize the session, providing <var title="true">sessionId</var> and the new object.</p>
+<p>Schedule a task to load the session, providing <var title="true">session</var> and <var title="true">sessionId</var>.</p>
         <p>The user agent will asynchronously execute the following steps in the task:</p>
         <ol>
           <li><p>Wait for the <a href="#dom-mediakeys-constructor"><code>MediaKeys</code> constructor</a> task to complete.</p></li>
           <li>
 <p>If error information is stored with the <code><a href="#dom-mediakeys">MediaKeys</a></code> object because of an error during the <a href="#dom-mediakeys-constructor"><code>MediaKeys</code> constructor</a> task:</p>
             <ol>
-              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object, providing the <a href="#mediakeyerror-names">error name</a> and system code that were stored with the <code><a href="#dom-mediakeys">MediaKeys</a></code> object.</p></li>
+              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <var title="true">session</var>, providing the <a href="#mediakeyerror-names">error name</a> and system code that were stored with the <code><a href="#dom-mediakeys">MediaKeys</a></code> object.</p></li>
               <li><p>Clear the error information stored with the <code><a href="#dom-mediakeys">MediaKeys</a></code> object.</p></li>
               <li><p>Abort these steps</p></li>
             </ol>
@@ -510,17 +511,17 @@
               <li>
 <p>If a message exchange <span class="non-normative">(e.g. a license request)</span> is required:</p>
                 <ol>
-                  <li><p>Let <var title="true">request</var> be a request generated by the <a href="#cdm">CDM</a> using <var title="true">sessionId</var>.</p></li>
-                  <li><p>If the stored data for <var title="true">sessionId</var> indicates a destination URL relevant to <var title="true">keySystem</var>, let <var title="true">destination URL</var> be that URL.</p></li>
+                  <li><p>Let <var title="true">request</var> be a request generated by the <a href="#cdm">CDM</a> using the <var title="true">sessionId</var>.</p></li>
+                  <li><p>If the stored data for the <var title="true">sessionId</var> indicates a destination URL relevant to <var title="true">keySystem</var>, let <var title="true">destination URL</var> be that URL.</p></li>
                 </ol>
               </li>
             </ol>
           </li>
-          <li><p>Set the <code><a href="#dom-sessionid">sessionId</a></code> attribute to <var title="true">sessionId</var></p></li>
+          <li><p>Set the <var title="true">session</var>'s <code><a href="#dom-sessionid">sessionId</a></code> attribute to <var title="true">sessionId</var></p></li>
           <li>
 <p>If any of the preceding steps in the task failed, run the following steps:</p>
             <ol>
-              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object, providing the appropriate <a href="#mediakeyerror-names">error name</a> and system code value, if provided, and 0 otherwise.</p></li>
+              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <var title="true">session</var>, providing the appropriate <a href="#mediakeyerror-names">error name</a> and system code value, if provided, and 0 otherwise.</p></li>
               <li><p>Abort the task</p></li>
             </ol>
           </li>
@@ -534,15 +535,13 @@
             <dl class="switch">
               <dt>If <var title="true">request</var> is not null</dt>
               <dd>
-                <p>Run the <a href="#algorithms-queue-message">Queue a "message" Event</a> algorithm on the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object, providing <var title="true">request</var> and <var title="true">destination URL</var>.</p>
+                <p>Run the <a href="#algorithms-queue-message">Queue a "message" Event</a> algorithm on the <var title="true">session</var>, providing <var title="true">request</var> and <var title="true">destination URL</var>.</p>
               </dd>
               <dt>Otherwise</dt>
               <dd>
                 <ol>
-                  <li><p>Let the state of the session be <code><a href="#dom-stateready">READY</a></code>.</p></li>
-                  <li>
-                    <p><a href="http://www.w3.org/TR/html5/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://www.w3.org/TR/html5/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-eventready">ready</a></code> at the new object.</p>
-                  </li>
+                  <li><p>Let the state of the <var title="true">session</var> be <code><a href="#dom-stateready">READY</a></code>.</p></li>
+                  <li><p><a href="http://www.w3.org/TR/html5/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://www.w3.org/TR/html5/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-eventready">ready</a></code> at the <var title="true">session</var>.</p></li>
                 </ol>
               </dd>
             </dl>
@@ -616,7 +615,7 @@
           <li>
 <p>If any of the preceding steps in the task failed, run the following steps:</p>
             <ol>
-              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object, providing the appropriate <a href="#mediakeyerror-names">error name</a> and system code value, if provided, and 0 otherwise.</p></li>
+              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on this object, providing the appropriate <a href="#mediakeyerror-names">error name</a> and system code value, if provided, and 0 otherwise.</p></li>
               <li><p>Abort the task</p></li>
             </ol>
           </li>
@@ -630,13 +629,13 @@
             <dl class="switch">
               <dt>If <var title="true">request</var> is not null</dt>
               <dd>
-                <p>Run the <a href="#algorithms-queue-message">Queue a "message" Event</a> algorithm on the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object, providing <var title="true">request</var> and null.</p>
+                <p>Run the <a href="#algorithms-queue-message">Queue a "message" Event</a> algorithm on this object, providing <var title="true">request</var> and null.</p>
               </dd>
               <dt>Otherwise</dt>
               <dd>
                 <ol>
-                  <li><p>Let the state of the session be <code><a href="#dom-stateready">READY</a></code>.</p></li>
-                  <li><p><a href="http://www.w3.org/TR/html5/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://www.w3.org/TR/html5/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-eventready">ready</a></code> at the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object.</p></li>
+                  <li><p>Let the state of this object be <code><a href="#dom-stateready">READY</a></code>.</p></li>
+                  <li><p><a href="http://www.w3.org/TR/html5/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://www.w3.org/TR/html5/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-eventready">ready</a></code> at this object.</p></li>
                 </ol>
               </dd>
             </dl>
@@ -645,11 +644,11 @@
       </li>
     </ol>
 
-    <p>The <dfn id="dom-release"><code>release()</code></dfn> method allows an application to indicate to the system that it may release any resources associated with the <code><a href="#dom-mediakeysession">MediaKeySession</a></code>. It must run the following steps:</p>
+    <p>The <dfn id="dom-release"><code>release()</code></dfn> method allows an application to indicate to the system that it may release any resources associated with this object. It must run the following steps:</p>
 
     <ol>
-      <li><p>If the state of the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> is <code><a href="#dom-stateclosed">CLOSED</a></code> then abort these steps.</p></li>
-      <li><p>If the state of the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> is <code><a href="#dom-stateerror">ERROR</a></code>, throw an <code><a href="http://www.w3.org/TR/dom/#dom-domexception-invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these steps.</p></li>
+      <li><p>If the state of this object is <code><a href="#dom-stateclosed">CLOSED</a></code> then abort these steps.</p></li>
+      <li><p>If the state of this object is <code><a href="#dom-stateerror">ERROR</a></code>, throw an <code><a href="http://www.w3.org/TR/dom/#dom-domexception-invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these steps.</p></li>
       <li>
 <p>Schedule a task to handle the call.</p>
         <p>The user agent will asynchronously execute the following steps in the task:</p>
@@ -660,10 +659,10 @@
             <ol>
               <li>
                 <p>Process the release request.</p>
-                <p class="non-normative">Note: the release() method is intended to act as a hint to the user agent that the application believes the MediaKeySession is no longer needed.
+                <p class="non-normative">Note: the release() method is intended to act as a hint to the user agent that the application believes the session is no longer needed.
                 However, the CDM determines whether resources can now be released.</p>
               </li>
-              <li><p>If the previous step caused the session to be closed, run the <a href="#algorithms-session-close">Session Close</a> algorithm for the <code><a href="#dom-mediakeysession">MediaKeySession</a></code>.</p></li>
+              <li><p>If the previous step caused the session to be closed, run the <a href="#algorithms-session-close">Session Close</a> algorithm on this object.</p></li>
             </ol>
           </li>
         </ol>
--- a/encrypted-media/encrypted-media.xml	Mon Mar 24 15:05:35 2014 -0700
+++ b/encrypted-media/encrypted-media.xml	Mon Mar 24 15:09:19 2014 -0700
@@ -353,7 +353,7 @@
       <li><p>If <var title="true">keySystem</var> is not one of the user agent's supported <a href="#key-system">Key Systems</a>, throw a <not-supported-err/> and abort these steps. Key system string comparison is case-sensitive.</p></li>
       <li>Create a new <coderef>MediaKeys</coderef> object.
         <ol>
-          <li><p>Let the <coderef>keySystem</coderef> attribute be <var title="true">keySystem</var>.</p></li>
+          <li><p>Set the <coderef>keySystem</coderef> attribute to <var title="true">keySystem</var>.</p></li>
         </ol>
       </li>
 
@@ -389,21 +389,21 @@
       <li><p>If <var title="true">contentType</var> contains an invalid or unrecognized MIME type, throw a <not-supported-err/> exception and abort these steps.</p></li>
       <li><p>Let <var title="true">initDataFormat</var> be the container type specified by <var title="true">contentType</var>.</p></li>
       <li><p>If the <a href="#cdm">content decryption module</a> corresponding to the <coderef>keySystem</coderef> attribute does not support the <a href="#initialization-data">Initialization Data</a> format <var title="true">initDataFormat</var>, throw a <not-supported-err/> exception and abort these steps.</p></li>
-
-      <li>Create a new <coderef>MediaKeySession</coderef> object.
+      <li>Let <var title="true">session</var> be a new <coderef>MediaKeySession</coderef> object, and initialize it as follows:
         <ol>
-          <li><p>Let the <coderef prefix="session">keySystem</coderef> attribute of the new object be <coderef>keySystem</coderef>.</p></li>
-          <li><p>Let the state of the new object be <coderef prefix="state">CREATED</coderef>.</p></li>
+          <li><p>Set the <coderef>error</coderef> attribute to null.</p></li>
+          <li><p>Set the <coderef prefix="session">keySystem</coderef> attribute to the value of the <coderef>MediaKeys</coderef> object's <coderef>keySystem</coderef> attribute.</p></li>
+          <li><p>Set the <coderef>sessionId</coderef> attribute to the empty string.</p></li>
+          <li><p>Let the state be <coderef prefix="state">CREATED</coderef>.</p></li>
         </ol>
       </li>
-      
-      <li><p>Schedule a task to initialize the session, providing <var title="true">initDataFormat</var>, <var title="true">initData</var>, and the new object.</p>
+      <li><p>Schedule a task to process the <var title="true">initData</var>, providing <var title="true">session</var>, <var title="true">initDataFormat</var>, and <var title="true">initData</var>.</p>
         <p>The user agent will asynchronously execute the following steps in the task:</p>
         <ol>
           <li><p>Wait for the <a href="#dom-mediakeys-constructor"><code>MediaKeys</code> constructor</a> task to complete.</p></li>
           <li><p>If error information is stored with the <coderef>MediaKeys</coderef> object because of an error during the <a href="#dom-mediakeys-constructor"><code>MediaKeys</code> constructor</a> task:</p>
             <ol>
-              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <coderef>MediaKeySession</coderef> object, providing the <a href="#mediakeyerror-names">error name</a> and system code that were stored with the <coderef>MediaKeys</coderef> object.</p></li>
+              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <var title="true">session</var>, providing the <a href="#mediakeyerror-names">error name</a> and system code that were stored with the <coderef>MediaKeys</coderef> object.</p></li>
               <li><p>Clear the error information stored with the <coderef>MediaKeys</coderef> object.</p></li>
               <li><p>Abort the task</p></li>
             </ol>
@@ -413,22 +413,22 @@
           <li><p>Let <var title="true">cdm</var> be the <var title="true">cdm</var> loaded in the <a href="#dom-mediakeys-constructor"><code>MediaKeys</code> constructor</a>.</p></li>
           <li><p>Use <var title="true">cdm</var> to execute the following steps:</p>
             <ol>
-              <li><p>Process <var title="true">initData</var>, interpreting it per <var title="true">initDataFormat</var>.</p></li>
+              <li><p>Process the <var title="true">initData</var>, interpreting it per <var title="true">initDataFormat</var>.</p></li>
               <li><p>If a message exchange <span class="non-normative">(e.g. a license request)</span> is required:</p>
                 <ol>
-                  <li><p>Let <var title="true">request</var> be a request generated by the <a href="#cdm">CDM</a> using <var title="true">initData</var>.</p>
-                    <p><var title="true">cdm</var> must not use any stream-specific data, including <videoanchor name="media-data">media data</videoanchor>, not provided via <var title="true">initData</var>.</p>
-                    <p class="non-normative">Note: <var title="true">request</var> may be a request for multiple keys, depending on the <var title="true"><a href="#key-system">keySystem</a></var> and/or <var title="true">initData</var>. This is transparent to the application.</p>                
+                  <li><p>Let <var title="true">request</var> be a request generated by the <a href="#cdm">CDM</a> using the <var title="true">initData</var>.</p>
+                    <p><var title="true">cdm</var> must not use any stream-specific data, including <videoanchor name="media-data">media data</videoanchor>, not provided via the <var title="true">initData</var>.</p>
+                    <p class="non-normative">Note: <var title="true">request</var> may be a request for multiple keys, depending on the <var title="true"><a href="#key-system">keySystem</a></var> and/or the <var title="true">initData</var>. This is transparent to the application.</p>                
                   </li>
-                  <li><p>If <var title="true">initData</var> indicates a default URL relevant to <var title="true">keySystem</var>, let <var title="true">default URL</var> be that URL.</p></li>
+                  <li><p>If the <var title="true">initData</var> indicates a default URL relevant to <var title="true">keySystem</var>, let <var title="true">default URL</var> be that URL.</p></li>
                 </ol>
               </li>
             </ol>
           </li>
-          <li><p>Let the <coderef>sessionId</coderef> attribute be a unique <a href="#session-id">Session ID</a> string. <span class="non-normative">It may be obtained from <var title="true">cdm</var>.</span></p></li>
+          <li><p>Set the <var title="true">session</var>'s <coderef>sessionId</coderef> attribute to a unique <a href="#session-id">Session ID</a> string. <span class="non-normative">It may be obtained from <var title="true">cdm</var>.</span></p></li>
           <li><p>If any of the preceding steps in the task failed, run the following steps:</p>
             <ol>
-              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <coderef>MediaKeySession</coderef> object, providing the appropriate <a href="#mediakeyerror-names">error name</a> and system code value, if provided, and 0 otherwise.</p></li>
+              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <var title="true">session</var>, providing the appropriate <a href="#mediakeyerror-names">error name</a> and system code value, if provided, and 0 otherwise.</p></li>
               <li><p>Abort the task</p></li>
             </ol>
           </li>
@@ -441,14 +441,14 @@
             <dl class="switch">
               <dt>If <var title="true">request</var> is not null</dt>
               <dd>
-                <p>Run the <a href="#algorithms-queue-message">Queue a "message" Event</a> algorithm on the <coderef>MediaKeySession</coderef> object, providing <var title="true">request</var> and <var title="true">default URL</var>.</p>
+                <p>Run the <a href="#algorithms-queue-message">Queue a "message" Event</a> algorithm on the <var title="true">session</var>, providing <var title="true">request</var> and <var title="true">default URL</var>.</p>
               </dd>
               <dt>Otherwise</dt>
               <dd>
                 <ol>
-                  <li><p>Let the state of the session be <coderef prefix="state">READY</coderef>.</p></li>
+                  <li><p>Let the state of the <var title="true">session</var> be <coderef prefix="state">READY</coderef>.</p></li>
                   <li>
-                    <p><Queue-a-task/> to <fire-a-simple-event/> named <coderef prefix="event">ready</coderef> at the new object.</p>
+                    <p><Queue-a-task/> to <fire-a-simple-event/> named <coderef prefix="event">ready</coderef> at the <var title="true">session</var>.</p>
                     <p class="non-normative">Note: this step makes it possible for a MediaKeySession to transition from the CREATED state to the READY state.
                     User agents might do this as an optimization but, even if this is done, all MediaKeySession instances must appear distinct regardless of the underlying implementation.</p>
                   </li>
@@ -469,20 +469,21 @@
     <ol>
       <li><p>If the <a href="#cdm">content decryption module</a> corresponding to the <coderef>keySystem</coderef> attribute does not support loading previous sessions, throw a <not-supported-err/> exception and abort these steps.</p></li>
       <li><p>If <var title="true">sessionId</var> is null or an empty string, throw an <invalid-access-err/> exception and abort these steps.</p></li>
-      <li>Create a new <coderef>MediaKeySession</coderef> object.
+      <li>Let <var title="true">session</var> be a new <coderef>MediaKeySession</coderef> object, and initialize it as follows:
         <ol>
-          <li><p>Let the <coderef prefix="session">keySystem</coderef> attribute of the new object be <coderef>keySystem</coderef>.</p></li>
-          <li><p>Let the state of the new object be <coderef prefix="state">CREATED</coderef>.</p></li>
+          <li><p>Set the <coderef>error</coderef> attribute to null.</p></li>
+          <li><p>Set the <coderef prefix="session">keySystem</coderef> attribute to the value of the <coderef>MediaKeys</coderef> object's <coderef>keySystem</coderef> attribute.</p></li>
+          <li><p>Set the <coderef>sessionId</coderef> attribute to the empty string.</p></li>
+          <li><p>Let the state be <coderef prefix="state">CREATED</coderef>.</p></li>
         </ol>
       </li>
-      
-      <li><p>Schedule a task to initialize the session, providing <var title="true">sessionId</var> and the new object.</p>
+      <li><p>Schedule a task to load the session, providing <var title="true">session</var> and <var title="true">sessionId</var>.</p>
         <p>The user agent will asynchronously execute the following steps in the task:</p>
         <ol>
           <li><p>Wait for the <a href="#dom-mediakeys-constructor"><code>MediaKeys</code> constructor</a> task to complete.</p></li>
           <li><p>If error information is stored with the <coderef>MediaKeys</coderef> object because of an error during the <a href="#dom-mediakeys-constructor"><code>MediaKeys</code> constructor</a> task:</p>
             <ol>
-              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <coderef>MediaKeySession</coderef> object, providing the <a href="#mediakeyerror-names">error name</a> and system code that were stored with the <coderef>MediaKeys</coderef> object.</p></li>
+              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <var title="true">session</var>, providing the <a href="#mediakeyerror-names">error name</a> and system code that were stored with the <coderef>MediaKeys</coderef> object.</p></li>
               <li><p>Clear the error information stored with the <coderef>MediaKeys</coderef> object.</p></li>
               <li><p>Abort these steps</p></li>
             </ol>
@@ -495,16 +496,16 @@
               <li><p>Initialize the session with stored data for the <var title="true">sessionId</var>.</p></li>
               <li><p>If a message exchange <span class="non-normative">(e.g. a license request)</span> is required:</p>
                 <ol>
-                  <li><p>Let <var title="true">request</var> be a request generated by the <a href="#cdm">CDM</a> using <var title="true">sessionId</var>.</p></li>
-                  <li><p>If the stored data for <var title="true">sessionId</var> indicates a destination URL relevant to <var title="true">keySystem</var>, let <var title="true">destination URL</var> be that URL.</p></li>
+                  <li><p>Let <var title="true">request</var> be a request generated by the <a href="#cdm">CDM</a> using the <var title="true">sessionId</var>.</p></li>
+                  <li><p>If the stored data for the <var title="true">sessionId</var> indicates a destination URL relevant to <var title="true">keySystem</var>, let <var title="true">destination URL</var> be that URL.</p></li>
                 </ol>
               </li>
             </ol>
           </li>
-          <li><p>Set the <coderef>sessionId</coderef> attribute to <var title="true">sessionId</var></p></li>
+          <li><p>Set the <var title="true">session</var>'s <coderef>sessionId</coderef> attribute to <var title="true">sessionId</var></p></li>
           <li><p>If any of the preceding steps in the task failed, run the following steps:</p>
             <ol>
-              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <coderef>MediaKeySession</coderef> object, providing the appropriate <a href="#mediakeyerror-names">error name</a> and system code value, if provided, and 0 otherwise.</p></li>
+              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <var title="true">session</var>, providing the appropriate <a href="#mediakeyerror-names">error name</a> and system code value, if provided, and 0 otherwise.</p></li>
               <li><p>Abort the task</p></li>
             </ol>
           </li>
@@ -517,15 +518,13 @@
             <dl class="switch">
               <dt>If <var title="true">request</var> is not null</dt>
               <dd>
-                <p>Run the <a href="#algorithms-queue-message">Queue a "message" Event</a> algorithm on the <coderef>MediaKeySession</coderef> object, providing <var title="true">request</var> and <var title="true">destination URL</var>.</p>
+                <p>Run the <a href="#algorithms-queue-message">Queue a "message" Event</a> algorithm on the <var title="true">session</var>, providing <var title="true">request</var> and <var title="true">destination URL</var>.</p>
               </dd>
               <dt>Otherwise</dt>
               <dd>
                 <ol>
-                  <li><p>Let the state of the session be <coderef prefix="state">READY</coderef>.</p></li>
-                  <li>
-                    <p><Queue-a-task/> to <fire-a-simple-event/> named <coderef prefix="event">ready</coderef> at the new object.</p>
-                  </li>
+                  <li><p>Let the state of the <var title="true">session</var> be <coderef prefix="state">READY</coderef>.</p></li>
+                  <li><p><Queue-a-task/> to <fire-a-simple-event/> named <coderef prefix="event">ready</coderef> at the <var title="true">session</var>.</p></li>
                 </ol>
               </dd>
             </dl>
@@ -595,7 +594,7 @@
           </li>
           <li><p>If any of the preceding steps in the task failed, run the following steps:</p>
             <ol>
-              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on the <coderef>MediaKeySession</coderef> object, providing the appropriate <a href="#mediakeyerror-names">error name</a> and system code value, if provided, and 0 otherwise.</p></li>
+              <li><p>Run the <a href="#algorithms-queue-error">Queue an "error" Event</a> algorithm on this object, providing the appropriate <a href="#mediakeyerror-names">error name</a> and system code value, if provided, and 0 otherwise.</p></li>
               <li><p>Abort the task</p></li>
             </ol>
           </li>
@@ -608,13 +607,13 @@
             <dl class="switch">
               <dt>If <var title="true">request</var> is not null</dt>
               <dd>
-                <p>Run the <a href="#algorithms-queue-message">Queue a "message" Event</a> algorithm on the <coderef>MediaKeySession</coderef> object, providing <var title="true">request</var> and null.</p>
+                <p>Run the <a href="#algorithms-queue-message">Queue a "message" Event</a> algorithm on this object, providing <var title="true">request</var> and null.</p>
               </dd>
               <dt>Otherwise</dt>
               <dd>
                 <ol>
-                  <li><p>Let the state of the session be <coderef prefix="state">READY</coderef>.</p></li>
-                  <li><p><Queue-a-task/> to <fire-a-simple-event/> named <coderef prefix="event">ready</coderef> at the <coderef>MediaKeySession</coderef> object.</p></li>
+                  <li><p>Let the state of this object be <coderef prefix="state">READY</coderef>.</p></li>
+                  <li><p><Queue-a-task/> to <fire-a-simple-event/> named <coderef prefix="event">ready</coderef> at this object.</p></li>
                 </ol>
               </dd>
             </dl>
@@ -623,11 +622,11 @@
       </li>
     </ol>
 
-    <p>The <methoddfn name="release">release()</methoddfn> method allows an application to indicate to the system that it may release any resources associated with the <coderef>MediaKeySession</coderef>. It must run the following steps:</p>
+    <p>The <methoddfn name="release">release()</methoddfn> method allows an application to indicate to the system that it may release any resources associated with this object. It must run the following steps:</p>
 
     <ol>
-      <li><p>If the state of the <coderef>MediaKeySession</coderef> is <coderef prefix="state">CLOSED</coderef> then abort these steps.</p></li>
-      <li><p>If the state of the <coderef>MediaKeySession</coderef> is <coderef prefix="state">ERROR</coderef>, throw an <invalid-state-err/> exception and abort these steps.</p></li>
+      <li><p>If the state of this object is <coderef prefix="state">CLOSED</coderef> then abort these steps.</p></li>
+      <li><p>If the state of this object is <coderef prefix="state">ERROR</coderef>, throw an <invalid-state-err/> exception and abort these steps.</p></li>
       <li><p>Schedule a task to handle the call.</p>
         <p>The user agent will asynchronously execute the following steps in the task:</p>
         <ol>
@@ -636,10 +635,10 @@
             <ol>
               <li>
                 <p>Process the release request.</p>
-                <p class="non-normative">Note: the release() method is intended to act as a hint to the user agent that the application believes the MediaKeySession is no longer needed.
+                <p class="non-normative">Note: the release() method is intended to act as a hint to the user agent that the application believes the session is no longer needed.
                 However, the CDM determines whether resources can now be released.</p>
               </li>
-              <li><p>If the previous step caused the session to be closed, run the <a href="#algorithms-session-close">Session Close</a> algorithm for the <coderef>MediaKeySession</coderef>.</p></li>
+              <li><p>If the previous step caused the session to be closed, run the <a href="#algorithms-session-close">Session Close</a> algorithm on this object.</p></li>
             </ol>
           </li>
         </ol>