| Index: third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp
|
| diff --git a/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp b/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp
|
| index 931af86f682a01b8714233f05ce1538a017f9f55..ced2ce83b1474dd8f1b0a7b43a8208e655bb1843 100644
|
| --- a/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp
|
| +++ b/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp
|
| @@ -7,6 +7,8 @@
|
| #include "bindings/core/v8/ScriptPromise.h"
|
| #include "bindings/core/v8/ScriptState.h"
|
| #include "core/dom/DOMException.h"
|
| +#include "core/dom/ExecutionContext.h"
|
| +#include "core/dom/ExecutionContextTask.h"
|
| #include "public/platform/WebString.h"
|
| #include "wtf/Assertions.h"
|
|
|
| @@ -85,6 +87,18 @@ ScriptPromise ContentDecryptionModuleResultPromise::promise()
|
|
|
| void ContentDecryptionModuleResultPromise::reject(ExceptionCode code, const String& errorMessage)
|
| {
|
| + // Reject the promise asynchronously. This avoids problems when gc is
|
| + // destroying objects that result in unfulfilled promises being rejected.
|
| + // (Resolving promises is still done synchronously as there may be events
|
| + // already posted that need to happen only after the promise is resolved.)
|
| + // TODO(jrummell): Make resolving a promise asynchronous as well (including
|
| + // making sure events still happen after the promise is resolved).
|
| + getExecutionContext()->postTask(BLINK_FROM_HERE,
|
| + createSameThreadTask(&ContentDecryptionModuleResultPromise::rejectInternal, this, code, errorMessage));
|
| +}
|
| +
|
| +void ContentDecryptionModuleResultPromise::rejectInternal(ExceptionCode code, const String& errorMessage)
|
| +{
|
| m_resolver->reject(DOMException::create(code, errorMessage));
|
| m_resolver.clear();
|
| }
|
|
|