| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" | 5 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
| 11 #include "bindings/core/v8/V8ThrowException.h" | 11 #include "bindings/core/v8/V8ThrowException.h" |
| 12 #include "core/dom/DOMException.h" | 12 #include "core/dom/DOMException.h" |
| 13 #include "core/dom/DOMTypedArray.h" | 13 #include "core/dom/DOMTypedArray.h" |
| 14 #include "core/dom/ExceptionCode.h" | 14 #include "core/dom/ExceptionCode.h" |
| 15 #include "core/dom/TaskRunnerHelper.h" |
| 15 #include "core/html/HTMLMediaElement.h" | 16 #include "core/html/HTMLMediaElement.h" |
| 16 #include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h" | 17 #include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h" |
| 17 #include "modules/encryptedmedia/EncryptedMediaUtils.h" | 18 #include "modules/encryptedmedia/EncryptedMediaUtils.h" |
| 18 #include "modules/encryptedmedia/MediaEncryptedEvent.h" | 19 #include "modules/encryptedmedia/MediaEncryptedEvent.h" |
| 19 #include "modules/encryptedmedia/MediaKeys.h" | 20 #include "modules/encryptedmedia/MediaKeys.h" |
| 20 #include "platform/ContentDecryptionModuleResult.h" | 21 #include "platform/ContentDecryptionModuleResult.h" |
| 21 #include "wtf/Functional.h" | 22 #include "wtf/Functional.h" |
| 22 | 23 |
| 23 #define EME_LOG_LEVEL 3 | 24 #define EME_LOG_LEVEL 3 |
| 24 | 25 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 44 void finish(); | 45 void finish(); |
| 45 void fail(ExceptionCode, const String& errorMessage); | 46 void fail(ExceptionCode, const String& errorMessage); |
| 46 | 47 |
| 47 void clearFailed(ExceptionCode, const String& errorMessage); | 48 void clearFailed(ExceptionCode, const String& errorMessage); |
| 48 void setFailed(ExceptionCode, const String& errorMessage); | 49 void setFailed(ExceptionCode, const String& errorMessage); |
| 49 | 50 |
| 50 // Keep media element alive until promise is fulfilled | 51 // Keep media element alive until promise is fulfilled |
| 51 Member<HTMLMediaElement> m_element; | 52 Member<HTMLMediaElement> m_element; |
| 52 Member<MediaKeys> m_newMediaKeys; | 53 Member<MediaKeys> m_newMediaKeys; |
| 53 bool m_madeReservation; | 54 bool m_madeReservation; |
| 54 Timer<SetMediaKeysHandler> m_timer; | 55 TaskRunnerTimer<SetMediaKeysHandler> m_timer; |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 typedef Function<void()> SuccessCallback; | 58 typedef Function<void()> SuccessCallback; |
| 58 typedef Function<void(ExceptionCode, const String&)> FailureCallback; | 59 typedef Function<void(ExceptionCode, const String&)> FailureCallback; |
| 59 | 60 |
| 60 // Represents the result used when setContentDecryptionModule() is called. | 61 // Represents the result used when setContentDecryptionModule() is called. |
| 61 // Calls |success| if result is resolved, |failure| if result is rejected. | 62 // Calls |success| if result is resolved, |failure| if result is rejected. |
| 62 class SetContentDecryptionModuleResult final | 63 class SetContentDecryptionModuleResult final |
| 63 : public ContentDecryptionModuleResult { | 64 : public ContentDecryptionModuleResult { |
| 64 public: | 65 public: |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 return handler->promise(); | 117 return handler->promise(); |
| 117 } | 118 } |
| 118 | 119 |
| 119 SetMediaKeysHandler::SetMediaKeysHandler(ScriptState* scriptState, | 120 SetMediaKeysHandler::SetMediaKeysHandler(ScriptState* scriptState, |
| 120 HTMLMediaElement& element, | 121 HTMLMediaElement& element, |
| 121 MediaKeys* mediaKeys) | 122 MediaKeys* mediaKeys) |
| 122 : ScriptPromiseResolver(scriptState), | 123 : ScriptPromiseResolver(scriptState), |
| 123 m_element(element), | 124 m_element(element), |
| 124 m_newMediaKeys(mediaKeys), | 125 m_newMediaKeys(mediaKeys), |
| 125 m_madeReservation(false), | 126 m_madeReservation(false), |
| 126 m_timer(this, &SetMediaKeysHandler::timerFired) { | 127 m_timer(TaskRunnerHelper::get(TaskType::MiscPlatformAPI, scriptState), |
| 128 this, |
| 129 &SetMediaKeysHandler::timerFired) { |
| 127 DVLOG(EME_LOG_LEVEL) << __func__; | 130 DVLOG(EME_LOG_LEVEL) << __func__; |
| 128 | 131 |
| 129 // 5. Run the following steps in parallel. | 132 // 5. Run the following steps in parallel. |
| 130 m_timer.startOneShot(0, BLINK_FROM_HERE); | 133 m_timer.startOneShot(0, BLINK_FROM_HERE); |
| 131 } | 134 } |
| 132 | 135 |
| 133 SetMediaKeysHandler::~SetMediaKeysHandler() {} | 136 SetMediaKeysHandler::~SetMediaKeysHandler() {} |
| 134 | 137 |
| 135 void SetMediaKeysHandler::timerFired(TimerBase*) { | 138 void SetMediaKeysHandler::timerFired(TimerBase*) { |
| 136 clearExistingMediaKeys(); | 139 clearExistingMediaKeys(); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 return m_mediaKeys ? m_mediaKeys->contentDecryptionModule() : 0; | 437 return m_mediaKeys ? m_mediaKeys->contentDecryptionModule() : 0; |
| 435 } | 438 } |
| 436 | 439 |
| 437 DEFINE_TRACE(HTMLMediaElementEncryptedMedia) { | 440 DEFINE_TRACE(HTMLMediaElementEncryptedMedia) { |
| 438 visitor->trace(m_mediaElement); | 441 visitor->trace(m_mediaElement); |
| 439 visitor->trace(m_mediaKeys); | 442 visitor->trace(m_mediaKeys); |
| 440 Supplement<HTMLMediaElement>::trace(visitor); | 443 Supplement<HTMLMediaElement>::trace(visitor); |
| 441 } | 444 } |
| 442 | 445 |
| 443 } // namespace blink | 446 } // namespace blink |
| OLD | NEW |