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

Unified Diff: media/base/cdm_callback_promise.cc

Issue 604283003: Refactor CdmPromise and related classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Variadic Templates 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: media/base/cdm_callback_promise.cc
diff --git a/media/base/cdm_callback_promise.cc b/media/base/cdm_callback_promise.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a10af3f4529f2683ad604d4496439dde34dfea48
--- /dev/null
+++ b/media/base/cdm_callback_promise.cc
@@ -0,0 +1,45 @@
+// 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.
+
+#include "media/base/cdm_callback_promise.h"
+
+#include "base/logging.h"
+
+namespace media {
+
+template <typename... T>
+CdmCallbackPromise<T...>::CdmCallbackPromise(
+ base::Callback<void(const T&...)> resolve_cb,
+ PromiseRejectedCB reject_cb)
+ : CdmPromiseTemplate<T...>(),
xhwang 2014/10/03 07:34:21 is this necessary?
jrummell 2014/10/03 18:58:30 Removed.
+ resolve_cb_(resolve_cb),
+ reject_cb_(reject_cb) {
+ DCHECK(!resolve_cb_.is_null());
+ DCHECK(!reject_cb_.is_null());
+}
+
+template <typename... T>
+CdmCallbackPromise<T...>::~CdmCallbackPromise() {
+}
+
+template <typename... T>
+void CdmCallbackPromise<T...>::resolve(const T&... result) {
+ this->PromiseSettled();
xhwang 2014/10/03 07:34:21 ditto
jrummell 2014/10/03 18:58:30 Done.
+ resolve_cb_.Run(result...);
+}
+
+template <typename... T>
+void CdmCallbackPromise<T...>::reject(MediaKeys::Exception exception_code,
+ uint32 system_code,
+ const std::string& error_message) {
+ this->PromiseSettled();
+ reject_cb_.Run(exception_code, system_code, error_message);
+}
+
+// Explicit template instantiation for the Promises needed.
+template class MEDIA_EXPORT CdmCallbackPromise<>;
+template class MEDIA_EXPORT CdmCallbackPromise<std::string>;
+template class MEDIA_EXPORT CdmCallbackPromise<KeyIdsVector>;
+
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698