Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_ | |
| 6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "media/base/cdm_promise.h" | |
| 13 #include "media/mojo/interfaces/content_decryption_module.mojom.h" | |
| 14 #include "mojo/public/cpp/bindings/interface_impl.h" | |
| 15 | |
| 16 namespace media { | |
| 17 | |
| 18 // media::CdmPromiseTemplate implementations backed by mojo::Callbacks. | |
| 19 | |
| 20 // 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.
| |
| 21 // allowed. There are ways to work around this but those end up with more | |
| 22 // complicated implementation. | |
| 23 | |
| 24 class SimpleMojoCdmPromise : public media::CdmPromiseTemplate<> { | |
| 25 public: | |
| 26 SimpleMojoCdmPromise( | |
| 27 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback); | |
| 28 ~SimpleMojoCdmPromise() final; | |
| 29 | |
| 30 // CdmPromiseTemplate<> implementation. | |
| 31 void resolve() final; | |
| 32 void reject(MediaKeys::Exception exception_code, | |
| 33 uint32 system_code, | |
| 34 const std::string& error_message) final; | |
| 35 | |
| 36 private: | |
| 37 mojo::Callback<void(mojo::CdmPromiseResultPtr)> callback_; | |
| 38 }; | |
| 39 | |
| 40 template <typename Type, typename MojoType> | |
| 41 class MojoCdmPromise : public media::CdmPromiseTemplate<Type> { | |
| 42 public: | |
| 43 MojoCdmPromise(const mojo::Callback<void(mojo::CdmPromiseResultPtr, | |
| 44 MojoType)>& callback); | |
| 45 ~MojoCdmPromise() final; | |
| 46 | |
| 47 // CdmPromiseTemplate<> implementation. | |
| 48 void resolve(const Type& arg) final; | |
| 49 void reject(MediaKeys::Exception exception_code, | |
| 50 uint32 system_code, | |
| 51 const std::string& error_message) final; | |
| 52 | |
| 53 private: | |
| 54 mojo::Callback<void(mojo::CdmPromiseResultPtr, MojoType)> callback_; | |
| 55 }; | |
| 56 | |
| 57 } // namespace media | |
| 58 | |
| 59 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_ | |
| OLD | NEW |