| Index: Source/bindings/v8/ScriptPromiseResolverWithContext.h
|
| diff --git a/Source/bindings/v8/ScriptPromiseResolverWithContext.h b/Source/bindings/v8/ScriptPromiseResolverWithContext.h
|
| index 0ccf94e1c1d77195839cb79d9341d22c808fd0b2..798e3e28686aca4b67576900bcb64b3168a58978 100644
|
| --- a/Source/bindings/v8/ScriptPromiseResolverWithContext.h
|
| +++ b/Source/bindings/v8/ScriptPromiseResolverWithContext.h
|
| @@ -31,13 +31,24 @@ class ScriptPromiseResolverWithContext : public ActiveDOMObject, public RefCount
|
| WTF_MAKE_NONCOPYABLE(ScriptPromiseResolverWithContext);
|
|
|
| public:
|
| - static PassRefPtr<ScriptPromiseResolverWithContext> create(ScriptState* scriptState)
|
| + enum Mode {
|
| + Default,
|
| + KeepAliveWhilePending,
|
| + };
|
| +
|
| + // Create a ScriptPromiseResolverWithContext.
|
| + // If |mode| is KeepAliveWhilePending, the resolver refers itself in order
|
| + // to stay alive while the promise is pending and the associated
|
| + // ExecutionContext isn't stopped.
|
| + static PassRefPtr<ScriptPromiseResolverWithContext> create(ScriptState* scriptState, Mode mode = Default)
|
| {
|
| - RefPtr<ScriptPromiseResolverWithContext> resolver = adoptRef(new ScriptPromiseResolverWithContext(scriptState));
|
| + RefPtr<ScriptPromiseResolverWithContext> resolver = adoptRef(new ScriptPromiseResolverWithContext(scriptState, mode));
|
| resolver->suspendIfNeeded();
|
| return resolver.release();
|
| }
|
|
|
| + virtual ~ScriptPromiseResolverWithContext();
|
| +
|
| // Anything that can be passed to toV8Value can be passed to this function.
|
| template <typename T>
|
| void resolve(T value)
|
| @@ -69,7 +80,7 @@ public:
|
| virtual void stop() OVERRIDE;
|
|
|
| protected:
|
| - explicit ScriptPromiseResolverWithContext(ScriptState*);
|
| + ScriptPromiseResolverWithContext(ScriptState*, Mode);
|
|
|
| private:
|
| enum ResolutionState {
|
| @@ -90,6 +101,7 @@ private:
|
| {
|
| if (m_state != Pending || !executionContext() || executionContext()->activeDOMObjectsAreStopped())
|
| return;
|
| + ASSERT(newState == Resolving || newState == Rejecting);
|
| m_state = newState;
|
| // Retain this object until it is actually resolved or rejected.
|
| // |deref| will be called in |clear|.
|
| @@ -107,6 +119,7 @@ private:
|
|
|
| ResolutionState m_state;
|
| const RefPtr<ScriptState> m_scriptState;
|
| + Mode m_mode;
|
| Timer<ScriptPromiseResolverWithContext> m_timer;
|
| RefPtr<ScriptPromiseResolver> m_resolver;
|
| ScopedPersistent<v8::Value> m_value;
|
|
|