Index: Source/modules/encryptedmedia/MediaKeys.cpp |
diff --git a/Source/modules/encryptedmedia/MediaKeys.cpp b/Source/modules/encryptedmedia/MediaKeys.cpp |
index b2d320c7fdd76383a717a6fed3124afcdd53d6c5..3c3798016e67e342f629da52217d932482e3852e 100644 |
--- a/Source/modules/encryptedmedia/MediaKeys.cpp |
+++ b/Source/modules/encryptedmedia/MediaKeys.cpp |
@@ -30,7 +30,6 @@ |
#include "core/events/ThreadLocalEventNames.h" |
#include "core/html/HTMLMediaElement.h" |
#include "modules/encryptedmedia/MediaKeyMessageEvent.h" |
-#include "modules/encryptedmedia/MediaKeySession.h" |
#include "platform/UUID.h" |
#include "platform/drm/ContentDecryptionModule.h" |
#include "wtf/HashSet.h" |
@@ -72,6 +71,7 @@ MediaKeys::MediaKeys(const String& keySystem, PassOwnPtr<ContentDecryptionModule |
: m_mediaElement(0) |
, m_keySystem(keySystem) |
, m_cdm(cdm) |
+ , m_initializeNewSessionTimer(this, &MediaKeys::initializeNewSessionTimerFired) |
{ |
ScriptWrappable::init(this); |
} |
@@ -87,18 +87,14 @@ PassRefPtr<MediaKeySession> MediaKeys::createSession(ExecutionContext* context, |
// The createSession(type, initData) method must run the following steps: |
// Note: The contents of initData are container-specific Initialization Data. |
- // FIXME: Follow the latest spec to check |type| and |initData|. |
- // If type is null or an empty string and initData is not null or an empty string, throw an |
- // InvalidAccessError exception and abort these steps. |
- if ((type.isEmpty()) && (!initData || initData->length())) { |
- exceptionState.throwDOMException(InvalidAccessError, "The type provided is empty, but initData is not empty."); |
+ if (type.isEmpty() || !initData || !initData->length()) { |
+ exceptionState.throwDOMException(InvalidAccessError, "The type or initData provided is empty or null."); |
return 0; |
} |
// 1. If type contains a MIME type that is not supported or is not supported by the keySystem, |
// throw a NOT_SUPPORTED_ERR exception and abort these steps. |
- ASSERT(!type.isEmpty()); |
- if (type.isEmpty() || !m_cdm->supportsMIMEType(type)) { |
+ if (!m_cdm->supportsMIMEType(type)) { |
exceptionState.throwDOMException(NotSupportedError, "The type provided ('" + type + "') is unsupported."); |
return 0; |
} |
@@ -113,10 +109,8 @@ PassRefPtr<MediaKeySession> MediaKeys::createSession(ExecutionContext* context, |
m_sessions.append(session); |
// 4. Schedule a task to initialize the session, providing type, initData, and the new object. |
- // FIXME: The spec says "schedule a task". We should move the timer here. |
- // FIXME: |initData| may be 0. We need to add more check before we dereference it. |
- // Note that this may become obsolete when the FIXME on l.90 is fixed. |
- session->initializeNewSession(type, initData); |
+ m_pendingInitializeNewSessionData.append(InitializeNewSessionData(session, type, initData)); |
+ m_initializeNewSessionTimer.startOneShot(0); |
acolwell GONE FROM CHROMIUM
2014/01/13 18:35:37
Shouldn't this have a if (!m_initializeNewSessionT
xhwang
2014/01/13 19:06:03
Done. Good to learn! Thanks!
|
// 5. Return the new object to the caller. |
return session; |
@@ -135,4 +129,15 @@ blink::WebContentDecryptionModule* MediaKeys::contentDecryptionModule() |
return m_cdm ? m_cdm->contentDecryptionModule() : 0; |
} |
+void MediaKeys::initializeNewSessionTimerFired(Timer<MediaKeys>*) |
+{ |
+ ASSERT(m_pendingInitializeNewSessionData.size()); |
+ |
+ while (!m_pendingInitializeNewSessionData.isEmpty()) { |
+ InitializeNewSessionData data = m_pendingInitializeNewSessionData.takeFirst(); |
+ // FIXME: Refer to the spec to see what needs to be done in blink. |
+ data.session->initializeNewSession(data.mimeType, data.initData.get()); |
+ } |
+} |
+ |
} |