| Index: third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.h
|
| diff --git a/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.h b/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.h
|
| index 104d15b4004d1686527843e6945961a750445c07..945d3289dfaf9b13d75d63296e7d66e05a372af2 100644
|
| --- a/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.h
|
| +++ b/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.h
|
| @@ -6,6 +6,7 @@
|
| #define ContentDecryptionModuleResultPromise_h
|
|
|
| #include "bindings/core/v8/ScriptPromiseResolver.h"
|
| +#include "core/dom/ContextLifecycleObserver.h"
|
| #include "core/dom/ExceptionCode.h"
|
| #include "platform/ContentDecryptionModuleResult.h"
|
|
|
| @@ -20,7 +21,10 @@ ExceptionCode WebCdmExceptionToExceptionCode(
|
| // with an error. It needs to be subclassed and the appropriate complete()
|
| // method overridden to resolve the promise as needed.
|
| class ContentDecryptionModuleResultPromise
|
| - : public ContentDecryptionModuleResult {
|
| + : public ContentDecryptionModuleResult,
|
| + public ContextLifecycleObserver {
|
| + USING_GARBAGE_COLLECTED_MIXIN(ContentDecryptionModuleResultPromise);
|
| +
|
| public:
|
| ~ContentDecryptionModuleResultPromise() override;
|
|
|
| @@ -34,6 +38,9 @@ class ContentDecryptionModuleResultPromise
|
| unsigned long systemCode,
|
| const WebString&) override;
|
|
|
| + // ContextLifecycleObserver implementation.
|
| + void contextDestroyed() override;
|
| +
|
| // It is only valid to call this before completion.
|
| ScriptPromise promise();
|
|
|
| @@ -46,6 +53,9 @@ class ContentDecryptionModuleResultPromise
|
| // promise.
|
| template <typename... T>
|
| void resolve(T... value) {
|
| + if (!isValidToFulfillPromise())
|
| + return;
|
| +
|
| m_resolver->resolve(value...);
|
| m_resolver.clear();
|
| }
|
| @@ -54,13 +64,14 @@ class ContentDecryptionModuleResultPromise
|
| // actually reject the promise later on.
|
| void reject(ExceptionCode, const String& errorMessage);
|
|
|
| - ExecutionContext* getExecutionContext() const;
|
| + // Determine if it's OK to resolve/reject this promise.
|
| + bool isValidToFulfillPromise();
|
|
|
| private:
|
| - // Rejects the promise with a DOMException.
|
| - void rejectInternal(ExceptionCode, const String& errorMessage);
|
| -
|
| Member<ScriptPromiseResolver> m_resolver;
|
| +
|
| + // Set once the Context is destroyed.
|
| + bool m_contextDestroyed;
|
| };
|
|
|
| } // namespace blink
|
|
|