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

Side by Side Diff: third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp

Issue 2342953002: Update EME errors to use TypeError (Closed)
Patch Set: Created 4 years, 3 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
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 "bindings/core/v8/V8Binding.h"
9 #include "core/dom/DOMException.h" 10 #include "core/dom/DOMException.h"
10 #include "core/dom/ExecutionContext.h" 11 #include "core/dom/ExecutionContext.h"
11 #include "core/dom/ExecutionContextTask.h" 12 #include "core/dom/ExecutionContextTask.h"
12 #include "public/platform/WebString.h" 13 #include "public/platform/WebString.h"
13 #include "wtf/Assertions.h" 14 #include "wtf/Assertions.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 ExceptionCode WebCdmExceptionToExceptionCode(WebContentDecryptionModuleException cdmException) 18 ExceptionCode WebCdmExceptionToExceptionCode(WebContentDecryptionModuleException cdmException)
18 { 19 {
19 switch (cdmException) { 20 switch (cdmException) {
20 case WebContentDecryptionModuleExceptionNotSupportedError: 21 case WebContentDecryptionModuleExceptionNotSupportedError:
21 return NotSupportedError; 22 return NotSupportedError;
22 case WebContentDecryptionModuleExceptionInvalidStateError: 23 case WebContentDecryptionModuleExceptionInvalidStateError:
23 return InvalidStateError; 24 return InvalidStateError;
24 case WebContentDecryptionModuleExceptionInvalidAccessError: 25 case WebContentDecryptionModuleExceptionInvalidAccessError:
ddorwin 2016/09/15 22:43:03 Is this still used? Maybe treat it as a TypeError
jrummell 2016/09/16 23:23:34 CDM interface has kInvalidAccessError, so it could
25 return InvalidAccessError; 26 return InvalidAccessError;
26 case WebContentDecryptionModuleExceptionQuotaExceededError: 27 case WebContentDecryptionModuleExceptionQuotaExceededError:
27 return QuotaExceededError; 28 return QuotaExceededError;
28 case WebContentDecryptionModuleExceptionUnknownError: 29 case WebContentDecryptionModuleExceptionUnknownError:
ddorwin 2016/09/15 22:43:03 Are these three still used? Remove/NOTREACHED and
jrummell 2016/09/16 23:23:34 Done.
29 return UnknownError; 30 return UnknownError;
ddorwin 2016/09/15 22:43:03 Remove this line since the comment below also appl
jrummell 2016/09/16 23:23:34 Removed the unnecessary values.
30 case WebContentDecryptionModuleExceptionClientError: 31 case WebContentDecryptionModuleExceptionClientError:
31 case WebContentDecryptionModuleExceptionOutputError: 32 case WebContentDecryptionModuleExceptionOutputError:
32 // Currently no matching DOMException for these 2 errors. 33 // Currently no matching DOMException for these 2 errors.
33 // FIXME: Update DOMException to handle these if actually added to 34 // FIXME: Update DOMException to handle these if actually added to
34 // the EME spec. 35 // the EME spec.
35 return UnknownError; 36 return UnknownError;
37 case WebContentDecryptionModuleExceptionTypeError:
38 // This is not a DOMException but rather a seperate TypeError. Use a
39 // different ExceptionCode for this so it can be checked for.
40 return TypeMismatchError;
36 } 41 }
37 42
38 NOTREACHED(); 43 NOTREACHED();
39 return UnknownError; 44 return UnknownError;
40 } 45 }
41 46
42 ContentDecryptionModuleResultPromise::ContentDecryptionModuleResultPromise(Scrip tState* scriptState) 47 ContentDecryptionModuleResultPromise::ContentDecryptionModuleResultPromise(Scrip tState* scriptState)
43 : m_resolver(ScriptPromiseResolver::create(scriptState)) 48 : m_resolver(ScriptPromiseResolver::create(scriptState))
44 { 49 {
45 } 50 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // already posted that need to happen only after the promise is resolved.) 101 // already posted that need to happen only after the promise is resolved.)
97 // TODO(jrummell): Make resolving a promise asynchronous as well (including 102 // TODO(jrummell): Make resolving a promise asynchronous as well (including
98 // making sure events still happen after the promise is resolved). 103 // making sure events still happen after the promise is resolved).
99 if (getExecutionContext()) { 104 if (getExecutionContext()) {
100 getExecutionContext()->postTask(BLINK_FROM_HERE, createSameThreadTask(&C ontentDecryptionModuleResultPromise::rejectInternal, wrapPersistent(this), code, errorMessage)); 105 getExecutionContext()->postTask(BLINK_FROM_HERE, createSameThreadTask(&C ontentDecryptionModuleResultPromise::rejectInternal, wrapPersistent(this), code, errorMessage));
101 } 106 }
102 } 107 }
103 108
104 void ContentDecryptionModuleResultPromise::rejectInternal(ExceptionCode code, co nst String& errorMessage) 109 void ContentDecryptionModuleResultPromise::rejectInternal(ExceptionCode code, co nst String& errorMessage)
105 { 110 {
106 m_resolver->reject(DOMException::create(code, errorMessage)); 111 if (code == TypeMismatchError) {
112 if (m_resolver->getScriptState()->contextIsValid()) {
113 ScriptState::Scope scope(m_resolver->getScriptState());
114 v8::Isolate* isolate = m_resolver->getScriptState()->isolate();
115 m_resolver->reject(v8::Exception::TypeError(v8String(isolate, errorM essage)));
116 }
117 } else {
118 m_resolver->reject(DOMException::create(code, errorMessage));
119 }
120
107 m_resolver.clear(); 121 m_resolver.clear();
108 } 122 }
109 123
110 ExecutionContext* ContentDecryptionModuleResultPromise::getExecutionContext() co nst 124 ExecutionContext* ContentDecryptionModuleResultPromise::getExecutionContext() co nst
111 { 125 {
112 return m_resolver->getExecutionContext(); 126 return m_resolver->getExecutionContext();
113 } 127 }
114 128
115 DEFINE_TRACE(ContentDecryptionModuleResultPromise) 129 DEFINE_TRACE(ContentDecryptionModuleResultPromise)
116 { 130 {
117 visitor->trace(m_resolver); 131 visitor->trace(m_resolver);
118 ContentDecryptionModuleResult::trace(visitor); 132 ContentDecryptionModuleResult::trace(visitor);
119 } 133 }
120 134
121 } // namespace blink 135 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698