| Index: third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.cpp
|
| index 5cdb01e6fa37442285ca6a62247414a36eb7f629..bc0ba8d0f7613a45b14907867731ce8af4efae42 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.cpp
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.cpp
|
| @@ -17,7 +17,7 @@ ScriptPromiseResolver::ScriptPromiseResolver(ScriptState* scriptState)
|
| #endif
|
| {
|
| if (executionContext()->activeDOMObjectsAreStopped()) {
|
| - m_state = ResolvedOrRejected;
|
| + m_state = Detached;
|
| m_resolver.clear();
|
| }
|
| }
|
| @@ -33,10 +33,15 @@ void ScriptPromiseResolver::resume()
|
| m_timer.startOneShot(0, BLINK_FROM_HERE);
|
| }
|
|
|
| -void ScriptPromiseResolver::stop()
|
| +void ScriptPromiseResolver::detach()
|
| {
|
| + if (m_state == Detached)
|
| + return;
|
| m_timer.stop();
|
| - clear();
|
| + m_state = Detached;
|
| + m_resolver.clear();
|
| + m_value.clear();
|
| + m_keepAlive.clear();
|
| }
|
|
|
| void ScriptPromiseResolver::keepAliveWhilePending()
|
| @@ -44,11 +49,11 @@ void ScriptPromiseResolver::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)
|
| + if (m_state == Detached || m_keepAlive)
|
| return;
|
|
|
| // Keep |this| around while the promise is Pending;
|
| - // see clear() for the dual operation.
|
| + // see detach() for the dual operation.
|
| m_keepAlive = this;
|
| }
|
|
|
| @@ -56,7 +61,7 @@ void ScriptPromiseResolver::onTimerFired(Timer<ScriptPromiseResolver>*)
|
| {
|
| ASSERT(m_state == Resolving || m_state == Rejecting);
|
| if (!scriptState()->contextIsValid()) {
|
| - clear();
|
| + detach();
|
| return;
|
| }
|
|
|
| @@ -76,17 +81,7 @@ void ScriptPromiseResolver::resolveOrRejectImmediately()
|
| m_resolver.reject(m_value.newLocal(m_scriptState->isolate()));
|
| }
|
| }
|
| - clear();
|
| -}
|
| -
|
| -void ScriptPromiseResolver::clear()
|
| -{
|
| - if (m_state == ResolvedOrRejected)
|
| - return;
|
| - m_state = ResolvedOrRejected;
|
| - m_resolver.clear();
|
| - m_value.clear();
|
| - m_keepAlive.clear();
|
| + detach();
|
| }
|
|
|
| DEFINE_TRACE(ScriptPromiseResolver)
|
|
|