[EME] Examples: Save keySession as a custom property on the XHR object.
authorDavid Dorwin <ddorwin@google.com>
Mon, 28 Apr 2014 14:29:39 -0700
changeset 293 6a85b27906f5
parent 292 dcd1e4007d08
child 294 782a76af27a4
[EME] Examples: Save keySession as a custom property on the XHR object.
encrypted-media/encrypted-media.html
encrypted-media/encrypted-media.xml
--- a/encrypted-media/encrypted-media.html	Mon Apr 28 14:12:51 2014 -0700
+++ b/encrypted-media/encrypted-media.html	Mon Apr 28 14:29:39 2014 -0700
@@ -1480,15 +1480,15 @@
   }
 
   function licenseRequestReady(event) {
-    var keySession = event.target;
     var request = event.<a href="#dom-message">message</a>;
 
     var xmlhttp = new XMLHttpRequest();
+    xmlhttp.keySession = event.target;
     xmlhttp.open("POST", licenseUrl);
     xmlhttp.onreadystatechange = function() {
       if (xmlhttp.readyState == 4) {
         var license = new Uint8Array(xmlhttp.response);
-        keySession.<a href="#dom-update">update</a>(license).catch(
+        xmlhttp.keySession.<a href="#dom-update">update</a>(license).catch(
           console.error.bind(console, "update() failed")
         );
       }
@@ -1585,10 +1585,11 @@
 
   function sendMessage(message, keySession) {
     xmlhttp = new XMLHttpRequest();
+    xmlhttp.keySession = keySession;
     xmlhttp.open("POST", licenseUrl);
     xmlhttp.onreadystatechange = function() {
       if (xmlhttp.readyState == 4)
-        handleMessageResponse(keySession, xmlhttp.response);
+        handleMessageResponse(xmlhttp.keySession, xmlhttp.response);
     }
     xmlhttp.send(message);
   }
--- a/encrypted-media/encrypted-media.xml	Mon Apr 28 14:12:51 2014 -0700
+++ b/encrypted-media/encrypted-media.xml	Mon Apr 28 14:29:39 2014 -0700
@@ -1411,15 +1411,15 @@
   }
 
   function licenseRequestReady(event) {
-    var keySession = event.target;
     var request = event.<precoderef>message</precoderef>;
 
     var xmlhttp = new XMLHttpRequest();
+    xmlhttp.keySession = event.target;
     xmlhttp.open("POST", licenseUrl);
     xmlhttp.onreadystatechange = function() {
       if (xmlhttp.readyState == 4) {
         var license = new Uint8Array(xmlhttp.response);
-        keySession.<premethodref>update</premethodref>(license).catch(
+        xmlhttp.keySession.<premethodref>update</premethodref>(license).catch(
           console.error.bind(console, "update() failed")
         );
       }
@@ -1516,10 +1516,11 @@
 
   function sendMessage(message, keySession) {
     xmlhttp = new XMLHttpRequest();
+    xmlhttp.keySession = keySession;
     xmlhttp.open("POST", licenseUrl);
     xmlhttp.onreadystatechange = function() {
       if (xmlhttp.readyState == 4)
-        handleMessageResponse(keySession, xmlhttp.response);
+        handleMessageResponse(xmlhttp.keySession, xmlhttp.response);
     }
     xmlhttp.send(message);
   }