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

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: 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..0d80221b20072243bac9083b117ea5e0c47baa24 100644
--- a/media/base/cdm_promise.h
+++ b/media/base/cdm_promise.h
@@ -14,6 +14,8 @@
namespace media {
+typedef std::vector<std::vector<uint8> > KeyIdsVector;
+
// Interface for promises being resolved/rejected in response to various
// session actions. These may be called synchronously or asynchronously.
// The promise must be resolved or rejected exactly once. It is expected that
@@ -61,12 +63,21 @@ class MEDIA_EXPORT CdmPromise {
protected:
CdmPromise();
CdmPromise(PromiseRejectedCB reject_cb);
+ CdmPromise(const std::string& uma_name);
// 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);
+ // Called by all resolve() methods to do the check on |is_pending_|
+ // and call the UMA success if required.
+ void ResolveBase();
sandersd (OOO until July 31) 2014/09/16 00:42:54 As discussed, rename as ReportResolution().
+
+ // Called by all reject() methods to do the check on |is_pending_|
+ // and call the UMA with |exception_code| if required.
+ void RejectBase(MediaKeys::Exception exception_code);
+
PromiseRejectedCB reject_cb_;
// Keep track of whether the promise hasn't been resolved or rejected yet.
@@ -78,69 +89,68 @@ class MEDIA_EXPORT CdmPromise {
DISALLOW_COPY_AND_ASSIGN(CdmPromise);
};
-// Specialization for no parameter to resolve().
-template <>
-class MEDIA_EXPORT CdmPromiseTemplate<void> : public CdmPromise {
+// Used when there is no parameter to resolve().
+class MEDIA_EXPORT SimpleCdmPromise : public CdmPromise {
public:
- CdmPromiseTemplate(base::Callback<void(void)> resolve_cb,
- PromiseRejectedCB rejected_cb);
- CdmPromiseTemplate(base::Callback<void(void)> resolve_cb,
- PromiseRejectedCB rejected_cb,
- const std::string& uma_name);
- virtual ~CdmPromiseTemplate();
+ SimpleCdmPromise(base::Callback<void(void)> resolve_cb,
+ PromiseRejectedCB rejected_cb);
+ SimpleCdmPromise(base::Callback<void(void)> resolve_cb,
+ PromiseRejectedCB rejected_cb,
+ const std::string& uma_name);
+ virtual ~SimpleCdmPromise();
virtual void resolve();
virtual ResolveParameterType GetResolveParameterType() const OVERRIDE;
protected:
- // Allow subclasses to completely override the implementation.
- CdmPromiseTemplate();
+ SimpleCdmPromise();
+ SimpleCdmPromise(const std::string& uma_name);
private:
base::Callback<void(void)> resolve_cb_;
- DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate);
+ DISALLOW_COPY_AND_ASSIGN(SimpleCdmPromise);
};
-template <>
-class MEDIA_EXPORT CdmPromiseTemplate<std::string> : public CdmPromise {
+class MEDIA_EXPORT NewSessionCdmPromise : public CdmPromise {
public:
- CdmPromiseTemplate(base::Callback<void(const std::string&)> resolve_cb,
- PromiseRejectedCB rejected_cb);
- CdmPromiseTemplate(base::Callback<void(const std::string&)> resolve_cb,
- PromiseRejectedCB rejected_cb,
- const std::string& uma_name);
- virtual ~CdmPromiseTemplate();
+ NewSessionCdmPromise(base::Callback<void(const std::string&)> resolve_cb,
+ PromiseRejectedCB rejected_cb);
+ NewSessionCdmPromise(base::Callback<void(const std::string&)> resolve_cb,
+ PromiseRejectedCB rejected_cb,
+ const std::string& uma_name);
+ virtual ~NewSessionCdmPromise();
virtual void resolve(const std::string& result);
virtual ResolveParameterType GetResolveParameterType() const OVERRIDE;
protected:
- // Allow subclasses to completely override the implementation.
- // TODO(jrummell): Remove when derived class SessionLoadedPromise
- // (in ppapi_decryptor.cc) is no longer needed.
- CdmPromiseTemplate();
+ NewSessionCdmPromise();
+ NewSessionCdmPromise(const std::string& uma_name);
private:
base::Callback<void(const std::string&)> resolve_cb_;
- DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate);
+ DISALLOW_COPY_AND_ASSIGN(NewSessionCdmPromise);
};
-template <>
-class MEDIA_EXPORT CdmPromiseTemplate<KeyIdsVector> : public CdmPromise {
+class MEDIA_EXPORT KeyIdsPromise : 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();
+ KeyIdsPromise(base::Callback<void(const KeyIdsVector&)> resolve_cb,
+ PromiseRejectedCB rejected_cb);
+ KeyIdsPromise(base::Callback<void(const KeyIdsVector&)> resolve_cb,
+ PromiseRejectedCB rejected_cb,
+ const std::string& uma_name);
+ virtual ~KeyIdsPromise();
virtual void resolve(const KeyIdsVector& result);
virtual ResolveParameterType GetResolveParameterType() const OVERRIDE;
+ protected:
+ KeyIdsPromise();
+ KeyIdsPromise(const std::string& uma_name);
+
private:
base::Callback<void(const KeyIdsVector&)> resolve_cb_;
- DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate);
+ DISALLOW_COPY_AND_ASSIGN(KeyIdsPromise);
};
} // namespace media
« 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