| OLD | NEW |
| 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" | 10 #include "core/dom/ExecutionContext.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 | 90 |
| 91 void ContentDecryptionModuleResultPromise::reject(ExceptionCode code, const Stri
ng& errorMessage) | 91 void ContentDecryptionModuleResultPromise::reject(ExceptionCode code, const Stri
ng& errorMessage) |
| 92 { | 92 { |
| 93 // Reject the promise asynchronously. This avoids problems when gc is | 93 // Reject the promise asynchronously. This avoids problems when gc is |
| 94 // destroying objects that result in unfulfilled promises being rejected. | 94 // destroying objects that result in unfulfilled promises being rejected. |
| 95 // (Resolving promises is still done synchronously as there may be events | 95 // (Resolving promises is still done synchronously as there may be events |
| 96 // already posted that need to happen only after the promise is resolved.) | 96 // already posted that need to happen only after the promise is resolved.) |
| 97 // TODO(jrummell): Make resolving a promise asynchronous as well (including | 97 // TODO(jrummell): Make resolving a promise asynchronous as well (including |
| 98 // making sure events still happen after the promise is resolved). | 98 // making sure events still happen after the promise is resolved). |
| 99 getExecutionContext()->postTask(BLINK_FROM_HERE, createSameThreadTask(&Conte
ntDecryptionModuleResultPromise::rejectInternal, wrapPersistent(this), code, err
orMessage)); | 99 if (getExecutionContext()) { |
| 100 getExecutionContext()->postTask(BLINK_FROM_HERE, createSameThreadTask(&C
ontentDecryptionModuleResultPromise::rejectInternal, wrapPersistent(this), code,
errorMessage)); |
| 101 } |
| 100 } | 102 } |
| 101 | 103 |
| 102 void ContentDecryptionModuleResultPromise::rejectInternal(ExceptionCode code, co
nst String& errorMessage) | 104 void ContentDecryptionModuleResultPromise::rejectInternal(ExceptionCode code, co
nst String& errorMessage) |
| 103 { | 105 { |
| 104 m_resolver->reject(DOMException::create(code, errorMessage)); | 106 m_resolver->reject(DOMException::create(code, errorMessage)); |
| 105 m_resolver.clear(); | 107 m_resolver.clear(); |
| 106 } | 108 } |
| 107 | 109 |
| 108 ExecutionContext* ContentDecryptionModuleResultPromise::getExecutionContext() co
nst | 110 ExecutionContext* ContentDecryptionModuleResultPromise::getExecutionContext() co
nst |
| 109 { | 111 { |
| 110 return m_resolver->getExecutionContext(); | 112 return m_resolver->getExecutionContext(); |
| 111 } | 113 } |
| 112 | 114 |
| 113 DEFINE_TRACE(ContentDecryptionModuleResultPromise) | 115 DEFINE_TRACE(ContentDecryptionModuleResultPromise) |
| 114 { | 116 { |
| 115 visitor->trace(m_resolver); | 117 visitor->trace(m_resolver); |
| 116 ContentDecryptionModuleResult::trace(visitor); | 118 ContentDecryptionModuleResult::trace(visitor); |
| 117 } | 119 } |
| 118 | 120 |
| 119 } // namespace blink | 121 } // namespace blink |
| OLD | NEW |