Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Unified Diff: Source/bindings/core/v8/ScriptPromiseResolver.h

Issue 1233173002: Have ScriptPromiseResolver on the Oilpan heap always. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: smaller review updates Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..fd42835125c88dad014ac84cb0e95b0000c84fc7 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,16 +115,18 @@ 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();
ScriptState::Scope scope(m_scriptState.get());
m_value.set(
m_scriptState->isolate(),
toV8(value, m_scriptState->context()->Global(), m_scriptState->isolate()));
- if (!executionContext()->activeDOMObjectsAreSuspended())
- resolveOrRejectImmediately();
+
+ if (executionContext()->activeDOMObjectsAreSuspended()) {
+ // Retain this object until it is actually resolved or rejected.
+ keepAliveWhilePending();
+ return;
+ }
+ resolveOrRejectImmediately();
}
void resolveOrRejectImmediately();
@@ -137,10 +135,14 @@ private:
ResolutionState m_state;
const RefPtr<ScriptState> m_scriptState;
- LifetimeMode m_mode;
Timer<ScriptPromiseResolver> m_timer;
Resolver m_resolver;
ScopedPersistent<v8::Value> m_value;
+
+ // To support keepAliveWhilePending(), this object needs to keep itself
+ // alive while in that state.
+ SelfKeepAlive<ScriptPromiseResolver> m_keepAlive;
+
#if ENABLE(ASSERT)
// True if promise() is called.
bool m_isPromiseCalled;

Powered by Google App Engine
This is Rietveld 408576698