forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcdm_result_promise_helper.cc
73 lines (63 loc) · 2.33 KB
/
cdm_result_promise_helper.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/blink/cdm_result_promise_helper.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
namespace media {
CdmResultForUMA ConvertCdmExceptionToResultForUMA(
CdmPromise::Exception exception_code) {
switch (exception_code) {
case CdmPromise::NOT_SUPPORTED_ERROR:
return NOT_SUPPORTED_ERROR;
case CdmPromise::INVALID_STATE_ERROR:
return INVALID_STATE_ERROR;
case CdmPromise::INVALID_ACCESS_ERROR:
return INVALID_ACCESS_ERROR;
case CdmPromise::QUOTA_EXCEEDED_ERROR:
return QUOTA_EXCEEDED_ERROR;
case CdmPromise::UNKNOWN_ERROR:
return UNKNOWN_ERROR;
case CdmPromise::CLIENT_ERROR:
return CLIENT_ERROR;
case CdmPromise::OUTPUT_ERROR:
return OUTPUT_ERROR;
}
NOTREACHED();
return UNKNOWN_ERROR;
}
blink::WebContentDecryptionModuleException ConvertCdmException(
CdmPromise::Exception exception_code) {
switch (exception_code) {
case CdmPromise::NOT_SUPPORTED_ERROR:
return blink::kWebContentDecryptionModuleExceptionNotSupportedError;
case CdmPromise::INVALID_STATE_ERROR:
return blink::kWebContentDecryptionModuleExceptionInvalidStateError;
// TODO(jrummell): Since InvalidAccess is not returned, thus should be
// renamed to TYPE_ERROR. http://crbug.com/570216#c11.
case CdmPromise::INVALID_ACCESS_ERROR:
return blink::kWebContentDecryptionModuleExceptionTypeError;
case CdmPromise::QUOTA_EXCEEDED_ERROR:
return blink::kWebContentDecryptionModuleExceptionQuotaExceededError;
case CdmPromise::UNKNOWN_ERROR:
return blink::kWebContentDecryptionModuleExceptionUnknownError;
// These are deprecated, and should be removed.
// http://crbug.com/570216#c11.
case CdmPromise::CLIENT_ERROR:
case CdmPromise::OUTPUT_ERROR:
break;
}
NOTREACHED();
return blink::kWebContentDecryptionModuleExceptionUnknownError;
}
void ReportCdmResultUMA(const std::string& uma_name, CdmResultForUMA result) {
if (uma_name.empty())
return;
base::LinearHistogram::FactoryGet(
uma_name,
1,
NUM_RESULT_CODES,
NUM_RESULT_CODES + 1,
base::HistogramBase::kUmaTargetedHistogramFlag)->Add(result);
}
} // namespace media