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(ENCRYPTED_MEDIA) |
24 | |
25 | #include "JSMediaKeySession.h" |
26 | |
27 | #include "DOMPromiseProxy.h" |
28 | #include "EventNames.h" |
29 | #include "JSDOMAttribute.h" |
30 | #include "JSDOMBinding.h" |
31 | #include "JSDOMConstructorNotConstructable.h" |
32 | #include "JSDOMConvertBufferSource.h" |
33 | #include "JSDOMConvertInterface.h" |
34 | #include "JSDOMConvertNumbers.h" |
35 | #include "JSDOMConvertPromise.h" |
36 | #include "JSDOMConvertStrings.h" |
37 | #include "JSDOMConvertUnion.h" |
38 | #include "JSDOMExceptionHandling.h" |
39 | #include "JSDOMGlobalObject.h" |
40 | #include "JSDOMOperation.h" |
41 | #include "JSDOMOperationReturningPromise.h" |
42 | #include "JSDOMWrapperCache.h" |
43 | #include "JSEventListener.h" |
44 | #include "JSMediaKeyStatusMap.h" |
45 | #include "ScriptExecutionContext.h" |
46 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
47 | #include <JavaScriptCore/JSCInlines.h> |
48 | #include <wtf/GetPtr.h> |
49 | #include <wtf/PointerPreparations.h> |
50 | #include <wtf/URL.h> |
51 | #include <wtf/Variant.h> |
52 | |
53 | |
54 | namespace WebCore { |
55 | using namespace JSC; |
56 | |
57 | // Functions |
58 | |
59 | JSC::EncodedJSValue JSC_HOST_CALL jsMediaKeySessionPrototypeFunctionGenerateRequest(JSC::ExecState*); |
60 | JSC::EncodedJSValue JSC_HOST_CALL jsMediaKeySessionPrototypeFunctionLoad(JSC::ExecState*); |
61 | JSC::EncodedJSValue JSC_HOST_CALL jsMediaKeySessionPrototypeFunctionUpdate(JSC::ExecState*); |
62 | JSC::EncodedJSValue JSC_HOST_CALL jsMediaKeySessionPrototypeFunctionClose(JSC::ExecState*); |
63 | JSC::EncodedJSValue JSC_HOST_CALL jsMediaKeySessionPrototypeFunctionRemove(JSC::ExecState*); |
64 | |
65 | // Attributes |
66 | |
67 | JSC::EncodedJSValue jsMediaKeySessionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
68 | bool setJSMediaKeySessionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
69 | JSC::EncodedJSValue jsMediaKeySessionSessionId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
70 | JSC::EncodedJSValue jsMediaKeySessionExpiration(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
71 | JSC::EncodedJSValue jsMediaKeySessionClosed(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
72 | JSC::EncodedJSValue jsMediaKeySessionKeyStatuses(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
73 | JSC::EncodedJSValue jsMediaKeySessionOnkeystatuseschange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
74 | bool setJSMediaKeySessionOnkeystatuseschange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
75 | JSC::EncodedJSValue jsMediaKeySessionOnmessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
76 | bool setJSMediaKeySessionOnmessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
77 | |
78 | class JSMediaKeySessionPrototype : public JSC::JSNonFinalObject { |
79 | public: |
80 | using Base = JSC::JSNonFinalObject; |
81 | static JSMediaKeySessionPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
82 | { |
83 | JSMediaKeySessionPrototype* ptr = new (NotNull, JSC::allocateCell<JSMediaKeySessionPrototype>(vm.heap)) JSMediaKeySessionPrototype(vm, globalObject, structure); |
84 | ptr->finishCreation(vm); |
85 | return ptr; |
86 | } |
87 | |
88 | DECLARE_INFO; |
89 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
90 | { |
91 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
92 | } |
93 | |
94 | private: |
95 | JSMediaKeySessionPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
96 | : JSC::JSNonFinalObject(vm, structure) |
97 | { |
98 | } |
99 | |
100 | void finishCreation(JSC::VM&); |
101 | }; |
102 | |
103 | using JSMediaKeySessionConstructor = JSDOMConstructorNotConstructable<JSMediaKeySession>; |
104 | |
105 | template<> JSValue JSMediaKeySessionConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
106 | { |
107 | return JSEventTarget::getConstructor(vm, &globalObject); |
108 | } |
109 | |
110 | template<> void JSMediaKeySessionConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
111 | { |
112 | putDirect(vm, vm.propertyNames->prototype, JSMediaKeySession::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
113 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("MediaKeySession"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
114 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
115 | } |
116 | |
117 | template<> const ClassInfo JSMediaKeySessionConstructor::s_info = { "MediaKeySession" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaKeySessionConstructor) }; |
118 | |
119 | /* Hash table for prototype */ |
120 | |
121 | static const HashTableValue JSMediaKeySessionPrototypeTableValues[] = |
122 | { |
123 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaKeySessionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaKeySessionConstructor) } }, |
124 | { "sessionId" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaKeySessionSessionId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
125 | { "expiration" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaKeySessionExpiration), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
126 | { "closed" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaKeySessionClosed), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
127 | { "keyStatuses" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaKeySessionKeyStatuses), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
128 | { "onkeystatuseschange" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaKeySessionOnkeystatuseschange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaKeySessionOnkeystatuseschange) } }, |
129 | { "onmessage" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaKeySessionOnmessage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaKeySessionOnmessage) } }, |
130 | { "generateRequest" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaKeySessionPrototypeFunctionGenerateRequest), (intptr_t) (2) } }, |
131 | { "load" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaKeySessionPrototypeFunctionLoad), (intptr_t) (1) } }, |
132 | { "update" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaKeySessionPrototypeFunctionUpdate), (intptr_t) (1) } }, |
133 | { "close" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaKeySessionPrototypeFunctionClose), (intptr_t) (0) } }, |
134 | { "remove" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaKeySessionPrototypeFunctionRemove), (intptr_t) (0) } }, |
135 | }; |
136 | |
137 | const ClassInfo JSMediaKeySessionPrototype::s_info = { "MediaKeySessionPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaKeySessionPrototype) }; |
138 | |
139 | void JSMediaKeySessionPrototype::finishCreation(VM& vm) |
140 | { |
141 | Base::finishCreation(vm); |
142 | reifyStaticProperties(vm, JSMediaKeySession::info(), JSMediaKeySessionPrototypeTableValues, *this); |
143 | } |
144 | |
145 | const ClassInfo JSMediaKeySession::s_info = { "MediaKeySession" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaKeySession) }; |
146 | |
147 | JSMediaKeySession::JSMediaKeySession(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MediaKeySession>&& impl) |
148 | : JSEventTarget(structure, globalObject, WTFMove(impl)) |
149 | { |
150 | } |
151 | |
152 | void JSMediaKeySession::finishCreation(VM& vm) |
153 | { |
154 | Base::finishCreation(vm); |
155 | ASSERT(inherits(vm, info())); |
156 | |
157 | } |
158 | |
159 | JSObject* JSMediaKeySession::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
160 | { |
161 | return JSMediaKeySessionPrototype::create(vm, &globalObject, JSMediaKeySessionPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
162 | } |
163 | |
164 | JSObject* JSMediaKeySession::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
165 | { |
166 | return getDOMPrototype<JSMediaKeySession>(vm, globalObject); |
167 | } |
168 | |
169 | JSValue JSMediaKeySession::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
170 | { |
171 | return getDOMConstructor<JSMediaKeySessionConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
172 | } |
173 | |
174 | template<> inline JSMediaKeySession* IDLAttribute<JSMediaKeySession>::cast(ExecState& state, EncodedJSValue thisValue) |
175 | { |
176 | return jsDynamicCast<JSMediaKeySession*>(state.vm(), JSValue::decode(thisValue)); |
177 | } |
178 | |
179 | template<> inline JSMediaKeySession* IDLOperation<JSMediaKeySession>::cast(ExecState& state) |
180 | { |
181 | return jsDynamicCast<JSMediaKeySession*>(state.vm(), state.thisValue()); |
182 | } |
183 | |
184 | EncodedJSValue jsMediaKeySessionConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
185 | { |
186 | VM& vm = state->vm(); |
187 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
188 | auto* prototype = jsDynamicCast<JSMediaKeySessionPrototype*>(vm, JSValue::decode(thisValue)); |
189 | if (UNLIKELY(!prototype)) |
190 | return throwVMTypeError(state, throwScope); |
191 | return JSValue::encode(JSMediaKeySession::getConstructor(state->vm(), prototype->globalObject())); |
192 | } |
193 | |
194 | bool setJSMediaKeySessionConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
195 | { |
196 | VM& vm = state->vm(); |
197 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
198 | auto* prototype = jsDynamicCast<JSMediaKeySessionPrototype*>(vm, JSValue::decode(thisValue)); |
199 | if (UNLIKELY(!prototype)) { |
200 | throwVMTypeError(state, throwScope); |
201 | return false; |
202 | } |
203 | // Shadowing a built-in constructor |
204 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
205 | } |
206 | |
207 | static inline JSValue jsMediaKeySessionSessionIdGetter(ExecState& state, JSMediaKeySession& thisObject, ThrowScope& throwScope) |
208 | { |
209 | UNUSED_PARAM(throwScope); |
210 | UNUSED_PARAM(state); |
211 | auto& impl = thisObject.wrapped(); |
212 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.sessionId()); |
213 | return result; |
214 | } |
215 | |
216 | EncodedJSValue jsMediaKeySessionSessionId(ExecState* state, EncodedJSValue thisValue, PropertyName) |
217 | { |
218 | return IDLAttribute<JSMediaKeySession>::get<jsMediaKeySessionSessionIdGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "sessionId" ); |
219 | } |
220 | |
221 | static inline JSValue jsMediaKeySessionExpirationGetter(ExecState& state, JSMediaKeySession& thisObject, ThrowScope& throwScope) |
222 | { |
223 | UNUSED_PARAM(throwScope); |
224 | UNUSED_PARAM(state); |
225 | auto& impl = thisObject.wrapped(); |
226 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.expiration()); |
227 | return result; |
228 | } |
229 | |
230 | EncodedJSValue jsMediaKeySessionExpiration(ExecState* state, EncodedJSValue thisValue, PropertyName) |
231 | { |
232 | return IDLAttribute<JSMediaKeySession>::get<jsMediaKeySessionExpirationGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "expiration" ); |
233 | } |
234 | |
235 | static inline JSValue jsMediaKeySessionClosedGetter(ExecState& state, JSMediaKeySession& thisObject, ThrowScope& throwScope) |
236 | { |
237 | UNUSED_PARAM(throwScope); |
238 | UNUSED_PARAM(state); |
239 | auto& impl = thisObject.wrapped(); |
240 | JSValue result = toJS<IDLPromise<IDLVoid>>(state, *thisObject.globalObject(), throwScope, impl.closed()); |
241 | return result; |
242 | } |
243 | |
244 | EncodedJSValue jsMediaKeySessionClosed(ExecState* state, EncodedJSValue thisValue, PropertyName) |
245 | { |
246 | return IDLAttribute<JSMediaKeySession>::get<jsMediaKeySessionClosedGetter, CastedThisErrorBehavior::RejectPromise>(*state, thisValue, "closed" ); |
247 | } |
248 | |
249 | static inline JSValue jsMediaKeySessionKeyStatusesGetter(ExecState& state, JSMediaKeySession& thisObject, ThrowScope& throwScope) |
250 | { |
251 | UNUSED_PARAM(throwScope); |
252 | UNUSED_PARAM(state); |
253 | auto& impl = thisObject.wrapped(); |
254 | JSValue result = toJS<IDLInterface<MediaKeyStatusMap>>(state, *thisObject.globalObject(), throwScope, impl.keyStatuses()); |
255 | return result; |
256 | } |
257 | |
258 | EncodedJSValue jsMediaKeySessionKeyStatuses(ExecState* state, EncodedJSValue thisValue, PropertyName) |
259 | { |
260 | return IDLAttribute<JSMediaKeySession>::get<jsMediaKeySessionKeyStatusesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "keyStatuses" ); |
261 | } |
262 | |
263 | static inline JSValue jsMediaKeySessionOnkeystatuseschangeGetter(ExecState& state, JSMediaKeySession& thisObject, ThrowScope& throwScope) |
264 | { |
265 | UNUSED_PARAM(throwScope); |
266 | UNUSED_PARAM(state); |
267 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().keystatuseschangeEvent, worldForDOMObject(thisObject)); |
268 | } |
269 | |
270 | EncodedJSValue jsMediaKeySessionOnkeystatuseschange(ExecState* state, EncodedJSValue thisValue, PropertyName) |
271 | { |
272 | return IDLAttribute<JSMediaKeySession>::get<jsMediaKeySessionOnkeystatuseschangeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onkeystatuseschange" ); |
273 | } |
274 | |
275 | static inline bool setJSMediaKeySessionOnkeystatuseschangeSetter(ExecState& state, JSMediaKeySession& thisObject, JSValue value, ThrowScope& throwScope) |
276 | { |
277 | UNUSED_PARAM(throwScope); |
278 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().keystatuseschangeEvent, value); |
279 | return true; |
280 | } |
281 | |
282 | bool setJSMediaKeySessionOnkeystatuseschange(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
283 | { |
284 | return IDLAttribute<JSMediaKeySession>::set<setJSMediaKeySessionOnkeystatuseschangeSetter>(*state, thisValue, encodedValue, "onkeystatuseschange" ); |
285 | } |
286 | |
287 | static inline JSValue jsMediaKeySessionOnmessageGetter(ExecState& state, JSMediaKeySession& thisObject, ThrowScope& throwScope) |
288 | { |
289 | UNUSED_PARAM(throwScope); |
290 | UNUSED_PARAM(state); |
291 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().messageEvent, worldForDOMObject(thisObject)); |
292 | } |
293 | |
294 | EncodedJSValue jsMediaKeySessionOnmessage(ExecState* state, EncodedJSValue thisValue, PropertyName) |
295 | { |
296 | return IDLAttribute<JSMediaKeySession>::get<jsMediaKeySessionOnmessageGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onmessage" ); |
297 | } |
298 | |
299 | static inline bool setJSMediaKeySessionOnmessageSetter(ExecState& state, JSMediaKeySession& thisObject, JSValue value, ThrowScope& throwScope) |
300 | { |
301 | UNUSED_PARAM(throwScope); |
302 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().messageEvent, value); |
303 | return true; |
304 | } |
305 | |
306 | bool setJSMediaKeySessionOnmessage(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
307 | { |
308 | return IDLAttribute<JSMediaKeySession>::set<setJSMediaKeySessionOnmessageSetter>(*state, thisValue, encodedValue, "onmessage" ); |
309 | } |
310 | |
311 | static inline JSC::EncodedJSValue jsMediaKeySessionPrototypeFunctionGenerateRequestBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSMediaKeySession>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
312 | { |
313 | UNUSED_PARAM(state); |
314 | UNUSED_PARAM(throwScope); |
315 | auto& impl = castedThis->wrapped(); |
316 | if (UNLIKELY(state->argumentCount() < 2)) |
317 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
318 | auto initDataType = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
319 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
320 | auto initData = convert<IDLUnion<IDLArrayBufferView, IDLArrayBuffer>>(*state, state->uncheckedArgument(1)); |
321 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
322 | impl.generateRequest(WTFMove(initDataType), WTFMove(initData), WTFMove(promise)); |
323 | return JSValue::encode(jsUndefined()); |
324 | } |
325 | |
326 | EncodedJSValue JSC_HOST_CALL jsMediaKeySessionPrototypeFunctionGenerateRequest(ExecState* state) |
327 | { |
328 | return IDLOperationReturningPromise<JSMediaKeySession>::call<jsMediaKeySessionPrototypeFunctionGenerateRequestBody, PromiseExecutionScope::WindowOnly>(*state, "generateRequest" ); |
329 | } |
330 | |
331 | static inline JSC::EncodedJSValue jsMediaKeySessionPrototypeFunctionLoadBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSMediaKeySession>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
332 | { |
333 | UNUSED_PARAM(state); |
334 | UNUSED_PARAM(throwScope); |
335 | auto& impl = castedThis->wrapped(); |
336 | if (UNLIKELY(state->argumentCount() < 1)) |
337 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
338 | auto sessionId = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
339 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
340 | impl.load(WTFMove(sessionId), WTFMove(promise)); |
341 | return JSValue::encode(jsUndefined()); |
342 | } |
343 | |
344 | EncodedJSValue JSC_HOST_CALL jsMediaKeySessionPrototypeFunctionLoad(ExecState* state) |
345 | { |
346 | return IDLOperationReturningPromise<JSMediaKeySession>::call<jsMediaKeySessionPrototypeFunctionLoadBody, PromiseExecutionScope::WindowOnly>(*state, "load" ); |
347 | } |
348 | |
349 | static inline JSC::EncodedJSValue jsMediaKeySessionPrototypeFunctionUpdateBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSMediaKeySession>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
350 | { |
351 | UNUSED_PARAM(state); |
352 | UNUSED_PARAM(throwScope); |
353 | auto& impl = castedThis->wrapped(); |
354 | if (UNLIKELY(state->argumentCount() < 1)) |
355 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
356 | auto response = convert<IDLUnion<IDLArrayBufferView, IDLArrayBuffer>>(*state, state->uncheckedArgument(0)); |
357 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
358 | impl.update(WTFMove(response), WTFMove(promise)); |
359 | return JSValue::encode(jsUndefined()); |
360 | } |
361 | |
362 | EncodedJSValue JSC_HOST_CALL jsMediaKeySessionPrototypeFunctionUpdate(ExecState* state) |
363 | { |
364 | return IDLOperationReturningPromise<JSMediaKeySession>::call<jsMediaKeySessionPrototypeFunctionUpdateBody, PromiseExecutionScope::WindowOnly>(*state, "update" ); |
365 | } |
366 | |
367 | static inline JSC::EncodedJSValue jsMediaKeySessionPrototypeFunctionCloseBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSMediaKeySession>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
368 | { |
369 | UNUSED_PARAM(state); |
370 | UNUSED_PARAM(throwScope); |
371 | auto& impl = castedThis->wrapped(); |
372 | impl.close(WTFMove(promise)); |
373 | return JSValue::encode(jsUndefined()); |
374 | } |
375 | |
376 | EncodedJSValue JSC_HOST_CALL jsMediaKeySessionPrototypeFunctionClose(ExecState* state) |
377 | { |
378 | return IDLOperationReturningPromise<JSMediaKeySession>::call<jsMediaKeySessionPrototypeFunctionCloseBody, PromiseExecutionScope::WindowOnly>(*state, "close" ); |
379 | } |
380 | |
381 | static inline JSC::EncodedJSValue jsMediaKeySessionPrototypeFunctionRemoveBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSMediaKeySession>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
382 | { |
383 | UNUSED_PARAM(state); |
384 | UNUSED_PARAM(throwScope); |
385 | auto& impl = castedThis->wrapped(); |
386 | impl.remove(WTFMove(promise)); |
387 | return JSValue::encode(jsUndefined()); |
388 | } |
389 | |
390 | EncodedJSValue JSC_HOST_CALL jsMediaKeySessionPrototypeFunctionRemove(ExecState* state) |
391 | { |
392 | return IDLOperationReturningPromise<JSMediaKeySession>::call<jsMediaKeySessionPrototypeFunctionRemoveBody, PromiseExecutionScope::WindowOnly>(*state, "remove" ); |
393 | } |
394 | |
395 | void JSMediaKeySession::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
396 | { |
397 | auto* thisObject = jsCast<JSMediaKeySession*>(cell); |
398 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
399 | if (thisObject->scriptExecutionContext()) |
400 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
401 | Base::heapSnapshot(cell, builder); |
402 | } |
403 | |
404 | #if ENABLE(BINDING_INTEGRITY) |
405 | #if PLATFORM(WIN) |
406 | #pragma warning(disable: 4483) |
407 | extern "C" { extern void (*const __identifier("??_7MediaKeySession@WebCore@@6B@" )[])(); } |
408 | #else |
409 | extern "C" { extern void* _ZTVN7WebCore15MediaKeySessionE[]; } |
410 | #endif |
411 | #endif |
412 | |
413 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MediaKeySession>&& impl) |
414 | { |
415 | |
416 | #if ENABLE(BINDING_INTEGRITY) |
417 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
418 | #if PLATFORM(WIN) |
419 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7MediaKeySession@WebCore@@6B@" )); |
420 | #else |
421 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore15MediaKeySessionE[2]); |
422 | #endif |
423 | |
424 | // If this fails MediaKeySession does not have a vtable, so you need to add the |
425 | // ImplementationLacksVTable attribute to the interface definition |
426 | static_assert(std::is_polymorphic<MediaKeySession>::value, "MediaKeySession is not polymorphic" ); |
427 | |
428 | // If you hit this assertion you either have a use after free bug, or |
429 | // MediaKeySession has subclasses. If MediaKeySession has subclasses that get passed |
430 | // to toJS() we currently require MediaKeySession you to opt out of binding hardening |
431 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
432 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
433 | #endif |
434 | return createWrapper<MediaKeySession>(globalObject, WTFMove(impl)); |
435 | } |
436 | |
437 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MediaKeySession& impl) |
438 | { |
439 | return wrap(state, globalObject, impl); |
440 | } |
441 | |
442 | MediaKeySession* JSMediaKeySession::toWrapped(JSC::VM& vm, JSC::JSValue value) |
443 | { |
444 | if (auto* wrapper = jsDynamicCast<JSMediaKeySession*>(vm, value)) |
445 | return &wrapper->wrapped(); |
446 | return nullptr; |
447 | } |
448 | |
449 | } |
450 | |
451 | #endif // ENABLE(ENCRYPTED_MEDIA) |
452 | |