blob: 8c36e0b174794bfa796013f32cdeef8aa217fbf4 [file] [log] [blame]
jrummell87a2db52015-05-05 22:27:181// Copyright 2015 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
xhwangfa492ce92015-06-12 22:56:235#include "media/base/cdm_initialized_promise.h"
jrummell87a2db52015-05-05 22:27:186
xhwangfa492ce92015-06-12 22:56:237namespace media {
jrummell87a2db52015-05-05 22:27:188
xhwangb24facb2015-11-03 02:09:279CdmInitializedPromise::CdmInitializedPromise(
tzikb13657f2017-06-12 10:53:2310 CdmCreatedCB cdm_created_cb,
11 scoped_refptr<ContentDecryptionModule> cdm)
12 : cdm_created_cb_(std::move(cdm_created_cb)), cdm_(std::move(cdm)) {}
jrummell87a2db52015-05-05 22:27:1813
Chris Watkins2de69292017-12-01 03:08:0114CdmInitializedPromise::~CdmInitializedPromise() = default;
jrummell87a2db52015-05-05 22:27:1815
16void CdmInitializedPromise::resolve() {
17 MarkPromiseSettled();
tzikb13657f2017-06-12 10:53:2318 std::move(cdm_created_cb_).Run(cdm_, "");
jrummell87a2db52015-05-05 22:27:1819}
20
corona101f1c7d32016-10-27 17:08:1021void CdmInitializedPromise::reject(CdmPromise::Exception exception_code,
Avi Drissman97785ea2015-12-19 01:11:3122 uint32_t system_code,
jrummell87a2db52015-05-05 22:27:1823 const std::string& error_message) {
24 MarkPromiseSettled();
tzikb13657f2017-06-12 10:53:2325 std::move(cdm_created_cb_).Run(nullptr, error_message);
xhwangfa492ce92015-06-12 22:56:2326 // Usually after this |this| (and the |cdm_| within it) will be destroyed.
jrummell87a2db52015-05-05 22:27:1827}
28
xhwangfa492ce92015-06-12 22:56:2329} // namespace media