Index: content/renderer/media/cdm_result_promise.h |
diff --git a/content/renderer/media/cdm_result_promise.h b/content/renderer/media/cdm_result_promise.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8674da383f22ea1c7b70bda75818ad69d28161fe |
--- /dev/null |
+++ b/content/renderer/media/cdm_result_promise.h |
@@ -0,0 +1,65 @@ |
+// 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 CONTENT_RENDERER_MEDIA_CDM_RESULT_PROMISE_H_ |
+#define CONTENT_RENDERER_MEDIA_CDM_RESULT_PROMISE_H_ |
+ |
+#include <map> |
+ |
+#include "base/basictypes.h" |
+#include "media/base/cdm_promise.h" |
+#include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" |
+ |
+namespace content { |
+ |
+// Used to convert a WebContentDecryptionModuleResult into a CdmPromise so that |
+// it can be passed through Chromium. When CdmPromise::resolve(T) is called, |
+// OnResolve(T) will be called and will call the appropriate complete...() |
+// method on WebContentDecryptionModuleResult. If CdmPromise::reject() is called |
+// instead, WebContentDecryptionModuleResult::completeWithError() is called. |
+template <typename T> |
+class CdmResultPromise : public media::CdmPromiseTemplate<T> { |
+ public: |
+ CdmResultPromise(blink::WebContentDecryptionModuleResult result); |
xhwang
2014/09/25 05:11:47
explicit
jrummell
2014/09/25 20:33:25
Done.
|
+ CdmResultPromise(blink::WebContentDecryptionModuleResult result, |
xhwang
2014/09/25 05:11:47
Pass the |result| by const-ref? I remember we had
jrummell
2014/09/25 20:33:25
Done.
|
+ const std::string& uma_name); |
xhwang
2014/09/25 05:11:46
Need a documentation about the uma_name version.
jrummell
2014/09/25 20:33:25
Done.
|
+ |
xhwang
2014/09/25 05:11:46
Here and in CdmPromiseTemplate, we should declare
jrummell
2014/09/25 20:33:25
Done. Will update CdmPromiseTemplate in a future C
|
+ protected: |
+ virtual void OnResolve(const T& result); |
+ void OnReject(media::MediaKeys::Exception exception_code, |
+ uint32 system_code, |
+ const std::string& error_message); |
xhwang
2014/09/25 05:11:46
We need some documentation here why we choose virt
jrummell
2014/09/25 20:33:24
Done.
|
+ |
+ blink::WebContentDecryptionModuleResult webCDMResult_; |
xhwang
2014/09/25 05:11:46
use chromium style: web_cdm_result_;
jrummell
2014/09/25 20:33:25
Done.
|
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(CdmResultPromise); |
+}; |
+ |
+// Specialization for no parameter to resolve(). |
+template <> |
+class CdmResultPromise<void> : public media::CdmPromiseTemplate<void> { |
+ public: |
+ CdmResultPromise(blink::WebContentDecryptionModuleResult result); |
+ CdmResultPromise(blink::WebContentDecryptionModuleResult result, |
+ const std::string& uma_name); |
+ |
+ protected: |
+ virtual void OnResolve(); |
+ void OnReject(media::MediaKeys::Exception exception_code, |
+ uint32 system_code, |
+ const std::string& error_message); |
+ |
+ blink::WebContentDecryptionModuleResult webCDMResult_; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(CdmResultPromise); |
+}; |
+ |
+typedef CdmResultPromise<void> SimpleCdmResultPromise; |
+typedef CdmResultPromise<media::KeyIdsVector> KeyIdsCdmResultPromise; |
ddorwin
2014/09/25 00:07:16
Can we define this where it's used? This file prob
ddorwin
2014/09/25 00:16:38
We could move this, but we can't move the others.
jrummell
2014/09/25 20:33:25
Done.
|
+ |
+} // namespace content |
+ |
+#endif // CONTENT_RENDERER_MEDIA_CDM_RESULT_PROMISE_H_ |