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

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

Issue 209853010: [ABANDONED] Enable V8 Promises (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 8 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/ScriptPromiseTest.cpp » ('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 0678ffcff0684341864e918a297cc72b24ae6ecc..5b3852918a10ef2853b6e90a9369e5a1ac7b3e8c 100644
--- a/Source/bindings/v8/ScriptPromiseResolverWithContext.cpp
+++ b/Source/bindings/v8/ScriptPromiseResolverWithContext.cpp
@@ -5,13 +5,15 @@
#include "config.h"
#include "bindings/v8/ScriptPromiseResolverWithContext.h"
+#include "bindings/v8/V8PerIsolateData.h"
+
namespace WebCore {
ScriptPromiseResolverWithContext::ScriptPromiseResolverWithContext(NewScriptState* scriptState)
: ActiveDOMObject(scriptState->executionContext())
, m_state(Pending)
, m_scriptState(scriptState)
- , m_timer(this, &ScriptPromiseResolverWithContext::resolveOrRejectImmediately)
+ , m_timer(this, &ScriptPromiseResolverWithContext::onTimerFired)
, m_resolver(ScriptPromiseResolver::create(m_scriptState->executionContext())) { }
void ScriptPromiseResolverWithContext::suspend()
@@ -31,20 +33,31 @@ void ScriptPromiseResolverWithContext::stop()
clear();
}
-void ScriptPromiseResolverWithContext::resolveOrRejectImmediately(Timer<ScriptPromiseResolverWithContext>*)
+void ScriptPromiseResolverWithContext::onTimerFired(Timer<ScriptPromiseResolverWithContext>*)
+{
+ RefPtr<ScriptPromiseResolverWithContext> protect(this);
+ NewScriptState::Scope scope(m_scriptState.get());
+ v8::Isolate* isolate = m_scriptState->isolate();
+ resolveOrRejectImmediately();
+
+ v8::V8::RunMicrotasks(isolate);
+}
+
+void ScriptPromiseResolverWithContext::resolveOrRejectImmediately()
{
ASSERT(!executionContext()->activeDOMObjectsAreStopped());
ASSERT(!executionContext()->activeDOMObjectsAreSuspended());
if (m_state == Resolving) {
- NewScriptState::Scope scope(m_scriptState.get());
m_resolver->resolve(m_value.newLocal(m_scriptState->isolate()));
} else {
ASSERT(m_state == Rejecting);
- NewScriptState::Scope scope(m_scriptState.get());
m_resolver->reject(m_value.newLocal(m_scriptState->isolate()));
}
m_state = ResolvedOrRejected;
clear();
+
+ // ref() was called in resolveOrRejected.
+ deref();
}
void ScriptPromiseResolverWithContext::clear()
« no previous file with comments | « Source/bindings/v8/ScriptPromiseResolverWithContext.h ('k') | Source/bindings/v8/ScriptPromiseTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698