| Index: Source/modules/encryptedmedia/MediaKeys.cpp
|
| diff --git a/Source/modules/encryptedmedia/MediaKeys.cpp b/Source/modules/encryptedmedia/MediaKeys.cpp
|
| index 1a0774756a57e6cc56266a3c8c750ee7ba656ae4..76e36180524786798fe7668be6c86578aecbc05b 100644
|
| --- a/Source/modules/encryptedmedia/MediaKeys.cpp
|
| +++ b/Source/modules/encryptedmedia/MediaKeys.cpp
|
| @@ -26,24 +26,18 @@
|
| #include "config.h"
|
| #include "modules/encryptedmedia/MediaKeys.h"
|
|
|
| -#include "bindings/core/v8/ScriptPromiseResolver.h"
|
| #include "bindings/core/v8/ScriptState.h"
|
| #include "core/dom/DOMArrayBuffer.h"
|
| #include "core/dom/DOMArrayBufferView.h"
|
| #include "core/dom/DOMException.h"
|
| -#include "core/dom/Document.h"
|
| #include "core/dom/ExceptionCode.h"
|
| #include "core/dom/ExecutionContext.h"
|
| -#include "modules/encryptedmedia/MediaKeyMessageEvent.h"
|
| #include "modules/encryptedmedia/MediaKeySession.h"
|
| -#include "modules/encryptedmedia/MediaKeysController.h"
|
| #include "modules/encryptedmedia/SimpleContentDecryptionModuleResult.h"
|
| #include "platform/ContentType.h"
|
| #include "platform/Logging.h"
|
| #include "platform/MIMETypeRegistry.h"
|
| #include "platform/Timer.h"
|
| -#include "platform/UUID.h"
|
| -#include "public/platform/Platform.h"
|
| #include "public/platform/WebContentDecryptionModule.h"
|
| #include "wtf/RefPtr.h"
|
|
|
| @@ -58,11 +52,6 @@ static bool isKeySystemSupportedWithContentType(const String& keySystem, const S
|
| return MIMETypeRegistry::isSupportedEncryptedMediaMIMEType(keySystem, type.type(), codecs);
|
| }
|
|
|
| -static ScriptPromise createRejectedPromise(ScriptState* scriptState, ExceptionCode error, const String& errorMessage)
|
| -{
|
| - return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(error, errorMessage));
|
| -}
|
| -
|
| // A class holding a pending action.
|
| class MediaKeys::PendingAction : public GarbageCollectedFinalized<MediaKeys::PendingAction> {
|
| public:
|
| @@ -103,107 +92,6 @@ private:
|
| const RefPtr<ArrayBuffer> m_data;
|
| };
|
|
|
| -// This class allows a MediaKeys object to be created asynchronously.
|
| -class MediaKeysInitializer : public ScriptPromiseResolver {
|
| - WTF_MAKE_NONCOPYABLE(MediaKeysInitializer);
|
| -
|
| -public:
|
| - static ScriptPromise create(ScriptState*, const String& keySystem);
|
| - virtual ~MediaKeysInitializer();
|
| -
|
| -private:
|
| - MediaKeysInitializer(ScriptState*, const String& keySystem);
|
| - void timerFired(Timer<MediaKeysInitializer>*);
|
| -
|
| - const String m_keySystem;
|
| - Timer<MediaKeysInitializer> m_timer;
|
| -};
|
| -
|
| -ScriptPromise MediaKeysInitializer::create(ScriptState* scriptState, const String& keySystem)
|
| -{
|
| - RefPtr<MediaKeysInitializer> initializer = adoptRef(new MediaKeysInitializer(scriptState, keySystem));
|
| - initializer->suspendIfNeeded();
|
| - initializer->keepAliveWhilePending();
|
| - return initializer->promise();
|
| -}
|
| -
|
| -MediaKeysInitializer::MediaKeysInitializer(ScriptState* scriptState, const String& keySystem)
|
| - : ScriptPromiseResolver(scriptState)
|
| - , m_keySystem(keySystem)
|
| - , m_timer(this, &MediaKeysInitializer::timerFired)
|
| -{
|
| - WTF_LOG(Media, "MediaKeysInitializer::MediaKeysInitializer");
|
| - // Start the timer so that MediaKeys can be created asynchronously.
|
| - m_timer.startOneShot(0, FROM_HERE);
|
| -}
|
| -
|
| -MediaKeysInitializer::~MediaKeysInitializer()
|
| -{
|
| - WTF_LOG(Media, "MediaKeysInitializer::~MediaKeysInitializer");
|
| -}
|
| -
|
| -void MediaKeysInitializer::timerFired(Timer<MediaKeysInitializer>*)
|
| -{
|
| - WTF_LOG(Media, "MediaKeysInitializer::timerFired");
|
| -
|
| - // NOTE: Continued from step 4. of MediaKeys::create().
|
| - // 4.1 Let cdm be the content decryption module corresponding to
|
| - // keySystem.
|
| - // 4.2 Load and initialize the cdm if necessary.
|
| - Document* document = toDocument(executionContext());
|
| - MediaKeysController* controller = MediaKeysController::from(document->page());
|
| - // FIXME: make createContentDecryptionModule() asynchronous.
|
| - OwnPtr<WebContentDecryptionModule> cdm = controller->createContentDecryptionModule(executionContext(), m_keySystem);
|
| -
|
| - // 4.3 If cdm fails to load or initialize, reject promise with a new
|
| - // DOMException whose name is the appropriate error name and that
|
| - // has an appropriate message.
|
| - if (!cdm) {
|
| - String message("A content decryption module could not be loaded for the '" + m_keySystem + "' key system.");
|
| - reject(DOMException::create(UnknownError, message));
|
| - return;
|
| - }
|
| -
|
| - // 4.4 Let media keys be a new MediaKeys object.
|
| - MediaKeys* mediaKeys = new MediaKeys(executionContext(), m_keySystem, cdm.release());
|
| -
|
| - // 4.5. Resolve promise with media keys.
|
| - resolve(mediaKeys);
|
| -
|
| - // Note: As soon as the promise is resolved (or rejected), the
|
| - // ScriptPromiseResolver object (|this|) is freed. So access to
|
| - // any members will crash once the promise is fulfilled.
|
| -}
|
| -
|
| -ScriptPromise MediaKeys::create(ScriptState* scriptState, const String& keySystem)
|
| -{
|
| - WTF_LOG(Media, "MediaKeys::create(%s)", keySystem.ascii().data());
|
| -
|
| - // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html#dom-create:
|
| - // The create(keySystem) method creates a new MediaKeys object for keySystem. It must run the following steps:
|
| -
|
| - // 1. If keySystem is an empty string, return a promise rejected with a new
|
| - // DOMException whose name is "InvalidAccessError" and that has the message
|
| - // "The keySystem parameter is empty."
|
| - if (keySystem.isEmpty()) {
|
| - return createRejectedPromise(scriptState, InvalidAccessError, "The keySystem parameter is empty.");
|
| - }
|
| -
|
| - // 2. If keySystem is not one of the Key Systems supported by the user
|
| - // agent, return a promise rejected with a new DOMException whose name is
|
| - // "NotSupportedError" and that has the message "The key system keySystem
|
| - // is not supported." String comparison is case-sensitive.
|
| - if (!isKeySystemSupportedWithContentType(keySystem, "")) {
|
| - // String message("The key system '" + keySystem + "' is not supported.");
|
| - return createRejectedPromise(scriptState, NotSupportedError, "The key system '" + keySystem + "' is not supported.");
|
| - }
|
| -
|
| - // 3. Let promise be a new promise.
|
| - // 4. Asynchronously create and initialize the MediaKeys.
|
| - // 5. Return promise.
|
| - return MediaKeysInitializer::create(scriptState, keySystem);
|
| -}
|
| -
|
| MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, PassOwnPtr<WebContentDecryptionModule> cdm)
|
| : ContextLifecycleObserver(context)
|
| , m_keySystem(keySystem)
|
|
|