| Index: Source/bindings/v8/ScriptPromiseResolverWithContext.h
|
| diff --git a/Source/bindings/v8/ScriptPromiseResolverWithContext.h b/Source/bindings/v8/ScriptPromiseResolverWithContext.h
|
| index 126b45b68d9bcc751b297b3172ce4aa07feb28bb..e2d9a9be35bac0c9e0f045bd79ef5567fe39176c 100644
|
| --- a/Source/bindings/v8/ScriptPromiseResolverWithContext.h
|
| +++ b/Source/bindings/v8/ScriptPromiseResolverWithContext.h
|
| @@ -42,26 +42,14 @@ public:
|
| template <typename T>
|
| void resolve(T value)
|
| {
|
| - if (m_state != Pending || !executionContext() || executionContext()->activeDOMObjectsAreStopped())
|
| - return;
|
| - m_state = Resolving;
|
| - NewScriptState::Scope scope(m_scriptState.get());
|
| - m_value.set(m_scriptState->isolate(), toV8Value(value));
|
| - if (!executionContext()->activeDOMObjectsAreSuspended())
|
| - resolveOrRejectImmediately(&m_timer);
|
| + resolveOrReject(value, Resolving);
|
| }
|
|
|
| // Anything that can be passed to toV8Value can be passed to this function.
|
| template <typename T>
|
| void reject(T value)
|
| {
|
| - if (m_state != Pending || !executionContext() || executionContext()->activeDOMObjectsAreStopped())
|
| - return;
|
| - m_state = Rejecting;
|
| - NewScriptState::Scope scope(m_scriptState.get());
|
| - m_value.set(m_scriptState->isolate(), toV8Value(value));
|
| - if (!executionContext()->activeDOMObjectsAreSuspended())
|
| - resolveOrRejectImmediately(&m_timer);
|
| + resolveOrReject(value, Rejecting);
|
| }
|
|
|
| NewScriptState* scriptState() { return m_scriptState.get(); }
|
| @@ -120,7 +108,30 @@ private:
|
| return v8ArrayNoInline(value, m_scriptState->isolate());
|
| }
|
|
|
| - void resolveOrRejectImmediately(Timer<ScriptPromiseResolverWithContext>*);
|
| + template <typename T>
|
| + void resolveOrReject(T value, ResolutionState newState)
|
| + {
|
| + if (m_state != Pending || !executionContext() || executionContext()->activeDOMObjectsAreStopped())
|
| + return;
|
| + m_state = newState;
|
| + // Retain this object until it is actually resolved or rejected.
|
| + // deref will be called in resolveOrRejectImmediately.
|
| + ref();
|
| +
|
| + bool isInContext = m_scriptState->isolate()->InContext();
|
| + NewScriptState::Scope scope(m_scriptState.get());
|
| + m_value.set(m_scriptState->isolate(), toV8Value(value));
|
| + if (!executionContext()->activeDOMObjectsAreSuspended()) {
|
| + if (isInContext) {
|
| + resolveOrRejectImmediately();
|
| + } else {
|
| + m_timer.startOneShot(0, FROM_HERE);
|
| + }
|
| + }
|
| + }
|
| +
|
| + void resolveOrRejectImmediately();
|
| + void onTimerFired(Timer<ScriptPromiseResolverWithContext>*);
|
| void clear();
|
|
|
| ResolutionState m_state;
|
|
|