| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/encryptedmedia/SimpleContentDecryptionModuleResult.h" | 6 #include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | |
| 10 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 11 #include "bindings/core/v8/V8Binding.h" | |
| 12 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| 13 #include "platform/Logging.h" | |
| 14 #include "public/platform/WebString.h" | 11 #include "public/platform/WebString.h" |
| 15 #include "wtf/Assertions.h" | 12 #include "wtf/Assertions.h" |
| 16 | 13 |
| 17 namespace blink { | 14 namespace blink { |
| 18 | 15 |
| 19 ExceptionCode WebCdmExceptionToExceptionCode(WebContentDecryptionModuleException
cdmException) | 16 ExceptionCode WebCdmExceptionToExceptionCode(WebContentDecryptionModuleException
cdmException) |
| 20 { | 17 { |
| 21 switch (cdmException) { | 18 switch (cdmException) { |
| 22 case WebContentDecryptionModuleExceptionNotSupportedError: | 19 case WebContentDecryptionModuleExceptionNotSupportedError: |
| 23 return NotSupportedError; | 20 return NotSupportedError; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 34 // Currently no matching DOMException for these 2 errors. | 31 // Currently no matching DOMException for these 2 errors. |
| 35 // FIXME: Update DOMException to handle these if actually added to | 32 // FIXME: Update DOMException to handle these if actually added to |
| 36 // the EME spec. | 33 // the EME spec. |
| 37 return UnknownError; | 34 return UnknownError; |
| 38 } | 35 } |
| 39 | 36 |
| 40 ASSERT_NOT_REACHED(); | 37 ASSERT_NOT_REACHED(); |
| 41 return UnknownError; | 38 return UnknownError; |
| 42 } | 39 } |
| 43 | 40 |
| 44 SimpleContentDecryptionModuleResult::SimpleContentDecryptionModuleResult(ScriptS
tate* scriptState) | 41 ContentDecryptionModuleResultPromise::ContentDecryptionModuleResultPromise(Scrip
tState* scriptState) |
| 45 : m_resolver(ScriptPromiseResolver::create(scriptState)) | 42 : m_resolver(ScriptPromiseResolver::create(scriptState)) |
| 46 { | 43 { |
| 47 } | 44 } |
| 48 | 45 |
| 49 SimpleContentDecryptionModuleResult::~SimpleContentDecryptionModuleResult() | 46 ContentDecryptionModuleResultPromise::~ContentDecryptionModuleResultPromise() |
| 50 { | 47 { |
| 51 } | 48 } |
| 52 | 49 |
| 53 void SimpleContentDecryptionModuleResult::complete() | 50 void ContentDecryptionModuleResultPromise::complete() |
| 54 { | 51 { |
| 55 m_resolver->resolve(V8UndefinedType()); | 52 ASSERT_NOT_REACHED(); |
| 56 m_resolver.clear(); | 53 reject(InvalidStateError, "Unexpected completion."); |
| 57 } | 54 } |
| 58 | 55 |
| 59 void SimpleContentDecryptionModuleResult::completeWithSession(WebContentDecrypti
onModuleResult::SessionStatus status) | 56 void ContentDecryptionModuleResultPromise::completeWithSession(WebContentDecrypt
ionModuleResult::SessionStatus status) |
| 60 { | 57 { |
| 61 ASSERT_NOT_REACHED(); | 58 ASSERT_NOT_REACHED(); |
| 62 completeWithDOMException(InvalidStateError, "Unexpected completion."); | 59 reject(InvalidStateError, "Unexpected completion."); |
| 63 } | 60 } |
| 64 | 61 |
| 65 void SimpleContentDecryptionModuleResult::completeWithError(WebContentDecryption
ModuleException exceptionCode, unsigned long systemCode, const WebString& errorM
essage) | 62 void ContentDecryptionModuleResultPromise::completeWithError(WebContentDecryptio
nModuleException exceptionCode, unsigned long systemCode, const WebString& error
Message) |
| 66 { | 63 { |
| 67 completeWithDOMException(WebCdmExceptionToExceptionCode(exceptionCode), erro
rMessage); | 64 reject(WebCdmExceptionToExceptionCode(exceptionCode), errorMessage); |
| 68 } | 65 } |
| 69 | 66 |
| 70 ScriptPromise SimpleContentDecryptionModuleResult::promise() | 67 ScriptPromise ContentDecryptionModuleResultPromise::promise() |
| 71 { | 68 { |
| 72 return m_resolver->promise(); | 69 return m_resolver->promise(); |
| 73 } | 70 } |
| 74 | 71 |
| 75 void SimpleContentDecryptionModuleResult::completeWithDOMException(ExceptionCode
code, const String& errorMessage) | 72 void ContentDecryptionModuleResultPromise::reject(ExceptionCode code, const Stri
ng& errorMessage) |
| 76 { | 73 { |
| 77 m_resolver->reject(DOMException::create(code, errorMessage)); | 74 m_resolver->reject(DOMException::create(code, errorMessage)); |
| 78 m_resolver.clear(); | 75 m_resolver.clear(); |
| 79 } | 76 } |
| 80 | 77 |
| 78 ExecutionContext* ContentDecryptionModuleResultPromise::executionContext() const |
| 79 { |
| 80 return m_resolver->executionContext(); |
| 81 } |
| 82 |
| 83 void ContentDecryptionModuleResultPromise::trace(Visitor* visitor) |
| 84 { |
| 85 ContentDecryptionModuleResult::trace(visitor); |
| 86 } |
| 87 |
| 81 } // namespace blink | 88 } // namespace blink |
| OLD | NEW |