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

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: reject asynchronously 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..312da4ad712323d052ec2076f9d0609e1a12ff50 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,16 @@ 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.
haraken 2016/06/07 23:45:52 When a GC destroys the object, reject() won't be c
xhwang 2016/06/08 06:52:56 We do reject unfulfilled promises during destructi
+ // (Resolving promises is still done synchronously as there may be events
+ // already posted that need to happen only after the promise is resolved.)
xhwang 2016/06/07 23:33:46 Can we add a TODO to improve the resolving part as
jrummell 2016/06/08 22:40:37 Done.
+ getExecutionContext()->postTask(BLINK_FROM_HERE,
+ createSameThreadTask(&ContentDecryptionModuleResultPromise::rejectLater, this, code, errorMessage));
+}
+
+void ContentDecryptionModuleResultPromise::rejectLater(ExceptionCode code, const String& errorMessage)
xhwang 2016/06/07 23:33:46 rejectLater() actually rejects the promise immedia
jrummell 2016/06/08 22:40:37 Done.
+{
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