| Index: Source/bindings/v8/ScriptPromiseResolverWithContext.h
|
| diff --git a/Source/bindings/v8/ScriptPromiseResolverWithContext.h b/Source/bindings/v8/ScriptPromiseResolverWithContext.h
|
| index 0ccf94e1c1d77195839cb79d9341d22c808fd0b2..d569326245345b021b39ef43ac4dd98c74ed3fb2 100644
|
| --- a/Source/bindings/v8/ScriptPromiseResolverWithContext.h
|
| +++ b/Source/bindings/v8/ScriptPromiseResolverWithContext.h
|
| @@ -27,7 +27,7 @@ namespace WebCore {
|
| // ExecutionContext state. When the ExecutionContext is suspended,
|
| // resolve or reject will be delayed. When it is stopped, resolve or reject
|
| // will be ignored.
|
| -class ScriptPromiseResolverWithContext : public ActiveDOMObject, public RefCounted<ScriptPromiseResolverWithContext> {
|
| +class ScriptPromiseResolverWithContext FINAL : public ActiveDOMObject, public RefCounted<ScriptPromiseResolverWithContext> {
|
| WTF_MAKE_NONCOPYABLE(ScriptPromiseResolverWithContext);
|
|
|
| public:
|
| @@ -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,8 +70,19 @@ public:
|
| virtual void resume() OVERRIDE;
|
| virtual void stop() OVERRIDE;
|
|
|
| -protected:
|
| - explicit ScriptPromiseResolverWithContext(ScriptState*);
|
| + // This function registers |value| to the associated Promise as a hidden
|
| + // property. As a result, |value| will be kept alive until one of the
|
| + // following events happens:
|
| + // - the Promise is resolved
|
| + // - the Promise is rejected
|
| + // - the Promise is disposed by the GC
|
| + // - this object is destructed
|
| + template<typename T>
|
| + void keepObjectWhilePending(const T& value)
|
| + {
|
| + ScriptState::Scope scope(m_scriptState.get());
|
| + keepObjectWhilePendingInternal(toV8Value(value));
|
| + }
|
|
|
| private:
|
| enum ResolutionState {
|
| @@ -79,6 +92,8 @@ private:
|
| ResolvedOrRejected,
|
| };
|
|
|
| + explicit ScriptPromiseResolverWithContext(ScriptState*);
|
| +
|
| template<typename T>
|
| v8::Handle<v8::Value> toV8Value(const T& value)
|
| {
|
| @@ -105,6 +120,9 @@ private:
|
| void onTimerFired(Timer<ScriptPromiseResolverWithContext>*);
|
| void clear();
|
|
|
| + void keepObjectWhilePendingInternal(v8::Handle<v8::Value>);
|
| + void unregisterKeptObject();
|
| +
|
| ResolutionState m_state;
|
| const RefPtr<ScriptState> m_scriptState;
|
| Timer<ScriptPromiseResolverWithContext> m_timer;
|
|
|