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

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

Issue 555223004: Update MediaKeys interface for EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: base::Time 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/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..77cc9926929e1e70e0fdb0dd6019c1ffb17f80c0
--- /dev/null
+++ b/content/renderer/media/cdm_result_promise.h
@@ -0,0 +1,73 @@
+// 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.
+// If constructed with a |uma_name| (which must be the name of a
+// CdmPromiseResult UMA), CdmResultPromise will report the promise result
+// (success or rejection code).
+template <typename T>
+class CdmResultPromise : public media::CdmPromiseTemplate<T> {
+ public:
+ explicit CdmResultPromise(
+ const blink::WebContentDecryptionModuleResult& result);
+ CdmResultPromise(const blink::WebContentDecryptionModuleResult& result,
+ const std::string& uma_name);
+ ~CdmResultPromise();
xhwang 2014/09/25 21:01:52 virtual
jrummell 2014/09/25 21:25:54 Done.
+
+ protected:
+ // OnResolve() is virtual as it needs to be overridden and handled differently
+ // when a new session is created.
ddorwin 2014/09/25 20:54:05 nit: The base class shouldn't have such details. I
jrummell 2014/09/25 21:25:54 Done.
+ virtual void OnResolve(const T& result);
+ void OnReject(media::MediaKeys::Exception exception_code,
+ uint32 system_code,
+ const std::string& error_message);
+
+ blink::WebContentDecryptionModuleResult web_cdm_result_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CdmResultPromise);
+};
+
+// Specialization for no parameter to resolve().
+template <>
+class CdmResultPromise<void> : public media::CdmPromiseTemplate<void> {
+ public:
+ explicit CdmResultPromise(
+ const blink::WebContentDecryptionModuleResult& result);
+ CdmResultPromise(const blink::WebContentDecryptionModuleResult& result,
+ const std::string& uma_name);
+ ~CdmResultPromise();
xhwang 2014/09/25 21:01:52 virtual
jrummell 2014/09/25 21:25:54 Done.
+
+ protected:
+ virtual void OnResolve();
+ void OnReject(media::MediaKeys::Exception exception_code,
+ uint32 system_code,
+ const std::string& error_message);
+
+ blink::WebContentDecryptionModuleResult web_cdm_result_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CdmResultPromise);
+};
+
+typedef CdmResultPromise<void> SimpleCdmResultPromise;
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_CDM_RESULT_PROMISE_H_

Powered by Google App Engine
This is Rietveld 408576698