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

Unified Diff: Source/bindings/v8/ScriptPromiseResolverWithContext.h

Issue 344733004: Stop calling [de]ref in ScriptPromiseResolverWithContext destructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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 | Source/bindings/v8/ScriptPromiseResolverWithContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/ScriptPromiseResolverWithContext.h
diff --git a/Source/bindings/v8/ScriptPromiseResolverWithContext.h b/Source/bindings/v8/ScriptPromiseResolverWithContext.h
index 59861252231c11a03981c1ce95ef67f9f5141a81..729fb15beed72f1456c89ee85dfff565413bb377 100644
--- a/Source/bindings/v8/ScriptPromiseResolverWithContext.h
+++ b/Source/bindings/v8/ScriptPromiseResolverWithContext.h
@@ -38,7 +38,14 @@ public:
return resolver.release();
}
- virtual ~ScriptPromiseResolverWithContext();
+ virtual ~ScriptPromiseResolverWithContext()
+ {
+ // This assertion fails if:
+ // - promise() is called at least once and
+ // - this resolver is destructed before it is resolved, rejected or
+ // the associated ExecutionContext is stopped.
+ ASSERT(m_state == ResolvedOrRejected || !m_isPromiseCalled);
+ }
// Anything that can be passed to toV8Value can be passed to this function.
template <typename T>
@@ -60,6 +67,9 @@ public:
// reject is called.
ScriptPromise promise()
{
+#if ASSERT_ENABLED
+ m_isPromiseCalled = true;
+#endif
return m_resolver ? m_resolver->promise() : ScriptPromise();
}
@@ -124,6 +134,10 @@ private:
Timer<ScriptPromiseResolverWithContext> m_timer;
RefPtr<ScriptPromiseResolver> m_resolver;
ScopedPersistent<v8::Value> m_value;
+#if ASSERT_ENABLED
+ // True if promise() is called.
+ bool m_isPromiseCalled;
+#endif
};
} // namespace WebCore
« no previous file with comments | « no previous file | Source/bindings/v8/ScriptPromiseResolverWithContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698