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 #ifndef SimpleContentDecryptionModuleResult_h | 5 #ifndef SimpleContentDecryptionModuleResult_h |
6 #define SimpleContentDecryptionModuleResult_h | 6 #define SimpleContentDecryptionModuleResult_h |
7 | 7 |
8 #include "core/dom/ExceptionCode.h" | 8 #include "core/dom/ExceptionCode.h" |
9 #include "platform/ContentDecryptionModuleResult.h" | 9 #include "platform/ContentDecryptionModuleResult.h" |
10 #include "wtf/Forward.h" | 10 #include "wtf/Forward.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 class WebString; | |
14 } | |
15 | |
16 namespace blink { | |
17 | 13 |
18 class ScriptPromise; | 14 class ScriptPromise; |
19 class ScriptPromiseResolver; | 15 class ScriptPromiseResolver; |
20 class ScriptState; | 16 class ScriptState; |
| 17 class WebString; |
21 | 18 |
22 ExceptionCode WebCdmExceptionToExceptionCode(blink::WebContentDecryptionModuleEx
ception); | 19 ExceptionCode WebCdmExceptionToExceptionCode(WebContentDecryptionModuleException
); |
23 | 20 |
24 // This class wraps the promise resolver and is passed (indirectly) to Chromium | 21 // This class wraps the promise resolver and is passed (indirectly) to Chromium |
25 // to fullfill the promise. This implementation of complete() will resolve the | 22 // to fullfill the promise. This implementation of complete() will resolve the |
26 // promise with undefined, while completeWithError() reject the promise with an | 23 // promise with undefined, while completeWithError() reject the promise with an |
27 // exception. completeWithSession() is not expected to be called, and will | 24 // exception. completeWithSession() is not expected to be called, and will |
28 // reject the promise. | 25 // reject the promise. |
29 class SimpleContentDecryptionModuleResult : public ContentDecryptionModuleResult
{ | 26 class SimpleContentDecryptionModuleResult : public ContentDecryptionModuleResult
{ |
30 public: | 27 public: |
31 explicit SimpleContentDecryptionModuleResult(ScriptState*); | 28 explicit SimpleContentDecryptionModuleResult(ScriptState*); |
32 virtual ~SimpleContentDecryptionModuleResult(); | 29 virtual ~SimpleContentDecryptionModuleResult(); |
33 | 30 |
34 // ContentDecryptionModuleResult implementation. | 31 // ContentDecryptionModuleResult implementation. |
35 virtual void complete() OVERRIDE; | 32 virtual void complete() OVERRIDE; |
36 virtual void completeWithSession(blink::WebContentDecryptionModuleResult::Se
ssionStatus) OVERRIDE; | 33 virtual void completeWithSession(WebContentDecryptionModuleResult::SessionSt
atus) OVERRIDE; |
37 virtual void completeWithError(blink::WebContentDecryptionModuleException, u
nsigned long systemCode, const blink::WebString&) OVERRIDE; | 34 virtual void completeWithError(WebContentDecryptionModuleException, unsigned
long systemCode, const WebString&) OVERRIDE; |
38 | 35 |
39 // It is only valid to call this before completion. | 36 // It is only valid to call this before completion. |
40 ScriptPromise promise(); | 37 ScriptPromise promise(); |
41 | 38 |
42 private: | 39 private: |
43 // Reject the promise with a DOMException. | 40 // Reject the promise with a DOMException. |
44 void completeWithDOMException(ExceptionCode, const String& errorMessage); | 41 void completeWithDOMException(ExceptionCode, const String& errorMessage); |
45 | 42 |
46 RefPtr<ScriptPromiseResolver> m_resolver; | 43 RefPtr<ScriptPromiseResolver> m_resolver; |
47 }; | 44 }; |
48 | 45 |
49 } // namespace blink | 46 } // namespace blink |
50 | 47 |
51 #endif // SimpleContentDecryptionModuleResult_h | 48 #endif // SimpleContentDecryptionModuleResult_h |
OLD | NEW |