1 | /* |
2 | This file is part of the WebKit open source project. |
3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #include "config.h" |
22 | |
23 | #if ENABLE(WEB_RTC) |
24 | |
25 | #include "JSRTCDataChannel.h" |
26 | |
27 | #include "EventNames.h" |
28 | #include "JSBlob.h" |
29 | #include "JSDOMAttribute.h" |
30 | #include "JSDOMBinding.h" |
31 | #include "JSDOMConstructorNotConstructable.h" |
32 | #include "JSDOMConvertBoolean.h" |
33 | #include "JSDOMConvertBufferSource.h" |
34 | #include "JSDOMConvertInterface.h" |
35 | #include "JSDOMConvertNullable.h" |
36 | #include "JSDOMConvertNumbers.h" |
37 | #include "JSDOMConvertStrings.h" |
38 | #include "JSDOMExceptionHandling.h" |
39 | #include "JSDOMOperation.h" |
40 | #include "JSDOMWrapperCache.h" |
41 | #include "JSEventListener.h" |
42 | #include "ScriptExecutionContext.h" |
43 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
44 | #include <JavaScriptCore/JSCInlines.h> |
45 | #include <JavaScriptCore/JSString.h> |
46 | #include <wtf/GetPtr.h> |
47 | #include <wtf/PointerPreparations.h> |
48 | #include <wtf/URL.h> |
49 | |
50 | |
51 | namespace WebCore { |
52 | using namespace JSC; |
53 | |
54 | #if ENABLE(WEB_RTC) |
55 | |
56 | String convertEnumerationToString(RTCDataChannelState enumerationValue) |
57 | { |
58 | static const NeverDestroyed<String> values[] = { |
59 | MAKE_STATIC_STRING_IMPL("connecting" ), |
60 | MAKE_STATIC_STRING_IMPL("open" ), |
61 | MAKE_STATIC_STRING_IMPL("closing" ), |
62 | MAKE_STATIC_STRING_IMPL("closed" ), |
63 | }; |
64 | static_assert(static_cast<size_t>(RTCDataChannelState::Connecting) == 0, "RTCDataChannelState::Connecting is not 0 as expected" ); |
65 | static_assert(static_cast<size_t>(RTCDataChannelState::Open) == 1, "RTCDataChannelState::Open is not 1 as expected" ); |
66 | static_assert(static_cast<size_t>(RTCDataChannelState::Closing) == 2, "RTCDataChannelState::Closing is not 2 as expected" ); |
67 | static_assert(static_cast<size_t>(RTCDataChannelState::Closed) == 3, "RTCDataChannelState::Closed is not 3 as expected" ); |
68 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
69 | return values[static_cast<size_t>(enumerationValue)]; |
70 | } |
71 | |
72 | template<> JSString* convertEnumerationToJS(ExecState& state, RTCDataChannelState enumerationValue) |
73 | { |
74 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
75 | } |
76 | |
77 | template<> Optional<RTCDataChannelState> parseEnumeration<RTCDataChannelState>(ExecState& state, JSValue value) |
78 | { |
79 | auto stringValue = value.toWTFString(&state); |
80 | if (stringValue == "connecting" ) |
81 | return RTCDataChannelState::Connecting; |
82 | if (stringValue == "open" ) |
83 | return RTCDataChannelState::Open; |
84 | if (stringValue == "closing" ) |
85 | return RTCDataChannelState::Closing; |
86 | if (stringValue == "closed" ) |
87 | return RTCDataChannelState::Closed; |
88 | return WTF::nullopt; |
89 | } |
90 | |
91 | template<> const char* expectedEnumerationValues<RTCDataChannelState>() |
92 | { |
93 | return "\"connecting\", \"open\", \"closing\", \"closed\"" ; |
94 | } |
95 | |
96 | #endif |
97 | |
98 | // Functions |
99 | |
100 | JSC::EncodedJSValue JSC_HOST_CALL jsRTCDataChannelPrototypeFunctionSend(JSC::ExecState*); |
101 | JSC::EncodedJSValue JSC_HOST_CALL jsRTCDataChannelPrototypeFunctionClose(JSC::ExecState*); |
102 | |
103 | // Attributes |
104 | |
105 | JSC::EncodedJSValue jsRTCDataChannelConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
106 | bool setJSRTCDataChannelConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
107 | JSC::EncodedJSValue jsRTCDataChannelLabel(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
108 | JSC::EncodedJSValue jsRTCDataChannelOrdered(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
109 | JSC::EncodedJSValue jsRTCDataChannelMaxPacketLifeTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
110 | JSC::EncodedJSValue jsRTCDataChannelMaxRetransmits(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
111 | JSC::EncodedJSValue jsRTCDataChannelProtocol(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
112 | JSC::EncodedJSValue jsRTCDataChannelNegotiated(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
113 | JSC::EncodedJSValue jsRTCDataChannelId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
114 | JSC::EncodedJSValue jsRTCDataChannelReadyState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
115 | JSC::EncodedJSValue jsRTCDataChannelBufferedAmount(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
116 | JSC::EncodedJSValue jsRTCDataChannelBufferedAmountLowThreshold(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
117 | bool setJSRTCDataChannelBufferedAmountLowThreshold(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
118 | JSC::EncodedJSValue jsRTCDataChannelBinaryType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
119 | bool setJSRTCDataChannelBinaryType(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
120 | JSC::EncodedJSValue jsRTCDataChannelOnopen(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
121 | bool setJSRTCDataChannelOnopen(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
122 | JSC::EncodedJSValue jsRTCDataChannelOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
123 | bool setJSRTCDataChannelOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
124 | JSC::EncodedJSValue jsRTCDataChannelOnclose(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
125 | bool setJSRTCDataChannelOnclose(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
126 | JSC::EncodedJSValue jsRTCDataChannelOnmessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
127 | bool setJSRTCDataChannelOnmessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
128 | JSC::EncodedJSValue jsRTCDataChannelOnbufferedamountlow(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
129 | bool setJSRTCDataChannelOnbufferedamountlow(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
130 | |
131 | class JSRTCDataChannelPrototype : public JSC::JSNonFinalObject { |
132 | public: |
133 | using Base = JSC::JSNonFinalObject; |
134 | static JSRTCDataChannelPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
135 | { |
136 | JSRTCDataChannelPrototype* ptr = new (NotNull, JSC::allocateCell<JSRTCDataChannelPrototype>(vm.heap)) JSRTCDataChannelPrototype(vm, globalObject, structure); |
137 | ptr->finishCreation(vm); |
138 | return ptr; |
139 | } |
140 | |
141 | DECLARE_INFO; |
142 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
143 | { |
144 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
145 | } |
146 | |
147 | private: |
148 | JSRTCDataChannelPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
149 | : JSC::JSNonFinalObject(vm, structure) |
150 | { |
151 | } |
152 | |
153 | void finishCreation(JSC::VM&); |
154 | }; |
155 | |
156 | using JSRTCDataChannelConstructor = JSDOMConstructorNotConstructable<JSRTCDataChannel>; |
157 | |
158 | template<> JSValue JSRTCDataChannelConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
159 | { |
160 | return JSEventTarget::getConstructor(vm, &globalObject); |
161 | } |
162 | |
163 | template<> void JSRTCDataChannelConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
164 | { |
165 | putDirect(vm, vm.propertyNames->prototype, JSRTCDataChannel::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
166 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("RTCDataChannel"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
167 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
168 | } |
169 | |
170 | template<> const ClassInfo JSRTCDataChannelConstructor::s_info = { "RTCDataChannel" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCDataChannelConstructor) }; |
171 | |
172 | /* Hash table for prototype */ |
173 | |
174 | static const HashTableValue JSRTCDataChannelPrototypeTableValues[] = |
175 | { |
176 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCDataChannelConstructor) } }, |
177 | { "label" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelLabel), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
178 | { "ordered" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelOrdered), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
179 | { "maxPacketLifeTime" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelMaxPacketLifeTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
180 | { "maxRetransmits" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelMaxRetransmits), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
181 | { "protocol" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelProtocol), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
182 | { "negotiated" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelNegotiated), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
183 | { "id" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
184 | { "readyState" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelReadyState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
185 | { "bufferedAmount" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelBufferedAmount), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
186 | { "bufferedAmountLowThreshold" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelBufferedAmountLowThreshold), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCDataChannelBufferedAmountLowThreshold) } }, |
187 | { "binaryType" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelBinaryType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCDataChannelBinaryType) } }, |
188 | { "onopen" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelOnopen), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCDataChannelOnopen) } }, |
189 | { "onerror" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelOnerror), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCDataChannelOnerror) } }, |
190 | { "onclose" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelOnclose), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCDataChannelOnclose) } }, |
191 | { "onmessage" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelOnmessage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCDataChannelOnmessage) } }, |
192 | { "onbufferedamountlow" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelOnbufferedamountlow), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCDataChannelOnbufferedamountlow) } }, |
193 | { "send" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCDataChannelPrototypeFunctionSend), (intptr_t) (1) } }, |
194 | { "close" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCDataChannelPrototypeFunctionClose), (intptr_t) (0) } }, |
195 | }; |
196 | |
197 | const ClassInfo JSRTCDataChannelPrototype::s_info = { "RTCDataChannelPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCDataChannelPrototype) }; |
198 | |
199 | void JSRTCDataChannelPrototype::finishCreation(VM& vm) |
200 | { |
201 | Base::finishCreation(vm); |
202 | reifyStaticProperties(vm, JSRTCDataChannel::info(), JSRTCDataChannelPrototypeTableValues, *this); |
203 | } |
204 | |
205 | const ClassInfo JSRTCDataChannel::s_info = { "RTCDataChannel" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCDataChannel) }; |
206 | |
207 | JSRTCDataChannel::JSRTCDataChannel(Structure* structure, JSDOMGlobalObject& globalObject, Ref<RTCDataChannel>&& impl) |
208 | : JSEventTarget(structure, globalObject, WTFMove(impl)) |
209 | { |
210 | } |
211 | |
212 | void JSRTCDataChannel::finishCreation(VM& vm) |
213 | { |
214 | Base::finishCreation(vm); |
215 | ASSERT(inherits(vm, info())); |
216 | |
217 | } |
218 | |
219 | JSObject* JSRTCDataChannel::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
220 | { |
221 | return JSRTCDataChannelPrototype::create(vm, &globalObject, JSRTCDataChannelPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
222 | } |
223 | |
224 | JSObject* JSRTCDataChannel::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
225 | { |
226 | return getDOMPrototype<JSRTCDataChannel>(vm, globalObject); |
227 | } |
228 | |
229 | JSValue JSRTCDataChannel::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
230 | { |
231 | return getDOMConstructor<JSRTCDataChannelConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
232 | } |
233 | |
234 | template<> inline JSRTCDataChannel* IDLAttribute<JSRTCDataChannel>::cast(ExecState& state, EncodedJSValue thisValue) |
235 | { |
236 | return jsDynamicCast<JSRTCDataChannel*>(state.vm(), JSValue::decode(thisValue)); |
237 | } |
238 | |
239 | template<> inline JSRTCDataChannel* IDLOperation<JSRTCDataChannel>::cast(ExecState& state) |
240 | { |
241 | return jsDynamicCast<JSRTCDataChannel*>(state.vm(), state.thisValue()); |
242 | } |
243 | |
244 | EncodedJSValue jsRTCDataChannelConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
245 | { |
246 | VM& vm = state->vm(); |
247 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
248 | auto* prototype = jsDynamicCast<JSRTCDataChannelPrototype*>(vm, JSValue::decode(thisValue)); |
249 | if (UNLIKELY(!prototype)) |
250 | return throwVMTypeError(state, throwScope); |
251 | return JSValue::encode(JSRTCDataChannel::getConstructor(state->vm(), prototype->globalObject())); |
252 | } |
253 | |
254 | bool setJSRTCDataChannelConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
255 | { |
256 | VM& vm = state->vm(); |
257 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
258 | auto* prototype = jsDynamicCast<JSRTCDataChannelPrototype*>(vm, JSValue::decode(thisValue)); |
259 | if (UNLIKELY(!prototype)) { |
260 | throwVMTypeError(state, throwScope); |
261 | return false; |
262 | } |
263 | // Shadowing a built-in constructor |
264 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
265 | } |
266 | |
267 | static inline JSValue jsRTCDataChannelLabelGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
268 | { |
269 | UNUSED_PARAM(throwScope); |
270 | UNUSED_PARAM(state); |
271 | auto& impl = thisObject.wrapped(); |
272 | JSValue result = toJS<IDLUSVString>(state, throwScope, impl.label()); |
273 | return result; |
274 | } |
275 | |
276 | EncodedJSValue jsRTCDataChannelLabel(ExecState* state, EncodedJSValue thisValue, PropertyName) |
277 | { |
278 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelLabelGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "label" ); |
279 | } |
280 | |
281 | static inline JSValue jsRTCDataChannelOrderedGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
282 | { |
283 | UNUSED_PARAM(throwScope); |
284 | UNUSED_PARAM(state); |
285 | auto& impl = thisObject.wrapped(); |
286 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.ordered()); |
287 | return result; |
288 | } |
289 | |
290 | EncodedJSValue jsRTCDataChannelOrdered(ExecState* state, EncodedJSValue thisValue, PropertyName) |
291 | { |
292 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelOrderedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "ordered" ); |
293 | } |
294 | |
295 | static inline JSValue jsRTCDataChannelMaxPacketLifeTimeGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
296 | { |
297 | UNUSED_PARAM(throwScope); |
298 | UNUSED_PARAM(state); |
299 | auto& impl = thisObject.wrapped(); |
300 | JSValue result = toJS<IDLNullable<IDLUnsignedShort>>(state, throwScope, impl.maxPacketLifeTime()); |
301 | return result; |
302 | } |
303 | |
304 | EncodedJSValue jsRTCDataChannelMaxPacketLifeTime(ExecState* state, EncodedJSValue thisValue, PropertyName) |
305 | { |
306 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelMaxPacketLifeTimeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "maxPacketLifeTime" ); |
307 | } |
308 | |
309 | static inline JSValue jsRTCDataChannelMaxRetransmitsGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
310 | { |
311 | UNUSED_PARAM(throwScope); |
312 | UNUSED_PARAM(state); |
313 | auto& impl = thisObject.wrapped(); |
314 | JSValue result = toJS<IDLNullable<IDLUnsignedShort>>(state, throwScope, impl.maxRetransmits()); |
315 | return result; |
316 | } |
317 | |
318 | EncodedJSValue jsRTCDataChannelMaxRetransmits(ExecState* state, EncodedJSValue thisValue, PropertyName) |
319 | { |
320 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelMaxRetransmitsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "maxRetransmits" ); |
321 | } |
322 | |
323 | static inline JSValue jsRTCDataChannelProtocolGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
324 | { |
325 | UNUSED_PARAM(throwScope); |
326 | UNUSED_PARAM(state); |
327 | auto& impl = thisObject.wrapped(); |
328 | JSValue result = toJS<IDLUSVString>(state, throwScope, impl.protocol()); |
329 | return result; |
330 | } |
331 | |
332 | EncodedJSValue jsRTCDataChannelProtocol(ExecState* state, EncodedJSValue thisValue, PropertyName) |
333 | { |
334 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelProtocolGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "protocol" ); |
335 | } |
336 | |
337 | static inline JSValue jsRTCDataChannelNegotiatedGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
338 | { |
339 | UNUSED_PARAM(throwScope); |
340 | UNUSED_PARAM(state); |
341 | auto& impl = thisObject.wrapped(); |
342 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.negotiated()); |
343 | return result; |
344 | } |
345 | |
346 | EncodedJSValue jsRTCDataChannelNegotiated(ExecState* state, EncodedJSValue thisValue, PropertyName) |
347 | { |
348 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelNegotiatedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "negotiated" ); |
349 | } |
350 | |
351 | static inline JSValue jsRTCDataChannelIdGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
352 | { |
353 | UNUSED_PARAM(throwScope); |
354 | UNUSED_PARAM(state); |
355 | auto& impl = thisObject.wrapped(); |
356 | JSValue result = toJS<IDLNullable<IDLUnsignedShort>>(state, throwScope, impl.id()); |
357 | return result; |
358 | } |
359 | |
360 | EncodedJSValue jsRTCDataChannelId(ExecState* state, EncodedJSValue thisValue, PropertyName) |
361 | { |
362 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelIdGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "id" ); |
363 | } |
364 | |
365 | static inline JSValue jsRTCDataChannelReadyStateGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
366 | { |
367 | UNUSED_PARAM(throwScope); |
368 | UNUSED_PARAM(state); |
369 | auto& impl = thisObject.wrapped(); |
370 | JSValue result = toJS<IDLEnumeration<RTCDataChannelState>>(state, throwScope, impl.readyState()); |
371 | return result; |
372 | } |
373 | |
374 | EncodedJSValue jsRTCDataChannelReadyState(ExecState* state, EncodedJSValue thisValue, PropertyName) |
375 | { |
376 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelReadyStateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "readyState" ); |
377 | } |
378 | |
379 | static inline JSValue jsRTCDataChannelBufferedAmountGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
380 | { |
381 | UNUSED_PARAM(throwScope); |
382 | UNUSED_PARAM(state); |
383 | auto& impl = thisObject.wrapped(); |
384 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.bufferedAmount()); |
385 | return result; |
386 | } |
387 | |
388 | EncodedJSValue jsRTCDataChannelBufferedAmount(ExecState* state, EncodedJSValue thisValue, PropertyName) |
389 | { |
390 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelBufferedAmountGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "bufferedAmount" ); |
391 | } |
392 | |
393 | static inline JSValue jsRTCDataChannelBufferedAmountLowThresholdGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
394 | { |
395 | UNUSED_PARAM(throwScope); |
396 | UNUSED_PARAM(state); |
397 | auto& impl = thisObject.wrapped(); |
398 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.bufferedAmountLowThreshold()); |
399 | return result; |
400 | } |
401 | |
402 | EncodedJSValue jsRTCDataChannelBufferedAmountLowThreshold(ExecState* state, EncodedJSValue thisValue, PropertyName) |
403 | { |
404 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelBufferedAmountLowThresholdGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "bufferedAmountLowThreshold" ); |
405 | } |
406 | |
407 | static inline bool setJSRTCDataChannelBufferedAmountLowThresholdSetter(ExecState& state, JSRTCDataChannel& thisObject, JSValue value, ThrowScope& throwScope) |
408 | { |
409 | UNUSED_PARAM(throwScope); |
410 | auto& impl = thisObject.wrapped(); |
411 | auto nativeValue = convert<IDLUnsignedLong>(state, value); |
412 | RETURN_IF_EXCEPTION(throwScope, false); |
413 | AttributeSetter::call(state, throwScope, [&] { |
414 | return impl.setBufferedAmountLowThreshold(WTFMove(nativeValue)); |
415 | }); |
416 | return true; |
417 | } |
418 | |
419 | bool setJSRTCDataChannelBufferedAmountLowThreshold(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
420 | { |
421 | return IDLAttribute<JSRTCDataChannel>::set<setJSRTCDataChannelBufferedAmountLowThresholdSetter>(*state, thisValue, encodedValue, "bufferedAmountLowThreshold" ); |
422 | } |
423 | |
424 | static inline JSValue jsRTCDataChannelBinaryTypeGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
425 | { |
426 | UNUSED_PARAM(throwScope); |
427 | UNUSED_PARAM(state); |
428 | auto& impl = thisObject.wrapped(); |
429 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.binaryType()); |
430 | return result; |
431 | } |
432 | |
433 | EncodedJSValue jsRTCDataChannelBinaryType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
434 | { |
435 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelBinaryTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "binaryType" ); |
436 | } |
437 | |
438 | static inline bool setJSRTCDataChannelBinaryTypeSetter(ExecState& state, JSRTCDataChannel& thisObject, JSValue value, ThrowScope& throwScope) |
439 | { |
440 | UNUSED_PARAM(throwScope); |
441 | auto& impl = thisObject.wrapped(); |
442 | auto nativeValue = convert<IDLDOMString>(state, value); |
443 | RETURN_IF_EXCEPTION(throwScope, false); |
444 | AttributeSetter::call(state, throwScope, [&] { |
445 | return impl.setBinaryType(WTFMove(nativeValue)); |
446 | }); |
447 | return true; |
448 | } |
449 | |
450 | bool setJSRTCDataChannelBinaryType(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
451 | { |
452 | return IDLAttribute<JSRTCDataChannel>::set<setJSRTCDataChannelBinaryTypeSetter>(*state, thisValue, encodedValue, "binaryType" ); |
453 | } |
454 | |
455 | static inline JSValue jsRTCDataChannelOnopenGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
456 | { |
457 | UNUSED_PARAM(throwScope); |
458 | UNUSED_PARAM(state); |
459 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().openEvent, worldForDOMObject(thisObject)); |
460 | } |
461 | |
462 | EncodedJSValue jsRTCDataChannelOnopen(ExecState* state, EncodedJSValue thisValue, PropertyName) |
463 | { |
464 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelOnopenGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onopen" ); |
465 | } |
466 | |
467 | static inline bool setJSRTCDataChannelOnopenSetter(ExecState& state, JSRTCDataChannel& thisObject, JSValue value, ThrowScope& throwScope) |
468 | { |
469 | UNUSED_PARAM(throwScope); |
470 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().openEvent, value); |
471 | return true; |
472 | } |
473 | |
474 | bool setJSRTCDataChannelOnopen(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
475 | { |
476 | return IDLAttribute<JSRTCDataChannel>::set<setJSRTCDataChannelOnopenSetter>(*state, thisValue, encodedValue, "onopen" ); |
477 | } |
478 | |
479 | static inline JSValue jsRTCDataChannelOnerrorGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
480 | { |
481 | UNUSED_PARAM(throwScope); |
482 | UNUSED_PARAM(state); |
483 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().errorEvent, worldForDOMObject(thisObject)); |
484 | } |
485 | |
486 | EncodedJSValue jsRTCDataChannelOnerror(ExecState* state, EncodedJSValue thisValue, PropertyName) |
487 | { |
488 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelOnerrorGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onerror" ); |
489 | } |
490 | |
491 | static inline bool setJSRTCDataChannelOnerrorSetter(ExecState& state, JSRTCDataChannel& thisObject, JSValue value, ThrowScope& throwScope) |
492 | { |
493 | UNUSED_PARAM(throwScope); |
494 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().errorEvent, value); |
495 | return true; |
496 | } |
497 | |
498 | bool setJSRTCDataChannelOnerror(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
499 | { |
500 | return IDLAttribute<JSRTCDataChannel>::set<setJSRTCDataChannelOnerrorSetter>(*state, thisValue, encodedValue, "onerror" ); |
501 | } |
502 | |
503 | static inline JSValue jsRTCDataChannelOncloseGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
504 | { |
505 | UNUSED_PARAM(throwScope); |
506 | UNUSED_PARAM(state); |
507 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().closeEvent, worldForDOMObject(thisObject)); |
508 | } |
509 | |
510 | EncodedJSValue jsRTCDataChannelOnclose(ExecState* state, EncodedJSValue thisValue, PropertyName) |
511 | { |
512 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelOncloseGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onclose" ); |
513 | } |
514 | |
515 | static inline bool setJSRTCDataChannelOncloseSetter(ExecState& state, JSRTCDataChannel& thisObject, JSValue value, ThrowScope& throwScope) |
516 | { |
517 | UNUSED_PARAM(throwScope); |
518 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().closeEvent, value); |
519 | return true; |
520 | } |
521 | |
522 | bool setJSRTCDataChannelOnclose(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
523 | { |
524 | return IDLAttribute<JSRTCDataChannel>::set<setJSRTCDataChannelOncloseSetter>(*state, thisValue, encodedValue, "onclose" ); |
525 | } |
526 | |
527 | static inline JSValue jsRTCDataChannelOnmessageGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
528 | { |
529 | UNUSED_PARAM(throwScope); |
530 | UNUSED_PARAM(state); |
531 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().messageEvent, worldForDOMObject(thisObject)); |
532 | } |
533 | |
534 | EncodedJSValue jsRTCDataChannelOnmessage(ExecState* state, EncodedJSValue thisValue, PropertyName) |
535 | { |
536 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelOnmessageGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onmessage" ); |
537 | } |
538 | |
539 | static inline bool setJSRTCDataChannelOnmessageSetter(ExecState& state, JSRTCDataChannel& thisObject, JSValue value, ThrowScope& throwScope) |
540 | { |
541 | UNUSED_PARAM(throwScope); |
542 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().messageEvent, value); |
543 | return true; |
544 | } |
545 | |
546 | bool setJSRTCDataChannelOnmessage(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
547 | { |
548 | return IDLAttribute<JSRTCDataChannel>::set<setJSRTCDataChannelOnmessageSetter>(*state, thisValue, encodedValue, "onmessage" ); |
549 | } |
550 | |
551 | static inline JSValue jsRTCDataChannelOnbufferedamountlowGetter(ExecState& state, JSRTCDataChannel& thisObject, ThrowScope& throwScope) |
552 | { |
553 | UNUSED_PARAM(throwScope); |
554 | UNUSED_PARAM(state); |
555 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().bufferedamountlowEvent, worldForDOMObject(thisObject)); |
556 | } |
557 | |
558 | EncodedJSValue jsRTCDataChannelOnbufferedamountlow(ExecState* state, EncodedJSValue thisValue, PropertyName) |
559 | { |
560 | return IDLAttribute<JSRTCDataChannel>::get<jsRTCDataChannelOnbufferedamountlowGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onbufferedamountlow" ); |
561 | } |
562 | |
563 | static inline bool setJSRTCDataChannelOnbufferedamountlowSetter(ExecState& state, JSRTCDataChannel& thisObject, JSValue value, ThrowScope& throwScope) |
564 | { |
565 | UNUSED_PARAM(throwScope); |
566 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().bufferedamountlowEvent, value); |
567 | return true; |
568 | } |
569 | |
570 | bool setJSRTCDataChannelOnbufferedamountlow(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
571 | { |
572 | return IDLAttribute<JSRTCDataChannel>::set<setJSRTCDataChannelOnbufferedamountlowSetter>(*state, thisValue, encodedValue, "onbufferedamountlow" ); |
573 | } |
574 | |
575 | static inline JSC::EncodedJSValue jsRTCDataChannelPrototypeFunctionSend1Body(JSC::ExecState* state, typename IDLOperation<JSRTCDataChannel>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
576 | { |
577 | UNUSED_PARAM(state); |
578 | UNUSED_PARAM(throwScope); |
579 | auto& impl = castedThis->wrapped(); |
580 | auto data = convert<IDLArrayBuffer>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "data" , "RTCDataChannel" , "send" , "ArrayBuffer" ); }); |
581 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
582 | propagateException(*state, throwScope, impl.send(*data)); |
583 | return JSValue::encode(jsUndefined()); |
584 | } |
585 | |
586 | static inline JSC::EncodedJSValue jsRTCDataChannelPrototypeFunctionSend2Body(JSC::ExecState* state, typename IDLOperation<JSRTCDataChannel>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
587 | { |
588 | UNUSED_PARAM(state); |
589 | UNUSED_PARAM(throwScope); |
590 | auto& impl = castedThis->wrapped(); |
591 | auto data = convert<IDLArrayBufferView>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "data" , "RTCDataChannel" , "send" , "ArrayBufferView" ); }); |
592 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
593 | propagateException(*state, throwScope, impl.send(data.releaseNonNull())); |
594 | return JSValue::encode(jsUndefined()); |
595 | } |
596 | |
597 | static inline JSC::EncodedJSValue jsRTCDataChannelPrototypeFunctionSend3Body(JSC::ExecState* state, typename IDLOperation<JSRTCDataChannel>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
598 | { |
599 | UNUSED_PARAM(state); |
600 | UNUSED_PARAM(throwScope); |
601 | auto& impl = castedThis->wrapped(); |
602 | auto data = convert<IDLInterface<Blob>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "data" , "RTCDataChannel" , "send" , "Blob" ); }); |
603 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
604 | propagateException(*state, throwScope, impl.send(*data)); |
605 | return JSValue::encode(jsUndefined()); |
606 | } |
607 | |
608 | static inline JSC::EncodedJSValue jsRTCDataChannelPrototypeFunctionSend4Body(JSC::ExecState* state, typename IDLOperation<JSRTCDataChannel>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
609 | { |
610 | UNUSED_PARAM(state); |
611 | UNUSED_PARAM(throwScope); |
612 | auto& impl = castedThis->wrapped(); |
613 | auto data = convert<IDLUSVString>(*state, state->uncheckedArgument(0)); |
614 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
615 | propagateException(*state, throwScope, impl.send(WTFMove(data))); |
616 | return JSValue::encode(jsUndefined()); |
617 | } |
618 | |
619 | static inline JSC::EncodedJSValue jsRTCDataChannelPrototypeFunctionSendOverloadDispatcher(JSC::ExecState* state, typename IDLOperation<JSRTCDataChannel>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
620 | { |
621 | UNUSED_PARAM(state); |
622 | UNUSED_PARAM(throwScope); |
623 | VM& vm = state->vm(); |
624 | UNUSED_PARAM(vm); |
625 | size_t argsCount = std::min<size_t>(1, state->argumentCount()); |
626 | if (argsCount == 1) { |
627 | JSValue distinguishingArg = state->uncheckedArgument(0); |
628 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSArrayBuffer>(vm)) |
629 | return jsRTCDataChannelPrototypeFunctionSend1Body(state, castedThis, throwScope); |
630 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSArrayBufferView>(vm)) |
631 | return jsRTCDataChannelPrototypeFunctionSend2Body(state, castedThis, throwScope); |
632 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSBlob>(vm)) |
633 | return jsRTCDataChannelPrototypeFunctionSend3Body(state, castedThis, throwScope); |
634 | return jsRTCDataChannelPrototypeFunctionSend4Body(state, castedThis, throwScope); |
635 | } |
636 | return argsCount < 1 ? throwVMError(state, throwScope, createNotEnoughArgumentsError(state)) : throwVMTypeError(state, throwScope); |
637 | } |
638 | |
639 | EncodedJSValue JSC_HOST_CALL jsRTCDataChannelPrototypeFunctionSend(ExecState* state) |
640 | { |
641 | return IDLOperation<JSRTCDataChannel>::call<jsRTCDataChannelPrototypeFunctionSendOverloadDispatcher>(*state, "send" ); |
642 | } |
643 | |
644 | static inline JSC::EncodedJSValue jsRTCDataChannelPrototypeFunctionCloseBody(JSC::ExecState* state, typename IDLOperation<JSRTCDataChannel>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
645 | { |
646 | UNUSED_PARAM(state); |
647 | UNUSED_PARAM(throwScope); |
648 | auto& impl = castedThis->wrapped(); |
649 | impl.close(); |
650 | return JSValue::encode(jsUndefined()); |
651 | } |
652 | |
653 | EncodedJSValue JSC_HOST_CALL jsRTCDataChannelPrototypeFunctionClose(ExecState* state) |
654 | { |
655 | return IDLOperation<JSRTCDataChannel>::call<jsRTCDataChannelPrototypeFunctionCloseBody>(*state, "close" ); |
656 | } |
657 | |
658 | void JSRTCDataChannel::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
659 | { |
660 | auto* thisObject = jsCast<JSRTCDataChannel*>(cell); |
661 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
662 | if (thisObject->scriptExecutionContext()) |
663 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
664 | Base::heapSnapshot(cell, builder); |
665 | } |
666 | |
667 | bool JSRTCDataChannelOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
668 | { |
669 | auto* jsRTCDataChannel = jsCast<JSRTCDataChannel*>(handle.slot()->asCell()); |
670 | if (jsRTCDataChannel->wrapped().hasPendingActivity()) { |
671 | if (UNLIKELY(reason)) |
672 | *reason = "ActiveDOMObject with pending activity" ; |
673 | return true; |
674 | } |
675 | if (jsRTCDataChannel->wrapped().isFiringEventListeners()) { |
676 | if (UNLIKELY(reason)) |
677 | *reason = "EventTarget firing event listeners" ; |
678 | return true; |
679 | } |
680 | UNUSED_PARAM(visitor); |
681 | UNUSED_PARAM(reason); |
682 | return false; |
683 | } |
684 | |
685 | void JSRTCDataChannelOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
686 | { |
687 | auto* jsRTCDataChannel = static_cast<JSRTCDataChannel*>(handle.slot()->asCell()); |
688 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
689 | uncacheWrapper(world, &jsRTCDataChannel->wrapped(), jsRTCDataChannel); |
690 | } |
691 | |
692 | #if ENABLE(BINDING_INTEGRITY) |
693 | #if PLATFORM(WIN) |
694 | #pragma warning(disable: 4483) |
695 | extern "C" { extern void (*const __identifier("??_7RTCDataChannel@WebCore@@6B@" )[])(); } |
696 | #else |
697 | extern "C" { extern void* _ZTVN7WebCore14RTCDataChannelE[]; } |
698 | #endif |
699 | #endif |
700 | |
701 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<RTCDataChannel>&& impl) |
702 | { |
703 | |
704 | #if ENABLE(BINDING_INTEGRITY) |
705 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
706 | #if PLATFORM(WIN) |
707 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7RTCDataChannel@WebCore@@6B@" )); |
708 | #else |
709 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore14RTCDataChannelE[2]); |
710 | #endif |
711 | |
712 | // If this fails RTCDataChannel does not have a vtable, so you need to add the |
713 | // ImplementationLacksVTable attribute to the interface definition |
714 | static_assert(std::is_polymorphic<RTCDataChannel>::value, "RTCDataChannel is not polymorphic" ); |
715 | |
716 | // If you hit this assertion you either have a use after free bug, or |
717 | // RTCDataChannel has subclasses. If RTCDataChannel has subclasses that get passed |
718 | // to toJS() we currently require RTCDataChannel you to opt out of binding hardening |
719 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
720 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
721 | #endif |
722 | return createWrapper<RTCDataChannel>(globalObject, WTFMove(impl)); |
723 | } |
724 | |
725 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RTCDataChannel& impl) |
726 | { |
727 | return wrap(state, globalObject, impl); |
728 | } |
729 | |
730 | RTCDataChannel* JSRTCDataChannel::toWrapped(JSC::VM& vm, JSC::JSValue value) |
731 | { |
732 | if (auto* wrapper = jsDynamicCast<JSRTCDataChannel*>(vm, value)) |
733 | return &wrapper->wrapped(); |
734 | return nullptr; |
735 | } |
736 | |
737 | } |
738 | |
739 | #endif // ENABLE(WEB_RTC) |
740 | |