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

Unified Diff: Source/bindings/v8/ScriptPromiseResolverWithContext.h

Issue 311733004: Introduce KeepAliveWhilePending to ScriptPromiseResolverWithContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@refactor-webmidi-initialization
Patch Set: Created 6 years, 6 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
« no previous file with comments | « no previous file | Source/bindings/v8/ScriptPromiseResolverWithContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/ScriptPromiseResolverWithContext.h
diff --git a/Source/bindings/v8/ScriptPromiseResolverWithContext.h b/Source/bindings/v8/ScriptPromiseResolverWithContext.h
index 0ccf94e1c1d77195839cb79d9341d22c808fd0b2..59861252231c11a03981c1ce95ef67f9f5141a81 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 LifetimeMode {
+ 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;
+ LifetimeMode m_mode;
Timer<ScriptPromiseResolverWithContext> m_timer;
RefPtr<ScriptPromiseResolver> m_resolver;
ScopedPersistent<v8::Value> m_value;
« no previous file with comments | « no previous file | Source/bindings/v8/ScriptPromiseResolverWithContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698