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 ScriptPromiseProperty_h | 5 #ifndef ScriptPromiseProperty_h |
6 #define ScriptPromiseProperty_h | 6 #define ScriptPromiseProperty_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromisePropertyBase.h" | 9 #include "bindings/core/v8/ScriptPromisePropertyBase.h" |
10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // Resets this property by unregistering the Promise property from the | 65 // Resets this property by unregistering the Promise property from the |
66 // holder wrapper. Resets the internal state to Pending and clears the | 66 // holder wrapper. Resets the internal state to Pending and clears the |
67 // resolved and the rejected values. | 67 // resolved and the rejected values. |
68 // This method keeps the holder object and the property name. | 68 // This method keeps the holder object and the property name. |
69 void reset(); | 69 void reset(); |
70 | 70 |
71 virtual void trace(Visitor*) override; | 71 virtual void trace(Visitor*) override; |
72 | 72 |
73 private: | 73 private: |
74 virtual v8::Handle<v8::Object> holder(v8::Handle<v8::Object> creationContext
, v8::Isolate*) override; | 74 virtual v8::Handle<v8::Object> holder(v8::Handle<v8::Object> creationContext
, v8::Isolate*) override; |
75 virtual v8::Handle<v8::Value> resolvedValue(v8::Handle<v8::Object> creationC
ontext, v8::Isolate*) override; | 75 virtual v8::Handle<v8::Value> resolvedValue(v8::Isolate*, v8::Handle<v8::Obj
ect> creationContext) override; |
76 virtual v8::Handle<v8::Value> rejectedValue(v8::Handle<v8::Object> creationC
ontext, v8::Isolate*) override; | 76 virtual v8::Handle<v8::Value> rejectedValue(v8::Isolate*, v8::Handle<v8::Obj
ect> creationContext) override; |
77 | 77 |
78 HolderType m_holder; | 78 HolderType m_holder; |
79 ResolvedType m_resolved; | 79 ResolvedType m_resolved; |
80 RejectedType m_rejected; | 80 RejectedType m_rejected; |
81 }; | 81 }; |
82 | 82 |
83 template<typename HolderType, typename ResolvedType, typename RejectedType> | 83 template<typename HolderType, typename ResolvedType, typename RejectedType> |
84 template<typename PassHolderType> | 84 template<typename PassHolderType> |
85 ScriptPromiseProperty<HolderType, ResolvedType, RejectedType>::ScriptPromiseProp
erty(ExecutionContext* executionContext, PassHolderType holder, Name name) | 85 ScriptPromiseProperty<HolderType, ResolvedType, RejectedType>::ScriptPromiseProp
erty(ExecutionContext* executionContext, PassHolderType holder, Name name) |
86 : ScriptPromisePropertyBase(executionContext, name) | 86 : ScriptPromisePropertyBase(executionContext, name) |
(...skipping 30 matching lines...) Expand all Loading... |
117 } | 117 } |
118 | 118 |
119 template<typename HolderType, typename ResolvedType, typename RejectedType> | 119 template<typename HolderType, typename ResolvedType, typename RejectedType> |
120 v8::Handle<v8::Object> ScriptPromiseProperty<HolderType, ResolvedType, RejectedT
ype>::holder(v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 120 v8::Handle<v8::Object> ScriptPromiseProperty<HolderType, ResolvedType, RejectedT
ype>::holder(v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
121 { | 121 { |
122 v8::Handle<v8::Value> value = V8ValueTraits<HolderType>::toV8Value(m_holder,
creationContext, isolate); | 122 v8::Handle<v8::Value> value = V8ValueTraits<HolderType>::toV8Value(m_holder,
creationContext, isolate); |
123 return value.As<v8::Object>(); | 123 return value.As<v8::Object>(); |
124 } | 124 } |
125 | 125 |
126 template<typename HolderType, typename ResolvedType, typename RejectedType> | 126 template<typename HolderType, typename ResolvedType, typename RejectedType> |
127 v8::Handle<v8::Value> ScriptPromiseProperty<HolderType, ResolvedType, RejectedTy
pe>::resolvedValue(v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 127 v8::Handle<v8::Value> ScriptPromiseProperty<HolderType, ResolvedType, RejectedTy
pe>::resolvedValue(v8::Isolate* isolate, v8::Handle<v8::Object> creationContext) |
128 { | 128 { |
129 ASSERT(state() == Resolved); | 129 ASSERT(state() == Resolved); |
130 return V8ValueTraits<ResolvedType>::toV8Value(m_resolved, creationContext, i
solate); | 130 return V8ValueTraits<ResolvedType>::toV8Value(m_resolved, creationContext, i
solate); |
131 } | 131 } |
132 | 132 |
133 template<typename HolderType, typename ResolvedType, typename RejectedType> | 133 template<typename HolderType, typename ResolvedType, typename RejectedType> |
134 v8::Handle<v8::Value> ScriptPromiseProperty<HolderType, ResolvedType, RejectedTy
pe>::rejectedValue(v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 134 v8::Handle<v8::Value> ScriptPromiseProperty<HolderType, ResolvedType, RejectedTy
pe>::rejectedValue(v8::Isolate* isolate, v8::Handle<v8::Object> creationContext) |
135 { | 135 { |
136 ASSERT(state() == Rejected); | 136 ASSERT(state() == Rejected); |
137 return V8ValueTraits<RejectedType>::toV8Value(m_rejected, creationContext, i
solate); | 137 return V8ValueTraits<RejectedType>::toV8Value(m_rejected, creationContext, i
solate); |
138 } | 138 } |
139 | 139 |
140 template<typename HolderType, typename ResolvedType, typename RejectedType> | 140 template<typename HolderType, typename ResolvedType, typename RejectedType> |
141 void ScriptPromiseProperty<HolderType, ResolvedType, RejectedType>::reset() | 141 void ScriptPromiseProperty<HolderType, ResolvedType, RejectedType>::reset() |
142 { | 142 { |
143 resetBase(); | 143 resetBase(); |
144 m_resolved = ResolvedType(); | 144 m_resolved = ResolvedType(); |
145 m_rejected = RejectedType(); | 145 m_rejected = RejectedType(); |
146 } | 146 } |
147 | 147 |
148 template<typename HolderType, typename ResolvedType, typename RejectedType> | 148 template<typename HolderType, typename ResolvedType, typename RejectedType> |
149 void ScriptPromiseProperty<HolderType, ResolvedType, RejectedType>::trace(Visito
r* visitor) | 149 void ScriptPromiseProperty<HolderType, ResolvedType, RejectedType>::trace(Visito
r* visitor) |
150 { | 150 { |
151 TraceIfNeeded<HolderType>::trace(visitor, &m_holder); | 151 TraceIfNeeded<HolderType>::trace(visitor, &m_holder); |
152 TraceIfNeeded<ResolvedType>::trace(visitor, &m_resolved); | 152 TraceIfNeeded<ResolvedType>::trace(visitor, &m_resolved); |
153 TraceIfNeeded<RejectedType>::trace(visitor, &m_rejected); | 153 TraceIfNeeded<RejectedType>::trace(visitor, &m_rejected); |
154 ScriptPromisePropertyBase::trace(visitor); | 154 ScriptPromisePropertyBase::trace(visitor); |
155 } | 155 } |
156 | 156 |
157 } // namespace blink | 157 } // namespace blink |
158 | 158 |
159 #endif // ScriptPromiseProperty_h | 159 #endif // ScriptPromiseProperty_h |
OLD | NEW |