Index: Source/bindings/core/v8/ScriptPromiseResolver.h |
diff --git a/Source/bindings/core/v8/ScriptPromiseResolver.h b/Source/bindings/core/v8/ScriptPromiseResolver.h |
index 62975ad0bc1763beb0fd12fff9eb1824089fb65a..0639cd23b159c207e468c37682a357ac8f2fb03e 100644 |
--- a/Source/bindings/core/v8/ScriptPromiseResolver.h |
+++ b/Source/bindings/core/v8/ScriptPromiseResolver.h |
@@ -26,15 +26,15 @@ namespace blink { |
// ExecutionContext state. When the ExecutionContext is suspended, |
// resolve or reject will be delayed. When it is stopped, resolve or reject |
// will be ignored. |
-class CORE_EXPORT ScriptPromiseResolver : public RefCountedWillBeRefCountedGarbageCollected<ScriptPromiseResolver>, public ActiveDOMObject { |
+class CORE_EXPORT ScriptPromiseResolver : public GarbageCollectedFinalized<ScriptPromiseResolver>, public ActiveDOMObject { |
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ScriptPromiseResolver); |
WTF_MAKE_NONCOPYABLE(ScriptPromiseResolver); |
public: |
- static PassRefPtrWillBeRawPtr<ScriptPromiseResolver> create(ScriptState* scriptState) |
+ static ScriptPromiseResolver* create(ScriptState* scriptState) |
{ |
- RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = adoptRefWillBeNoop(new ScriptPromiseResolver(scriptState)); |
+ ScriptPromiseResolver* resolver = new ScriptPromiseResolver(scriptState); |
resolver->suspendIfNeeded(); |
- return resolver.release(); |
+ return resolver; |
} |
#if ENABLE(ASSERT) |
@@ -107,10 +107,6 @@ private: |
Rejecting, |
ResolvedOrRejected, |
}; |
- enum LifetimeMode { |
- Default, |
- KeepAliveWhilePending, |
- }; |
template<typename T> |
void resolveOrReject(T value, ResolutionState newState) |
@@ -119,9 +115,6 @@ private: |
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|. |
- ref(); |
yhirano
2015/07/16 07:09:30
This ref() was called to keep the resolver alive w
sof
2015/07/16 07:13:54
The object is on the stack and thereby reachable.
yhirano
2015/07/16 07:19:38
I think about the following case, for example.
//
sof
2015/07/16 07:33:23
Thanks. Yes, we need retain a strong reference for
|
ScriptState::Scope scope(m_scriptState.get()); |
m_value.set( |
@@ -137,7 +130,6 @@ private: |
ResolutionState m_state; |
const RefPtr<ScriptState> m_scriptState; |
- LifetimeMode m_mode; |
Timer<ScriptPromiseResolver> m_timer; |
Resolver m_resolver; |
ScopedPersistent<v8::Value> m_value; |
@@ -145,6 +137,11 @@ private: |
// True if promise() is called. |
bool m_isPromiseCalled; |
#endif |
+ |
+ // To support keepAliveWhilePending(), a self-referential |
+ // Persistent<> is needed. |
+ GC_PLUGIN_IGNORE("") |
+ Persistent<ScriptPromiseResolver> m_keepAlive; |
}; |
} // namespace blink |