OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "bindings/core/v8/ScriptPromiseResolver.h" | 6 #include "bindings/core/v8/ScriptPromiseResolver.h" |
7 | 7 |
8 #include "bindings/core/v8/V8RecursionScope.h" | 8 #include "bindings/core/v8/V8RecursionScope.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 ASSERT(m_state == Resolving || m_state == Rejecting); | 57 ASSERT(m_state == Resolving || m_state == Rejecting); |
58 ScriptState::Scope scope(m_scriptState.get()); | 58 ScriptState::Scope scope(m_scriptState.get()); |
59 resolveOrRejectImmediately(); | 59 resolveOrRejectImmediately(); |
60 } | 60 } |
61 | 61 |
62 void ScriptPromiseResolver::resolveOrRejectImmediately() | 62 void ScriptPromiseResolver::resolveOrRejectImmediately() |
63 { | 63 { |
64 ASSERT(!executionContext()->activeDOMObjectsAreStopped()); | 64 ASSERT(!executionContext()->activeDOMObjectsAreStopped()); |
65 ASSERT(!executionContext()->activeDOMObjectsAreSuspended()); | 65 ASSERT(!executionContext()->activeDOMObjectsAreSuspended()); |
66 { | 66 { |
67 // FIXME: The V8RecursionScope is only necessary to force microtask deli
very for promises | |
68 // resolved or rejected in workers. It can be removed once worker thread
s run microtasks | |
69 // at the end of every task (rather than just the main thread). | |
70 V8RecursionScope scope(m_scriptState->isolate(), m_scriptState->executio
nContext()); | |
71 if (m_state == Resolving) { | 67 if (m_state == Resolving) { |
72 m_resolver.resolve(m_value.newLocal(m_scriptState->isolate())); | 68 m_resolver.resolve(m_value.newLocal(m_scriptState->isolate())); |
73 } else { | 69 } else { |
74 ASSERT(m_state == Rejecting); | 70 ASSERT(m_state == Rejecting); |
75 m_resolver.reject(m_value.newLocal(m_scriptState->isolate())); | 71 m_resolver.reject(m_value.newLocal(m_scriptState->isolate())); |
76 } | 72 } |
77 } | 73 } |
78 clear(); | 74 clear(); |
79 } | 75 } |
80 | 76 |
(...skipping 12 matching lines...) Expand all Loading... |
93 // |this| may be deleted here, but it is safe to check |state| because | 89 // |this| may be deleted here, but it is safe to check |state| because |
94 // it doesn't depend on |this|. When |this| is deleted, |state| can't be | 90 // it doesn't depend on |this|. When |this| is deleted, |state| can't be |
95 // |Resolving| nor |Rejecting| and hence |this->deref()| can't be executed. | 91 // |Resolving| nor |Rejecting| and hence |this->deref()| can't be executed. |
96 if (state == Resolving || state == Rejecting) { | 92 if (state == Resolving || state == Rejecting) { |
97 // |ref| was called in |resolveOrReject|. | 93 // |ref| was called in |resolveOrReject|. |
98 deref(); | 94 deref(); |
99 } | 95 } |
100 } | 96 } |
101 | 97 |
102 } // namespace blink | 98 } // namespace blink |
OLD | NEW |