Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Unified Diff: media/blink/cdm_result_promise_helper.cc

Issue 651113002: Move CdmResultPromise to media/blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/blink/cdm_result_promise_helper.h ('k') | media/blink/media_blink.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/cdm_result_promise_helper.cc
diff --git a/media/blink/cdm_result_promise_helper.cc b/media/blink/cdm_result_promise_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c96121a0fed7aac94bb58165df4f8112e9b12b74
--- /dev/null
+++ b/media/blink/cdm_result_promise_helper.cc
@@ -0,0 +1,68 @@
+// 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(
+ MediaKeys::Exception exception_code) {
+ switch (exception_code) {
+ case MediaKeys::NOT_SUPPORTED_ERROR:
+ return NOT_SUPPORTED_ERROR;
+ case MediaKeys::INVALID_STATE_ERROR:
+ return INVALID_STATE_ERROR;
+ case MediaKeys::INVALID_ACCESS_ERROR:
+ return INVALID_ACCESS_ERROR;
+ case MediaKeys::QUOTA_EXCEEDED_ERROR:
+ return QUOTA_EXCEEDED_ERROR;
+ case MediaKeys::UNKNOWN_ERROR:
+ return UNKNOWN_ERROR;
+ case MediaKeys::CLIENT_ERROR:
+ return CLIENT_ERROR;
+ case MediaKeys::OUTPUT_ERROR:
+ return OUTPUT_ERROR;
+ }
+ NOTREACHED();
+ return UNKNOWN_ERROR;
+}
+
+blink::WebContentDecryptionModuleException ConvertCdmException(
+ MediaKeys::Exception exception_code) {
+ switch (exception_code) {
+ case MediaKeys::NOT_SUPPORTED_ERROR:
+ return blink::WebContentDecryptionModuleExceptionNotSupportedError;
+ case MediaKeys::INVALID_STATE_ERROR:
+ return blink::WebContentDecryptionModuleExceptionInvalidStateError;
+ case MediaKeys::INVALID_ACCESS_ERROR:
+ return blink::WebContentDecryptionModuleExceptionInvalidAccessError;
+ case MediaKeys::QUOTA_EXCEEDED_ERROR:
+ return blink::WebContentDecryptionModuleExceptionQuotaExceededError;
+ case MediaKeys::UNKNOWN_ERROR:
+ return blink::WebContentDecryptionModuleExceptionUnknownError;
+ case MediaKeys::CLIENT_ERROR:
+ return blink::WebContentDecryptionModuleExceptionClientError;
+ case MediaKeys::OUTPUT_ERROR:
+ return blink::WebContentDecryptionModuleExceptionOutputError;
+ }
+ NOTREACHED();
+ return blink::WebContentDecryptionModuleExceptionUnknownError;
+}
+
+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
« no previous file with comments | « media/blink/cdm_result_promise_helper.h ('k') | media/blink/media_blink.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698