Chromium Code Reviews| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 is_pending_ = false; | 56 is_pending_ = false; |
| 57 if (!uma_name_.empty()) { | 57 if (!uma_name_.empty()) { |
| 58 ResultCodeForUMA result_code = ConvertExceptionToUMAResult(exception_code); | 58 ResultCodeForUMA result_code = ConvertExceptionToUMAResult(exception_code); |
| 59 base::LinearHistogram::FactoryGet( | 59 base::LinearHistogram::FactoryGet( |
| 60 uma_name_, 1, NUM_RESULT_CODES, NUM_RESULT_CODES + 1, | 60 uma_name_, 1, NUM_RESULT_CODES, NUM_RESULT_CODES + 1, |
| 61 base::HistogramBase::kUmaTargetedHistogramFlag)->Add(result_code); | 61 base::HistogramBase::kUmaTargetedHistogramFlag)->Add(result_code); |
| 62 } | 62 } |
| 63 reject_cb_.Run(exception_code, system_code, error_message); | 63 reject_cb_.Run(exception_code, system_code, error_message); |
| 64 } | 64 } |
| 65 | 65 |
| 66 CdmPromise::PromiseType CdmPromise::Type() { | |
| 67 return UNKNOWN_TYPE; | |
|
ddorwin
2014/08/25 22:55:01
This is a symptom. Either the value should be prov
jrummell
2014/08/26 00:19:23
Done.
| |
| 68 } | |
| 69 | |
| 66 template <typename T> | 70 template <typename T> |
| 67 CdmPromiseTemplate<T>::CdmPromiseTemplate( | 71 CdmPromiseTemplate<T>::CdmPromiseTemplate( |
| 68 base::Callback<void(const T&)> resolve_cb, | 72 base::Callback<void(const T&)> resolve_cb, |
| 69 PromiseRejectedCB reject_cb) | 73 PromiseRejectedCB reject_cb) |
| 70 : CdmPromise(reject_cb), resolve_cb_(resolve_cb) { | 74 : CdmPromise(reject_cb), resolve_cb_(resolve_cb) { |
| 71 DCHECK(!resolve_cb_.is_null()); | 75 DCHECK(!resolve_cb_.is_null()); |
| 72 } | 76 } |
| 73 | 77 |
| 74 template <typename T> | 78 template <typename T> |
| 75 CdmPromiseTemplate<T>::CdmPromiseTemplate( | 79 CdmPromiseTemplate<T>::CdmPromiseTemplate( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 DCHECK(is_pending_); | 130 DCHECK(is_pending_); |
| 127 is_pending_ = false; | 131 is_pending_ = false; |
| 128 if (!uma_name_.empty()) { | 132 if (!uma_name_.empty()) { |
| 129 base::LinearHistogram::FactoryGet( | 133 base::LinearHistogram::FactoryGet( |
| 130 uma_name_, 1, NUM_RESULT_CODES, NUM_RESULT_CODES + 1, | 134 uma_name_, 1, NUM_RESULT_CODES, NUM_RESULT_CODES + 1, |
| 131 base::HistogramBase::kUmaTargetedHistogramFlag)->Add(SUCCESS); | 135 base::HistogramBase::kUmaTargetedHistogramFlag)->Add(SUCCESS); |
| 132 } | 136 } |
| 133 resolve_cb_.Run(); | 137 resolve_cb_.Run(); |
| 134 } | 138 } |
| 135 | 139 |
| 140 CdmPromise::PromiseType CdmPromiseTemplate<void>::Type() { | |
| 141 return SIMPLE_TYPE; | |
|
ddorwin
2014/08/25 22:55:01
Per previous comments, move these to the construct
jrummell
2014/08/26 00:19:23
Since these are templates, hard to do. Changed to
| |
| 142 } | |
| 143 | |
| 144 template <> | |
| 145 CdmPromise::PromiseType CdmPromiseTemplate<std::string>::Type() { | |
| 146 return NEW_SESSION_TYPE; | |
| 147 } | |
| 148 | |
| 149 template <> | |
| 150 CdmPromise::PromiseType CdmPromiseTemplate<KeyIdsVector>::Type() { | |
| 151 return KEY_IDS_TYPE; | |
| 152 } | |
| 153 | |
| 136 // Explicit template instantiation for the Promises needed. | 154 // Explicit template instantiation for the Promises needed. |
| 137 template class MEDIA_EXPORT CdmPromiseTemplate<std::string>; | 155 template class MEDIA_EXPORT CdmPromiseTemplate<std::string>; |
| 138 template class MEDIA_EXPORT CdmPromiseTemplate<KeyIdsVector>; | 156 template class MEDIA_EXPORT CdmPromiseTemplate<KeyIdsVector>; |
| 139 | 157 |
| 140 } // namespace media | 158 } // namespace media |
| OLD | NEW |