summaryrefslogtreecommitdiffstats
path: root/media/blink/cdm_result_promise_helper.h
blob: e2a67c3f904e7e682a104f987ef5e44aa003dd61 (plain)
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
// 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.

#ifndef MEDIA_BLINK_CDM_RESULT_PROMISE_HELPER_H_
#define MEDIA_BLINK_CDM_RESULT_PROMISE_HELPER_H_

#include <string>

#include "media/base/media_keys.h"
#include "media/blink/media_blink_export.h"
#include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"

namespace media {

// A superset of media::MediaKeys::Exception for UMA reporting. These values
// should never be changed as it will affect existing reporting, and must match
// the values for CdmPromiseResult in tools/metrics/histograms/histograms.xml.
enum CdmResultForUMA {
  SUCCESS = 0,
  NOT_SUPPORTED_ERROR = 1,
  INVALID_STATE_ERROR = 2,
  INVALID_ACCESS_ERROR = 3,
  QUOTA_EXCEEDED_ERROR = 4,
  UNKNOWN_ERROR = 5,
  CLIENT_ERROR = 6,
  OUTPUT_ERROR = 7,
  NUM_RESULT_CODES
};

MEDIA_BLINK_EXPORT CdmResultForUMA
ConvertCdmExceptionToResultForUMA(MediaKeys::Exception exception_code);

MEDIA_BLINK_EXPORT blink::WebContentDecryptionModuleException
ConvertCdmException(MediaKeys::Exception exception_code);

MEDIA_BLINK_EXPORT void ReportCdmResultUMA(const std::string& uma_name,
                                           CdmResultForUMA result);

}  // namespace media

#endif  // MEDIA_BLINK_CDM_RESULT_PROMISE_HELPER_H_