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.
5 #include "media/base/cdm_promise.h"
8 #include "base/logging.h"
12 CdmPromise::CdmPromise() : is_pending_(true) {
15 CdmPromise::CdmPromise(PromiseRejectedCB reject_cb
)
16 : reject_cb_(reject_cb
), is_pending_(true) {
17 DCHECK(!reject_cb_
.is_null());
20 CdmPromise::~CdmPromise() {
24 void CdmPromise::reject(MediaKeys::Exception exception_code
,
26 const std::string
& error_message
) {
29 reject_cb_
.Run(exception_code
, system_code
, error_message
);
33 CdmPromiseTemplate
<T
>::CdmPromiseTemplate(
34 base::Callback
<void(const T
&)> resolve_cb
,
35 PromiseRejectedCB reject_cb
)
36 : CdmPromise(reject_cb
), resolve_cb_(resolve_cb
) {
37 DCHECK(!resolve_cb_
.is_null());
41 CdmPromiseTemplate
<T
>::~CdmPromiseTemplate() {
46 void CdmPromiseTemplate
<T
>::resolve(const T
& result
) {
49 resolve_cb_
.Run(result
);
52 CdmPromiseTemplate
<void>::CdmPromiseTemplate(base::Callback
<void()> resolve_cb
,
53 PromiseRejectedCB reject_cb
)
54 : CdmPromise(reject_cb
), resolve_cb_(resolve_cb
) {
55 DCHECK(!resolve_cb_
.is_null());
58 CdmPromiseTemplate
<void>::CdmPromiseTemplate() {
61 CdmPromiseTemplate
<void>::~CdmPromiseTemplate() {
65 void CdmPromiseTemplate
<void>::resolve() {
71 // Explicit template instantiation for the Promises needed.
72 template class MEDIA_EXPORT CdmPromiseTemplate
<std::string
>;