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

Unified Diff: media/mojo/services/mojo_cdm_promise.h

Issue 763883006: Add Mojo CDM Service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add more comments. Created 6 years 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: media/mojo/services/mojo_cdm_promise.h
diff --git a/media/mojo/services/mojo_cdm_promise.h b/media/mojo/services/mojo_cdm_promise.h
new file mode 100644
index 0000000000000000000000000000000000000000..089c0db2b169238e88506d4eee9eec446bd95220
--- /dev/null
+++ b/media/mojo/services/mojo_cdm_promise.h
@@ -0,0 +1,59 @@
+// 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 MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_
+#define MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "media/base/cdm_promise.h"
+#include "media/mojo/interfaces/content_decryption_module.mojom.h"
+#include "mojo/public/cpp/bindings/interface_impl.h"
+
+namespace media {
+
+// media::CdmPromiseTemplate implementations backed by mojo::Callbacks.
+
+// Note: Variadic template was considered, but two parameter packs are not
ddorwin 2014/12/08 23:46:49 As discussed, see if you can use traits.
xhwang 2014/12/10 04:59:16 Done.
+// allowed. There are ways to work around this but those end up with more
+// complicated implementation.
+
+class SimpleMojoCdmPromise : public media::CdmPromiseTemplate<> {
+ public:
+ SimpleMojoCdmPromise(
+ const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback);
+ ~SimpleMojoCdmPromise() final;
+
+ // CdmPromiseTemplate<> implementation.
+ void resolve() final;
+ void reject(MediaKeys::Exception exception_code,
+ uint32 system_code,
+ const std::string& error_message) final;
+
+ private:
+ mojo::Callback<void(mojo::CdmPromiseResultPtr)> callback_;
+};
+
+template <typename Type, typename MojoType>
+class MojoCdmPromise : public media::CdmPromiseTemplate<Type> {
+ public:
+ MojoCdmPromise(const mojo::Callback<void(mojo::CdmPromiseResultPtr,
+ MojoType)>& callback);
+ ~MojoCdmPromise() final;
+
+ // CdmPromiseTemplate<> implementation.
+ void resolve(const Type& arg) final;
+ void reject(MediaKeys::Exception exception_code,
+ uint32 system_code,
+ const std::string& error_message) final;
+
+ private:
+ mojo::Callback<void(mojo::CdmPromiseResultPtr, MojoType)> callback_;
+};
+
+} // namespace media
+
+#endif // MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_

Powered by Google App Engine
This is Rietveld 408576698