Reviewers: ddorwin
CL:
https://codereview.chromium.org/2108033002/Message:
PTAL.
Description:
EME: Clear Key CDM now generates keystatuseschange event on close()
EME spec requires a CDM to generate a keystatuseschange event when
close() is called (as any available keys for that session are now
gone). This updates the Clear Key CDM to generate the required event.
BUG=622956
TEST=updated EME tests passes
Base URL:
https://chromium.googlesource.com/chromium/src.git@masterAffected files (+30, -2 lines):
M media/cdm/aes_decryptor.cc
M third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-keystatuses.html
Index: media/cdm/aes_decryptor.cc
diff --git a/media/cdm/aes_decryptor.cc b/media/cdm/aes_decryptor.cc
index af7182f1097ab3fdbaeebe8180c97bb95d690802..f01fe8b10593645d130095d8ae55757083b7510d 100644
--- a/media/cdm/aes_decryptor.cc
+++ b/media/cdm/aes_decryptor.cc
@@ -411,6 +411,13 @@ void AesDecryptor::CloseSession(const std::string& session_id,
// Close the session.
DeleteKeysForSession(session_id);
promise->resolve();
+
+ // Update key statuses. All keys are gone, so it's an empty set.
+ session_keys_change_cb_.Run(session_id, false, CdmKeysInfo());
+
+ // Update expiration time to NaN. (
http://crbug.com/624192)
+
+ // Resolve the closed attribute.
session_closed_cb_.Run(session_id);
}
Index: third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-keystatuses.html
diff --git a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-keystatuses.html b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-keystatuses.html
index 3654f8c273b373c8a186a655646ba69ce48d7a07..91922bbe08e32e4de75a9b2f1f6b5383214fbad8 100644
--- a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-keystatuses.html
+++ b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-keystatuses.html
@@ -14,6 +14,7 @@
var mediaKeySession;
var initDataType;
var initData;
+ var closed = false;
// Even though key ids are uint8, using printable values so that
// they can be verified easily.
@@ -39,7 +40,7 @@
});
}
- function processKeyStatusesChange(event)
+ function checkKeyStatusFor2Keys()
{
// Two keys added, so both should show up in |keyStatuses|.
assert_equals(mediaKeySession.keyStatuses.size, 2);
@@ -124,8 +125,28 @@
invalid6.set(key1, 0); // Last element will be 0.
assert_false(mediaKeySession.keyStatuses.has(invalid6));
assert_equals(mediaKeySession.keyStatuses.get(invalid6), undefined);
+ }
- test.done();
+ function processKeyStatusesChange(event)
+ {
+ if ( !closed )
+ {
+ // The first keystatuseschange (caused by update())
+ // should include both keys.
+ checkKeyStatusFor2Keys();
+
+ mediaKeySession.close().catch(function(error) {
+ forceTestFailureFromPromise(test, error);
+ });
+ closed = true;
+ }
+ else
+ {
+ // The second keystatuseschange (caused by close())
+ // should not have any keys.
+ assert_equals(mediaKeySession.keyStatuses.size, 0);
+ test.done();
+ }
}
getSupportedInitDataType().then(function(type) {