Index: content/renderer/media/webcontentdecryptionmodulesession_impl.cc |
diff --git a/content/renderer/media/webcontentdecryptionmodulesession_impl.cc b/content/renderer/media/webcontentdecryptionmodulesession_impl.cc |
index f9f0b55eb812a992f87a8a14a077d19a3efba709..f872d99dec74766c58e128874efb9fb519e115d4 100644 |
--- a/content/renderer/media/webcontentdecryptionmodulesession_impl.cc |
+++ b/content/renderer/media/webcontentdecryptionmodulesession_impl.cc |
@@ -7,24 +7,25 @@ |
#include "base/callback_helpers.h" |
#include "base/logging.h" |
#include "base/strings/string_util.h" |
+#include "content/renderer/media/cdm_session_adapter.h" |
#include "third_party/WebKit/public/platform/WebURL.h" |
namespace content { |
WebContentDecryptionModuleSessionImpl::WebContentDecryptionModuleSessionImpl( |
uint32 session_id, |
- media::MediaKeys* media_keys, |
Client* client, |
- const SessionClosedCB& session_closed_cb) |
- : media_keys_(media_keys), |
+ scoped_refptr<CdmSessionAdapter> adapter) |
+ : adapter_(adapter), |
client_(client), |
- session_closed_cb_(session_closed_cb), |
- session_id_(session_id) { |
- DCHECK(media_keys_); |
+ session_id_(session_id), |
+ is_closed_(false) { |
} |
WebContentDecryptionModuleSessionImpl:: |
-~WebContentDecryptionModuleSessionImpl() { |
+ ~WebContentDecryptionModuleSessionImpl() { |
+ if (!is_closed_) |
+ adapter_->RemoveSession(session_id_); |
} |
blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const { |
@@ -42,18 +43,18 @@ void WebContentDecryptionModuleSessionImpl::initializeNewSession( |
return; |
} |
- media_keys_->CreateSession( |
+ adapter_->CreateSession( |
session_id_, UTF16ToASCII(mime_type), init_data, init_data_length); |
} |
void WebContentDecryptionModuleSessionImpl::update(const uint8* response, |
size_t response_length) { |
DCHECK(response); |
- media_keys_->UpdateSession(session_id_, response, response_length); |
+ adapter_->UpdateSession(session_id_, response, response_length); |
} |
void WebContentDecryptionModuleSessionImpl::release() { |
- media_keys_->ReleaseSession(session_id_); |
+ adapter_->ReleaseSession(session_id_); |
} |
void WebContentDecryptionModuleSessionImpl::OnSessionCreated( |
@@ -83,8 +84,10 @@ void WebContentDecryptionModuleSessionImpl::OnSessionReady() { |
void WebContentDecryptionModuleSessionImpl::OnSessionClosed() { |
client_->close(); |
- if (!session_closed_cb_.is_null()) |
- base::ResetAndReturn(&session_closed_cb_).Run(session_id_); |
+ |
+ // Now that the session is closed, no more events will come from the CDM. |
+ is_closed_ = true; |
+ adapter_->RemoveSession(session_id_); |
ddorwin
2014/02/19 01:41:53
Is there any advantage in de-registering the sessi
jrummell
2014/02/19 20:42:10
Not really. I just added it here in case the Blink
|
} |
void WebContentDecryptionModuleSessionImpl::OnSessionError( |