Chromium Code Reviews| Index: Source/bindings/v8/ScriptPromiseResolverWithContext.h |
| diff --git a/Source/bindings/v8/ScriptPromiseResolverWithContext.h b/Source/bindings/v8/ScriptPromiseResolverWithContext.h |
| index 0ccf94e1c1d77195839cb79d9341d22c808fd0b2..6525145e4961e524d3fd9b5cd8608c87a536ae57 100644 |
| --- a/Source/bindings/v8/ScriptPromiseResolverWithContext.h |
| +++ b/Source/bindings/v8/ScriptPromiseResolverWithContext.h |
| @@ -38,6 +38,8 @@ public: |
| 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) |
| @@ -68,7 +70,13 @@ public: |
| virtual void resume() OVERRIDE; |
| virtual void stop() OVERRIDE; |
| + // Once this function is called this resolver stays alive while the |
| + // promise is pending and the associated ExecutionContext isn't stopped. |
| + void keepAliveWhilePending(); |
| + |
| protected: |
| + // You need to call suspendIfNeeded after the construction because |
| + // this is an ActiveDOMObject. |
| explicit ScriptPromiseResolverWithContext(ScriptState*); |
| private: |
| @@ -78,6 +86,10 @@ private: |
| Rejecting, |
| ResolvedOrRejected, |
| }; |
| + enum LifeMode { |
|
haraken
2014/06/18 06:56:01
LifetimeMode ?
yhirano
2014/06/18 07:03:33
Done.
|
| + Default, |
| + KeepAliveWhilePending, |
| + }; |
| template<typename T> |
| v8::Handle<v8::Value> toV8Value(const T& value) |
| @@ -90,6 +102,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 +120,7 @@ private: |
| ResolutionState m_state; |
| const RefPtr<ScriptState> m_scriptState; |
| + LifeMode m_mode; |
| Timer<ScriptPromiseResolverWithContext> m_timer; |
| RefPtr<ScriptPromiseResolver> m_resolver; |
| ScopedPersistent<v8::Value> m_value; |