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