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/mojo/services/mojo_cdm_promise.h" | 5 #include "media/mojo/services/mojo_cdm_promise.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 } | 33 } |
34 | 34 |
35 template <typename... T> | 35 template <typename... T> |
36 MojoCdmPromise<T...>::~MojoCdmPromise() { | 36 MojoCdmPromise<T...>::~MojoCdmPromise() { |
37 if (!callback_.is_null()) | 37 if (!callback_.is_null()) |
38 DVLOG(1) << "Promise not resolved before destruction."; | 38 DVLOG(1) << "Promise not resolved before destruction."; |
39 } | 39 } |
40 | 40 |
41 template <typename... T> | 41 template <typename... T> |
42 void MojoCdmPromise<T...>::resolve(const T&... result) { | 42 void MojoCdmPromise<T...>::resolve(const T&... result) { |
| 43 MarkPromiseSettled(); |
43 mojo::CdmPromiseResultPtr cdm_promise_result(mojo::CdmPromiseResult::New()); | 44 mojo::CdmPromiseResultPtr cdm_promise_result(mojo::CdmPromiseResult::New()); |
44 cdm_promise_result->success = true; | 45 cdm_promise_result->success = true; |
45 callback_.Run(cdm_promise_result.Pass(), | 46 callback_.Run(cdm_promise_result.Pass(), |
46 MojoTypeTrait<T>::MojoType::From(result)...); | 47 MojoTypeTrait<T>::MojoType::From(result)...); |
47 callback_.reset(); | 48 callback_.reset(); |
48 } | 49 } |
49 | 50 |
50 template <typename... T> | 51 template <typename... T> |
51 void MojoCdmPromise<T...>::reject(MediaKeys::Exception exception, | 52 void MojoCdmPromise<T...>::reject(MediaKeys::Exception exception, |
52 uint32_t system_code, | 53 uint32_t system_code, |
53 const std::string& error_message) { | 54 const std::string& error_message) { |
| 55 MarkPromiseSettled(); |
54 callback_.Run(GetRejectResult(exception, system_code, error_message), | 56 callback_.Run(GetRejectResult(exception, system_code, error_message), |
55 MojoTypeTrait<T>::DefaultValue()...); | 57 MojoTypeTrait<T>::DefaultValue()...); |
56 callback_.reset(); | 58 callback_.reset(); |
57 } | 59 } |
58 | 60 |
59 template class MojoCdmPromise<>; | 61 template class MojoCdmPromise<>; |
60 template class MojoCdmPromise<std::string>; | 62 template class MojoCdmPromise<std::string>; |
61 | 63 |
62 } // namespace media | 64 } // namespace media |
OLD | NEW |