| 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.h" | 5 #include "media/base/cdm_promise.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 | 10 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 template <typename T> | 74 template <typename T> |
| 75 CdmPromiseTemplate<T>::CdmPromiseTemplate( | 75 CdmPromiseTemplate<T>::CdmPromiseTemplate( |
| 76 base::Callback<void(const T&)> resolve_cb, | 76 base::Callback<void(const T&)> resolve_cb, |
| 77 PromiseRejectedCB reject_cb, | 77 PromiseRejectedCB reject_cb, |
| 78 const std::string& uma_name) | 78 const std::string& uma_name) |
| 79 : CdmPromise(reject_cb, uma_name), resolve_cb_(resolve_cb) { | 79 : CdmPromise(reject_cb, uma_name), resolve_cb_(resolve_cb) { |
| 80 DCHECK(!resolve_cb_.is_null()); | 80 DCHECK(!resolve_cb_.is_null()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 template <typename T> | 83 template <typename T> |
| 84 CdmPromiseTemplate<T>::CdmPromiseTemplate() { |
| 85 } |
| 86 |
| 87 template <typename T> |
| 84 CdmPromiseTemplate<T>::~CdmPromiseTemplate() { | 88 CdmPromiseTemplate<T>::~CdmPromiseTemplate() { |
| 85 DCHECK(!is_pending_); | 89 DCHECK(!is_pending_); |
| 86 } | 90 } |
| 87 | 91 |
| 88 template <typename T> | 92 template <typename T> |
| 89 void CdmPromiseTemplate<T>::resolve(const T& result) { | 93 void CdmPromiseTemplate<T>::resolve(const T& result) { |
| 90 DCHECK(is_pending_); | 94 DCHECK(is_pending_); |
| 91 is_pending_ = false; | 95 is_pending_ = false; |
| 92 if (!uma_name_.empty()) { | 96 if (!uma_name_.empty()) { |
| 93 base::LinearHistogram::FactoryGet( | 97 base::LinearHistogram::FactoryGet( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 124 if (!uma_name_.empty()) { | 128 if (!uma_name_.empty()) { |
| 125 base::LinearHistogram::FactoryGet( | 129 base::LinearHistogram::FactoryGet( |
| 126 uma_name_, 1, NUM_RESULT_CODES, NUM_RESULT_CODES + 1, | 130 uma_name_, 1, NUM_RESULT_CODES, NUM_RESULT_CODES + 1, |
| 127 base::HistogramBase::kUmaTargetedHistogramFlag)->Add(SUCCESS); | 131 base::HistogramBase::kUmaTargetedHistogramFlag)->Add(SUCCESS); |
| 128 } | 132 } |
| 129 resolve_cb_.Run(); | 133 resolve_cb_.Run(); |
| 130 } | 134 } |
| 131 | 135 |
| 132 // Explicit template instantiation for the Promises needed. | 136 // Explicit template instantiation for the Promises needed. |
| 133 template class MEDIA_EXPORT CdmPromiseTemplate<std::string>; | 137 template class MEDIA_EXPORT CdmPromiseTemplate<std::string>; |
| 138 template class MEDIA_EXPORT CdmPromiseTemplate<KeyIdsVector>; |
| 134 | 139 |
| 135 } // namespace media | 140 } // namespace media |
| OLD | NEW |