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 { |
11 | 11 |
12 ScriptPromiseResolver::ScriptPromiseResolver(ScriptState* scriptState) | 12 ScriptPromiseResolver::ScriptPromiseResolver(ScriptState* scriptState) |
13 : ActiveDOMObject(scriptState->executionContext()) | 13 : ActiveDOMObject(scriptState->executionContext()) |
14 , m_state(Pending) | 14 , m_state(Pending) |
15 , m_scriptState(scriptState) | 15 , m_scriptState(scriptState) |
16 , m_mode(Default) | 16 , m_mode(Default) |
17 , m_timer(this, &ScriptPromiseResolver::onTimerFired) | 17 , m_timer(this, &ScriptPromiseResolver::onTimerFired) |
18 , m_resolver(scriptState) | 18 , m_resolver(scriptState) |
19 #if ENABLE(ASSERT) | 19 #if ENABLE(ASSERT) |
20 , m_isPromiseCalled(false) | 20 , m_isPromiseCalled(false) |
21 #endif | 21 #endif |
22 { | 22 { |
23 if (executionContext()->activeDOMObjectsAreStopped()) | 23 if (executionContext()->activeDOMObjectsAreStopped()) { |
24 m_state = ResolvedOrRejected; | 24 m_state = ResolvedOrRejected; |
| 25 m_resolver.clear(); |
| 26 } |
25 } | 27 } |
26 | 28 |
27 void ScriptPromiseResolver::suspend() | 29 void ScriptPromiseResolver::suspend() |
28 { | 30 { |
29 m_timer.stop(); | 31 m_timer.stop(); |
30 } | 32 } |
31 | 33 |
32 void ScriptPromiseResolver::resume() | 34 void ScriptPromiseResolver::resume() |
33 { | 35 { |
34 if (m_state == Resolving || m_state == Rejecting) | 36 if (m_state == Resolving || m_state == Rejecting) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // |this| may be deleted here, but it is safe to check |state| because | 91 // |this| may be deleted here, but it is safe to check |state| because |
90 // it doesn't depend on |this|. When |this| is deleted, |state| can't be | 92 // it doesn't depend on |this|. When |this| is deleted, |state| can't be |
91 // |Resolving| nor |Rejecting| and hence |this->deref()| can't be executed. | 93 // |Resolving| nor |Rejecting| and hence |this->deref()| can't be executed. |
92 if (state == Resolving || state == Rejecting) { | 94 if (state == Resolving || state == Rejecting) { |
93 // |ref| was called in |resolveOrReject|. | 95 // |ref| was called in |resolveOrReject|. |
94 deref(); | 96 deref(); |
95 } | 97 } |
96 } | 98 } |
97 | 99 |
98 } // namespace blink | 100 } // namespace blink |
OLD | NEW |