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

Unified Diff: content/renderer/media/cdm_result_promise.h

Issue 604283003: Refactor CdmPromise and related classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Variadic Templates Created 6 years, 3 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
Index: content/renderer/media/cdm_result_promise.h
diff --git a/content/renderer/media/cdm_result_promise.h b/content/renderer/media/cdm_result_promise.h
index 39bcc0d0e7f1962130019fc5f61a7b22579f2e1d..f987ac4fec5d2d850f40631d152807ee5ad95efa 100644
--- a/content/renderer/media/cdm_result_promise.h
+++ b/content/renderer/media/cdm_result_promise.h
@@ -13,59 +13,52 @@
namespace content {
-// Used to convert a WebContentDecryptionModuleResult into a CdmPromise so that
-// it can be passed through Chromium. When CdmPromise::resolve(T) is called,
-// OnResolve(T) will be called and will call the appropriate complete...()
-// method on WebContentDecryptionModuleResult. If CdmPromise::reject() is called
-// instead, WebContentDecryptionModuleResult::completeWithError() is called.
-// If constructed with a |uma_name| (which must be the name of a
-// CdmPromiseResult UMA), CdmResultPromise will report the promise result
-// (success or rejection code).
-template <typename T>
-class CdmResultPromise : public media::CdmPromiseTemplate<T> {
- public:
- explicit CdmResultPromise(
- const blink::WebContentDecryptionModuleResult& result);
- CdmResultPromise(const blink::WebContentDecryptionModuleResult& result,
- const std::string& uma_name);
- virtual ~CdmResultPromise();
-
- protected:
- // OnResolve() is virtual as it may need special handling in derived classes.
- virtual void OnResolve(const T& result);
- void OnReject(media::MediaKeys::Exception exception_code,
- uint32 system_code,
- const std::string& error_message);
-
- blink::WebContentDecryptionModuleResult web_cdm_result_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CdmResultPromise);
+// 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 ResultCodeForUMA {
+ 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
};
-// Specialization for no parameter to resolve().
-template <>
-class CdmResultPromise<void> : public media::CdmPromiseTemplate<void> {
+// Used to convert a WebContentDecryptionModuleResult into a CdmPromiseTemplate
+// so that it can be passed through Chromium. When resolve(T) is called, the
+// appropriate complete...() method on WebContentDecryptionModuleResult will be
+// invoked. If reject() is called instead,
+// WebContentDecryptionModuleResult::completeWithError() is called.
+// If constructed with a |uma_name|, CdmResultPromise will report the promise
+// result (success or rejection code) to UMA.
+template <typename... T>
+class CdmResultPromise : public media::CdmPromiseTemplate<T...> {
xhwang 2014/10/03 07:34:21 Cool!
jrummell 2014/10/03 18:58:30 Acknowledged. I like it too.
public:
- explicit CdmResultPromise(
- const blink::WebContentDecryptionModuleResult& result);
CdmResultPromise(const blink::WebContentDecryptionModuleResult& result,
const std::string& uma_name);
virtual ~CdmResultPromise();
- protected:
- virtual void OnResolve();
- void OnReject(media::MediaKeys::Exception exception_code,
- uint32 system_code,
- const std::string& error_message);
+ // CdmPromiseTemplate<T> implementation.
+ virtual void resolve(const T&... result) OVERRIDE;
+ virtual void reject(media::MediaKeys::Exception exception_code,
+ uint32 system_code,
+ const std::string& error_message) OVERRIDE;
+ protected:
blink::WebContentDecryptionModuleResult web_cdm_result_;
private:
xhwang 2014/10/03 07:34:21 You can have this here: using media::CdmPromiseTe
jrummell 2014/10/03 18:58:30 Done.
+ // UMA name to report result to.
+ std::string uma_name_;
+
DISALLOW_COPY_AND_ASSIGN(CdmResultPromise);
};
-typedef CdmResultPromise<void> SimpleCdmResultPromise;
+typedef CdmResultPromise<> SimpleCdmResultPromise;
} // namespace content
« no previous file with comments | « no previous file | content/renderer/media/cdm_result_promise.cc » ('j') | content/renderer/media/cdm_result_promise.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698