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
3 // found in the LICENSE file.
5 #include "media/blink/cdm_result_promise_helper.h"
7 #include "base/logging.h"
8 #include "base/metrics/histogram.h"
12 CdmResultForUMA
ConvertCdmExceptionToResultForUMA(
13 MediaKeys::Exception exception_code
) {
14 switch (exception_code
) {
15 case MediaKeys::NOT_SUPPORTED_ERROR
:
16 return NOT_SUPPORTED_ERROR
;
17 case MediaKeys::INVALID_STATE_ERROR
:
18 return INVALID_STATE_ERROR
;
19 case MediaKeys::INVALID_ACCESS_ERROR
:
20 return INVALID_ACCESS_ERROR
;
21 case MediaKeys::QUOTA_EXCEEDED_ERROR
:
22 return QUOTA_EXCEEDED_ERROR
;
23 case MediaKeys::UNKNOWN_ERROR
:
25 case MediaKeys::CLIENT_ERROR
:
27 case MediaKeys::OUTPUT_ERROR
:
34 blink::WebContentDecryptionModuleException
ConvertCdmException(
35 MediaKeys::Exception exception_code
) {
36 switch (exception_code
) {
37 case MediaKeys::NOT_SUPPORTED_ERROR
:
38 return blink::WebContentDecryptionModuleExceptionNotSupportedError
;
39 case MediaKeys::INVALID_STATE_ERROR
:
40 return blink::WebContentDecryptionModuleExceptionInvalidStateError
;
41 case MediaKeys::INVALID_ACCESS_ERROR
:
42 return blink::WebContentDecryptionModuleExceptionInvalidAccessError
;
43 case MediaKeys::QUOTA_EXCEEDED_ERROR
:
44 return blink::WebContentDecryptionModuleExceptionQuotaExceededError
;
45 case MediaKeys::UNKNOWN_ERROR
:
46 return blink::WebContentDecryptionModuleExceptionUnknownError
;
47 case MediaKeys::CLIENT_ERROR
:
48 return blink::WebContentDecryptionModuleExceptionClientError
;
49 case MediaKeys::OUTPUT_ERROR
:
50 return blink::WebContentDecryptionModuleExceptionOutputError
;
53 return blink::WebContentDecryptionModuleExceptionUnknownError
;
56 void ReportCdmResultUMA(const std::string
& uma_name
, CdmResultForUMA result
) {
60 base::LinearHistogram::FactoryGet(
65 base::HistogramBase::kUmaTargetedHistogramFlag
)->Add(result
);