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 "bindings/core/v8/V8ThrowException.h" | 9 #include "bindings/core/v8/V8ThrowDOMException.h" |
10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
11 #include "core/dom/ExecutionContext.h" | 11 #include "core/dom/ExecutionContext.h" |
12 #include "platform/wtf/Assertions.h" | 12 #include "platform/wtf/Assertions.h" |
13 #include "public/platform/WebString.h" | 13 #include "public/platform/WebString.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 ExceptionCode WebCdmExceptionToExceptionCode( | 17 ExceptionCode WebCdmExceptionToExceptionCode( |
18 WebContentDecryptionModuleException cdm_exception) { | 18 WebContentDecryptionModuleException cdm_exception) { |
19 switch (cdm_exception) { | 19 switch (cdm_exception) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 return resolver_->Promise(); | 88 return resolver_->Promise(); |
89 } | 89 } |
90 | 90 |
91 void ContentDecryptionModuleResultPromise::Reject(ExceptionCode code, | 91 void ContentDecryptionModuleResultPromise::Reject(ExceptionCode code, |
92 const String& error_message) { | 92 const String& error_message) { |
93 DCHECK(IsValidToFulfillPromise()); | 93 DCHECK(IsValidToFulfillPromise()); |
94 | 94 |
95 ScriptState::Scope scope(resolver_->GetScriptState()); | 95 ScriptState::Scope scope(resolver_->GetScriptState()); |
96 v8::Isolate* isolate = resolver_->GetScriptState()->GetIsolate(); | 96 v8::Isolate* isolate = resolver_->GetScriptState()->GetIsolate(); |
97 resolver_->Reject( | 97 resolver_->Reject( |
98 V8ThrowException::CreateDOMException(isolate, code, error_message)); | 98 V8ThrowDOMException::CreateDOMException(isolate, code, error_message)); |
99 resolver_.Clear(); | 99 resolver_.Clear(); |
100 } | 100 } |
101 | 101 |
102 ExecutionContext* ContentDecryptionModuleResultPromise::GetExecutionContext() | 102 ExecutionContext* ContentDecryptionModuleResultPromise::GetExecutionContext() |
103 const { | 103 const { |
104 return resolver_->GetExecutionContext(); | 104 return resolver_->GetExecutionContext(); |
105 } | 105 } |
106 | 106 |
107 bool ContentDecryptionModuleResultPromise::IsValidToFulfillPromise() { | 107 bool ContentDecryptionModuleResultPromise::IsValidToFulfillPromise() { |
108 // getExecutionContext() is no longer valid once the context is destroyed. | 108 // getExecutionContext() is no longer valid once the context is destroyed. |
109 // isContextDestroyed() is called to see if the context is in the | 109 // isContextDestroyed() is called to see if the context is in the |
110 // process of being destroyed. If it is, there is no need to fulfill this | 110 // process of being destroyed. If it is, there is no need to fulfill this |
111 // promise which is about to go away anyway. | 111 // promise which is about to go away anyway. |
112 return GetExecutionContext() && !GetExecutionContext()->IsContextDestroyed(); | 112 return GetExecutionContext() && !GetExecutionContext()->IsContextDestroyed(); |
113 } | 113 } |
114 | 114 |
115 DEFINE_TRACE(ContentDecryptionModuleResultPromise) { | 115 DEFINE_TRACE(ContentDecryptionModuleResultPromise) { |
116 visitor->Trace(resolver_); | 116 visitor->Trace(resolver_); |
117 ContentDecryptionModuleResult::Trace(visitor); | 117 ContentDecryptionModuleResult::Trace(visitor); |
118 } | 118 } |
119 | 119 |
120 } // namespace blink | 120 } // namespace blink |
OLD | NEW |