suppress uninit error at WebEmbeddedWorkerImpl::startWorkerContext
[chromium-blink-merge.git] / media / base / cdm_promise.cc
blobec5e913dbb8aae93c90aa30a24835aaa1a3cc3e8
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"
7 #include "base/bind.h"
8 #include "base/logging.h"
10 namespace media {
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() {
21 DCHECK(!is_pending_);
24 void CdmPromise::reject(MediaKeys::Exception exception_code,
25 uint32 system_code,
26 const std::string& error_message) {
27 DCHECK(is_pending_);
28 is_pending_ = false;
29 reject_cb_.Run(exception_code, system_code, error_message);
32 template <typename T>
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());
40 template <typename T>
41 CdmPromiseTemplate<T>::~CdmPromiseTemplate() {
42 DCHECK(!is_pending_);
45 template <typename T>
46 void CdmPromiseTemplate<T>::resolve(const T& result) {
47 DCHECK(is_pending_);
48 is_pending_ = false;
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() {
62 DCHECK(!is_pending_);
65 void CdmPromiseTemplate<void>::resolve() {
66 DCHECK(is_pending_);
67 is_pending_ = false;
68 resolve_cb_.Run();
71 // Explicit template instantiation for the Promises needed.
72 template class MEDIA_EXPORT CdmPromiseTemplate<std::string>;
74 } // namespace media