| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_ |
| 6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_ | 6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "media/base/cdm_promise.h" | 12 #include "media/base/cdm_promise.h" |
| 13 #include "media/mojo/common/mojo_type_trait.h" | |
| 14 #include "media/mojo/interfaces/content_decryption_module.mojom.h" | 13 #include "media/mojo/interfaces/content_decryption_module.mojom.h" |
| 15 | 14 |
| 16 namespace media { | 15 namespace media { |
| 17 | 16 |
| 18 // media::CdmPromiseTemplate implementations backed by base::Callbacks. | 17 // media::CdmPromiseTemplate implementations backed by base::Callbacks. |
| 19 template <typename... T> | 18 template <typename... T> |
| 20 class MojoCdmPromise : public CdmPromiseTemplate<T...> { | 19 class MojoCdmPromise : public CdmPromiseTemplate<T...> { |
| 21 public: | 20 public: |
| 22 typedef base::Callback<void(mojom::CdmPromiseResultPtr, | 21 using CallbackType = |
| 23 typename MojoTypeTrait<T>::MojoType...)> | 22 base::Callback<void(mojom::CdmPromiseResultPtr, const T&...)>; |
| 24 CallbackType; | |
| 25 | 23 |
| 26 MojoCdmPromise(const CallbackType& callback); | 24 explicit MojoCdmPromise(const CallbackType& callback); |
| 27 ~MojoCdmPromise() final; | 25 ~MojoCdmPromise() final; |
| 28 | 26 |
| 29 // CdmPromiseTemplate<> implementation. | 27 // CdmPromiseTemplate<> implementation. |
| 30 void resolve(const T&... result) final; | 28 void resolve(const T&... result) final; |
| 31 void reject(MediaKeys::Exception exception, | 29 void reject(MediaKeys::Exception exception, |
| 32 uint32_t system_code, | 30 uint32_t system_code, |
| 33 const std::string& error_message) final; | 31 const std::string& error_message) final; |
| 34 | 32 |
| 35 private: | 33 private: |
| 36 using CdmPromiseTemplate<T...>::IsPromiseSettled; | 34 using CdmPromiseTemplate<T...>::IsPromiseSettled; |
| 37 using CdmPromiseTemplate<T...>::MarkPromiseSettled; | 35 using CdmPromiseTemplate<T...>::MarkPromiseSettled; |
| 38 using CdmPromiseTemplate<T...>::RejectPromiseOnDestruction; | 36 using CdmPromiseTemplate<T...>::RejectPromiseOnDestruction; |
| 39 | 37 |
| 40 CallbackType callback_; | 38 CallbackType callback_; |
| 41 }; | 39 }; |
| 42 | 40 |
| 43 } // namespace media | 41 } // namespace media |
| 44 | 42 |
| 45 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_ | 43 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_ |
| OLD | NEW |