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

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

Issue 303693005: Simplify Blink <-> V8 Microtask queue running protocol (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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 | « Source/bindings/v8/ScriptPromiseResolverWithContext.h ('k') | Source/bindings/v8/V8PerIsolateData.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/ScriptPromiseResolverWithContext.cpp
diff --git a/Source/bindings/v8/ScriptPromiseResolverWithContext.cpp b/Source/bindings/v8/ScriptPromiseResolverWithContext.cpp
index 44d733997d385a223915c774c32f43abafaf5690..1a39cac07223f4c777f9d4df80e891041609d0fa 100644
--- a/Source/bindings/v8/ScriptPromiseResolverWithContext.cpp
+++ b/Source/bindings/v8/ScriptPromiseResolverWithContext.cpp
@@ -5,38 +5,10 @@
#include "config.h"
#include "bindings/v8/ScriptPromiseResolverWithContext.h"
-#include "bindings/v8/V8PerIsolateData.h"
-#include "core/dom/ExecutionContextTask.h"
-#include "wtf/PassOwnPtr.h"
+#include "bindings/v8/V8RecursionScope.h"
namespace WebCore {
-namespace {
-
-class RunMicrotasksTask FINAL : public ExecutionContextTask {
-public:
- static PassOwnPtr<RunMicrotasksTask> create(ScriptState* scriptState)
- {
- return adoptPtr<RunMicrotasksTask>(new RunMicrotasksTask(scriptState));
- }
-
- virtual void performTask(ExecutionContext* executionContext) OVERRIDE
- {
- if (m_scriptState->contextIsEmpty())
- return;
- if (executionContext->activeDOMObjectsAreStopped())
- return;
- ScriptState::Scope scope(m_scriptState.get());
- m_scriptState->isolate()->RunMicrotasks();
- }
-
-private:
- explicit RunMicrotasksTask(ScriptState* scriptState) : m_scriptState(scriptState) { }
- RefPtr<ScriptState> m_scriptState;
-};
-
-} // namespace
-
ScriptPromiseResolverWithContext::ScriptPromiseResolverWithContext(ScriptState* scriptState)
: ActiveDOMObject(scriptState->executionContext())
, m_state(Pending)
@@ -67,32 +39,28 @@ void ScriptPromiseResolverWithContext::onTimerFired(Timer<ScriptPromiseResolverW
{
RefPtr<ScriptPromiseResolverWithContext> protect(this);
ScriptState::Scope scope(m_scriptState.get());
- v8::Isolate* isolate = m_scriptState->isolate();
resolveOrRejectImmediately();
-
- // There is no need to post a RunMicrotasksTask because it is safe to
- // call RunMicrotasks here.
- isolate->RunMicrotasks();
}
void ScriptPromiseResolverWithContext::resolveOrRejectImmediately()
{
ASSERT(!executionContext()->activeDOMObjectsAreStopped());
ASSERT(!executionContext()->activeDOMObjectsAreSuspended());
- if (m_state == Resolving) {
- m_resolver->resolve(m_value.newLocal(m_scriptState->isolate()));
- } else {
- ASSERT(m_state == Rejecting);
- m_resolver->reject(m_value.newLocal(m_scriptState->isolate()));
+ {
+ // FIXME: The V8RecursionScope is only necessary to force microtask delivery for promises
+ // resolved or rejected in workers. It can be removed once worker threads run microtasks
+ // at the end of every task (rather than just the main thread).
+ V8RecursionScope scope(m_scriptState->isolate(), m_scriptState->executionContext());
+ if (m_state == Resolving) {
+ m_resolver->resolve(m_value.newLocal(m_scriptState->isolate()));
+ } else {
+ ASSERT(m_state == Rejecting);
+ m_resolver->reject(m_value.newLocal(m_scriptState->isolate()));
+ }
}
clear();
}
-void ScriptPromiseResolverWithContext::postRunMicrotasks()
-{
- executionContext()->postTask(RunMicrotasksTask::create(m_scriptState.get()));
-}
-
void ScriptPromiseResolverWithContext::clear()
{
ResolutionState state = m_state;
« no previous file with comments | « Source/bindings/v8/ScriptPromiseResolverWithContext.h ('k') | Source/bindings/v8/V8PerIsolateData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698