jrummell | 87a2db5 | 2015-05-05 22:27:18 | [diff] [blame] | 1 | // 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 | |
xhwang | fa492ce9 | 2015-06-12 22:56:23 | [diff] [blame] | 5 | #include "media/base/cdm_initialized_promise.h" |
jrummell | 87a2db5 | 2015-05-05 22:27:18 | [diff] [blame] | 6 | |
xhwang | fa492ce9 | 2015-06-12 22:56:23 | [diff] [blame] | 7 | namespace media { |
jrummell | 87a2db5 | 2015-05-05 22:27:18 | [diff] [blame] | 8 | |
xhwang | b24facb | 2015-11-03 02:09:27 | [diff] [blame] | 9 | CdmInitializedPromise::CdmInitializedPromise( |
tzik | b13657f | 2017-06-12 10:53:23 | [diff] [blame] | 10 | CdmCreatedCB cdm_created_cb, |
| 11 | scoped_refptr<ContentDecryptionModule> cdm) |
| 12 | : cdm_created_cb_(std::move(cdm_created_cb)), cdm_(std::move(cdm)) {} |
jrummell | 87a2db5 | 2015-05-05 22:27:18 | [diff] [blame] | 13 | |
Chris Watkins | 2de6929 | 2017-12-01 03:08:01 | [diff] [blame] | 14 | CdmInitializedPromise::~CdmInitializedPromise() = default; |
jrummell | 87a2db5 | 2015-05-05 22:27:18 | [diff] [blame] | 15 | |
| 16 | void CdmInitializedPromise::resolve() { |
| 17 | MarkPromiseSettled(); |
tzik | b13657f | 2017-06-12 10:53:23 | [diff] [blame] | 18 | std::move(cdm_created_cb_).Run(cdm_, ""); |
jrummell | 87a2db5 | 2015-05-05 22:27:18 | [diff] [blame] | 19 | } |
| 20 | |
corona10 | 1f1c7d3 | 2016-10-27 17:08:10 | [diff] [blame] | 21 | void CdmInitializedPromise::reject(CdmPromise::Exception exception_code, |
Avi Drissman | 97785ea | 2015-12-19 01:11:31 | [diff] [blame] | 22 | uint32_t system_code, |
jrummell | 87a2db5 | 2015-05-05 22:27:18 | [diff] [blame] | 23 | const std::string& error_message) { |
| 24 | MarkPromiseSettled(); |
tzik | b13657f | 2017-06-12 10:53:23 | [diff] [blame] | 25 | std::move(cdm_created_cb_).Run(nullptr, error_message); |
xhwang | fa492ce9 | 2015-06-12 22:56:23 | [diff] [blame] | 26 | // Usually after this |this| (and the |cdm_| within it) will be destroyed. |
jrummell | 87a2db5 | 2015-05-05 22:27:18 | [diff] [blame] | 27 | } |
| 28 | |
xhwang | fa492ce9 | 2015-06-12 22:56:23 | [diff] [blame] | 29 | } // namespace media |