| 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 #ifndef ScriptPromiseResolver_h | 5 #ifndef ScriptPromiseResolver_h |
| 6 #define ScriptPromiseResolver_h | 6 #define ScriptPromiseResolver_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScopedPersistent.h" | 8 #include "bindings/core/v8/ScopedPersistent.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 enum ResolutionState { | 112 enum ResolutionState { |
| 113 Pending, | 113 Pending, |
| 114 Resolving, | 114 Resolving, |
| 115 Rejecting, | 115 Rejecting, |
| 116 Detached, | 116 Detached, |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 template <typename T> | 119 template <typename T> |
| 120 void resolveOrReject(T value, ResolutionState newState) { | 120 void resolveOrReject(T value, ResolutionState newState) { |
| 121 if (m_state != Pending || !getScriptState()->contextIsValid() || | 121 if (m_state != Pending || !getScriptState()->contextIsValid() || |
| 122 !getExecutionContext() || | 122 !getExecutionContext()) |
| 123 getExecutionContext()->activeDOMObjectsAreStopped()) | |
| 124 return; | 123 return; |
| 125 ASSERT(newState == Resolving || newState == Rejecting); | 124 ASSERT(newState == Resolving || newState == Rejecting); |
| 126 m_state = newState; | 125 m_state = newState; |
| 127 | 126 |
| 128 ScriptState::Scope scope(m_scriptState.get()); | 127 ScriptState::Scope scope(m_scriptState.get()); |
| 129 m_value.set(m_scriptState->isolate(), | 128 m_value.set(m_scriptState->isolate(), |
| 130 toV8(value, m_scriptState->context()->Global(), | 129 toV8(value, m_scriptState->context()->Global(), |
| 131 m_scriptState->isolate())); | 130 m_scriptState->isolate())); |
| 132 | 131 |
| 133 if (getExecutionContext()->activeDOMObjectsAreSuspended()) { | 132 if (getExecutionContext()->activeDOMObjectsAreSuspended()) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 153 | 152 |
| 154 #if ENABLE(ASSERT) | 153 #if ENABLE(ASSERT) |
| 155 // True if promise() is called. | 154 // True if promise() is called. |
| 156 bool m_isPromiseCalled; | 155 bool m_isPromiseCalled; |
| 157 #endif | 156 #endif |
| 158 }; | 157 }; |
| 159 | 158 |
| 160 } // namespace blink | 159 } // namespace blink |
| 161 | 160 |
| 162 #endif // ScriptPromiseResolver_h | 161 #endif // ScriptPromiseResolver_h |
| OLD | NEW |