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

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

Issue 1696553005: Add ScriptPromiseResolver::detach (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.h b/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.h
index 526c157f362a1f61ae5a700256ffe805fcf9627b..11542e158cc677ce25c6a9bc1fab385ccda22f47 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.h
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.h
@@ -46,10 +46,10 @@ public:
{
// This assertion fails if:
// - promise() is called at least once and
- // - this resolver is destructed before it is resolved, rejected, the
- // V8 isolate is terminated or the associated ExecutionContext is
- // stopped.
- ASSERT(m_state == ResolvedOrRejected || !m_isPromiseCalled || !scriptState()->contextIsValid() || !executionContext() || executionContext()->activeDOMObjectsAreStopped());
+ // - this resolver is destructed before it is resolved, rejected,
+ // detached, the V8 isolate is terminated or the associated
+ // ExecutionContext is stopped.
+ ASSERT(m_state == Detached || !m_isPromiseCalled || !scriptState()->contextIsValid() || !executionContext() || executionContext()->activeDOMObjectsAreStopped());
}
#endif
@@ -87,7 +87,13 @@ public:
// ActiveDOMObject implementation.
void suspend() override;
void resume() override;
- void stop() override;
+ void stop() override { detach(); }
+
+ // Calling this function makes the resolver release its internal resources.
+ // That means the associated promise will never be resolved or rejected
+ // unless it's already been resolved or rejected.
+ // Do not call this function unless you truly need the behavior.
+ void detach();
// Once this function is called this resolver stays alive while the
// promise is pending and the associated ExecutionContext isn't stopped.
@@ -106,7 +112,7 @@ private:
Pending,
Resolving,
Rejecting,
- ResolvedOrRejected,
+ Detached,
};
template<typename T>
@@ -132,7 +138,6 @@ private:
void resolveOrRejectImmediately();
void onTimerFired(Timer<ScriptPromiseResolver>*);
- void clear();
ResolutionState m_state;
const RefPtr<ScriptState> m_scriptState;
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698