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

Unified Diff: media/base/cdm_promise.h

Issue 567123002: Cleanup template in CdmPromise (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ReportResultToUMA 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
« no previous file with comments | « no previous file | media/base/cdm_promise.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/cdm_promise.h
diff --git a/media/base/cdm_promise.h b/media/base/cdm_promise.h
index 33ec042510c841baa7d6715dff94440d57032642..8e6703d0c7dd63c7074f272725781c73d0804d98 100644
--- a/media/base/cdm_promise.h
+++ b/media/base/cdm_promise.h
@@ -56,89 +56,74 @@ class MEDIA_EXPORT CdmPromise {
uint32 system_code,
const std::string& error_message);
- virtual ResolveParameterType GetResolveParameterType() const = 0;
+ ResolveParameterType GetResolveParameterType() const {
+ return parameter_type_;
+ }
protected:
- CdmPromise();
- CdmPromise(PromiseRejectedCB reject_cb);
+ explicit CdmPromise(ResolveParameterType parameter_type);
+ CdmPromise(ResolveParameterType parameter_type, PromiseRejectedCB reject_cb);
xhwang 2014/09/22 20:55:31 In another CL, pass callbacks by const-ref?
jrummell 2014/09/22 23:57:32 Acknowledged.
// If constructed with a |uma_name| (which must be the name of a
// CdmPromiseResult UMA), CdmPromise will report the promise result (success
// or rejection code).
- CdmPromise(PromiseRejectedCB reject_cb, const std::string& uma_name);
+ CdmPromise(ResolveParameterType parameter_type,
+ PromiseRejectedCB reject_cb,
+ const std::string& uma_name);
+ // Called by all resolve()/reject() methods to report the UMA result if
+ // applicable, and update |is_pending_|.
+ void ReportResultToUMA(ResultCodeForUMA result);
+
+ const ResolveParameterType parameter_type_;
PromiseRejectedCB reject_cb_;
// Keep track of whether the promise hasn't been resolved or rejected yet.
bool is_pending_;
- // UMA to report result to.
+ // UMA name to report result to.
std::string uma_name_;
DISALLOW_COPY_AND_ASSIGN(CdmPromise);
};
-// Specialization for no parameter to resolve().
-template <>
-class MEDIA_EXPORT CdmPromiseTemplate<void> : public CdmPromise {
+template <typename T>
+class MEDIA_EXPORT CdmPromiseTemplate : public CdmPromise {
public:
- CdmPromiseTemplate(base::Callback<void(void)> resolve_cb,
+ CdmPromiseTemplate(base::Callback<void(const T&)> resolve_cb,
PromiseRejectedCB rejected_cb);
xhwang 2014/09/22 20:55:31 ditto: pass both callbacks in const-ref?
jrummell 2014/09/22 23:57:32 Acknowledged.
- CdmPromiseTemplate(base::Callback<void(void)> resolve_cb,
+ CdmPromiseTemplate(base::Callback<void(const T&)> resolve_cb,
PromiseRejectedCB rejected_cb,
const std::string& uma_name);
- virtual ~CdmPromiseTemplate();
- virtual void resolve();
- virtual ResolveParameterType GetResolveParameterType() const OVERRIDE;
+ virtual void resolve(const T& result);
protected:
// Allow subclasses to completely override the implementation.
CdmPromiseTemplate();
private:
- base::Callback<void(void)> resolve_cb_;
+ base::Callback<void(const T&)> resolve_cb_;
DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate);
};
+// Specialization for no parameter to resolve().
template <>
-class MEDIA_EXPORT CdmPromiseTemplate<std::string> : public CdmPromise {
+class MEDIA_EXPORT CdmPromiseTemplate<void> : public CdmPromise {
public:
- CdmPromiseTemplate(base::Callback<void(const std::string&)> resolve_cb,
+ CdmPromiseTemplate(base::Callback<void(void)> resolve_cb,
PromiseRejectedCB rejected_cb);
- CdmPromiseTemplate(base::Callback<void(const std::string&)> resolve_cb,
+ CdmPromiseTemplate(base::Callback<void(void)> resolve_cb,
PromiseRejectedCB rejected_cb,
const std::string& uma_name);
- virtual ~CdmPromiseTemplate();
- virtual void resolve(const std::string& result);
- virtual ResolveParameterType GetResolveParameterType() const OVERRIDE;
+ virtual void resolve();
protected:
// Allow subclasses to completely override the implementation.
- // TODO(jrummell): Remove when derived class SessionLoadedPromise
- // (in ppapi_decryptor.cc) is no longer needed.
CdmPromiseTemplate();
private:
- base::Callback<void(const std::string&)> resolve_cb_;
-
- DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate);
-};
-
-template <>
-class MEDIA_EXPORT CdmPromiseTemplate<KeyIdsVector> : public CdmPromise {
- public:
- CdmPromiseTemplate(base::Callback<void(const KeyIdsVector&)> resolve_cb,
- PromiseRejectedCB rejected_cb);
- CdmPromiseTemplate(base::Callback<void(const KeyIdsVector&)> resolve_cb,
- PromiseRejectedCB rejected_cb,
- const std::string& uma_name);
- virtual ~CdmPromiseTemplate();
- virtual void resolve(const KeyIdsVector& result);
- virtual ResolveParameterType GetResolveParameterType() const OVERRIDE;
-
- private:
- base::Callback<void(const KeyIdsVector&)> resolve_cb_;
+ base::Callback<void(void)> resolve_cb_;
DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate);
};
« no previous file with comments | « no previous file | media/base/cdm_promise.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698