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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h" 5 #include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h"
6 6
7 #include "bindings/core/v8/ScriptPromise.h" 7 #include "bindings/core/v8/ScriptPromise.h"
8 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
10 #include "core/dom/ExecutionContext.h"
11 #include "core/dom/ExecutionContextTask.h"
10 #include "public/platform/WebString.h" 12 #include "public/platform/WebString.h"
11 #include "wtf/Assertions.h" 13 #include "wtf/Assertions.h"
12 14
13 namespace blink { 15 namespace blink {
14 16
15 ExceptionCode WebCdmExceptionToExceptionCode(WebContentDecryptionModuleException cdmException) 17 ExceptionCode WebCdmExceptionToExceptionCode(WebContentDecryptionModuleException cdmException)
16 { 18 {
17 switch (cdmException) { 19 switch (cdmException) {
18 case WebContentDecryptionModuleExceptionNotSupportedError: 20 case WebContentDecryptionModuleExceptionNotSupportedError:
19 return NotSupportedError; 21 return NotSupportedError;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 reject(WebCdmExceptionToExceptionCode(exceptionCode), errorString); 80 reject(WebCdmExceptionToExceptionCode(exceptionCode), errorString);
79 } 81 }
80 82
81 ScriptPromise ContentDecryptionModuleResultPromise::promise() 83 ScriptPromise ContentDecryptionModuleResultPromise::promise()
82 { 84 {
83 return m_resolver->promise(); 85 return m_resolver->promise();
84 } 86 }
85 87
86 void ContentDecryptionModuleResultPromise::reject(ExceptionCode code, const Stri ng& errorMessage) 88 void ContentDecryptionModuleResultPromise::reject(ExceptionCode code, const Stri ng& errorMessage)
87 { 89 {
90 // Reject the promise asynchronously. This avoids problems when gc is
91 // 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
92 // (Resolving promises is still done synchronously as there may be events
93 // 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.
94 getExecutionContext()->postTask(BLINK_FROM_HERE,
95 createSameThreadTask(&ContentDecryptionModuleResultPromise::rejectLater, this, code, errorMessage));
96 }
97
98 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.
99 {
88 m_resolver->reject(DOMException::create(code, errorMessage)); 100 m_resolver->reject(DOMException::create(code, errorMessage));
89 m_resolver.clear(); 101 m_resolver.clear();
90 } 102 }
91 103
92 ExecutionContext* ContentDecryptionModuleResultPromise::getExecutionContext() co nst 104 ExecutionContext* ContentDecryptionModuleResultPromise::getExecutionContext() co nst
93 { 105 {
94 return m_resolver->getExecutionContext(); 106 return m_resolver->getExecutionContext();
95 } 107 }
96 108
97 DEFINE_TRACE(ContentDecryptionModuleResultPromise) 109 DEFINE_TRACE(ContentDecryptionModuleResultPromise)
98 { 110 {
99 visitor->trace(m_resolver); 111 visitor->trace(m_resolver);
100 ContentDecryptionModuleResult::trace(visitor); 112 ContentDecryptionModuleResult::trace(visitor);
101 } 113 }
102 114
103 } // namespace blink 115 } // namespace blink
OLDNEW
« 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