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_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_H_ |
6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_H_ | 6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "media/base/media_keys.h" | 10 #include "media/base/media_keys.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 uint32_t system_code, | 67 uint32_t system_code, |
68 const mojo::String& error_message) final; | 68 const mojo::String& error_message) final; |
69 void OnSessionKeysChange( | 69 void OnSessionKeysChange( |
70 const mojo::String& session_id, | 70 const mojo::String& session_id, |
71 bool has_additional_usable_key, | 71 bool has_additional_usable_key, |
72 mojo::Array<mojo::CdmKeyInformationPtr> keys_info) final; | 72 mojo::Array<mojo::CdmKeyInformationPtr> keys_info) final; |
73 void OnSessionExpirationUpdate(const mojo::String& session_id, | 73 void OnSessionExpirationUpdate(const mojo::String& session_id, |
74 int64_t new_expiry_time_usec) final; | 74 int64_t new_expiry_time_usec) final; |
75 | 75 |
76 // Callbacks to handle CDM promises. | 76 // Callbacks to handle CDM promises. |
| 77 // We have to inline this method, since MS VS 2013 compiler fails to compile |
| 78 // it when this method is not inlined. It fails with error C2244 |
| 79 // "unable to match function definition to an existing declaration". |
77 template <typename... T> | 80 template <typename... T> |
78 void OnPromiseResult(scoped_ptr<CdmPromiseTemplate<T...>> promise, | 81 void OnPromiseResult(scoped_ptr<CdmPromiseTemplate<T...>> promise, |
79 mojo::CdmPromiseResultPtr result, | 82 mojo::CdmPromiseResultPtr result, |
80 typename MojoTypeTrait<T>::MojoType... args); | 83 typename MojoTypeTrait<T>::MojoType... args) { |
| 84 if (result->success) |
| 85 promise->resolve(args.template To<T>()...); // See ISO C++03 14.2/4. |
| 86 else |
| 87 RejectPromise(promise.Pass(), result.Pass()); |
| 88 } |
81 | 89 |
82 mojo::ContentDecryptionModulePtr remote_cdm_; | 90 mojo::ContentDecryptionModulePtr remote_cdm_; |
83 | 91 |
84 // Callbacks for firing session events. | 92 // Callbacks for firing session events. |
85 SessionMessageCB session_message_cb_; | 93 SessionMessageCB session_message_cb_; |
86 SessionClosedCB session_closed_cb_; | 94 SessionClosedCB session_closed_cb_; |
87 SessionErrorCB session_error_cb_; | 95 SessionErrorCB session_error_cb_; |
88 SessionKeysChangeCB session_keys_change_cb_; | 96 SessionKeysChangeCB session_keys_change_cb_; |
89 SessionExpirationUpdateCB session_expiration_update_cb_; | 97 SessionExpirationUpdateCB session_expiration_update_cb_; |
90 | 98 |
91 base::WeakPtrFactory<MojoCdm> weak_factory_; | 99 base::WeakPtrFactory<MojoCdm> weak_factory_; |
92 | 100 |
93 DISALLOW_COPY_AND_ASSIGN(MojoCdm); | 101 DISALLOW_COPY_AND_ASSIGN(MojoCdm); |
94 }; | 102 }; |
95 | 103 |
96 } // namespace media | 104 } // namespace media |
97 | 105 |
98 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_H_ | 106 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_H_ |
OLD | NEW |