summaryrefslogtreecommitdiffstats
path: root/media/cdm
diff options
context:
space:
mode:
authorjrummell@chromium.org <jrummell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-11 04:28:12 +0000
committerjrummell@chromium.org <jrummell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-11 04:28:12 +0000
commit26ff5f02212c15fa96b95f826234e91cfe145222 (patch)
treea3b8eba526e7fec4a5cb2c4f72592043dac126f1 /media/cdm
parent24b78bb76caa05607ca32543f64797f0d23695ca (diff)
downloadchromium_src-26ff5f02212c15fa96b95f826234e91cfe145222.zip
chromium_src-26ff5f02212c15fa96b95f826234e91cfe145222.tar.gz
chromium_src-26ff5f02212c15fa96b95f826234e91cfe145222.tar.bz2
Clear Key CDM to generate close event when session is closed.
The current EME spec separates closing a session ("allows an application to indicate that it no longer needs the session") and the actual closing of the session (done by the CDM at any point "such as in response to a close() call, when the session is no longer needed, or when system resources are lost.") Update Clear Key to generate the close event when the session is closed, as Clear Key does not distinguish between the two. For unprefixed EME calls, promises are not yet implemented in blink, so this results in 2 close events, which isn't handled properly. The second close event will not be passed to blink until blink is updated to use promises. For prefixed EME calls, the second close event will always be ignored. BUG=224791 TEST=existing EME tests pass Review URL: https://codereview.chromium.org/322793005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276252 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/cdm')
-rw-r--r--media/cdm/aes_decryptor.cc8
-rw-r--r--media/cdm/aes_decryptor.h4
-rw-r--r--media/cdm/aes_decryptor_unittest.cc4
-rw-r--r--media/cdm/ppapi/external_clear_key/clear_key_cdm.cc7
-rw-r--r--media/cdm/ppapi/external_clear_key/clear_key_cdm.h1
5 files changed, 20 insertions, 4 deletions
diff --git a/media/cdm/aes_decryptor.cc b/media/cdm/aes_decryptor.cc
index 9416707..3530c3e 100644
--- a/media/cdm/aes_decryptor.cc
+++ b/media/cdm/aes_decryptor.cc
@@ -219,9 +219,12 @@ static scoped_refptr<DecoderBuffer> DecryptData(const DecoderBuffer& input,
return output;
}
-AesDecryptor::AesDecryptor(const SessionMessageCB& session_message_cb)
- : session_message_cb_(session_message_cb) {
+AesDecryptor::AesDecryptor(const SessionMessageCB& session_message_cb,
+ const SessionClosedCB& session_closed_cb)
+ : session_message_cb_(session_message_cb),
+ session_closed_cb_(session_closed_cb) {
DCHECK(!session_message_cb_.is_null());
+ DCHECK(!session_closed_cb_.is_null());
}
AesDecryptor::~AesDecryptor() {
@@ -327,6 +330,7 @@ void AesDecryptor::ReleaseSession(const std::string& web_session_id,
// Close the session.
DeleteKeysForSession(web_session_id);
promise->resolve();
+ session_closed_cb_.Run(web_session_id);
}
Decryptor* AesDecryptor::GetDecryptor() {
diff --git a/media/cdm/aes_decryptor.h b/media/cdm/aes_decryptor.h
index ab7c980..3a17770 100644
--- a/media/cdm/aes_decryptor.h
+++ b/media/cdm/aes_decryptor.h
@@ -27,7 +27,8 @@ namespace media {
// encryption must be CTR with a key size of 128bits.
class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor {
public:
- explicit AesDecryptor(const SessionMessageCB& session_message_cb);
+ AesDecryptor(const SessionMessageCB& session_message_cb,
+ const SessionClosedCB& session_closed_cb);
virtual ~AesDecryptor();
// MediaKeys implementation.
@@ -115,6 +116,7 @@ class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor {
// Callbacks for firing session events.
SessionMessageCB session_message_cb_;
+ SessionClosedCB session_closed_cb_;
// Since only Decrypt() is called off the renderer thread, we only need to
// protect |key_map_|, the only member variable that is shared between
diff --git a/media/cdm/aes_decryptor_unittest.cc b/media/cdm/aes_decryptor_unittest.cc
index 8452527..d2d7ee0 100644
--- a/media/cdm/aes_decryptor_unittest.cc
+++ b/media/cdm/aes_decryptor_unittest.cc
@@ -201,6 +201,8 @@ class AesDecryptorTest : public testing::Test {
public:
AesDecryptorTest()
: decryptor_(base::Bind(&AesDecryptorTest::OnSessionMessage,
+ base::Unretained(this)),
+ base::Bind(&AesDecryptorTest::OnSessionClosed,
base::Unretained(this))),
decrypt_cb_(base::Bind(&AesDecryptorTest::BufferDecrypted,
base::Unretained(this))),
@@ -273,6 +275,7 @@ class AesDecryptorTest : public testing::Test {
// Releases the session specified by |session_id|.
void ReleaseSession(const std::string& session_id) {
+ EXPECT_CALL(*this, OnSessionClosed(session_id));
decryptor_.ReleaseSession(session_id, CreatePromise(RESOLVED));
}
@@ -352,6 +355,7 @@ class AesDecryptorTest : public testing::Test {
void(const std::string& web_session_id,
const std::vector<uint8>& message,
const GURL& destination_url));
+ MOCK_METHOD1(OnSessionClosed, void(const std::string& web_session_id));
AesDecryptor decryptor_;
AesDecryptor::DecryptCB decrypt_cb_;
diff --git a/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc b/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
index b10111e..6f0809f 100644
--- a/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
+++ b/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
@@ -221,7 +221,8 @@ namespace media {
ClearKeyCdm::ClearKeyCdm(ClearKeyCdmHost* host, const std::string& key_system)
: decryptor_(
- base::Bind(&ClearKeyCdm::OnSessionMessage, base::Unretained(this))),
+ base::Bind(&ClearKeyCdm::OnSessionMessage, base::Unretained(this)),
+ base::Bind(&ClearKeyCdm::OnSessionClosed, base::Unretained(this))),
host_(host),
key_system_(key_system),
timer_delay_ms_(kInitialTimerDelayMs),
@@ -650,6 +651,10 @@ void ClearKeyCdm::OnSessionMessage(const std::string& web_session_id,
destination_url.spec().size());
}
+void ClearKeyCdm::OnSessionClosed(const std::string& web_session_id) {
+ host_->OnSessionClosed(web_session_id.data(), web_session_id.length());
+}
+
void ClearKeyCdm::OnSessionCreated(uint32 promise_id,
const std::string& web_session_id) {
// Save the latest session ID for heartbeat and file IO test messages.
diff --git a/media/cdm/ppapi/external_clear_key/clear_key_cdm.h b/media/cdm/ppapi/external_clear_key/clear_key_cdm.h
index e489c1b..5903642 100644
--- a/media/cdm/ppapi/external_clear_key/clear_key_cdm.h
+++ b/media/cdm/ppapi/external_clear_key/clear_key_cdm.h
@@ -86,6 +86,7 @@ class ClearKeyCdm : public ClearKeyCdmInterface {
void OnSessionMessage(const std::string& web_session_id,
const std::vector<uint8>& message,
const GURL& destination_url);
+ void OnSessionClosed(const std::string& web_session_id);
// Handle the success/failure of a promise. These methods are responsible for
// calling |host_| to resolve or reject the promise.