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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
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 // TODO(aobzhirov): Converting value to the wrapper can trigger assert |
| 130 // if the script is forbidden. |
| 131 // The script check below will be unreachable in this case. |
129 m_value.set(m_scriptState->isolate(), | 132 m_value.set(m_scriptState->isolate(), |
130 ToV8(value, m_scriptState->context()->Global(), | 133 ToV8(value, m_scriptState->context()->Global(), |
131 m_scriptState->isolate())); | 134 m_scriptState->isolate())); |
132 | 135 |
133 if (getExecutionContext()->isContextSuspended()) { | 136 if (getExecutionContext()->isContextSuspended()) { |
134 // Retain this object until it is actually resolved or rejected. | 137 // Retain this object until it is actually resolved or rejected. |
135 keepAliveWhilePending(); | 138 keepAliveWhilePending(); |
136 return; | 139 return; |
137 } | 140 } |
138 // TODO(esprehn): This is a hack, instead we should RELEASE_ASSERT that | 141 // TODO(esprehn): This is a hack, instead we should RELEASE_ASSERT that |
(...skipping 24 matching lines...) Expand all Loading... |
163 | 166 |
164 #if DCHECK_IS_ON() | 167 #if DCHECK_IS_ON() |
165 // True if promise() is called. | 168 // True if promise() is called. |
166 bool m_isPromiseCalled = false; | 169 bool m_isPromiseCalled = false; |
167 #endif | 170 #endif |
168 }; | 171 }; |
169 | 172 |
170 } // namespace blink | 173 } // namespace blink |
171 | 174 |
172 #endif // ScriptPromiseResolver_h | 175 #endif // ScriptPromiseResolver_h |
OLD | NEW |