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 14 matching lines...) Expand all Loading... |
25 clearWrappers(); | 25 clearWrappers(); |
26 } | 26 } |
27 | 27 |
28 static void clearHandle(const v8::WeakCallbackInfo<ScopedPersistent<v8::Object>>
& data) | 28 static void clearHandle(const v8::WeakCallbackInfo<ScopedPersistent<v8::Object>>
& data) |
29 { | 29 { |
30 data.GetParameter()->clear(); | 30 data.GetParameter()->clear(); |
31 } | 31 } |
32 | 32 |
33 ScriptPromise ScriptPromisePropertyBase::promise(DOMWrapperWorld& world) | 33 ScriptPromise ScriptPromisePropertyBase::promise(DOMWrapperWorld& world) |
34 { | 34 { |
35 if (!executionContext()) | 35 if (!getExecutionContext()) |
36 return ScriptPromise(); | 36 return ScriptPromise(); |
37 | 37 |
38 v8::HandleScope handleScope(m_isolate); | 38 v8::HandleScope handleScope(m_isolate); |
39 v8::Local<v8::Context> context = toV8Context(executionContext(), world); | 39 v8::Local<v8::Context> context = toV8Context(getExecutionContext(), world); |
40 if (context.IsEmpty()) | 40 if (context.IsEmpty()) |
41 return ScriptPromise(); | 41 return ScriptPromise(); |
42 ScriptState* scriptState = ScriptState::from(context); | 42 ScriptState* scriptState = ScriptState::from(context); |
43 ScriptState::Scope scope(scriptState); | 43 ScriptState::Scope scope(scriptState); |
44 | 44 |
45 v8::Local<v8::Object> wrapper = ensureHolderWrapper(scriptState); | 45 v8::Local<v8::Object> wrapper = ensureHolderWrapper(scriptState); |
46 ASSERT(wrapper->CreationContext() == context); | 46 ASSERT(wrapper->CreationContext() == context); |
47 | 47 |
48 v8::Local<v8::Value> cachedPromise = V8HiddenValue::getHiddenValue(scriptSta
te, wrapper, promiseName()); | 48 v8::Local<v8::Value> cachedPromise = V8HiddenValue::getHiddenValue(scriptSta
te, wrapper, promiseName()); |
49 if (!cachedPromise.IsEmpty() && cachedPromise->IsPromise()) | 49 if (!cachedPromise.IsEmpty() && cachedPromise->IsPromise()) |
(...skipping 15 matching lines...) Expand all Loading... |
65 case Rejected: | 65 case Rejected: |
66 resolveOrRejectInternal(resolver); | 66 resolveOrRejectInternal(resolver); |
67 break; | 67 break; |
68 } | 68 } |
69 | 69 |
70 return ScriptPromise(scriptState, promise); | 70 return ScriptPromise(scriptState, promise); |
71 } | 71 } |
72 | 72 |
73 void ScriptPromisePropertyBase::resolveOrReject(State targetState) | 73 void ScriptPromisePropertyBase::resolveOrReject(State targetState) |
74 { | 74 { |
75 ASSERT(executionContext()); | 75 ASSERT(getExecutionContext()); |
76 ASSERT(m_state == Pending); | 76 ASSERT(m_state == Pending); |
77 ASSERT(targetState == Resolved || targetState == Rejected); | 77 ASSERT(targetState == Resolved || targetState == Rejected); |
78 | 78 |
79 m_state = targetState; | 79 m_state = targetState; |
80 | 80 |
81 v8::HandleScope handleScope(m_isolate); | 81 v8::HandleScope handleScope(m_isolate); |
82 size_t i = 0; | 82 size_t i = 0; |
83 while (i < m_wrappers.size()) { | 83 while (i < m_wrappers.size()) { |
84 const OwnPtr<ScopedPersistent<v8::Object>>& persistent = m_wrappers[i]; | 84 const OwnPtr<ScopedPersistent<v8::Object>>& persistent = m_wrappers[i]; |
85 if (persistent->isEmpty()) { | 85 if (persistent->isEmpty()) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 ASSERT_NOT_REACHED(); | 208 ASSERT_NOT_REACHED(); |
209 return v8::Local<v8::String>(); | 209 return v8::Local<v8::String>(); |
210 } | 210 } |
211 | 211 |
212 DEFINE_TRACE(ScriptPromisePropertyBase) | 212 DEFINE_TRACE(ScriptPromisePropertyBase) |
213 { | 213 { |
214 ContextLifecycleObserver::trace(visitor); | 214 ContextLifecycleObserver::trace(visitor); |
215 } | 215 } |
216 | 216 |
217 } // namespace blink | 217 } // namespace blink |
OLD | NEW |