1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_
6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_
10 #include "base/functional/callback.h"
11 #include "media/base/cdm_promise.h"
15 // media::CdmPromiseTemplate implementations backed by base::Callbacks.
16 // TODO(xhwang): We need a new type F to solve the issue where parameters in the
17 // callback can be passed in by value or as const-refs. Find a better solution
19 template <typename F, typename... T>
20 class MojoCdmPromise final : public CdmPromiseTemplate<T...> {
22 using CallbackType = base::OnceCallback<F>;
24 explicit MojoCdmPromise(CallbackType callback);
25 ~MojoCdmPromise() final;
27 // CdmPromiseTemplate<> implementation.
29 void resolve(const T&... result) final;
30 void reject(CdmPromise::Exception exception,
32 const std::string& error_message) final;
35 using CdmPromiseTemplate<T...>::IsPromiseSettled;
36 using CdmPromiseTemplate<T...>::MarkPromiseSettled;
37 using CdmPromiseTemplate<T...>::RejectPromiseOnDestruction;
39 CallbackType callback_;
44 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_