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 "bindings/core/v8/ScriptPromisePropertyBase.h" | 5 #include "bindings/core/v8/ScriptPromisePropertyBase.h" |
6 | 6 |
7 #include "bindings/core/v8/ScopedPersistent.h" | 7 #include "bindings/core/v8/ScopedPersistent.h" |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "bindings/core/v8/V8Binding.h" | 9 #include "bindings/core/v8/V8Binding.h" |
10 #include "bindings/core/v8/V8HiddenValue.h" | 10 #include "bindings/core/v8/V8HiddenValue.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 v8::HandleScope handleScope(m_isolate); | 77 v8::HandleScope handleScope(m_isolate); |
78 size_t i = 0; | 78 size_t i = 0; |
79 while (i < m_wrappers.size()) { | 79 while (i < m_wrappers.size()) { |
80 const std::unique_ptr<ScopedPersistent<v8::Object>>& persistent = | 80 const std::unique_ptr<ScopedPersistent<v8::Object>>& persistent = |
81 m_wrappers[i]; | 81 m_wrappers[i]; |
82 if (persistent->isEmpty()) { | 82 if (persistent->isEmpty()) { |
83 // wrapper has died. | 83 // wrapper has died. |
84 // Since v8 GC can run during the iteration and clear the reference, | 84 // Since v8 GC can run during the iteration and clear the reference, |
85 // we can't move this check out of the loop. | 85 // we can't move this check out of the loop. |
86 m_wrappers.remove(i); | 86 m_wrappers.erase(i); |
87 continue; | 87 continue; |
88 } | 88 } |
89 v8::Local<v8::Object> wrapper = persistent->newLocal(m_isolate); | 89 v8::Local<v8::Object> wrapper = persistent->newLocal(m_isolate); |
90 ScriptState* scriptState = ScriptState::from(wrapper->CreationContext()); | 90 ScriptState* scriptState = ScriptState::from(wrapper->CreationContext()); |
91 ScriptState::Scope scope(scriptState); | 91 ScriptState::Scope scope(scriptState); |
92 | 92 |
93 v8::Local<v8::Promise::Resolver> resolver = | 93 v8::Local<v8::Promise::Resolver> resolver = |
94 V8HiddenValue::getHiddenValue(scriptState, wrapper, resolverName()) | 94 V8HiddenValue::getHiddenValue(scriptState, wrapper, resolverName()) |
95 .As<v8::Promise::Resolver>(); | 95 .As<v8::Promise::Resolver>(); |
96 DCHECK(!resolver.IsEmpty()); | 96 DCHECK(!resolver.IsEmpty()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 ScriptState* scriptState) { | 129 ScriptState* scriptState) { |
130 v8::Local<v8::Context> context = scriptState->context(); | 130 v8::Local<v8::Context> context = scriptState->context(); |
131 size_t i = 0; | 131 size_t i = 0; |
132 while (i < m_wrappers.size()) { | 132 while (i < m_wrappers.size()) { |
133 const std::unique_ptr<ScopedPersistent<v8::Object>>& persistent = | 133 const std::unique_ptr<ScopedPersistent<v8::Object>>& persistent = |
134 m_wrappers[i]; | 134 m_wrappers[i]; |
135 if (persistent->isEmpty()) { | 135 if (persistent->isEmpty()) { |
136 // wrapper has died. | 136 // wrapper has died. |
137 // Since v8 GC can run during the iteration and clear the reference, | 137 // Since v8 GC can run during the iteration and clear the reference, |
138 // we can't move this check out of the loop. | 138 // we can't move this check out of the loop. |
139 m_wrappers.remove(i); | 139 m_wrappers.erase(i); |
140 continue; | 140 continue; |
141 } | 141 } |
142 | 142 |
143 v8::Local<v8::Object> wrapper = persistent->newLocal(m_isolate); | 143 v8::Local<v8::Object> wrapper = persistent->newLocal(m_isolate); |
144 if (wrapper->CreationContext() == context) | 144 if (wrapper->CreationContext() == context) |
145 return wrapper; | 145 return wrapper; |
146 ++i; | 146 ++i; |
147 } | 147 } |
148 v8::Local<v8::Object> wrapper = holder(m_isolate, context->Global()); | 148 v8::Local<v8::Object> wrapper = holder(m_isolate, context->Global()); |
149 std::unique_ptr<ScopedPersistent<v8::Object>> weakPersistent = | 149 std::unique_ptr<ScopedPersistent<v8::Object>> weakPersistent = |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 ASSERT_NOT_REACHED(); | 209 ASSERT_NOT_REACHED(); |
210 return v8::Local<v8::String>(); | 210 return v8::Local<v8::String>(); |
211 } | 211 } |
212 | 212 |
213 DEFINE_TRACE(ScriptPromisePropertyBase) { | 213 DEFINE_TRACE(ScriptPromisePropertyBase) { |
214 ContextClient::trace(visitor); | 214 ContextClient::trace(visitor); |
215 } | 215 } |
216 | 216 |
217 } // namespace blink | 217 } // namespace blink |
OLD | NEW |