Index: Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.h |
diff --git a/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.h b/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..072a287b95705538430a8e60da63b4118bfc6f84 |
--- /dev/null |
+++ b/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.h |
@@ -0,0 +1,55 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef ContentDecryptionModuleResultPromise_h |
+#define ContentDecryptionModuleResultPromise_h |
+ |
+#include "bindings/core/v8/ScriptPromiseResolver.h" |
+#include "core/dom/ExceptionCode.h" |
+#include "platform/ContentDecryptionModuleResult.h" |
+ |
+namespace blink { |
+ |
+ExceptionCode WebCdmExceptionToExceptionCode(WebContentDecryptionModuleException); |
+ |
+// This class wraps the promise resolver to simplify creation of |
+// 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.
|
+// 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.
|
+// completeWithSession(), etc. will reject the promise with an error. |
+class ContentDecryptionModuleResultPromise : public ContentDecryptionModuleResult { |
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
|
+public: |
+ explicit ContentDecryptionModuleResultPromise(ScriptState*); |
ddorwin
2014/11/11 22:44:09
protected? Should this really be instantiated?
jrummell
2014/11/11 23:30:10
Done.
|
+ virtual ~ContentDecryptionModuleResultPromise(); |
+ |
+ // ContentDecryptionModuleResult implementation. |
+ virtual void complete() override; |
+ virtual void completeWithSession(WebContentDecryptionModuleResult::SessionStatus) 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
|
+ virtual void completeWithError(WebContentDecryptionModuleException, unsigned long systemCode, const WebString&) final; |
+ |
+ // It is only valid to call this before completion. |
+ ScriptPromise promise(); |
+ |
+ virtual void trace(Visitor*); |
+ |
+protected: |
+ // 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.
|
+ template <typename... T> |
+ void resolve(T... value) |
+ { |
+ m_resolver->resolve(value...); |
+ m_resolver.clear(); |
+ } |
+ |
+ // Reject the promise with a DOMException. |
ddorwin
2014/11/11 22:44:09
nit: Rejects
jrummell
2014/11/11 23:30:10
Done.
|
+ void reject(ExceptionCode, const String& errorMessage); |
+ |
+ ExecutionContext* executionContext() const; |
+ |
+private: |
+ RefPtr<ScriptPromiseResolver> m_resolver; |
+}; |
+ |
+} // namespace blink |
+ |
+#endif // ContentDecryptionModuleResultPromise_h |