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

Unified Diff: Source/bindings/core/v8/ScriptPromiseResolver.cpp

Issue 1233173002: Have ScriptPromiseResolver on the Oilpan heap always. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix webusb ScriptPromiseResolver usage Created 5 years, 4 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: Source/bindings/core/v8/ScriptPromiseResolver.cpp
diff --git a/Source/bindings/core/v8/ScriptPromiseResolver.cpp b/Source/bindings/core/v8/ScriptPromiseResolver.cpp
index 584b4203962ccb8d53a8c5747e02f449a4cffa8f..574964f8ce4c7129db32503daab28970587049c7 100644
--- a/Source/bindings/core/v8/ScriptPromiseResolver.cpp
+++ b/Source/bindings/core/v8/ScriptPromiseResolver.cpp
@@ -11,7 +11,6 @@ ScriptPromiseResolver::ScriptPromiseResolver(ScriptState* scriptState)
: ActiveDOMObject(scriptState->executionContext())
, m_state(Pending)
, m_scriptState(scriptState)
- , m_mode(Default)
, m_timer(this, &ScriptPromiseResolver::onTimerFired)
, m_resolver(scriptState)
#if ENABLE(ASSERT)
@@ -43,13 +42,15 @@ void ScriptPromiseResolver::stop()
void ScriptPromiseResolver::keepAliveWhilePending()
{
- if (m_state == ResolvedOrRejected || m_mode == KeepAliveWhilePending)
+ // keepAliveWhilePending() will be called twice if the resolver
+ // is created in a suspended execution context and the resolver
+ // is then resolved/rejected while in that suspended state.
+ if (m_state == ResolvedOrRejected || m_keepAlive)
return;
- // Keep |this| while the promise is Pending.
- // deref() will be called in clear().
- m_mode = KeepAliveWhilePending;
- ref();
+ // Keep |this| around while the promise is Pending;
+ // see clear() for the dual operation.
+ m_keepAlive = this;
}
void ScriptPromiseResolver::onTimerFired(Timer<ScriptPromiseResolver>*)
@@ -83,21 +84,10 @@ void ScriptPromiseResolver::clear()
{
if (m_state == ResolvedOrRejected)
return;
- ResolutionState state = m_state;
m_state = ResolvedOrRejected;
m_resolver.clear();
m_value.clear();
- if (m_mode == KeepAliveWhilePending) {
- // |ref| was called in |keepAliveWhilePending|.
- deref();
- }
- // |this| may be deleted here, but it is safe to check |state| because
- // it doesn't depend on |this|. When |this| is deleted, |state| can't be
- // |Resolving| nor |Rejecting| and hence |this->deref()| can't be executed.
- if (state == Resolving || state == Rejecting) {
- // |ref| was called in |resolveOrReject|.
- deref();
- }
+ m_keepAlive.clear();
}
DEFINE_TRACE(ScriptPromiseResolver)
« no previous file with comments | « Source/bindings/core/v8/ScriptPromiseResolver.h ('k') | Source/bindings/core/v8/ScriptPromiseResolverTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698