OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ContentDecryptionModuleResultPromise_h | |
6 #define ContentDecryptionModuleResultPromise_h | |
7 | |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | |
9 #include "core/dom/ExceptionCode.h" | |
10 #include "platform/ContentDecryptionModuleResult.h" | |
11 | |
12 namespace blink { | |
13 | |
14 ExceptionCode WebCdmExceptionToExceptionCode(WebContentDecryptionModuleException ); | |
15 | |
16 // This class wraps the promise resolver to simplify creation of | |
17 // ContentDecryptionModuleResult objects, and is to be derived from to resolve | |
ddorwin
2014/11/11 22:44:09
nit: s/derived from/subclassed/
That reads better.
jrummell
2014/11/11 23:30:10
Done.
| |
18 // promises as needed. The default implementations of complete(), | |
ddorwin
2014/11/11 22:44:09
I'm not sure what "resolve promises as needed" mea
jrummell
2014/11/11 23:30:11
Done.
| |
19 // completeWithSession(), etc. will reject the promise with an error. | |
20 class ContentDecryptionModuleResultPromise : public ContentDecryptionModuleResul t { | |
ddorwin
2014/11/11 22:44:09
Why is this a "...ResultPromise"? It doesn't look
jrummell
2014/11/11 23:30:11
I guess ...ResultWithPromise would be better. Howe
| |
21 public: | |
22 explicit ContentDecryptionModuleResultPromise(ScriptState*); | |
ddorwin
2014/11/11 22:44:09
protected? Should this really be instantiated?
jrummell
2014/11/11 23:30:10
Done.
| |
23 virtual ~ContentDecryptionModuleResultPromise(); | |
24 | |
25 // ContentDecryptionModuleResult implementation. | |
26 virtual void complete() override; | |
27 virtual void completeWithSession(WebContentDecryptionModuleResult::SessionSt atus) override; | |
ddorwin
2014/11/11 22:44:09
Why does this "base class" have this specialized c
jrummell
2014/11/11 23:30:11
ContentDecryptionModuleResult has 3 complete metho
| |
28 virtual void completeWithError(WebContentDecryptionModuleException, unsigned long systemCode, const WebString&) final; | |
29 | |
30 // It is only valid to call this before completion. | |
31 ScriptPromise promise(); | |
32 | |
33 virtual void trace(Visitor*); | |
34 | |
35 protected: | |
36 // Called when the promise is to be resolved by derived classes. | |
ddorwin
2014/11/11 22:44:09
Resolves the promise with |value|. Used by subclas
jrummell
2014/11/11 23:30:11
Done.
| |
37 template <typename... T> | |
38 void resolve(T... value) | |
39 { | |
40 m_resolver->resolve(value...); | |
41 m_resolver.clear(); | |
42 } | |
43 | |
44 // Reject the promise with a DOMException. | |
ddorwin
2014/11/11 22:44:09
nit: Rejects
jrummell
2014/11/11 23:30:10
Done.
| |
45 void reject(ExceptionCode, const String& errorMessage); | |
46 | |
47 ExecutionContext* executionContext() const; | |
48 | |
49 private: | |
50 RefPtr<ScriptPromiseResolver> m_resolver; | |
51 }; | |
52 | |
53 } // namespace blink | |
54 | |
55 #endif // ContentDecryptionModuleResultPromise_h | |
OLD | NEW |