| 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..51ace41b38bfe1adef8e16cee88706af2d78f475 100644
|
| --- a/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.h
|
| +++ b/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.h
|
| @@ -19,6 +19,15 @@ ExceptionCode WebCdmExceptionToExceptionCode(
|
| // complete(), completeWithSession(), etc. methods will reject the promise
|
| // with an error. It needs to be subclassed and the appropriate complete()
|
| // method overridden to resolve the promise as needed.
|
| +//
|
| +// Subclasses need to keep a Member<> to the object that created them so
|
| +// that the creator remains around as long as this promise is pending. This
|
| +// promise is not referenced by the object that created it (e.g MediaKeys,
|
| +// MediaKeySession, Navigator.requestMediaKeySystemAccess), so this promise
|
| +// may be cleaned up before or after it's creator once both become unreachable.
|
| +// If it is after, the destruction of the creator may trigger this promise,
|
| +// so use isValidToFulfillPromise() to verify that it is safe to fulfill
|
| +// the promise.
|
| class ContentDecryptionModuleResultPromise
|
| : public ContentDecryptionModuleResult {
|
| public:
|
| @@ -46,20 +55,21 @@ class ContentDecryptionModuleResultPromise
|
| // promise.
|
| template <typename... T>
|
| void resolve(T... value) {
|
| + DCHECK(isValidToFulfillPromise());
|
| +
|
| m_resolver->resolve(value...);
|
| m_resolver.clear();
|
| }
|
|
|
| - // Rejects the promise with a DOMException. This will post a task to
|
| - // actually reject the promise later on.
|
| + // Rejects the promise with a DOMException.
|
| void reject(ExceptionCode, const String& errorMessage);
|
|
|
| ExecutionContext* getExecutionContext() const;
|
|
|
| - private:
|
| - // Rejects the promise with a DOMException.
|
| - void rejectInternal(ExceptionCode, const String& errorMessage);
|
| + // Determine if it's OK to resolve/reject this promise.
|
| + bool isValidToFulfillPromise();
|
|
|
| + private:
|
| Member<ScriptPromiseResolver> m_resolver;
|
| };
|
|
|
|
|