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 "config.h" | 5 #include "config.h" |
6 #include "bindings/core/v8/ScriptPromisePropertyBase.h" | 6 #include "bindings/core/v8/ScriptPromisePropertyBase.h" |
7 | 7 |
8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
9 #include "bindings/core/v8/V8HiddenValue.h" | 9 #include "bindings/core/v8/V8HiddenValue.h" |
10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 if (wrapper.IsEmpty()) { | 55 if (wrapper.IsEmpty()) { |
56 wrapper = holder(context->Global(), m_isolate); | 56 wrapper = holder(context->Global(), m_isolate); |
57 ASSERT(!wrapper.IsEmpty()); | 57 ASSERT(!wrapper.IsEmpty()); |
58 ASSERT(V8HiddenValue::getHiddenValue(m_isolate, wrapper, resolverName())
.IsEmpty()); | 58 ASSERT(V8HiddenValue::getHiddenValue(m_isolate, wrapper, resolverName())
.IsEmpty()); |
59 ASSERT(V8HiddenValue::getHiddenValue(m_isolate, wrapper, promiseName()).
IsEmpty()); | 59 ASSERT(V8HiddenValue::getHiddenValue(m_isolate, wrapper, promiseName()).
IsEmpty()); |
60 m_mainWorldWrapper.set(m_isolate, wrapper); | 60 m_mainWorldWrapper.set(m_isolate, wrapper); |
61 m_mainWorldWrapper.setWeak(&m_mainWorldWrapper, &clearHandle); | 61 m_mainWorldWrapper.setWeak(&m_mainWorldWrapper, &clearHandle); |
62 } | 62 } |
63 ASSERT(wrapper->CreationContext() == context); | 63 ASSERT(wrapper->CreationContext() == context); |
64 | 64 |
65 v8::Handle<v8::Promise> promise = V8HiddenValue::getHiddenValue(m_isolate, w
rapper, promiseName()).As<v8::Promise>(); | 65 v8::Handle<v8::Value> cachedPromise = V8HiddenValue::getHiddenValue(m_isolat
e, wrapper, promiseName()); |
66 if (!promise.IsEmpty()) { | 66 if (!cachedPromise.IsEmpty()) |
67 // Return cached Promise | 67 return ScriptPromise(scriptState, cachedPromise); |
68 return ScriptPromise(scriptState, promise); | |
69 } | |
70 | 68 |
71 // Create and cache the Promise | 69 // Create and cache the Promise |
72 v8::Handle<v8::Promise::Resolver> resolver = v8::Promise::Resolver::New(m_is
olate); | 70 v8::Handle<v8::Promise::Resolver> resolver = v8::Promise::Resolver::New(m_is
olate); |
73 promise = resolver->GetPromise(); | 71 v8::Handle<v8::Promise> promise = resolver->GetPromise(); |
74 V8HiddenValue::setHiddenValue(m_isolate, wrapper, promiseName(), promise); | 72 V8HiddenValue::setHiddenValue(m_isolate, wrapper, promiseName(), promise); |
75 | 73 |
76 switch (m_state) { | 74 switch (m_state) { |
77 case Pending: | 75 case Pending: |
78 // Cache the resolver too | 76 // Cache the resolver too |
79 V8HiddenValue::setHiddenValue(m_isolate, wrapper, resolverName(), resolv
er); | 77 V8HiddenValue::setHiddenValue(m_isolate, wrapper, resolverName(), resolv
er); |
80 break; | 78 break; |
81 case Resolved: | 79 case Resolved: |
82 case Rejected: | 80 case Rejected: |
83 resolveOrRejectInternal(resolver); | 81 resolveOrRejectInternal(resolver); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 144 |
147 SCRIPT_PROMISE_PROPERTIES(P) | 145 SCRIPT_PROMISE_PROPERTIES(P) |
148 | 146 |
149 #undef P | 147 #undef P |
150 } | 148 } |
151 ASSERT_NOT_REACHED(); | 149 ASSERT_NOT_REACHED(); |
152 return v8::Handle<v8::String>(); | 150 return v8::Handle<v8::String>(); |
153 } | 151 } |
154 | 152 |
155 } // namespace WebCore | 153 } // namespace WebCore |
OLD | NEW |