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

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

Issue 351423002: Moved files under Source/bindings/v8 to Source/bindings/core/v8. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
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 | « Source/bindings/v8/ScriptPromiseResolver.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/ScriptPromiseResolver.cpp
diff --git a/Source/bindings/v8/ScriptPromiseResolver.cpp b/Source/bindings/v8/ScriptPromiseResolver.cpp
deleted file mode 100644
index b05974885f385efa5af7c2100195ac9c402a6017..0000000000000000000000000000000000000000
--- a/Source/bindings/v8/ScriptPromiseResolver.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "bindings/v8/ScriptPromiseResolver.h"
-
-#include "bindings/v8/V8RecursionScope.h"
-
-namespace WebCore {
-
-ScriptPromiseResolver::ScriptPromiseResolver(ScriptState* scriptState)
- : ActiveDOMObject(scriptState->executionContext())
- , m_state(Pending)
- , m_scriptState(scriptState)
- , m_mode(Default)
- , m_timer(this, &ScriptPromiseResolver::onTimerFired)
- , m_resolver(scriptState)
-#if ASSERTION_ENABLED
- , m_isPromiseCalled(false)
-#endif
-{
- if (executionContext()->activeDOMObjectsAreStopped())
- m_state = ResolvedOrRejected;
-}
-
-void ScriptPromiseResolver::suspend()
-{
- m_timer.stop();
-}
-
-void ScriptPromiseResolver::resume()
-{
- if (m_state == Resolving || m_state == Rejecting)
- m_timer.startOneShot(0, FROM_HERE);
-}
-
-void ScriptPromiseResolver::stop()
-{
- m_timer.stop();
- clear();
-}
-
-void ScriptPromiseResolver::keepAliveWhilePending()
-{
- if (m_state == ResolvedOrRejected || m_mode == KeepAliveWhilePending)
- return;
-
- // Keep |this| while the promise is Pending.
- // deref() will be called in clear().
- m_mode = KeepAliveWhilePending;
- ref();
-}
-
-void ScriptPromiseResolver::onTimerFired(Timer<ScriptPromiseResolver>*)
-{
- ASSERT(m_state == Resolving || m_state == Rejecting);
- ScriptState::Scope scope(m_scriptState.get());
- resolveOrRejectImmediately();
-}
-
-void ScriptPromiseResolver::resolveOrRejectImmediately()
-{
- ASSERT(!executionContext()->activeDOMObjectsAreStopped());
- ASSERT(!executionContext()->activeDOMObjectsAreSuspended());
- {
- // 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 ScriptPromiseResolver::clear()
-{
- if (m_state == ResolvedOrRejected)
- return;
- ResolutionState state = m_state;
- m_state = ResolvedOrRejected;
- m_resolver.clear();
- m_value.clear();
- if (m_mode == KeepAliveWhilePending) {
- // |ref| was called in |keepAliveWhilePending|.
- deref();
- }
- // |this| may be deleted here, but it is safe to check |state| because
- // it doesn't depend on |this|. When |this| is deleted, |state| can't be
- // |Resolving| nor |Rejecting| and hence |this->deref()| can't be executed.
- if (state == Resolving || state == Rejecting) {
- // |ref| was called in |resolveOrReject|.
- deref();
- }
-}
-
-} // namespace WebCore
« no previous file with comments | « Source/bindings/v8/ScriptPromiseResolver.h ('k') | Source/bindings/v8/ScriptPromiseTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698