| Index: Source/bindings/v8/ScriptPromiseResolverWithContext.cpp
|
| diff --git a/Source/bindings/v8/ScriptPromiseResolverWithContext.cpp b/Source/bindings/v8/ScriptPromiseResolverWithContext.cpp
|
| index f0b6f88bee320fd0614dd44e3ca178031e7ac93d..1a39cac07223f4c777f9d4df80e891041609d0fa 100644
|
| --- a/Source/bindings/v8/ScriptPromiseResolverWithContext.cpp
|
| +++ b/Source/bindings/v8/ScriptPromiseResolverWithContext.cpp
|
| @@ -9,31 +9,13 @@
|
|
|
| namespace WebCore {
|
|
|
| -ScriptPromiseResolverWithContext::ScriptPromiseResolverWithContext(ScriptState* scriptState, Mode mode)
|
| +ScriptPromiseResolverWithContext::ScriptPromiseResolverWithContext(ScriptState* scriptState)
|
| : ActiveDOMObject(scriptState->executionContext())
|
| , m_state(Pending)
|
| , m_scriptState(scriptState)
|
| - , m_mode(mode)
|
| , m_timer(this, &ScriptPromiseResolverWithContext::onTimerFired)
|
| , m_resolver(ScriptPromiseResolver::create(m_scriptState.get()))
|
| {
|
| - if (mode == KeepAliveWhilePending) {
|
| - // In order to call ref() here, I relax the adoption requirement.
|
| - // adoptRef is required neverthless.
|
| - relaxAdoptionRequirement();
|
| - // Keep |this| while the promise is Pending.
|
| - // deref() will be called in clear().
|
| - ref();
|
| - }
|
| -}
|
| -
|
| -ScriptPromiseResolverWithContext::~ScriptPromiseResolverWithContext()
|
| -{
|
| - if (m_state != ResolvedOrRejected) {
|
| - ScriptState::Scope scope(m_scriptState.get());
|
| - reject(v8::Exception::Error(v8::String::NewFromUtf8(m_scriptState->isolate(),
|
| - "ScriptPromiseResolverWithContext is destructed without resolve / reject")));
|
| - }
|
| }
|
|
|
| void ScriptPromiseResolverWithContext::suspend()
|
| @@ -55,6 +37,7 @@
|
|
|
| void ScriptPromiseResolverWithContext::onTimerFired(Timer<ScriptPromiseResolverWithContext>*)
|
| {
|
| + RefPtr<ScriptPromiseResolverWithContext> protect(this);
|
| ScriptState::Scope scope(m_scriptState.get());
|
| resolveOrRejectImmediately();
|
| }
|
| @@ -80,23 +63,15 @@
|
|
|
| void ScriptPromiseResolverWithContext::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 the constructor.
|
| - 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();
|
| }
|
| + // |this| may be deleted here.
|
| }
|
|
|
| } // namespace WebCore
|
|
|