/work/obj-fuzz/dom/bindings/PeerConnectionObserverBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM PeerConnectionObserver.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AtomList.h" |
4 | | #include "PeerConnectionObserverBinding.h" |
5 | | #include "RTCPeerConnectionBinding.h" |
6 | | #include "RTCStatsReportBinding.h" |
7 | | #include "TransceiverImpl.h" |
8 | | #include "WrapperFactory.h" |
9 | | #include "jsfriendapi.h" |
10 | | #include "mozilla/OwningNonNull.h" |
11 | | #include "mozilla/dom/BindingUtils.h" |
12 | | #include "mozilla/dom/DOMJSClass.h" |
13 | | #include "mozilla/dom/MediaStreamTrack.h" |
14 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
15 | | #include "mozilla/dom/PrimitiveConversions.h" |
16 | | #include "mozilla/dom/XrayExpandoClass.h" |
17 | | #include "nsContentUtils.h" |
18 | | #include "nsDOMDataChannel.h" |
19 | | #include "nsIGlobalObject.h" |
20 | | |
21 | | namespace mozilla { |
22 | | namespace dom { |
23 | | |
24 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
25 | | using namespace mozilla::dom::binding_detail; |
26 | | |
27 | | |
28 | | namespace PeerConnectionObserver_Binding { |
29 | | |
30 | | MOZ_CAN_RUN_SCRIPT static bool |
31 | | onCreateOfferSuccess(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
32 | 0 | { |
33 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onCreateOfferSuccess", DOM, cx); |
34 | 0 |
|
35 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
36 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver.onCreateOfferSuccess"); |
37 | 0 | } |
38 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
39 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
40 | 0 | if (objIsXray) { |
41 | 0 | unwrappedObj.emplace(cx, obj); |
42 | 0 | } |
43 | 0 | binding_detail::FakeString arg0; |
44 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
45 | 0 | return false; |
46 | 0 | } |
47 | 0 | if (objIsXray) { |
48 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
49 | 0 | if (!unwrappedObj.ref()) { |
50 | 0 | return false; |
51 | 0 | } |
52 | 0 | } |
53 | 0 | FastErrorResult rv; |
54 | 0 | self->OnCreateOfferSuccess(NonNullHelper(Constify(arg0)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
55 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
56 | 0 | return false; |
57 | 0 | } |
58 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
59 | 0 | args.rval().setUndefined(); |
60 | 0 | return true; |
61 | 0 | } |
62 | | |
63 | | static const JSJitInfo onCreateOfferSuccess_methodinfo = { |
64 | | { (JSJitGetterOp)onCreateOfferSuccess }, |
65 | | { prototypes::id::PeerConnectionObserver }, |
66 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
67 | | JSJitInfo::Method, |
68 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
69 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
70 | | false, /* isInfallible. False in setters. */ |
71 | | false, /* isMovable. Not relevant for setters. */ |
72 | | false, /* isEliminatable. Not relevant for setters. */ |
73 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
74 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
75 | | false, /* isTypedMethod. Only relevant for methods. */ |
76 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
77 | | }; |
78 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
79 | | static_assert(0 < 1, "There is no slot for us"); |
80 | | |
81 | | MOZ_CAN_RUN_SCRIPT static bool |
82 | | onCreateOfferError(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
83 | 0 | { |
84 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onCreateOfferError", DOM, cx); |
85 | 0 |
|
86 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
87 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver.onCreateOfferError"); |
88 | 0 | } |
89 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
90 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
91 | 0 | if (objIsXray) { |
92 | 0 | unwrappedObj.emplace(cx, obj); |
93 | 0 | } |
94 | 0 | uint32_t arg0; |
95 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
96 | 0 | return false; |
97 | 0 | } |
98 | 0 | binding_detail::FakeString arg1; |
99 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
100 | 0 | return false; |
101 | 0 | } |
102 | 0 | if (objIsXray) { |
103 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
104 | 0 | if (!unwrappedObj.ref()) { |
105 | 0 | return false; |
106 | 0 | } |
107 | 0 | } |
108 | 0 | FastErrorResult rv; |
109 | 0 | self->OnCreateOfferError(arg0, NonNullHelper(Constify(arg1)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
110 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
111 | 0 | return false; |
112 | 0 | } |
113 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
114 | 0 | args.rval().setUndefined(); |
115 | 0 | return true; |
116 | 0 | } |
117 | | |
118 | | static const JSJitInfo onCreateOfferError_methodinfo = { |
119 | | { (JSJitGetterOp)onCreateOfferError }, |
120 | | { prototypes::id::PeerConnectionObserver }, |
121 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
122 | | JSJitInfo::Method, |
123 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
124 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
125 | | false, /* isInfallible. False in setters. */ |
126 | | false, /* isMovable. Not relevant for setters. */ |
127 | | false, /* isEliminatable. Not relevant for setters. */ |
128 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
129 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
130 | | false, /* isTypedMethod. Only relevant for methods. */ |
131 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
132 | | }; |
133 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
134 | | static_assert(0 < 1, "There is no slot for us"); |
135 | | |
136 | | MOZ_CAN_RUN_SCRIPT static bool |
137 | | onCreateAnswerSuccess(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
138 | 0 | { |
139 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onCreateAnswerSuccess", DOM, cx); |
140 | 0 |
|
141 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
142 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver.onCreateAnswerSuccess"); |
143 | 0 | } |
144 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
145 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
146 | 0 | if (objIsXray) { |
147 | 0 | unwrappedObj.emplace(cx, obj); |
148 | 0 | } |
149 | 0 | binding_detail::FakeString arg0; |
150 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
151 | 0 | return false; |
152 | 0 | } |
153 | 0 | if (objIsXray) { |
154 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
155 | 0 | if (!unwrappedObj.ref()) { |
156 | 0 | return false; |
157 | 0 | } |
158 | 0 | } |
159 | 0 | FastErrorResult rv; |
160 | 0 | self->OnCreateAnswerSuccess(NonNullHelper(Constify(arg0)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
161 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
162 | 0 | return false; |
163 | 0 | } |
164 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
165 | 0 | args.rval().setUndefined(); |
166 | 0 | return true; |
167 | 0 | } |
168 | | |
169 | | static const JSJitInfo onCreateAnswerSuccess_methodinfo = { |
170 | | { (JSJitGetterOp)onCreateAnswerSuccess }, |
171 | | { prototypes::id::PeerConnectionObserver }, |
172 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
173 | | JSJitInfo::Method, |
174 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
175 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
176 | | false, /* isInfallible. False in setters. */ |
177 | | false, /* isMovable. Not relevant for setters. */ |
178 | | false, /* isEliminatable. Not relevant for setters. */ |
179 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
180 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
181 | | false, /* isTypedMethod. Only relevant for methods. */ |
182 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
183 | | }; |
184 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
185 | | static_assert(0 < 1, "There is no slot for us"); |
186 | | |
187 | | MOZ_CAN_RUN_SCRIPT static bool |
188 | | onCreateAnswerError(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
189 | 0 | { |
190 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onCreateAnswerError", DOM, cx); |
191 | 0 |
|
192 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
193 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver.onCreateAnswerError"); |
194 | 0 | } |
195 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
196 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
197 | 0 | if (objIsXray) { |
198 | 0 | unwrappedObj.emplace(cx, obj); |
199 | 0 | } |
200 | 0 | uint32_t arg0; |
201 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
202 | 0 | return false; |
203 | 0 | } |
204 | 0 | binding_detail::FakeString arg1; |
205 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
206 | 0 | return false; |
207 | 0 | } |
208 | 0 | if (objIsXray) { |
209 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
210 | 0 | if (!unwrappedObj.ref()) { |
211 | 0 | return false; |
212 | 0 | } |
213 | 0 | } |
214 | 0 | FastErrorResult rv; |
215 | 0 | self->OnCreateAnswerError(arg0, NonNullHelper(Constify(arg1)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
216 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
217 | 0 | return false; |
218 | 0 | } |
219 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
220 | 0 | args.rval().setUndefined(); |
221 | 0 | return true; |
222 | 0 | } |
223 | | |
224 | | static const JSJitInfo onCreateAnswerError_methodinfo = { |
225 | | { (JSJitGetterOp)onCreateAnswerError }, |
226 | | { prototypes::id::PeerConnectionObserver }, |
227 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
228 | | JSJitInfo::Method, |
229 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
230 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
231 | | false, /* isInfallible. False in setters. */ |
232 | | false, /* isMovable. Not relevant for setters. */ |
233 | | false, /* isEliminatable. Not relevant for setters. */ |
234 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
235 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
236 | | false, /* isTypedMethod. Only relevant for methods. */ |
237 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
238 | | }; |
239 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
240 | | static_assert(0 < 1, "There is no slot for us"); |
241 | | |
242 | | MOZ_CAN_RUN_SCRIPT static bool |
243 | | onSetLocalDescriptionSuccess(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
244 | 0 | { |
245 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onSetLocalDescriptionSuccess", DOM, cx); |
246 | 0 |
|
247 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
248 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
249 | 0 | if (objIsXray) { |
250 | 0 | unwrappedObj.emplace(cx, obj); |
251 | 0 | } |
252 | 0 | if (objIsXray) { |
253 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
254 | 0 | if (!unwrappedObj.ref()) { |
255 | 0 | return false; |
256 | 0 | } |
257 | 0 | } |
258 | 0 | FastErrorResult rv; |
259 | 0 | self->OnSetLocalDescriptionSuccess(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
260 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
261 | 0 | return false; |
262 | 0 | } |
263 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
264 | 0 | args.rval().setUndefined(); |
265 | 0 | return true; |
266 | 0 | } |
267 | | |
268 | | static const JSJitInfo onSetLocalDescriptionSuccess_methodinfo = { |
269 | | { (JSJitGetterOp)onSetLocalDescriptionSuccess }, |
270 | | { prototypes::id::PeerConnectionObserver }, |
271 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
272 | | JSJitInfo::Method, |
273 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
274 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
275 | | false, /* isInfallible. False in setters. */ |
276 | | false, /* isMovable. Not relevant for setters. */ |
277 | | false, /* isEliminatable. Not relevant for setters. */ |
278 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
279 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
280 | | false, /* isTypedMethod. Only relevant for methods. */ |
281 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
282 | | }; |
283 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
284 | | static_assert(0 < 1, "There is no slot for us"); |
285 | | |
286 | | MOZ_CAN_RUN_SCRIPT static bool |
287 | | onSetRemoteDescriptionSuccess(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
288 | 0 | { |
289 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onSetRemoteDescriptionSuccess", DOM, cx); |
290 | 0 |
|
291 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
292 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
293 | 0 | if (objIsXray) { |
294 | 0 | unwrappedObj.emplace(cx, obj); |
295 | 0 | } |
296 | 0 | if (objIsXray) { |
297 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
298 | 0 | if (!unwrappedObj.ref()) { |
299 | 0 | return false; |
300 | 0 | } |
301 | 0 | } |
302 | 0 | FastErrorResult rv; |
303 | 0 | self->OnSetRemoteDescriptionSuccess(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
304 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
305 | 0 | return false; |
306 | 0 | } |
307 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
308 | 0 | args.rval().setUndefined(); |
309 | 0 | return true; |
310 | 0 | } |
311 | | |
312 | | static const JSJitInfo onSetRemoteDescriptionSuccess_methodinfo = { |
313 | | { (JSJitGetterOp)onSetRemoteDescriptionSuccess }, |
314 | | { prototypes::id::PeerConnectionObserver }, |
315 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
316 | | JSJitInfo::Method, |
317 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
318 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
319 | | false, /* isInfallible. False in setters. */ |
320 | | false, /* isMovable. Not relevant for setters. */ |
321 | | false, /* isEliminatable. Not relevant for setters. */ |
322 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
323 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
324 | | false, /* isTypedMethod. Only relevant for methods. */ |
325 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
326 | | }; |
327 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
328 | | static_assert(0 < 1, "There is no slot for us"); |
329 | | |
330 | | MOZ_CAN_RUN_SCRIPT static bool |
331 | | onSetLocalDescriptionError(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
332 | 0 | { |
333 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onSetLocalDescriptionError", DOM, cx); |
334 | 0 |
|
335 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
336 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver.onSetLocalDescriptionError"); |
337 | 0 | } |
338 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
339 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
340 | 0 | if (objIsXray) { |
341 | 0 | unwrappedObj.emplace(cx, obj); |
342 | 0 | } |
343 | 0 | uint32_t arg0; |
344 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
345 | 0 | return false; |
346 | 0 | } |
347 | 0 | binding_detail::FakeString arg1; |
348 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
349 | 0 | return false; |
350 | 0 | } |
351 | 0 | if (objIsXray) { |
352 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
353 | 0 | if (!unwrappedObj.ref()) { |
354 | 0 | return false; |
355 | 0 | } |
356 | 0 | } |
357 | 0 | FastErrorResult rv; |
358 | 0 | self->OnSetLocalDescriptionError(arg0, NonNullHelper(Constify(arg1)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
359 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
360 | 0 | return false; |
361 | 0 | } |
362 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
363 | 0 | args.rval().setUndefined(); |
364 | 0 | return true; |
365 | 0 | } |
366 | | |
367 | | static const JSJitInfo onSetLocalDescriptionError_methodinfo = { |
368 | | { (JSJitGetterOp)onSetLocalDescriptionError }, |
369 | | { prototypes::id::PeerConnectionObserver }, |
370 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
371 | | JSJitInfo::Method, |
372 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
373 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
374 | | false, /* isInfallible. False in setters. */ |
375 | | false, /* isMovable. Not relevant for setters. */ |
376 | | false, /* isEliminatable. Not relevant for setters. */ |
377 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
378 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
379 | | false, /* isTypedMethod. Only relevant for methods. */ |
380 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
381 | | }; |
382 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
383 | | static_assert(0 < 1, "There is no slot for us"); |
384 | | |
385 | | MOZ_CAN_RUN_SCRIPT static bool |
386 | | onSetRemoteDescriptionError(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
387 | 0 | { |
388 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onSetRemoteDescriptionError", DOM, cx); |
389 | 0 |
|
390 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
391 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver.onSetRemoteDescriptionError"); |
392 | 0 | } |
393 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
394 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
395 | 0 | if (objIsXray) { |
396 | 0 | unwrappedObj.emplace(cx, obj); |
397 | 0 | } |
398 | 0 | uint32_t arg0; |
399 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
400 | 0 | return false; |
401 | 0 | } |
402 | 0 | binding_detail::FakeString arg1; |
403 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
404 | 0 | return false; |
405 | 0 | } |
406 | 0 | if (objIsXray) { |
407 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
408 | 0 | if (!unwrappedObj.ref()) { |
409 | 0 | return false; |
410 | 0 | } |
411 | 0 | } |
412 | 0 | FastErrorResult rv; |
413 | 0 | self->OnSetRemoteDescriptionError(arg0, NonNullHelper(Constify(arg1)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
414 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
415 | 0 | return false; |
416 | 0 | } |
417 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
418 | 0 | args.rval().setUndefined(); |
419 | 0 | return true; |
420 | 0 | } |
421 | | |
422 | | static const JSJitInfo onSetRemoteDescriptionError_methodinfo = { |
423 | | { (JSJitGetterOp)onSetRemoteDescriptionError }, |
424 | | { prototypes::id::PeerConnectionObserver }, |
425 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
426 | | JSJitInfo::Method, |
427 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
428 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
429 | | false, /* isInfallible. False in setters. */ |
430 | | false, /* isMovable. Not relevant for setters. */ |
431 | | false, /* isEliminatable. Not relevant for setters. */ |
432 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
433 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
434 | | false, /* isTypedMethod. Only relevant for methods. */ |
435 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
436 | | }; |
437 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
438 | | static_assert(0 < 1, "There is no slot for us"); |
439 | | |
440 | | MOZ_CAN_RUN_SCRIPT static bool |
441 | | onAddIceCandidateSuccess(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
442 | 0 | { |
443 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onAddIceCandidateSuccess", DOM, cx); |
444 | 0 |
|
445 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
446 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
447 | 0 | if (objIsXray) { |
448 | 0 | unwrappedObj.emplace(cx, obj); |
449 | 0 | } |
450 | 0 | if (objIsXray) { |
451 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
452 | 0 | if (!unwrappedObj.ref()) { |
453 | 0 | return false; |
454 | 0 | } |
455 | 0 | } |
456 | 0 | FastErrorResult rv; |
457 | 0 | self->OnAddIceCandidateSuccess(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
458 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
459 | 0 | return false; |
460 | 0 | } |
461 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
462 | 0 | args.rval().setUndefined(); |
463 | 0 | return true; |
464 | 0 | } |
465 | | |
466 | | static const JSJitInfo onAddIceCandidateSuccess_methodinfo = { |
467 | | { (JSJitGetterOp)onAddIceCandidateSuccess }, |
468 | | { prototypes::id::PeerConnectionObserver }, |
469 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
470 | | JSJitInfo::Method, |
471 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
472 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
473 | | false, /* isInfallible. False in setters. */ |
474 | | false, /* isMovable. Not relevant for setters. */ |
475 | | false, /* isEliminatable. Not relevant for setters. */ |
476 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
477 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
478 | | false, /* isTypedMethod. Only relevant for methods. */ |
479 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
480 | | }; |
481 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
482 | | static_assert(0 < 1, "There is no slot for us"); |
483 | | |
484 | | MOZ_CAN_RUN_SCRIPT static bool |
485 | | onAddIceCandidateError(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
486 | 0 | { |
487 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onAddIceCandidateError", DOM, cx); |
488 | 0 |
|
489 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
490 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver.onAddIceCandidateError"); |
491 | 0 | } |
492 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
493 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
494 | 0 | if (objIsXray) { |
495 | 0 | unwrappedObj.emplace(cx, obj); |
496 | 0 | } |
497 | 0 | uint32_t arg0; |
498 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
499 | 0 | return false; |
500 | 0 | } |
501 | 0 | binding_detail::FakeString arg1; |
502 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
503 | 0 | return false; |
504 | 0 | } |
505 | 0 | if (objIsXray) { |
506 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
507 | 0 | if (!unwrappedObj.ref()) { |
508 | 0 | return false; |
509 | 0 | } |
510 | 0 | } |
511 | 0 | FastErrorResult rv; |
512 | 0 | self->OnAddIceCandidateError(arg0, NonNullHelper(Constify(arg1)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
513 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
514 | 0 | return false; |
515 | 0 | } |
516 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
517 | 0 | args.rval().setUndefined(); |
518 | 0 | return true; |
519 | 0 | } |
520 | | |
521 | | static const JSJitInfo onAddIceCandidateError_methodinfo = { |
522 | | { (JSJitGetterOp)onAddIceCandidateError }, |
523 | | { prototypes::id::PeerConnectionObserver }, |
524 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
525 | | JSJitInfo::Method, |
526 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
527 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
528 | | false, /* isInfallible. False in setters. */ |
529 | | false, /* isMovable. Not relevant for setters. */ |
530 | | false, /* isEliminatable. Not relevant for setters. */ |
531 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
532 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
533 | | false, /* isTypedMethod. Only relevant for methods. */ |
534 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
535 | | }; |
536 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
537 | | static_assert(0 < 1, "There is no slot for us"); |
538 | | |
539 | | MOZ_CAN_RUN_SCRIPT static bool |
540 | | onIceCandidate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
541 | 0 | { |
542 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onIceCandidate", DOM, cx); |
543 | 0 |
|
544 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
545 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver.onIceCandidate"); |
546 | 0 | } |
547 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
548 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
549 | 0 | if (objIsXray) { |
550 | 0 | unwrappedObj.emplace(cx, obj); |
551 | 0 | } |
552 | 0 | uint16_t arg0; |
553 | 0 | if (!ValueToPrimitive<uint16_t, eDefault>(cx, args[0], &arg0)) { |
554 | 0 | return false; |
555 | 0 | } |
556 | 0 | binding_detail::FakeString arg1; |
557 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
558 | 0 | return false; |
559 | 0 | } |
560 | 0 | binding_detail::FakeString arg2; |
561 | 0 | if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) { |
562 | 0 | return false; |
563 | 0 | } |
564 | 0 | if (objIsXray) { |
565 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
566 | 0 | if (!unwrappedObj.ref()) { |
567 | 0 | return false; |
568 | 0 | } |
569 | 0 | } |
570 | 0 | FastErrorResult rv; |
571 | 0 | self->OnIceCandidate(arg0, NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
572 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
573 | 0 | return false; |
574 | 0 | } |
575 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
576 | 0 | args.rval().setUndefined(); |
577 | 0 | return true; |
578 | 0 | } |
579 | | |
580 | | static const JSJitInfo onIceCandidate_methodinfo = { |
581 | | { (JSJitGetterOp)onIceCandidate }, |
582 | | { prototypes::id::PeerConnectionObserver }, |
583 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
584 | | JSJitInfo::Method, |
585 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
586 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
587 | | false, /* isInfallible. False in setters. */ |
588 | | false, /* isMovable. Not relevant for setters. */ |
589 | | false, /* isEliminatable. Not relevant for setters. */ |
590 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
591 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
592 | | false, /* isTypedMethod. Only relevant for methods. */ |
593 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
594 | | }; |
595 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
596 | | static_assert(0 < 1, "There is no slot for us"); |
597 | | |
598 | | MOZ_CAN_RUN_SCRIPT static bool |
599 | | onGetStatsSuccess(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
600 | 0 | { |
601 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onGetStatsSuccess", DOM, cx); |
602 | 0 |
|
603 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
604 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
605 | 0 | if (objIsXray) { |
606 | 0 | unwrappedObj.emplace(cx, obj); |
607 | 0 | } |
608 | 0 | binding_detail::FastRTCStatsReportInternal arg0; |
609 | 0 | if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1 of PeerConnectionObserver.onGetStatsSuccess", true)) { |
610 | 0 | return false; |
611 | 0 | } |
612 | 0 | if (objIsXray) { |
613 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
614 | 0 | if (!unwrappedObj.ref()) { |
615 | 0 | return false; |
616 | 0 | } |
617 | 0 | } |
618 | 0 | FastErrorResult rv; |
619 | 0 | self->OnGetStatsSuccess(Constify(arg0), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
620 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
621 | 0 | return false; |
622 | 0 | } |
623 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
624 | 0 | args.rval().setUndefined(); |
625 | 0 | return true; |
626 | 0 | } |
627 | | |
628 | | static const JSJitInfo onGetStatsSuccess_methodinfo = { |
629 | | { (JSJitGetterOp)onGetStatsSuccess }, |
630 | | { prototypes::id::PeerConnectionObserver }, |
631 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
632 | | JSJitInfo::Method, |
633 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
634 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
635 | | false, /* isInfallible. False in setters. */ |
636 | | false, /* isMovable. Not relevant for setters. */ |
637 | | false, /* isEliminatable. Not relevant for setters. */ |
638 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
639 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
640 | | false, /* isTypedMethod. Only relevant for methods. */ |
641 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
642 | | }; |
643 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
644 | | static_assert(0 < 1, "There is no slot for us"); |
645 | | |
646 | | MOZ_CAN_RUN_SCRIPT static bool |
647 | | onGetStatsError(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
648 | 0 | { |
649 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onGetStatsError", DOM, cx); |
650 | 0 |
|
651 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
652 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver.onGetStatsError"); |
653 | 0 | } |
654 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
655 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
656 | 0 | if (objIsXray) { |
657 | 0 | unwrappedObj.emplace(cx, obj); |
658 | 0 | } |
659 | 0 | uint32_t arg0; |
660 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
661 | 0 | return false; |
662 | 0 | } |
663 | 0 | binding_detail::FakeString arg1; |
664 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
665 | 0 | return false; |
666 | 0 | } |
667 | 0 | if (objIsXray) { |
668 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
669 | 0 | if (!unwrappedObj.ref()) { |
670 | 0 | return false; |
671 | 0 | } |
672 | 0 | } |
673 | 0 | FastErrorResult rv; |
674 | 0 | self->OnGetStatsError(arg0, NonNullHelper(Constify(arg1)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
675 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
676 | 0 | return false; |
677 | 0 | } |
678 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
679 | 0 | args.rval().setUndefined(); |
680 | 0 | return true; |
681 | 0 | } |
682 | | |
683 | | static const JSJitInfo onGetStatsError_methodinfo = { |
684 | | { (JSJitGetterOp)onGetStatsError }, |
685 | | { prototypes::id::PeerConnectionObserver }, |
686 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
687 | | JSJitInfo::Method, |
688 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
689 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
690 | | false, /* isInfallible. False in setters. */ |
691 | | false, /* isMovable. Not relevant for setters. */ |
692 | | false, /* isEliminatable. Not relevant for setters. */ |
693 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
694 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
695 | | false, /* isTypedMethod. Only relevant for methods. */ |
696 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
697 | | }; |
698 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
699 | | static_assert(0 < 1, "There is no slot for us"); |
700 | | |
701 | | MOZ_CAN_RUN_SCRIPT static bool |
702 | | notifyDataChannel(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
703 | 0 | { |
704 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.notifyDataChannel", DOM, cx); |
705 | 0 |
|
706 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
707 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver.notifyDataChannel"); |
708 | 0 | } |
709 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
710 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
711 | 0 | if (objIsXray) { |
712 | 0 | unwrappedObj.emplace(cx, obj); |
713 | 0 | } |
714 | 0 | NonNull<nsDOMDataChannel> arg0; |
715 | 0 | if (args[0].isObject()) { |
716 | 0 | { |
717 | 0 | nsresult rv = UnwrapObject<prototypes::id::RTCDataChannel, nsDOMDataChannel>(args[0], arg0); |
718 | 0 | if (NS_FAILED(rv)) { |
719 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of PeerConnectionObserver.notifyDataChannel", "RTCDataChannel"); |
720 | 0 | return false; |
721 | 0 | } |
722 | 0 | } |
723 | 0 | } else { |
724 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of PeerConnectionObserver.notifyDataChannel"); |
725 | 0 | return false; |
726 | 0 | } |
727 | 0 | if (objIsXray) { |
728 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
729 | 0 | if (!unwrappedObj.ref()) { |
730 | 0 | return false; |
731 | 0 | } |
732 | 0 | } |
733 | 0 | FastErrorResult rv; |
734 | 0 | self->NotifyDataChannel(MOZ_KnownLive(NonNullHelper(arg0)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
735 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
736 | 0 | return false; |
737 | 0 | } |
738 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
739 | 0 | args.rval().setUndefined(); |
740 | 0 | return true; |
741 | 0 | } |
742 | | |
743 | | static const JSJitInfo notifyDataChannel_methodinfo = { |
744 | | { (JSJitGetterOp)notifyDataChannel }, |
745 | | { prototypes::id::PeerConnectionObserver }, |
746 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
747 | | JSJitInfo::Method, |
748 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
749 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
750 | | false, /* isInfallible. False in setters. */ |
751 | | false, /* isMovable. Not relevant for setters. */ |
752 | | false, /* isEliminatable. Not relevant for setters. */ |
753 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
754 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
755 | | false, /* isTypedMethod. Only relevant for methods. */ |
756 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
757 | | }; |
758 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
759 | | static_assert(0 < 1, "There is no slot for us"); |
760 | | |
761 | | MOZ_CAN_RUN_SCRIPT static bool |
762 | | onStateChange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
763 | 0 | { |
764 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onStateChange", DOM, cx); |
765 | 0 |
|
766 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
767 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver.onStateChange"); |
768 | 0 | } |
769 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
770 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
771 | 0 | if (objIsXray) { |
772 | 0 | unwrappedObj.emplace(cx, obj); |
773 | 0 | } |
774 | 0 | PCObserverStateType arg0; |
775 | 0 | { |
776 | 0 | int index; |
777 | 0 | if (!FindEnumStringIndex<true>(cx, args[0], PCObserverStateTypeValues::strings, "PCObserverStateType", "Argument 1 of PeerConnectionObserver.onStateChange", &index)) { |
778 | 0 | return false; |
779 | 0 | } |
780 | 0 | MOZ_ASSERT(index >= 0); |
781 | 0 | arg0 = static_cast<PCObserverStateType>(index); |
782 | 0 | } |
783 | 0 | if (objIsXray) { |
784 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
785 | 0 | if (!unwrappedObj.ref()) { |
786 | 0 | return false; |
787 | 0 | } |
788 | 0 | } |
789 | 0 | FastErrorResult rv; |
790 | 0 | self->OnStateChange(arg0, rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
791 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
792 | 0 | return false; |
793 | 0 | } |
794 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
795 | 0 | args.rval().setUndefined(); |
796 | 0 | return true; |
797 | 0 | } |
798 | | |
799 | | static const JSJitInfo onStateChange_methodinfo = { |
800 | | { (JSJitGetterOp)onStateChange }, |
801 | | { prototypes::id::PeerConnectionObserver }, |
802 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
803 | | JSJitInfo::Method, |
804 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
805 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
806 | | false, /* isInfallible. False in setters. */ |
807 | | false, /* isMovable. Not relevant for setters. */ |
808 | | false, /* isEliminatable. Not relevant for setters. */ |
809 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
810 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
811 | | false, /* isTypedMethod. Only relevant for methods. */ |
812 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
813 | | }; |
814 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
815 | | static_assert(0 < 1, "There is no slot for us"); |
816 | | |
817 | | MOZ_CAN_RUN_SCRIPT static bool |
818 | | onTransceiverNeeded(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
819 | 0 | { |
820 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onTransceiverNeeded", DOM, cx); |
821 | 0 |
|
822 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
823 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver.onTransceiverNeeded"); |
824 | 0 | } |
825 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
826 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
827 | 0 | if (objIsXray) { |
828 | 0 | unwrappedObj.emplace(cx, obj); |
829 | 0 | } |
830 | 0 | binding_detail::FakeString arg0; |
831 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
832 | 0 | return false; |
833 | 0 | } |
834 | 0 | NonNull<mozilla::TransceiverImpl> arg1; |
835 | 0 | if (args[1].isObject()) { |
836 | 0 | { |
837 | 0 | nsresult rv = UnwrapObject<prototypes::id::TransceiverImpl, mozilla::TransceiverImpl>(args[1], arg1); |
838 | 0 | if (NS_FAILED(rv)) { |
839 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of PeerConnectionObserver.onTransceiverNeeded", "TransceiverImpl"); |
840 | 0 | return false; |
841 | 0 | } |
842 | 0 | } |
843 | 0 | } else { |
844 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of PeerConnectionObserver.onTransceiverNeeded"); |
845 | 0 | return false; |
846 | 0 | } |
847 | 0 | if (objIsXray) { |
848 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
849 | 0 | if (!unwrappedObj.ref()) { |
850 | 0 | return false; |
851 | 0 | } |
852 | 0 | } |
853 | 0 | FastErrorResult rv; |
854 | 0 | self->OnTransceiverNeeded(NonNullHelper(Constify(arg0)), MOZ_KnownLive(NonNullHelper(arg1)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
855 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
856 | 0 | return false; |
857 | 0 | } |
858 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
859 | 0 | args.rval().setUndefined(); |
860 | 0 | return true; |
861 | 0 | } |
862 | | |
863 | | static const JSJitInfo onTransceiverNeeded_methodinfo = { |
864 | | { (JSJitGetterOp)onTransceiverNeeded }, |
865 | | { prototypes::id::PeerConnectionObserver }, |
866 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
867 | | JSJitInfo::Method, |
868 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
869 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
870 | | false, /* isInfallible. False in setters. */ |
871 | | false, /* isMovable. Not relevant for setters. */ |
872 | | false, /* isEliminatable. Not relevant for setters. */ |
873 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
874 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
875 | | false, /* isTypedMethod. Only relevant for methods. */ |
876 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
877 | | }; |
878 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
879 | | static_assert(0 < 1, "There is no slot for us"); |
880 | | |
881 | | MOZ_CAN_RUN_SCRIPT static bool |
882 | | onDTMFToneChange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
883 | 0 | { |
884 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onDTMFToneChange", DOM, cx); |
885 | 0 |
|
886 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
887 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver.onDTMFToneChange"); |
888 | 0 | } |
889 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
890 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
891 | 0 | if (objIsXray) { |
892 | 0 | unwrappedObj.emplace(cx, obj); |
893 | 0 | } |
894 | 0 | NonNull<mozilla::dom::MediaStreamTrack> arg0; |
895 | 0 | if (args[0].isObject()) { |
896 | 0 | { |
897 | 0 | nsresult rv = UnwrapObject<prototypes::id::MediaStreamTrack, mozilla::dom::MediaStreamTrack>(args[0], arg0); |
898 | 0 | if (NS_FAILED(rv)) { |
899 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of PeerConnectionObserver.onDTMFToneChange", "MediaStreamTrack"); |
900 | 0 | return false; |
901 | 0 | } |
902 | 0 | } |
903 | 0 | } else { |
904 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of PeerConnectionObserver.onDTMFToneChange"); |
905 | 0 | return false; |
906 | 0 | } |
907 | 0 | binding_detail::FakeString arg1; |
908 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
909 | 0 | return false; |
910 | 0 | } |
911 | 0 | if (objIsXray) { |
912 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
913 | 0 | if (!unwrappedObj.ref()) { |
914 | 0 | return false; |
915 | 0 | } |
916 | 0 | } |
917 | 0 | FastErrorResult rv; |
918 | 0 | self->OnDTMFToneChange(MOZ_KnownLive(NonNullHelper(arg0)), NonNullHelper(Constify(arg1)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
919 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
920 | 0 | return false; |
921 | 0 | } |
922 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
923 | 0 | args.rval().setUndefined(); |
924 | 0 | return true; |
925 | 0 | } |
926 | | |
927 | | static const JSJitInfo onDTMFToneChange_methodinfo = { |
928 | | { (JSJitGetterOp)onDTMFToneChange }, |
929 | | { prototypes::id::PeerConnectionObserver }, |
930 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
931 | | JSJitInfo::Method, |
932 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
933 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
934 | | false, /* isInfallible. False in setters. */ |
935 | | false, /* isMovable. Not relevant for setters. */ |
936 | | false, /* isEliminatable. Not relevant for setters. */ |
937 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
938 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
939 | | false, /* isTypedMethod. Only relevant for methods. */ |
940 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
941 | | }; |
942 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
943 | | static_assert(0 < 1, "There is no slot for us"); |
944 | | |
945 | | MOZ_CAN_RUN_SCRIPT static bool |
946 | | onPacket(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
947 | 0 | { |
948 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.onPacket", DOM, cx); |
949 | 0 |
|
950 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
951 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver.onPacket"); |
952 | 0 | } |
953 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
954 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
955 | 0 | if (objIsXray) { |
956 | 0 | unwrappedObj.emplace(cx, obj); |
957 | 0 | } |
958 | 0 | uint32_t arg0; |
959 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
960 | 0 | return false; |
961 | 0 | } |
962 | 0 | mozPacketDumpType arg1; |
963 | 0 | { |
964 | 0 | int index; |
965 | 0 | if (!FindEnumStringIndex<true>(cx, args[1], mozPacketDumpTypeValues::strings, "mozPacketDumpType", "Argument 2 of PeerConnectionObserver.onPacket", &index)) { |
966 | 0 | return false; |
967 | 0 | } |
968 | 0 | MOZ_ASSERT(index >= 0); |
969 | 0 | arg1 = static_cast<mozPacketDumpType>(index); |
970 | 0 | } |
971 | 0 | bool arg2; |
972 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) { |
973 | 0 | return false; |
974 | 0 | } |
975 | 0 | RootedSpiderMonkeyInterface<ArrayBuffer> arg3(cx); |
976 | 0 | if (args[3].isObject()) { |
977 | 0 | if (!arg3.Init(&args[3].toObject())) { |
978 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 4 of PeerConnectionObserver.onPacket", "ArrayBuffer"); |
979 | 0 | return false; |
980 | 0 | } |
981 | 0 | } else { |
982 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of PeerConnectionObserver.onPacket"); |
983 | 0 | return false; |
984 | 0 | } |
985 | 0 | if (objIsXray) { |
986 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
987 | 0 | if (!unwrappedObj.ref()) { |
988 | 0 | return false; |
989 | 0 | } |
990 | 0 | } |
991 | 0 | FastErrorResult rv; |
992 | 0 | self->OnPacket(arg0, arg1, arg2, Constify(arg3), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
993 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
994 | 0 | return false; |
995 | 0 | } |
996 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
997 | 0 | args.rval().setUndefined(); |
998 | 0 | return true; |
999 | 0 | } |
1000 | | |
1001 | | static const JSJitInfo onPacket_methodinfo = { |
1002 | | { (JSJitGetterOp)onPacket }, |
1003 | | { prototypes::id::PeerConnectionObserver }, |
1004 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
1005 | | JSJitInfo::Method, |
1006 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1007 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1008 | | false, /* isInfallible. False in setters. */ |
1009 | | false, /* isMovable. Not relevant for setters. */ |
1010 | | false, /* isEliminatable. Not relevant for setters. */ |
1011 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1012 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1013 | | false, /* isTypedMethod. Only relevant for methods. */ |
1014 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1015 | | }; |
1016 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1017 | | static_assert(0 < 1, "There is no slot for us"); |
1018 | | |
1019 | | MOZ_CAN_RUN_SCRIPT static bool |
1020 | | syncTransceivers(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PeerConnectionObserver* self, const JSJitMethodCallArgs& args) |
1021 | 0 | { |
1022 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver.syncTransceivers", DOM, cx); |
1023 | 0 |
|
1024 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
1025 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1026 | 0 | if (objIsXray) { |
1027 | 0 | unwrappedObj.emplace(cx, obj); |
1028 | 0 | } |
1029 | 0 | if (objIsXray) { |
1030 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
1031 | 0 | if (!unwrappedObj.ref()) { |
1032 | 0 | return false; |
1033 | 0 | } |
1034 | 0 | } |
1035 | 0 | FastErrorResult rv; |
1036 | 0 | self->SyncTransceivers(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
1037 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1038 | 0 | return false; |
1039 | 0 | } |
1040 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1041 | 0 | args.rval().setUndefined(); |
1042 | 0 | return true; |
1043 | 0 | } |
1044 | | |
1045 | | static const JSJitInfo syncTransceivers_methodinfo = { |
1046 | | { (JSJitGetterOp)syncTransceivers }, |
1047 | | { prototypes::id::PeerConnectionObserver }, |
1048 | | { PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth }, |
1049 | | JSJitInfo::Method, |
1050 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1051 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1052 | | false, /* isInfallible. False in setters. */ |
1053 | | false, /* isMovable. Not relevant for setters. */ |
1054 | | false, /* isEliminatable. Not relevant for setters. */ |
1055 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1056 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1057 | | false, /* isTypedMethod. Only relevant for methods. */ |
1058 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1059 | | }; |
1060 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1061 | | static_assert(0 < 1, "There is no slot for us"); |
1062 | | |
1063 | | static bool |
1064 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
1065 | 0 | { |
1066 | 0 | mozilla::dom::PeerConnectionObserver* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PeerConnectionObserver>(obj); |
1067 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
1068 | 0 | // obviously can't preserve if we're not initialized. |
1069 | 0 | if (self && self->GetWrapperPreserveColor()) { |
1070 | 0 | PreserveWrapper(self); |
1071 | 0 | } |
1072 | 0 | return true; |
1073 | 0 | } |
1074 | | |
1075 | | static void |
1076 | | _finalize(js::FreeOp* fop, JSObject* obj) |
1077 | 0 | { |
1078 | 0 | mozilla::dom::PeerConnectionObserver* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PeerConnectionObserver>(obj); |
1079 | 0 | if (self) { |
1080 | 0 | ClearWrapper(self, self, obj); |
1081 | 0 | AddForDeferredFinalization<mozilla::dom::PeerConnectionObserver>(self); |
1082 | 0 | } |
1083 | 0 | } |
1084 | | |
1085 | | static size_t |
1086 | | _objectMoved(JSObject* obj, JSObject* old) |
1087 | 0 | { |
1088 | 0 | mozilla::dom::PeerConnectionObserver* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PeerConnectionObserver>(obj); |
1089 | 0 | if (self) { |
1090 | 0 | UpdateWrapper(self, self, obj, old); |
1091 | 0 | } |
1092 | 0 |
|
1093 | 0 | return 0; |
1094 | 0 | } |
1095 | | |
1096 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1097 | | #if defined(__clang__) |
1098 | | #pragma clang diagnostic push |
1099 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1100 | | #endif |
1101 | | static const JSFunctionSpec sChromeStaticMethods_specs[] = { |
1102 | | JS_FNSPEC("_create", PeerConnectionObserver::_Create, nullptr, 2, 0, nullptr), |
1103 | | JS_FS_END |
1104 | | }; |
1105 | | #if defined(__clang__) |
1106 | | #pragma clang diagnostic pop |
1107 | | #endif |
1108 | | |
1109 | | |
1110 | | static const Prefable<const JSFunctionSpec> sChromeStaticMethods[] = { |
1111 | | { nullptr, &sChromeStaticMethods_specs[0] }, |
1112 | | { nullptr, nullptr } |
1113 | | }; |
1114 | | |
1115 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1116 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1117 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1118 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1119 | | |
1120 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1121 | | #if defined(__clang__) |
1122 | | #pragma clang diagnostic push |
1123 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1124 | | #endif |
1125 | | static const JSFunctionSpec sMethods_specs[] = { |
1126 | | JS_FNSPEC("onCreateOfferSuccess", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onCreateOfferSuccess_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1127 | | JS_FNSPEC("onCreateOfferError", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onCreateOfferError_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
1128 | | JS_FNSPEC("onCreateAnswerSuccess", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onCreateAnswerSuccess_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1129 | | JS_FNSPEC("onCreateAnswerError", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onCreateAnswerError_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
1130 | | JS_FNSPEC("onSetLocalDescriptionSuccess", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onSetLocalDescriptionSuccess_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1131 | | JS_FNSPEC("onSetRemoteDescriptionSuccess", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onSetRemoteDescriptionSuccess_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1132 | | JS_FNSPEC("onSetLocalDescriptionError", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onSetLocalDescriptionError_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
1133 | | JS_FNSPEC("onSetRemoteDescriptionError", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onSetRemoteDescriptionError_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
1134 | | JS_FNSPEC("onAddIceCandidateSuccess", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onAddIceCandidateSuccess_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1135 | | JS_FNSPEC("onAddIceCandidateError", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onAddIceCandidateError_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
1136 | | JS_FNSPEC("onIceCandidate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onIceCandidate_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
1137 | | JS_FNSPEC("onGetStatsSuccess", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onGetStatsSuccess_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1138 | | JS_FNSPEC("onGetStatsError", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onGetStatsError_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
1139 | | JS_FNSPEC("notifyDataChannel", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(¬ifyDataChannel_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1140 | | JS_FNSPEC("onStateChange", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onStateChange_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1141 | | JS_FNSPEC("onTransceiverNeeded", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onTransceiverNeeded_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
1142 | | JS_FNSPEC("onDTMFToneChange", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onDTMFToneChange_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
1143 | | JS_FNSPEC("onPacket", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&onPacket_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
1144 | | JS_FNSPEC("syncTransceivers", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&syncTransceivers_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1145 | | JS_FS_END |
1146 | | }; |
1147 | | #if defined(__clang__) |
1148 | | #pragma clang diagnostic pop |
1149 | | #endif |
1150 | | |
1151 | | |
1152 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
1153 | | { nullptr, &sMethods_specs[0] }, |
1154 | | { nullptr, nullptr } |
1155 | | }; |
1156 | | |
1157 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1158 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1159 | | static_assert(19 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1160 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1161 | | |
1162 | | |
1163 | | static uint16_t sNativeProperties_sortedPropertyIndices[19]; |
1164 | | static PropertyInfo sNativeProperties_propertyInfos[19]; |
1165 | | |
1166 | | static const NativePropertiesN<1> sNativeProperties = { |
1167 | | false, 0, |
1168 | | false, 0, |
1169 | | true, 0 /* sMethods */, |
1170 | | false, 0, |
1171 | | false, 0, |
1172 | | false, 0, |
1173 | | false, 0, |
1174 | | -1, |
1175 | | 19, |
1176 | | sNativeProperties_sortedPropertyIndices, |
1177 | | { |
1178 | | { sMethods, &sNativeProperties_propertyInfos[0] } |
1179 | | } |
1180 | | }; |
1181 | | static_assert(19 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
1182 | | "We have a property info count that is oversized"); |
1183 | | |
1184 | | static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1]; |
1185 | | static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1]; |
1186 | | |
1187 | | static const NativePropertiesN<1> sChromeOnlyNativeProperties = { |
1188 | | true, 0 /* sChromeStaticMethods */, |
1189 | | false, 0, |
1190 | | false, 0, |
1191 | | false, 0, |
1192 | | false, 0, |
1193 | | false, 0, |
1194 | | false, 0, |
1195 | | -1, |
1196 | | 1, |
1197 | | sChromeOnlyNativeProperties_sortedPropertyIndices, |
1198 | | { |
1199 | | { sChromeStaticMethods, &sChromeOnlyNativeProperties_propertyInfos[0] } |
1200 | | } |
1201 | | }; |
1202 | | static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount), |
1203 | | "We have a property info count that is oversized"); |
1204 | | |
1205 | | static bool |
1206 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
1207 | 0 | { |
1208 | 0 | AUTO_PROFILER_LABEL_FAST("PeerConnectionObserver constructor", DOM, cx); |
1209 | 0 |
|
1210 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
1211 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
1212 | 0 | if (!args.isConstructing()) { |
1213 | 0 | // XXXbz wish I could get the name from the callee instead of |
1214 | 0 | // Adding more relocations |
1215 | 0 | return ThrowConstructorWithoutNew(cx, "PeerConnectionObserver"); |
1216 | 0 | } |
1217 | 0 | |
1218 | 0 | JS::Rooted<JSObject*> desiredProto(cx); |
1219 | 0 | if (!GetDesiredProto(cx, args, &desiredProto)) { |
1220 | 0 | return false; |
1221 | 0 | } |
1222 | 0 | |
1223 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1224 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver"); |
1225 | 0 | } |
1226 | 0 | GlobalObject global(cx, obj); |
1227 | 0 | if (global.Failed()) { |
1228 | 0 | return false; |
1229 | 0 | } |
1230 | 0 | |
1231 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1232 | 0 | NonNull<mozilla::dom::RTCPeerConnection> arg0; |
1233 | 0 | if (args[0].isObject()) { |
1234 | 0 | { |
1235 | 0 | nsresult rv = UnwrapObject<prototypes::id::RTCPeerConnection, mozilla::dom::RTCPeerConnection>(args[0], arg0); |
1236 | 0 | if (NS_FAILED(rv)) { |
1237 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of PeerConnectionObserver.constructor", "RTCPeerConnection"); |
1238 | 0 | return false; |
1239 | 0 | } |
1240 | 0 | } |
1241 | 0 | } else { |
1242 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of PeerConnectionObserver.constructor"); |
1243 | 0 | return false; |
1244 | 0 | } |
1245 | 0 | Maybe<JSAutoRealm> ar; |
1246 | 0 | if (objIsXray) { |
1247 | 0 | obj = js::CheckedUnwrap(obj); |
1248 | 0 | if (!obj) { |
1249 | 0 | return false; |
1250 | 0 | } |
1251 | 0 | ar.emplace(cx, obj); |
1252 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
1253 | 0 | return false; |
1254 | 0 | } |
1255 | 0 | } |
1256 | 0 | FastErrorResult rv; |
1257 | 0 | auto result(StrongOrRawPtr<mozilla::dom::PeerConnectionObserver>(mozilla::dom::PeerConnectionObserver::Constructor(global, cx, MOZ_KnownLive(NonNullHelper(arg0)), rv, desiredProto))); |
1258 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1259 | 0 | return false; |
1260 | 0 | } |
1261 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1262 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
1263 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
1264 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { |
1265 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1266 | 0 | return false; |
1267 | 0 | } |
1268 | 0 | return true; |
1269 | 0 | } |
1270 | | |
1271 | | static const js::ClassOps sInterfaceObjectClassOps = { |
1272 | | nullptr, /* addProperty */ |
1273 | | nullptr, /* delProperty */ |
1274 | | nullptr, /* enumerate */ |
1275 | | nullptr, /* newEnumerate */ |
1276 | | nullptr, /* resolve */ |
1277 | | nullptr, /* mayResolve */ |
1278 | | nullptr, /* finalize */ |
1279 | | _constructor, /* call */ |
1280 | | nullptr, /* hasInstance */ |
1281 | | _constructor, /* construct */ |
1282 | | nullptr, /* trace */ |
1283 | | }; |
1284 | | |
1285 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
1286 | | { |
1287 | | "Function", |
1288 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
1289 | | &sInterfaceObjectClassOps, |
1290 | | JS_NULL_CLASS_SPEC, |
1291 | | JS_NULL_CLASS_EXT, |
1292 | | &sInterfaceObjectClassObjectOps |
1293 | | }, |
1294 | | eInterface, |
1295 | | true, |
1296 | | prototypes::id::PeerConnectionObserver, |
1297 | | PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth, |
1298 | | sNativePropertyHooks, |
1299 | | "function PeerConnectionObserver() {\n [native code]\n}", |
1300 | | JS::GetRealmFunctionPrototype |
1301 | | }; |
1302 | | |
1303 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
1304 | | { |
1305 | | "PeerConnectionObserverPrototype", |
1306 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
1307 | | JS_NULL_CLASS_OPS, |
1308 | | JS_NULL_CLASS_SPEC, |
1309 | | JS_NULL_CLASS_EXT, |
1310 | | JS_NULL_OBJECT_OPS |
1311 | | }, |
1312 | | eInterfacePrototype, |
1313 | | false, |
1314 | | prototypes::id::PeerConnectionObserver, |
1315 | | PrototypeTraits<prototypes::id::PeerConnectionObserver>::Depth, |
1316 | | sNativePropertyHooks, |
1317 | | "[object PeerConnectionObserverPrototype]", |
1318 | | JS::GetRealmObjectPrototype |
1319 | | }; |
1320 | | |
1321 | | bool |
1322 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
1323 | 0 | { |
1324 | 0 | return nsContentUtils::ThreadsafeIsSystemCaller(aCx); |
1325 | 0 | } |
1326 | | |
1327 | | static const js::ClassOps sClassOps = { |
1328 | | _addProperty, /* addProperty */ |
1329 | | nullptr, /* delProperty */ |
1330 | | nullptr, /* enumerate */ |
1331 | | nullptr, /* newEnumerate */ |
1332 | | nullptr, /* resolve */ |
1333 | | nullptr, /* mayResolve */ |
1334 | | _finalize, /* finalize */ |
1335 | | nullptr, /* call */ |
1336 | | nullptr, /* hasInstance */ |
1337 | | nullptr, /* construct */ |
1338 | | nullptr, /* trace */ |
1339 | | }; |
1340 | | |
1341 | | static const js::ClassExtension sClassExtension = { |
1342 | | nullptr, /* weakmapKeyDelegateOp */ |
1343 | | _objectMoved /* objectMovedOp */ |
1344 | | }; |
1345 | | |
1346 | | static const DOMJSClass sClass = { |
1347 | | { "PeerConnectionObserver", |
1348 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
1349 | | &sClassOps, |
1350 | | JS_NULL_CLASS_SPEC, |
1351 | | &sClassExtension, |
1352 | | JS_NULL_OBJECT_OPS |
1353 | | }, |
1354 | | { prototypes::id::PeerConnectionObserver, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
1355 | | IsBaseOf<nsISupports, mozilla::dom::PeerConnectionObserver >::value, |
1356 | | sNativePropertyHooks, |
1357 | | FindAssociatedGlobalForNative<mozilla::dom::PeerConnectionObserver>::Get, |
1358 | | GetProtoObjectHandle, |
1359 | | GetCCParticipant<mozilla::dom::PeerConnectionObserver>::Get() |
1360 | | }; |
1361 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
1362 | | "Must have the right minimal number of reserved slots."); |
1363 | | static_assert(1 >= 1, |
1364 | | "Must have enough reserved slots."); |
1365 | | |
1366 | | const JSClass* |
1367 | | GetJSClass() |
1368 | 0 | { |
1369 | 0 | return sClass.ToJSClass(); |
1370 | 0 | } |
1371 | | |
1372 | | bool |
1373 | | Wrap(JSContext* aCx, mozilla::dom::PeerConnectionObserver* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
1374 | 0 | { |
1375 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::PeerConnectionObserver>::value, |
1376 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
1377 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::PeerConnectionObserver*>(aObject) == |
1378 | 0 | reinterpret_cast<mozilla::dom::PeerConnectionObserver*>(aObject), |
1379 | 0 | "Multiple inheritance for mozilla::dom::PeerConnectionObserver is broken."); |
1380 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
1381 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
1382 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
1383 | 0 | "You should probably not be using Wrap() directly; use " |
1384 | 0 | "GetOrCreateDOMReflector instead"); |
1385 | 0 |
|
1386 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
1387 | 0 | "nsISupports must be on our primary inheritance chain"); |
1388 | 0 |
|
1389 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
1390 | 0 | if (!global) { |
1391 | 0 | return false; |
1392 | 0 | } |
1393 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
1394 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
1395 | 0 |
|
1396 | 0 | // That might have ended up wrapping us already, due to the wonders |
1397 | 0 | // of XBL. Check for that, and bail out as needed. |
1398 | 0 | aReflector.set(aCache->GetWrapper()); |
1399 | 0 | if (aReflector) { |
1400 | | #ifdef DEBUG |
1401 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
1402 | | #endif // DEBUG |
1403 | | return true; |
1404 | 0 | } |
1405 | 0 |
|
1406 | 0 | JSAutoRealm ar(aCx, global); |
1407 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
1408 | 0 | if (!canonicalProto) { |
1409 | 0 | return false; |
1410 | 0 | } |
1411 | 0 | JS::Rooted<JSObject*> proto(aCx); |
1412 | 0 | if (aGivenProto) { |
1413 | 0 | proto = aGivenProto; |
1414 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
1415 | 0 | // coming in, we changed compartments to that of "parent" so may need |
1416 | 0 | // to wrap the proto here. |
1417 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
1418 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
1419 | 0 | return false; |
1420 | 0 | } |
1421 | 0 | } |
1422 | 0 | } else { |
1423 | 0 | proto = canonicalProto; |
1424 | 0 | } |
1425 | 0 |
|
1426 | 0 | BindingJSObjectCreator<mozilla::dom::PeerConnectionObserver> creator(aCx); |
1427 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
1428 | 0 | if (!aReflector) { |
1429 | 0 | return false; |
1430 | 0 | } |
1431 | 0 | |
1432 | 0 | aCache->SetWrapper(aReflector); |
1433 | 0 | creator.InitializationSucceeded(); |
1434 | 0 |
|
1435 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
1436 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
1437 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
1438 | 0 | // otherwise we won't be able to properly recreate it later, since |
1439 | 0 | // we won't know what proto to use. Note that we don't check |
1440 | 0 | // aGivenProto here, since it's entirely possible (and even |
1441 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
1442 | 0 | // same as canonicalProto. |
1443 | 0 | if (proto != canonicalProto) { |
1444 | 0 | PreserveWrapper(aObject); |
1445 | 0 | } |
1446 | 0 |
|
1447 | 0 | return true; |
1448 | 0 | } |
1449 | | |
1450 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
1451 | | nullptr, |
1452 | | nullptr, |
1453 | | nullptr, |
1454 | | { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() }, |
1455 | | prototypes::id::PeerConnectionObserver, |
1456 | | constructors::id::PeerConnectionObserver, |
1457 | | nullptr, |
1458 | | &DefaultXrayExpandoObjectClass |
1459 | | } }; |
1460 | | |
1461 | | void |
1462 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
1463 | 0 | { |
1464 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
1465 | 0 | if (!parentProto) { |
1466 | 0 | return; |
1467 | 0 | } |
1468 | 0 | |
1469 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
1470 | 0 | if (!constructorProto) { |
1471 | 0 | return; |
1472 | 0 | } |
1473 | 0 | |
1474 | 0 | static bool sIdsInited = false; |
1475 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
1476 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
1477 | 0 | return; |
1478 | 0 | } |
1479 | 0 | if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) { |
1480 | 0 | return; |
1481 | 0 | } |
1482 | 0 | sIdsInited = true; |
1483 | 0 | } |
1484 | 0 |
|
1485 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PeerConnectionObserver); |
1486 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PeerConnectionObserver); |
1487 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
1488 | 0 | &sPrototypeClass.mBase, protoCache, |
1489 | 0 | nullptr, |
1490 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr, |
1491 | 0 | interfaceCache, |
1492 | 0 | sNativeProperties.Upcast(), |
1493 | 0 | sChromeOnlyNativeProperties.Upcast(), |
1494 | 0 | "PeerConnectionObserver", aDefineOnGlobal, |
1495 | 0 | nullptr, |
1496 | 0 | false); |
1497 | 0 | } |
1498 | | |
1499 | | JSObject* |
1500 | | GetConstructorObject(JSContext* aCx) |
1501 | 0 | { |
1502 | 0 | return GetConstructorObjectHandle(aCx); |
1503 | 0 | } |
1504 | | |
1505 | | } // namespace PeerConnectionObserver_Binding |
1506 | | |
1507 | | |
1508 | | |
1509 | | void |
1510 | | PeerConnectionObserverJSImpl::OnCreateOfferSuccess(const nsAString& offer, ErrorResult& aRv, JS::Realm* aRealm) |
1511 | 0 | { |
1512 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onCreateOfferSuccess", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1513 | 0 | JSContext* cx = s.GetContext(); |
1514 | 0 | if (!cx) { |
1515 | 0 | MOZ_ASSERT(aRv.Failed()); |
1516 | 0 | return; |
1517 | 0 | } |
1518 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
1519 | 0 | JS::AutoValueVector argv(cx); |
1520 | 0 | if (!argv.resize(1)) { |
1521 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
1522 | 0 | return; |
1523 | 0 | } |
1524 | 0 | unsigned argc = 1; |
1525 | 0 |
|
1526 | 0 | do { |
1527 | 0 | nsString mutableStr(offer); |
1528 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[0])) { |
1529 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1530 | 0 | return; |
1531 | 0 | } |
1532 | 0 | break; |
1533 | 0 | } while (false); |
1534 | 0 |
|
1535 | 0 | JS::Rooted<JS::Value> callable(cx); |
1536 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
1537 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
1538 | 0 | !GetCallableProperty(cx, atomsCache->onCreateOfferSuccess_id, &callable)) { |
1539 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1540 | 0 | return; |
1541 | 0 | } |
1542 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
1543 | 0 | if (!JS::Call(cx, thisValue, callable, |
1544 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
1545 | 0 | aRv.NoteJSContextException(cx); |
1546 | 0 | return; |
1547 | 0 | } |
1548 | 0 | } |
1549 | | |
1550 | | void |
1551 | | PeerConnectionObserverJSImpl::OnCreateOfferError(uint32_t name, const nsAString& message, ErrorResult& aRv, JS::Realm* aRealm) |
1552 | 0 | { |
1553 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onCreateOfferError", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1554 | 0 | JSContext* cx = s.GetContext(); |
1555 | 0 | if (!cx) { |
1556 | 0 | MOZ_ASSERT(aRv.Failed()); |
1557 | 0 | return; |
1558 | 0 | } |
1559 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
1560 | 0 | JS::AutoValueVector argv(cx); |
1561 | 0 | if (!argv.resize(2)) { |
1562 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
1563 | 0 | return; |
1564 | 0 | } |
1565 | 0 | unsigned argc = 2; |
1566 | 0 |
|
1567 | 0 | do { |
1568 | 0 | nsString mutableStr(message); |
1569 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[1])) { |
1570 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1571 | 0 | return; |
1572 | 0 | } |
1573 | 0 | break; |
1574 | 0 | } while (false); |
1575 | 0 |
|
1576 | 0 | do { |
1577 | 0 | argv[0].setNumber(name); |
1578 | 0 | break; |
1579 | 0 | } while (false); |
1580 | 0 |
|
1581 | 0 | JS::Rooted<JS::Value> callable(cx); |
1582 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
1583 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
1584 | 0 | !GetCallableProperty(cx, atomsCache->onCreateOfferError_id, &callable)) { |
1585 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1586 | 0 | return; |
1587 | 0 | } |
1588 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
1589 | 0 | if (!JS::Call(cx, thisValue, callable, |
1590 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
1591 | 0 | aRv.NoteJSContextException(cx); |
1592 | 0 | return; |
1593 | 0 | } |
1594 | 0 | } |
1595 | | |
1596 | | void |
1597 | | PeerConnectionObserverJSImpl::OnCreateAnswerSuccess(const nsAString& answer, ErrorResult& aRv, JS::Realm* aRealm) |
1598 | 0 | { |
1599 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onCreateAnswerSuccess", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1600 | 0 | JSContext* cx = s.GetContext(); |
1601 | 0 | if (!cx) { |
1602 | 0 | MOZ_ASSERT(aRv.Failed()); |
1603 | 0 | return; |
1604 | 0 | } |
1605 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
1606 | 0 | JS::AutoValueVector argv(cx); |
1607 | 0 | if (!argv.resize(1)) { |
1608 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
1609 | 0 | return; |
1610 | 0 | } |
1611 | 0 | unsigned argc = 1; |
1612 | 0 |
|
1613 | 0 | do { |
1614 | 0 | nsString mutableStr(answer); |
1615 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[0])) { |
1616 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1617 | 0 | return; |
1618 | 0 | } |
1619 | 0 | break; |
1620 | 0 | } while (false); |
1621 | 0 |
|
1622 | 0 | JS::Rooted<JS::Value> callable(cx); |
1623 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
1624 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
1625 | 0 | !GetCallableProperty(cx, atomsCache->onCreateAnswerSuccess_id, &callable)) { |
1626 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1627 | 0 | return; |
1628 | 0 | } |
1629 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
1630 | 0 | if (!JS::Call(cx, thisValue, callable, |
1631 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
1632 | 0 | aRv.NoteJSContextException(cx); |
1633 | 0 | return; |
1634 | 0 | } |
1635 | 0 | } |
1636 | | |
1637 | | void |
1638 | | PeerConnectionObserverJSImpl::OnCreateAnswerError(uint32_t name, const nsAString& message, ErrorResult& aRv, JS::Realm* aRealm) |
1639 | 0 | { |
1640 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onCreateAnswerError", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1641 | 0 | JSContext* cx = s.GetContext(); |
1642 | 0 | if (!cx) { |
1643 | 0 | MOZ_ASSERT(aRv.Failed()); |
1644 | 0 | return; |
1645 | 0 | } |
1646 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
1647 | 0 | JS::AutoValueVector argv(cx); |
1648 | 0 | if (!argv.resize(2)) { |
1649 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
1650 | 0 | return; |
1651 | 0 | } |
1652 | 0 | unsigned argc = 2; |
1653 | 0 |
|
1654 | 0 | do { |
1655 | 0 | nsString mutableStr(message); |
1656 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[1])) { |
1657 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1658 | 0 | return; |
1659 | 0 | } |
1660 | 0 | break; |
1661 | 0 | } while (false); |
1662 | 0 |
|
1663 | 0 | do { |
1664 | 0 | argv[0].setNumber(name); |
1665 | 0 | break; |
1666 | 0 | } while (false); |
1667 | 0 |
|
1668 | 0 | JS::Rooted<JS::Value> callable(cx); |
1669 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
1670 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
1671 | 0 | !GetCallableProperty(cx, atomsCache->onCreateAnswerError_id, &callable)) { |
1672 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1673 | 0 | return; |
1674 | 0 | } |
1675 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
1676 | 0 | if (!JS::Call(cx, thisValue, callable, |
1677 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
1678 | 0 | aRv.NoteJSContextException(cx); |
1679 | 0 | return; |
1680 | 0 | } |
1681 | 0 | } |
1682 | | |
1683 | | void |
1684 | | PeerConnectionObserverJSImpl::OnSetLocalDescriptionSuccess(ErrorResult& aRv, JS::Realm* aRealm) |
1685 | 0 | { |
1686 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onSetLocalDescriptionSuccess", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1687 | 0 | JSContext* cx = s.GetContext(); |
1688 | 0 | if (!cx) { |
1689 | 0 | MOZ_ASSERT(aRv.Failed()); |
1690 | 0 | return; |
1691 | 0 | } |
1692 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
1693 | 0 |
|
1694 | 0 | JS::Rooted<JS::Value> callable(cx); |
1695 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
1696 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
1697 | 0 | !GetCallableProperty(cx, atomsCache->onSetLocalDescriptionSuccess_id, &callable)) { |
1698 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1699 | 0 | return; |
1700 | 0 | } |
1701 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
1702 | 0 | if (!JS::Call(cx, thisValue, callable, |
1703 | 0 | JS::HandleValueArray::empty(), &rval)) { |
1704 | 0 | aRv.NoteJSContextException(cx); |
1705 | 0 | return; |
1706 | 0 | } |
1707 | 0 | } |
1708 | | |
1709 | | void |
1710 | | PeerConnectionObserverJSImpl::OnSetRemoteDescriptionSuccess(ErrorResult& aRv, JS::Realm* aRealm) |
1711 | 0 | { |
1712 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onSetRemoteDescriptionSuccess", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1713 | 0 | JSContext* cx = s.GetContext(); |
1714 | 0 | if (!cx) { |
1715 | 0 | MOZ_ASSERT(aRv.Failed()); |
1716 | 0 | return; |
1717 | 0 | } |
1718 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
1719 | 0 |
|
1720 | 0 | JS::Rooted<JS::Value> callable(cx); |
1721 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
1722 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
1723 | 0 | !GetCallableProperty(cx, atomsCache->onSetRemoteDescriptionSuccess_id, &callable)) { |
1724 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1725 | 0 | return; |
1726 | 0 | } |
1727 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
1728 | 0 | if (!JS::Call(cx, thisValue, callable, |
1729 | 0 | JS::HandleValueArray::empty(), &rval)) { |
1730 | 0 | aRv.NoteJSContextException(cx); |
1731 | 0 | return; |
1732 | 0 | } |
1733 | 0 | } |
1734 | | |
1735 | | void |
1736 | | PeerConnectionObserverJSImpl::OnSetLocalDescriptionError(uint32_t name, const nsAString& message, ErrorResult& aRv, JS::Realm* aRealm) |
1737 | 0 | { |
1738 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onSetLocalDescriptionError", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1739 | 0 | JSContext* cx = s.GetContext(); |
1740 | 0 | if (!cx) { |
1741 | 0 | MOZ_ASSERT(aRv.Failed()); |
1742 | 0 | return; |
1743 | 0 | } |
1744 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
1745 | 0 | JS::AutoValueVector argv(cx); |
1746 | 0 | if (!argv.resize(2)) { |
1747 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
1748 | 0 | return; |
1749 | 0 | } |
1750 | 0 | unsigned argc = 2; |
1751 | 0 |
|
1752 | 0 | do { |
1753 | 0 | nsString mutableStr(message); |
1754 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[1])) { |
1755 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1756 | 0 | return; |
1757 | 0 | } |
1758 | 0 | break; |
1759 | 0 | } while (false); |
1760 | 0 |
|
1761 | 0 | do { |
1762 | 0 | argv[0].setNumber(name); |
1763 | 0 | break; |
1764 | 0 | } while (false); |
1765 | 0 |
|
1766 | 0 | JS::Rooted<JS::Value> callable(cx); |
1767 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
1768 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
1769 | 0 | !GetCallableProperty(cx, atomsCache->onSetLocalDescriptionError_id, &callable)) { |
1770 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1771 | 0 | return; |
1772 | 0 | } |
1773 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
1774 | 0 | if (!JS::Call(cx, thisValue, callable, |
1775 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
1776 | 0 | aRv.NoteJSContextException(cx); |
1777 | 0 | return; |
1778 | 0 | } |
1779 | 0 | } |
1780 | | |
1781 | | void |
1782 | | PeerConnectionObserverJSImpl::OnSetRemoteDescriptionError(uint32_t name, const nsAString& message, ErrorResult& aRv, JS::Realm* aRealm) |
1783 | 0 | { |
1784 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onSetRemoteDescriptionError", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1785 | 0 | JSContext* cx = s.GetContext(); |
1786 | 0 | if (!cx) { |
1787 | 0 | MOZ_ASSERT(aRv.Failed()); |
1788 | 0 | return; |
1789 | 0 | } |
1790 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
1791 | 0 | JS::AutoValueVector argv(cx); |
1792 | 0 | if (!argv.resize(2)) { |
1793 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
1794 | 0 | return; |
1795 | 0 | } |
1796 | 0 | unsigned argc = 2; |
1797 | 0 |
|
1798 | 0 | do { |
1799 | 0 | nsString mutableStr(message); |
1800 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[1])) { |
1801 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1802 | 0 | return; |
1803 | 0 | } |
1804 | 0 | break; |
1805 | 0 | } while (false); |
1806 | 0 |
|
1807 | 0 | do { |
1808 | 0 | argv[0].setNumber(name); |
1809 | 0 | break; |
1810 | 0 | } while (false); |
1811 | 0 |
|
1812 | 0 | JS::Rooted<JS::Value> callable(cx); |
1813 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
1814 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
1815 | 0 | !GetCallableProperty(cx, atomsCache->onSetRemoteDescriptionError_id, &callable)) { |
1816 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1817 | 0 | return; |
1818 | 0 | } |
1819 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
1820 | 0 | if (!JS::Call(cx, thisValue, callable, |
1821 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
1822 | 0 | aRv.NoteJSContextException(cx); |
1823 | 0 | return; |
1824 | 0 | } |
1825 | 0 | } |
1826 | | |
1827 | | void |
1828 | | PeerConnectionObserverJSImpl::OnAddIceCandidateSuccess(ErrorResult& aRv, JS::Realm* aRealm) |
1829 | 0 | { |
1830 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onAddIceCandidateSuccess", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1831 | 0 | JSContext* cx = s.GetContext(); |
1832 | 0 | if (!cx) { |
1833 | 0 | MOZ_ASSERT(aRv.Failed()); |
1834 | 0 | return; |
1835 | 0 | } |
1836 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
1837 | 0 |
|
1838 | 0 | JS::Rooted<JS::Value> callable(cx); |
1839 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
1840 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
1841 | 0 | !GetCallableProperty(cx, atomsCache->onAddIceCandidateSuccess_id, &callable)) { |
1842 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1843 | 0 | return; |
1844 | 0 | } |
1845 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
1846 | 0 | if (!JS::Call(cx, thisValue, callable, |
1847 | 0 | JS::HandleValueArray::empty(), &rval)) { |
1848 | 0 | aRv.NoteJSContextException(cx); |
1849 | 0 | return; |
1850 | 0 | } |
1851 | 0 | } |
1852 | | |
1853 | | void |
1854 | | PeerConnectionObserverJSImpl::OnAddIceCandidateError(uint32_t name, const nsAString& message, ErrorResult& aRv, JS::Realm* aRealm) |
1855 | 0 | { |
1856 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onAddIceCandidateError", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1857 | 0 | JSContext* cx = s.GetContext(); |
1858 | 0 | if (!cx) { |
1859 | 0 | MOZ_ASSERT(aRv.Failed()); |
1860 | 0 | return; |
1861 | 0 | } |
1862 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
1863 | 0 | JS::AutoValueVector argv(cx); |
1864 | 0 | if (!argv.resize(2)) { |
1865 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
1866 | 0 | return; |
1867 | 0 | } |
1868 | 0 | unsigned argc = 2; |
1869 | 0 |
|
1870 | 0 | do { |
1871 | 0 | nsString mutableStr(message); |
1872 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[1])) { |
1873 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1874 | 0 | return; |
1875 | 0 | } |
1876 | 0 | break; |
1877 | 0 | } while (false); |
1878 | 0 |
|
1879 | 0 | do { |
1880 | 0 | argv[0].setNumber(name); |
1881 | 0 | break; |
1882 | 0 | } while (false); |
1883 | 0 |
|
1884 | 0 | JS::Rooted<JS::Value> callable(cx); |
1885 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
1886 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
1887 | 0 | !GetCallableProperty(cx, atomsCache->onAddIceCandidateError_id, &callable)) { |
1888 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1889 | 0 | return; |
1890 | 0 | } |
1891 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
1892 | 0 | if (!JS::Call(cx, thisValue, callable, |
1893 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
1894 | 0 | aRv.NoteJSContextException(cx); |
1895 | 0 | return; |
1896 | 0 | } |
1897 | 0 | } |
1898 | | |
1899 | | void |
1900 | | PeerConnectionObserverJSImpl::OnIceCandidate(uint16_t level, const nsAString& mid, const nsAString& candidate, ErrorResult& aRv, JS::Realm* aRealm) |
1901 | 0 | { |
1902 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onIceCandidate", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1903 | 0 | JSContext* cx = s.GetContext(); |
1904 | 0 | if (!cx) { |
1905 | 0 | MOZ_ASSERT(aRv.Failed()); |
1906 | 0 | return; |
1907 | 0 | } |
1908 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
1909 | 0 | JS::AutoValueVector argv(cx); |
1910 | 0 | if (!argv.resize(3)) { |
1911 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
1912 | 0 | return; |
1913 | 0 | } |
1914 | 0 | unsigned argc = 3; |
1915 | 0 |
|
1916 | 0 | do { |
1917 | 0 | nsString mutableStr(candidate); |
1918 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[2])) { |
1919 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1920 | 0 | return; |
1921 | 0 | } |
1922 | 0 | break; |
1923 | 0 | } while (false); |
1924 | 0 |
|
1925 | 0 | do { |
1926 | 0 | nsString mutableStr(mid); |
1927 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[1])) { |
1928 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1929 | 0 | return; |
1930 | 0 | } |
1931 | 0 | break; |
1932 | 0 | } while (false); |
1933 | 0 |
|
1934 | 0 | do { |
1935 | 0 | argv[0].setInt32(int32_t(level)); |
1936 | 0 | break; |
1937 | 0 | } while (false); |
1938 | 0 |
|
1939 | 0 | JS::Rooted<JS::Value> callable(cx); |
1940 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
1941 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
1942 | 0 | !GetCallableProperty(cx, atomsCache->onIceCandidate_id, &callable)) { |
1943 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1944 | 0 | return; |
1945 | 0 | } |
1946 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
1947 | 0 | if (!JS::Call(cx, thisValue, callable, |
1948 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
1949 | 0 | aRv.NoteJSContextException(cx); |
1950 | 0 | return; |
1951 | 0 | } |
1952 | 0 | } |
1953 | | |
1954 | | void |
1955 | | PeerConnectionObserverJSImpl::OnGetStatsSuccess(const RTCStatsReportInternal& report, ErrorResult& aRv, JS::Realm* aRealm) |
1956 | 0 | { |
1957 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onGetStatsSuccess", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1958 | 0 | JSContext* cx = s.GetContext(); |
1959 | 0 | if (!cx) { |
1960 | 0 | MOZ_ASSERT(aRv.Failed()); |
1961 | 0 | return; |
1962 | 0 | } |
1963 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
1964 | 0 | JS::AutoValueVector argv(cx); |
1965 | 0 | if (!argv.resize(1)) { |
1966 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
1967 | 0 | return; |
1968 | 0 | } |
1969 | 0 | unsigned argc = 1; |
1970 | 0 |
|
1971 | 0 | do { |
1972 | 0 | if (!report.ToObjectInternal(cx, argv[0])) { |
1973 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1974 | 0 | return; |
1975 | 0 | } |
1976 | 0 | break; |
1977 | 0 | } while (false); |
1978 | 0 |
|
1979 | 0 | JS::Rooted<JS::Value> callable(cx); |
1980 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
1981 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
1982 | 0 | !GetCallableProperty(cx, atomsCache->onGetStatsSuccess_id, &callable)) { |
1983 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1984 | 0 | return; |
1985 | 0 | } |
1986 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
1987 | 0 | if (!JS::Call(cx, thisValue, callable, |
1988 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
1989 | 0 | aRv.NoteJSContextException(cx); |
1990 | 0 | return; |
1991 | 0 | } |
1992 | 0 | } |
1993 | | |
1994 | | void |
1995 | | PeerConnectionObserverJSImpl::OnGetStatsError(uint32_t name, const nsAString& message, ErrorResult& aRv, JS::Realm* aRealm) |
1996 | 0 | { |
1997 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onGetStatsError", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1998 | 0 | JSContext* cx = s.GetContext(); |
1999 | 0 | if (!cx) { |
2000 | 0 | MOZ_ASSERT(aRv.Failed()); |
2001 | 0 | return; |
2002 | 0 | } |
2003 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2004 | 0 | JS::AutoValueVector argv(cx); |
2005 | 0 | if (!argv.resize(2)) { |
2006 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
2007 | 0 | return; |
2008 | 0 | } |
2009 | 0 | unsigned argc = 2; |
2010 | 0 |
|
2011 | 0 | do { |
2012 | 0 | nsString mutableStr(message); |
2013 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[1])) { |
2014 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2015 | 0 | return; |
2016 | 0 | } |
2017 | 0 | break; |
2018 | 0 | } while (false); |
2019 | 0 |
|
2020 | 0 | do { |
2021 | 0 | argv[0].setNumber(name); |
2022 | 0 | break; |
2023 | 0 | } while (false); |
2024 | 0 |
|
2025 | 0 | JS::Rooted<JS::Value> callable(cx); |
2026 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
2027 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2028 | 0 | !GetCallableProperty(cx, atomsCache->onGetStatsError_id, &callable)) { |
2029 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2030 | 0 | return; |
2031 | 0 | } |
2032 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2033 | 0 | if (!JS::Call(cx, thisValue, callable, |
2034 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
2035 | 0 | aRv.NoteJSContextException(cx); |
2036 | 0 | return; |
2037 | 0 | } |
2038 | 0 | } |
2039 | | |
2040 | | void |
2041 | | PeerConnectionObserverJSImpl::NotifyDataChannel(nsDOMDataChannel& channel, ErrorResult& aRv, JS::Realm* aRealm) |
2042 | 0 | { |
2043 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.notifyDataChannel", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2044 | 0 | JSContext* cx = s.GetContext(); |
2045 | 0 | if (!cx) { |
2046 | 0 | MOZ_ASSERT(aRv.Failed()); |
2047 | 0 | return; |
2048 | 0 | } |
2049 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2050 | 0 | JS::AutoValueVector argv(cx); |
2051 | 0 | if (!argv.resize(1)) { |
2052 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
2053 | 0 | return; |
2054 | 0 | } |
2055 | 0 | unsigned argc = 1; |
2056 | 0 |
|
2057 | 0 | do { |
2058 | 0 | if (!GetOrCreateDOMReflector(cx, channel, argv[0])) { |
2059 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2060 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2061 | 0 | return; |
2062 | 0 | } |
2063 | 0 | break; |
2064 | 0 | } while (false); |
2065 | 0 |
|
2066 | 0 | JS::Rooted<JS::Value> callable(cx); |
2067 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
2068 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2069 | 0 | !GetCallableProperty(cx, atomsCache->notifyDataChannel_id, &callable)) { |
2070 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2071 | 0 | return; |
2072 | 0 | } |
2073 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2074 | 0 | if (!JS::Call(cx, thisValue, callable, |
2075 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
2076 | 0 | aRv.NoteJSContextException(cx); |
2077 | 0 | return; |
2078 | 0 | } |
2079 | 0 | } |
2080 | | |
2081 | | void |
2082 | | PeerConnectionObserverJSImpl::OnStateChange(PCObserverStateType state, ErrorResult& aRv, JS::Realm* aRealm) |
2083 | 0 | { |
2084 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onStateChange", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2085 | 0 | JSContext* cx = s.GetContext(); |
2086 | 0 | if (!cx) { |
2087 | 0 | MOZ_ASSERT(aRv.Failed()); |
2088 | 0 | return; |
2089 | 0 | } |
2090 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2091 | 0 | JS::AutoValueVector argv(cx); |
2092 | 0 | if (!argv.resize(1)) { |
2093 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
2094 | 0 | return; |
2095 | 0 | } |
2096 | 0 | unsigned argc = 1; |
2097 | 0 |
|
2098 | 0 | do { |
2099 | 0 | if (!ToJSValue(cx, state, argv[0])) { |
2100 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2101 | 0 | return; |
2102 | 0 | } |
2103 | 0 | break; |
2104 | 0 | } while (false); |
2105 | 0 |
|
2106 | 0 | JS::Rooted<JS::Value> callable(cx); |
2107 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
2108 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2109 | 0 | !GetCallableProperty(cx, atomsCache->onStateChange_id, &callable)) { |
2110 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2111 | 0 | return; |
2112 | 0 | } |
2113 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2114 | 0 | if (!JS::Call(cx, thisValue, callable, |
2115 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
2116 | 0 | aRv.NoteJSContextException(cx); |
2117 | 0 | return; |
2118 | 0 | } |
2119 | 0 | } |
2120 | | |
2121 | | void |
2122 | | PeerConnectionObserverJSImpl::OnTransceiverNeeded(const nsAString& kind, TransceiverImpl& transceiverImpl, ErrorResult& aRv, JS::Realm* aRealm) |
2123 | 0 | { |
2124 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onTransceiverNeeded", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2125 | 0 | JSContext* cx = s.GetContext(); |
2126 | 0 | if (!cx) { |
2127 | 0 | MOZ_ASSERT(aRv.Failed()); |
2128 | 0 | return; |
2129 | 0 | } |
2130 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2131 | 0 | JS::AutoValueVector argv(cx); |
2132 | 0 | if (!argv.resize(2)) { |
2133 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
2134 | 0 | return; |
2135 | 0 | } |
2136 | 0 | unsigned argc = 2; |
2137 | 0 |
|
2138 | 0 | do { |
2139 | 0 | if (!WrapNewBindingNonWrapperCachedObject(cx, CallbackKnownNotGray(), transceiverImpl, argv[1])) { |
2140 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2141 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2142 | 0 | return; |
2143 | 0 | } |
2144 | 0 | break; |
2145 | 0 | } while (false); |
2146 | 0 |
|
2147 | 0 | do { |
2148 | 0 | nsString mutableStr(kind); |
2149 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[0])) { |
2150 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2151 | 0 | return; |
2152 | 0 | } |
2153 | 0 | break; |
2154 | 0 | } while (false); |
2155 | 0 |
|
2156 | 0 | JS::Rooted<JS::Value> callable(cx); |
2157 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
2158 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2159 | 0 | !GetCallableProperty(cx, atomsCache->onTransceiverNeeded_id, &callable)) { |
2160 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2161 | 0 | return; |
2162 | 0 | } |
2163 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2164 | 0 | if (!JS::Call(cx, thisValue, callable, |
2165 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
2166 | 0 | aRv.NoteJSContextException(cx); |
2167 | 0 | return; |
2168 | 0 | } |
2169 | 0 | } |
2170 | | |
2171 | | void |
2172 | | PeerConnectionObserverJSImpl::OnDTMFToneChange(MediaStreamTrack& track, const nsAString& tone, ErrorResult& aRv, JS::Realm* aRealm) |
2173 | 0 | { |
2174 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onDTMFToneChange", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2175 | 0 | JSContext* cx = s.GetContext(); |
2176 | 0 | if (!cx) { |
2177 | 0 | MOZ_ASSERT(aRv.Failed()); |
2178 | 0 | return; |
2179 | 0 | } |
2180 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2181 | 0 | JS::AutoValueVector argv(cx); |
2182 | 0 | if (!argv.resize(2)) { |
2183 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
2184 | 0 | return; |
2185 | 0 | } |
2186 | 0 | unsigned argc = 2; |
2187 | 0 |
|
2188 | 0 | do { |
2189 | 0 | nsString mutableStr(tone); |
2190 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[1])) { |
2191 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2192 | 0 | return; |
2193 | 0 | } |
2194 | 0 | break; |
2195 | 0 | } while (false); |
2196 | 0 |
|
2197 | 0 | do { |
2198 | 0 | if (!GetOrCreateDOMReflector(cx, track, argv[0])) { |
2199 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2200 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2201 | 0 | return; |
2202 | 0 | } |
2203 | 0 | break; |
2204 | 0 | } while (false); |
2205 | 0 |
|
2206 | 0 | JS::Rooted<JS::Value> callable(cx); |
2207 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
2208 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2209 | 0 | !GetCallableProperty(cx, atomsCache->onDTMFToneChange_id, &callable)) { |
2210 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2211 | 0 | return; |
2212 | 0 | } |
2213 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2214 | 0 | if (!JS::Call(cx, thisValue, callable, |
2215 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
2216 | 0 | aRv.NoteJSContextException(cx); |
2217 | 0 | return; |
2218 | 0 | } |
2219 | 0 | } |
2220 | | |
2221 | | void |
2222 | | PeerConnectionObserverJSImpl::OnPacket(uint32_t level, mozPacketDumpType type, bool sending, const ArrayBuffer& packet, ErrorResult& aRv, JS::Realm* aRealm) |
2223 | 0 | { |
2224 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.onPacket", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2225 | 0 | JSContext* cx = s.GetContext(); |
2226 | 0 | if (!cx) { |
2227 | 0 | MOZ_ASSERT(aRv.Failed()); |
2228 | 0 | return; |
2229 | 0 | } |
2230 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2231 | 0 | JS::AutoValueVector argv(cx); |
2232 | 0 | if (!argv.resize(4)) { |
2233 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
2234 | 0 | return; |
2235 | 0 | } |
2236 | 0 | unsigned argc = 4; |
2237 | 0 |
|
2238 | 0 | do { |
2239 | 0 | argv[3].setObject(*packet.Obj()); |
2240 | 0 | if (!MaybeWrapNonDOMObjectValue(cx, argv[3])) { |
2241 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2242 | 0 | return; |
2243 | 0 | } |
2244 | 0 | break; |
2245 | 0 | } while (false); |
2246 | 0 |
|
2247 | 0 | do { |
2248 | 0 | argv[2].setBoolean(sending); |
2249 | 0 | break; |
2250 | 0 | } while (false); |
2251 | 0 |
|
2252 | 0 | do { |
2253 | 0 | if (!ToJSValue(cx, type, argv[1])) { |
2254 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2255 | 0 | return; |
2256 | 0 | } |
2257 | 0 | break; |
2258 | 0 | } while (false); |
2259 | 0 |
|
2260 | 0 | do { |
2261 | 0 | argv[0].setNumber(level); |
2262 | 0 | break; |
2263 | 0 | } while (false); |
2264 | 0 |
|
2265 | 0 | JS::Rooted<JS::Value> callable(cx); |
2266 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
2267 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2268 | 0 | !GetCallableProperty(cx, atomsCache->onPacket_id, &callable)) { |
2269 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2270 | 0 | return; |
2271 | 0 | } |
2272 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2273 | 0 | if (!JS::Call(cx, thisValue, callable, |
2274 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
2275 | 0 | aRv.NoteJSContextException(cx); |
2276 | 0 | return; |
2277 | 0 | } |
2278 | 0 | } |
2279 | | |
2280 | | void |
2281 | | PeerConnectionObserverJSImpl::SyncTransceivers(ErrorResult& aRv, JS::Realm* aRealm) |
2282 | 0 | { |
2283 | 0 | CallSetup s(this, aRv, "PeerConnectionObserver.syncTransceivers", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2284 | 0 | JSContext* cx = s.GetContext(); |
2285 | 0 | if (!cx) { |
2286 | 0 | MOZ_ASSERT(aRv.Failed()); |
2287 | 0 | return; |
2288 | 0 | } |
2289 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2290 | 0 |
|
2291 | 0 | JS::Rooted<JS::Value> callable(cx); |
2292 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
2293 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2294 | 0 | !GetCallableProperty(cx, atomsCache->syncTransceivers_id, &callable)) { |
2295 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2296 | 0 | return; |
2297 | 0 | } |
2298 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2299 | 0 | if (!JS::Call(cx, thisValue, callable, |
2300 | 0 | JS::HandleValueArray::empty(), &rval)) { |
2301 | 0 | aRv.NoteJSContextException(cx); |
2302 | 0 | return; |
2303 | 0 | } |
2304 | 0 | } |
2305 | | |
2306 | | void |
2307 | | PeerConnectionObserverJSImpl::__Init(RTCPeerConnection& domPC, ErrorResult& aRv, JS::Realm* aRealm) |
2308 | 0 | { |
2309 | 0 | CallSetup s(this, aRv, "__init", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2310 | 0 | JSContext* cx = s.GetContext(); |
2311 | 0 | if (!cx) { |
2312 | 0 | MOZ_ASSERT(aRv.Failed()); |
2313 | 0 | return; |
2314 | 0 | } |
2315 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2316 | 0 | JS::AutoValueVector argv(cx); |
2317 | 0 | if (!argv.resize(1)) { |
2318 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
2319 | 0 | return; |
2320 | 0 | } |
2321 | 0 | unsigned argc = 1; |
2322 | 0 |
|
2323 | 0 | do { |
2324 | 0 | if (!GetOrCreateDOMReflector(cx, domPC, argv[0])) { |
2325 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2326 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2327 | 0 | return; |
2328 | 0 | } |
2329 | 0 | break; |
2330 | 0 | } while (false); |
2331 | 0 |
|
2332 | 0 | JS::Rooted<JS::Value> callable(cx); |
2333 | 0 | PeerConnectionObserverAtoms* atomsCache = GetAtomCache<PeerConnectionObserverAtoms>(cx); |
2334 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2335 | 0 | !GetCallableProperty(cx, atomsCache->__init_id, &callable)) { |
2336 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2337 | 0 | return; |
2338 | 0 | } |
2339 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2340 | 0 | if (!JS::Call(cx, thisValue, callable, |
2341 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
2342 | 0 | aRv.NoteJSContextException(cx); |
2343 | 0 | return; |
2344 | 0 | } |
2345 | 0 | } |
2346 | | |
2347 | | bool |
2348 | | PeerConnectionObserverJSImpl::InitIds(JSContext* cx, PeerConnectionObserverAtoms* atomsCache) |
2349 | 0 | { |
2350 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
2351 | 0 |
|
2352 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
2353 | 0 | // uninitialized. |
2354 | 0 | if (!atomsCache->__init_id.init(cx, "__init") || |
2355 | 0 | !atomsCache->syncTransceivers_id.init(cx, "syncTransceivers") || |
2356 | 0 | !atomsCache->onPacket_id.init(cx, "onPacket") || |
2357 | 0 | !atomsCache->onDTMFToneChange_id.init(cx, "onDTMFToneChange") || |
2358 | 0 | !atomsCache->onTransceiverNeeded_id.init(cx, "onTransceiverNeeded") || |
2359 | 0 | !atomsCache->onStateChange_id.init(cx, "onStateChange") || |
2360 | 0 | !atomsCache->notifyDataChannel_id.init(cx, "notifyDataChannel") || |
2361 | 0 | !atomsCache->onGetStatsError_id.init(cx, "onGetStatsError") || |
2362 | 0 | !atomsCache->onGetStatsSuccess_id.init(cx, "onGetStatsSuccess") || |
2363 | 0 | !atomsCache->onIceCandidate_id.init(cx, "onIceCandidate") || |
2364 | 0 | !atomsCache->onAddIceCandidateError_id.init(cx, "onAddIceCandidateError") || |
2365 | 0 | !atomsCache->onAddIceCandidateSuccess_id.init(cx, "onAddIceCandidateSuccess") || |
2366 | 0 | !atomsCache->onSetRemoteDescriptionError_id.init(cx, "onSetRemoteDescriptionError") || |
2367 | 0 | !atomsCache->onSetLocalDescriptionError_id.init(cx, "onSetLocalDescriptionError") || |
2368 | 0 | !atomsCache->onSetRemoteDescriptionSuccess_id.init(cx, "onSetRemoteDescriptionSuccess") || |
2369 | 0 | !atomsCache->onSetLocalDescriptionSuccess_id.init(cx, "onSetLocalDescriptionSuccess") || |
2370 | 0 | !atomsCache->onCreateAnswerError_id.init(cx, "onCreateAnswerError") || |
2371 | 0 | !atomsCache->onCreateAnswerSuccess_id.init(cx, "onCreateAnswerSuccess") || |
2372 | 0 | !atomsCache->onCreateOfferError_id.init(cx, "onCreateOfferError") || |
2373 | 0 | !atomsCache->onCreateOfferSuccess_id.init(cx, "onCreateOfferSuccess")) { |
2374 | 0 | return false; |
2375 | 0 | } |
2376 | 0 | return true; |
2377 | 0 | } |
2378 | | |
2379 | | |
2380 | | |
2381 | | NS_IMPL_CYCLE_COLLECTION_CLASS(PeerConnectionObserver) |
2382 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(PeerConnectionObserver) |
2383 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK(mImpl) |
2384 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent) |
2385 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER |
2386 | 0 | tmp->ClearWeakReferences(); |
2387 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK_END |
2388 | 0 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(PeerConnectionObserver) |
2389 | 0 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mImpl) |
2390 | 0 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent) |
2391 | 0 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END |
2392 | | NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(PeerConnectionObserver) |
2393 | | NS_IMPL_CYCLE_COLLECTING_ADDREF(PeerConnectionObserver) |
2394 | | NS_IMPL_CYCLE_COLLECTING_RELEASE(PeerConnectionObserver) |
2395 | 0 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PeerConnectionObserver) |
2396 | 0 | NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY |
2397 | 0 | NS_INTERFACE_MAP_ENTRY(nsISupports) |
2398 | 0 | NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) |
2399 | 0 | NS_INTERFACE_MAP_END |
2400 | | |
2401 | | PeerConnectionObserver::PeerConnectionObserver(JS::Handle<JSObject*> aJSImplObject, JS::Handle<JSObject*> aJSImplGlobal, nsIGlobalObject* aParent) |
2402 | | : mImpl(new PeerConnectionObserverJSImpl(nullptr, aJSImplObject, aJSImplGlobal, /* aIncumbentGlobal = */ nullptr)), |
2403 | | mParent(aParent) |
2404 | 0 | { |
2405 | 0 | } |
2406 | | |
2407 | | |
2408 | | PeerConnectionObserver::~PeerConnectionObserver() |
2409 | 0 | { |
2410 | 0 | } |
2411 | | |
2412 | | nsISupports* |
2413 | | PeerConnectionObserver::GetParentObject() const |
2414 | 0 | { |
2415 | 0 | return mParent; |
2416 | 0 | } |
2417 | | |
2418 | | JSObject* |
2419 | | PeerConnectionObserver::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) |
2420 | 0 | { |
2421 | 0 | JS::Rooted<JSObject*> obj(aCx, PeerConnectionObserver_Binding::Wrap(aCx, this, aGivenProto)); |
2422 | 0 | if (!obj) { |
2423 | 0 | return nullptr; |
2424 | 0 | } |
2425 | 0 | |
2426 | 0 | // Now define it on our chrome object |
2427 | 0 | JSAutoRealm ar(aCx, mImpl->CallbackGlobalOrNull()); |
2428 | 0 | if (!JS_WrapObject(aCx, &obj)) { |
2429 | 0 | return nullptr; |
2430 | 0 | } |
2431 | 0 | if (!JS_DefineProperty(aCx, mImpl->CallbackOrNull(), "__DOM_IMPL__", obj, 0)) { |
2432 | 0 | return nullptr; |
2433 | 0 | } |
2434 | 0 | return obj; |
2435 | 0 | } |
2436 | | |
2437 | | already_AddRefed<PeerConnectionObserver> |
2438 | | PeerConnectionObserver::Constructor(const GlobalObject& global, JSContext* cx, RTCPeerConnection& domPC, ErrorResult& aRv, JS::Handle<JSObject*> aGivenProto) |
2439 | 0 | { |
2440 | 0 | JS::Rooted<JSObject*> jsImplObj(cx); |
2441 | 0 | nsCOMPtr<nsIGlobalObject> globalHolder = |
2442 | 0 | ConstructJSImplementation("@mozilla.org/dom/peerconnectionobserver;1", global, &jsImplObj, aRv); |
2443 | 0 | if (aRv.Failed()) { |
2444 | 0 | return nullptr; |
2445 | 0 | } |
2446 | 0 | // We should be getting the implementation object for the relevant |
2447 | 0 | // contract here, which should never be a cross-compartment wrapper. |
2448 | 0 | JS::Rooted<JSObject*> jsImplGlobal(cx, JS::GetNonCCWObjectGlobal(jsImplObj)); |
2449 | 0 | // Build the C++ implementation. |
2450 | 0 | RefPtr<PeerConnectionObserver> impl = new PeerConnectionObserver(jsImplObj, jsImplGlobal, globalHolder); |
2451 | 0 | // Wrap the object before calling __Init so that __DOM_IMPL__ is available. |
2452 | 0 | JS::Rooted<JSObject*> scopeObj(cx, globalHolder->GetGlobalJSObject()); |
2453 | 0 | MOZ_ASSERT(js::IsObjectInContextCompartment(scopeObj, cx)); |
2454 | 0 | JS::Rooted<JS::Value> wrappedVal(cx); |
2455 | 0 | if (!GetOrCreateDOMReflector(cx, impl, &wrappedVal, aGivenProto)) { |
2456 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2457 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2458 | 0 | return nullptr; |
2459 | 0 | } |
2460 | 0 | // Initialize the object with the constructor arguments. |
2461 | 0 | impl->mImpl->__Init(domPC, aRv, js::GetNonCCWObjectRealm(scopeObj)); |
2462 | 0 | if (aRv.Failed()) { |
2463 | 0 | return nullptr; |
2464 | 0 | } |
2465 | 0 | return impl.forget(); |
2466 | 0 | } |
2467 | | |
2468 | | void |
2469 | | PeerConnectionObserver::OnCreateOfferSuccess(const nsAString& offer, ErrorResult& aRv, JS::Realm* aRealm) |
2470 | 0 | { |
2471 | 0 | return mImpl->OnCreateOfferSuccess(offer, aRv, aRealm); |
2472 | 0 | } |
2473 | | |
2474 | | void |
2475 | | PeerConnectionObserver::OnCreateOfferError(uint32_t name, const nsAString& message, ErrorResult& aRv, JS::Realm* aRealm) |
2476 | 0 | { |
2477 | 0 | return mImpl->OnCreateOfferError(name, message, aRv, aRealm); |
2478 | 0 | } |
2479 | | |
2480 | | void |
2481 | | PeerConnectionObserver::OnCreateAnswerSuccess(const nsAString& answer, ErrorResult& aRv, JS::Realm* aRealm) |
2482 | 0 | { |
2483 | 0 | return mImpl->OnCreateAnswerSuccess(answer, aRv, aRealm); |
2484 | 0 | } |
2485 | | |
2486 | | void |
2487 | | PeerConnectionObserver::OnCreateAnswerError(uint32_t name, const nsAString& message, ErrorResult& aRv, JS::Realm* aRealm) |
2488 | 0 | { |
2489 | 0 | return mImpl->OnCreateAnswerError(name, message, aRv, aRealm); |
2490 | 0 | } |
2491 | | |
2492 | | void |
2493 | | PeerConnectionObserver::OnSetLocalDescriptionSuccess(ErrorResult& aRv, JS::Realm* aRealm) |
2494 | 0 | { |
2495 | 0 | return mImpl->OnSetLocalDescriptionSuccess(aRv, aRealm); |
2496 | 0 | } |
2497 | | |
2498 | | void |
2499 | | PeerConnectionObserver::OnSetRemoteDescriptionSuccess(ErrorResult& aRv, JS::Realm* aRealm) |
2500 | 0 | { |
2501 | 0 | return mImpl->OnSetRemoteDescriptionSuccess(aRv, aRealm); |
2502 | 0 | } |
2503 | | |
2504 | | void |
2505 | | PeerConnectionObserver::OnSetLocalDescriptionError(uint32_t name, const nsAString& message, ErrorResult& aRv, JS::Realm* aRealm) |
2506 | 0 | { |
2507 | 0 | return mImpl->OnSetLocalDescriptionError(name, message, aRv, aRealm); |
2508 | 0 | } |
2509 | | |
2510 | | void |
2511 | | PeerConnectionObserver::OnSetRemoteDescriptionError(uint32_t name, const nsAString& message, ErrorResult& aRv, JS::Realm* aRealm) |
2512 | 0 | { |
2513 | 0 | return mImpl->OnSetRemoteDescriptionError(name, message, aRv, aRealm); |
2514 | 0 | } |
2515 | | |
2516 | | void |
2517 | | PeerConnectionObserver::OnAddIceCandidateSuccess(ErrorResult& aRv, JS::Realm* aRealm) |
2518 | 0 | { |
2519 | 0 | return mImpl->OnAddIceCandidateSuccess(aRv, aRealm); |
2520 | 0 | } |
2521 | | |
2522 | | void |
2523 | | PeerConnectionObserver::OnAddIceCandidateError(uint32_t name, const nsAString& message, ErrorResult& aRv, JS::Realm* aRealm) |
2524 | 0 | { |
2525 | 0 | return mImpl->OnAddIceCandidateError(name, message, aRv, aRealm); |
2526 | 0 | } |
2527 | | |
2528 | | void |
2529 | | PeerConnectionObserver::OnIceCandidate(uint16_t level, const nsAString& mid, const nsAString& candidate, ErrorResult& aRv, JS::Realm* aRealm) |
2530 | 0 | { |
2531 | 0 | return mImpl->OnIceCandidate(level, mid, candidate, aRv, aRealm); |
2532 | 0 | } |
2533 | | |
2534 | | void |
2535 | | PeerConnectionObserver::OnGetStatsSuccess(const RTCStatsReportInternal& report, ErrorResult& aRv, JS::Realm* aRealm) |
2536 | 0 | { |
2537 | 0 | return mImpl->OnGetStatsSuccess(report, aRv, aRealm); |
2538 | 0 | } |
2539 | | |
2540 | | void |
2541 | | PeerConnectionObserver::OnGetStatsError(uint32_t name, const nsAString& message, ErrorResult& aRv, JS::Realm* aRealm) |
2542 | 0 | { |
2543 | 0 | return mImpl->OnGetStatsError(name, message, aRv, aRealm); |
2544 | 0 | } |
2545 | | |
2546 | | void |
2547 | | PeerConnectionObserver::NotifyDataChannel(nsDOMDataChannel& channel, ErrorResult& aRv, JS::Realm* aRealm) |
2548 | 0 | { |
2549 | 0 | return mImpl->NotifyDataChannel(channel, aRv, aRealm); |
2550 | 0 | } |
2551 | | |
2552 | | void |
2553 | | PeerConnectionObserver::OnStateChange(PCObserverStateType state, ErrorResult& aRv, JS::Realm* aRealm) |
2554 | 0 | { |
2555 | 0 | return mImpl->OnStateChange(state, aRv, aRealm); |
2556 | 0 | } |
2557 | | |
2558 | | void |
2559 | | PeerConnectionObserver::OnTransceiverNeeded(const nsAString& kind, TransceiverImpl& transceiverImpl, ErrorResult& aRv, JS::Realm* aRealm) |
2560 | 0 | { |
2561 | 0 | return mImpl->OnTransceiverNeeded(kind, transceiverImpl, aRv, aRealm); |
2562 | 0 | } |
2563 | | |
2564 | | void |
2565 | | PeerConnectionObserver::OnDTMFToneChange(MediaStreamTrack& track, const nsAString& tone, ErrorResult& aRv, JS::Realm* aRealm) |
2566 | 0 | { |
2567 | 0 | return mImpl->OnDTMFToneChange(track, tone, aRv, aRealm); |
2568 | 0 | } |
2569 | | |
2570 | | void |
2571 | | PeerConnectionObserver::OnPacket(uint32_t level, mozPacketDumpType type, bool sending, const ArrayBuffer& packet, ErrorResult& aRv, JS::Realm* aRealm) |
2572 | 0 | { |
2573 | 0 | return mImpl->OnPacket(level, type, sending, packet, aRv, aRealm); |
2574 | 0 | } |
2575 | | |
2576 | | void |
2577 | | PeerConnectionObserver::SyncTransceivers(ErrorResult& aRv, JS::Realm* aRealm) |
2578 | 0 | { |
2579 | 0 | return mImpl->SyncTransceivers(aRv, aRealm); |
2580 | 0 | } |
2581 | | |
2582 | | bool |
2583 | | PeerConnectionObserver::_Create(JSContext* cx, unsigned argc, JS::Value* vp) |
2584 | 0 | { |
2585 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
2586 | 0 | if (args.length() < 2) { |
2587 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PeerConnectionObserver._create"); |
2588 | 0 | } |
2589 | 0 | if (!args[0].isObject()) { |
2590 | 0 | return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of PeerConnectionObserver._create"); |
2591 | 0 | } |
2592 | 0 | if (!args[1].isObject()) { |
2593 | 0 | return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of PeerConnectionObserver._create"); |
2594 | 0 | } |
2595 | 0 | |
2596 | 0 | // GlobalObject will go through wrappers as needed for us, and |
2597 | 0 | // is simpler than the right UnwrapArg incantation. |
2598 | 0 | GlobalObject global(cx, &args[0].toObject()); |
2599 | 0 | if (global.Failed()) { |
2600 | 0 | return false; |
2601 | 0 | } |
2602 | 0 | nsCOMPtr<nsIGlobalObject> globalHolder = do_QueryInterface(global.GetAsSupports()); |
2603 | 0 | MOZ_ASSERT(globalHolder); |
2604 | 0 | JS::Rooted<JSObject*> arg(cx, &args[1].toObject()); |
2605 | 0 | JS::Rooted<JSObject*> argGlobal(cx, JS::CurrentGlobalOrNull(cx)); |
2606 | 0 | RefPtr<PeerConnectionObserver> impl = new PeerConnectionObserver(arg, argGlobal, globalHolder); |
2607 | 0 | MOZ_ASSERT(js::IsObjectInContextCompartment(arg, cx)); |
2608 | 0 | return GetOrCreateDOMReflector(cx, impl, args.rval()); |
2609 | 0 | } |
2610 | | |
2611 | | |
2612 | | } // namespace dom |
2613 | | } // namespace mozilla |