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 #include "media/base/cdm_promise_adapter.h" | 5 #include "media/base/cdm_promise_adapter.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "media/base/media_keys.h" | 9 #include "media/base/media_keys.h" |
8 | 10 |
9 namespace media { | 11 namespace media { |
10 | 12 |
11 CdmPromiseAdapter::CdmPromiseAdapter() : next_promise_id_(1) { | 13 CdmPromiseAdapter::CdmPromiseAdapter() : next_promise_id_(1) { |
12 } | 14 } |
13 | 15 |
14 CdmPromiseAdapter::~CdmPromiseAdapter() { | 16 CdmPromiseAdapter::~CdmPromiseAdapter() { |
15 DCHECK(promises_.empty()); | 17 DCHECK(promises_.empty()); |
16 DCHECK(thread_checker_.CalledOnValidThread()); | 18 DCHECK(thread_checker_.CalledOnValidThread()); |
17 Clear(); | 19 Clear(); |
18 } | 20 } |
19 | 21 |
20 uint32_t CdmPromiseAdapter::SavePromise(scoped_ptr<CdmPromise> promise) { | 22 uint32_t CdmPromiseAdapter::SavePromise(scoped_ptr<CdmPromise> promise) { |
21 DCHECK(thread_checker_.CalledOnValidThread()); | 23 DCHECK(thread_checker_.CalledOnValidThread()); |
22 uint32_t promise_id = next_promise_id_++; | 24 uint32_t promise_id = next_promise_id_++; |
23 promises_.add(promise_id, promise.Pass()); | 25 promises_.add(promise_id, std::move(promise)); |
24 return promise_id; | 26 return promise_id; |
25 } | 27 } |
26 | 28 |
27 template <typename... T> | 29 template <typename... T> |
28 void CdmPromiseAdapter::ResolvePromise(uint32_t promise_id, | 30 void CdmPromiseAdapter::ResolvePromise(uint32_t promise_id, |
29 const T&... result) { | 31 const T&... result) { |
30 scoped_ptr<CdmPromise> promise = TakePromise(promise_id); | 32 scoped_ptr<CdmPromise> promise = TakePromise(promise_id); |
31 if (!promise) { | 33 if (!promise) { |
32 NOTREACHED() << "Promise not found for " << promise_id; | 34 NOTREACHED() << "Promise not found for " << promise_id; |
33 return; | 35 return; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return promises_.take_and_erase(it); | 75 return promises_.take_and_erase(it); |
74 } | 76 } |
75 | 77 |
76 // Explicit instantiation of function templates. | 78 // Explicit instantiation of function templates. |
77 template MEDIA_EXPORT void CdmPromiseAdapter::ResolvePromise(uint32_t); | 79 template MEDIA_EXPORT void CdmPromiseAdapter::ResolvePromise(uint32_t); |
78 template MEDIA_EXPORT void CdmPromiseAdapter::ResolvePromise( | 80 template MEDIA_EXPORT void CdmPromiseAdapter::ResolvePromise( |
79 uint32_t, | 81 uint32_t, |
80 const std::string&); | 82 const std::string&); |
81 | 83 |
82 } // namespace media | 84 } // namespace media |
OLD | NEW |