Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(882)

Unified Diff: third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp

Issue 1987883002: Change back to destroy the CDM synchronously (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 811874b0ef452d084fb879c6deb708d4fcb3a93d..45d42529303ead8c6f0f9d5c596b395ef43fa64b 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();
}
« no previous file with comments | « third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698