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

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
Index: Source/bindings/v8/ScriptPromiseResolverWithContext.h
diff --git a/Source/bindings/v8/ScriptPromiseResolverWithContext.h b/Source/bindings/v8/ScriptPromiseResolverWithContext.h
index 0ccf94e1c1d77195839cb79d9341d22c808fd0b2..2de442dd68eae7002f5dd01ec657b1fbfbdc5850 100644
--- a/Source/bindings/v8/ScriptPromiseResolverWithContext.h
+++ b/Source/bindings/v8/ScriptPromiseResolverWithContext.h
@@ -31,13 +31,24 @@ class ScriptPromiseResolverWithContext : public ActiveDOMObject, public RefCount
WTF_MAKE_NONCOPYABLE(ScriptPromiseResolverWithContext);
public:
- static PassRefPtr<ScriptPromiseResolverWithContext> create(ScriptState* scriptState)
+ enum Mode {
+ Default,
+ KeepSelfWhilePending,
haraken 2014/06/16 10:54:04 KeepAliveWhilePending ?
yhirano 2014/06/16 11:47:51 Done.
+ };
+
+ // Create a ScriptPromiseResolverWithContext.
+ // If |mode| is KeepSelfWhilePending, the resolver refers itself in order
+ // to stay alive while the promise is pending and the accosiated
+ // ExecutionContext isn't stopped.
+ static PassRefPtr<ScriptPromiseResolverWithContext> create(ScriptState* scriptState, Mode mode = Default)
{
- RefPtr<ScriptPromiseResolverWithContext> resolver = adoptRef(new ScriptPromiseResolverWithContext(scriptState));
+ RefPtr<ScriptPromiseResolverWithContext> resolver = adoptRef(new ScriptPromiseResolverWithContext(scriptState, mode));
resolver->suspendIfNeeded();
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)
@@ -69,7 +80,7 @@ public:
virtual void stop() OVERRIDE;
protected:
- explicit ScriptPromiseResolverWithContext(ScriptState*);
+ ScriptPromiseResolverWithContext(ScriptState*, Mode);
private:
enum ResolutionState {
@@ -90,6 +101,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 +119,7 @@ private:
ResolutionState m_state;
const RefPtr<ScriptState> m_scriptState;
+ Mode m_mode;
Timer<ScriptPromiseResolverWithContext> m_timer;
RefPtr<ScriptPromiseResolver> m_resolver;
ScopedPersistent<v8::Value> m_value;

Powered by Google App Engine
This is Rietveld 408576698