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

Unified Diff: content/renderer/media/webcontentdecryptionmoduleresult_helper.h

Issue 555223004: Update MediaKeys interface for EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WebCdmPromiseTemplate Created 6 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/webcontentdecryptionmoduleresult_helper.h
diff --git a/content/renderer/media/webcontentdecryptionmoduleresult_helper.h b/content/renderer/media/webcontentdecryptionmoduleresult_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..9eaf3aa1901e3a4e44f712634cbed8e4c77a53bc
--- /dev/null
+++ b/content/renderer/media/webcontentdecryptionmoduleresult_helper.h
@@ -0,0 +1,63 @@
+// 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_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_H_
+#define CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_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 WebCdmPromiseTemplate : public media::CdmPromiseTemplate<T> {
ddorwin 2014/09/24 17:37:47 While thinking about how to name this file, I real
jrummell 2014/09/24 22:32:32 CdmResultPromise it is.
+ public:
+ WebCdmPromiseTemplate(blink::WebContentDecryptionModuleResult result);
+ WebCdmPromiseTemplate(blink::WebContentDecryptionModuleResult result,
+ const std::string& uma_name);
+
+ protected:
+ virtual void OnResolve(const T& result);
+ void OnReject(media::MediaKeys::Exception exception_code,
+ uint32 system_code,
+ const std::string& error_message);
+
+ blink::WebContentDecryptionModuleResult webCDMResult_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebCdmPromiseTemplate);
+};
+
+// Specialization for no parameter to resolve().
+template <>
+class WebCdmPromiseTemplate<void> : public media::CdmPromiseTemplate<void> {
+ public:
+ WebCdmPromiseTemplate(blink::WebContentDecryptionModuleResult result);
+ WebCdmPromiseTemplate(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_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebCdmPromiseTemplate);
+};
+
+typedef WebCdmPromiseTemplate<void> WebSimpleCdmPromise;
+typedef WebCdmPromiseTemplate<media::KeyIdsVector> WebKeyIdsPromise;
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698