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

Unified Diff: media/base/cdm_promise.h

Issue 1729063003: media: Reject pending CDM promise during destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 4 years, 10 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/base/cdm_callback_promise.cc ('k') | media/blink/cdm_result_promise.h » ('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 0c44f80c8fa19a19fcec0a1e79ba670ee4826478..dc11e7a01442b4be675375a2132937e724cbb526 100644
--- a/media/base/cdm_promise.h
+++ b/media/base/cdm_promise.h
@@ -99,6 +99,8 @@ class MEDIA_EXPORT CdmPromiseTemplate : public CdmPromise {
}
protected:
+ bool IsPromiseSettled() const { return is_settled_; }
+
// All implementations must call this method in resolve() and reject() methods
// to indicate that the promise has been settled.
void MarkPromiseSettled() {
@@ -107,6 +109,17 @@ class MEDIA_EXPORT CdmPromiseTemplate : public CdmPromise {
is_settled_ = true;
}
+ // Must be called by the concrete destructor if !IsPromiseSettled().
+ // Note: We can't call reject() in ~CdmPromise() because reject() is virtual.
+ void RejectPromiseOnDestruction() {
+ DCHECK(!is_settled_);
+ std::string message =
+ "Unfulfilled promise rejected automatically during destruction.";
+ DVLOG(1) << message;
+ reject(MediaKeys::INVALID_STATE_ERROR, 0, message);
+ DCHECK(is_settled_);
+ }
+
private:
// Keep track of whether the promise has been resolved or rejected yet.
bool is_settled_;
« no previous file with comments | « media/base/cdm_callback_promise.cc ('k') | media/blink/cdm_result_promise.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698