| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 template <typename T> | 120 template <typename T> |
| 121 void resolveOrReject(T value, ResolutionState newState) { | 121 void resolveOrReject(T value, ResolutionState newState) { |
| 122 if (m_state != Pending || !getScriptState()->contextIsValid() || | 122 if (m_state != Pending || !getScriptState()->contextIsValid() || |
| 123 !getExecutionContext() || getExecutionContext()->isContextDestroyed()) | 123 !getExecutionContext() || getExecutionContext()->isContextDestroyed()) |
| 124 return; | 124 return; |
| 125 ASSERT(newState == Resolving || newState == Rejecting); | 125 ASSERT(newState == Resolving || newState == Rejecting); |
| 126 m_state = newState; | 126 m_state = newState; |
| 127 | 127 |
| 128 ScriptState::Scope scope(m_scriptState.get()); | 128 ScriptState::Scope scope(m_scriptState.get()); |
| 129 m_value.set(m_scriptState->isolate(), | 129 m_value.set(m_scriptState->isolate(), |
| 130 toV8(value, m_scriptState->context()->Global(), | 130 ToV8(value, m_scriptState->context()->Global(), |
| 131 m_scriptState->isolate())); | 131 m_scriptState->isolate())); |
| 132 | 132 |
| 133 if (getExecutionContext()->isContextSuspended()) { | 133 if (getExecutionContext()->isContextSuspended()) { |
| 134 // Retain this object until it is actually resolved or rejected. | 134 // Retain this object until it is actually resolved or rejected. |
| 135 keepAliveWhilePending(); | 135 keepAliveWhilePending(); |
| 136 return; | 136 return; |
| 137 } | 137 } |
| 138 // TODO(esprehn): This is a hack, instead we should RELEASE_ASSERT that | 138 // TODO(esprehn): This is a hack, instead we should RELEASE_ASSERT that |
| 139 // script is allowed, and v8 should be running the entry hooks below and | 139 // script is allowed, and v8 should be running the entry hooks below and |
| 140 // crashing if script is forbidden. We should then audit all users of | 140 // crashing if script is forbidden. We should then audit all users of |
| (...skipping 22 matching lines...) Expand all Loading... |
| 163 | 163 |
| 164 #if ENABLE(ASSERT) | 164 #if ENABLE(ASSERT) |
| 165 // True if promise() is called. | 165 // True if promise() is called. |
| 166 bool m_isPromiseCalled; | 166 bool m_isPromiseCalled; |
| 167 #endif | 167 #endif |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 } // namespace blink | 170 } // namespace blink |
| 171 | 171 |
| 172 #endif // ScriptPromiseResolver_h | 172 #endif // ScriptPromiseResolver_h |
| OLD | NEW |