LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - MediaKeySessionBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 290 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 30 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM MediaKeySession.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "EventHandlerBinding.h"
       4             : #include "EventTargetBinding.h"
       5             : #include "MediaKeySessionBinding.h"
       6             : #include "WrapperFactory.h"
       7             : #include "mozilla/OwningNonNull.h"
       8             : #include "mozilla/dom/BindingUtils.h"
       9             : #include "mozilla/dom/DOMJSClass.h"
      10             : #include "mozilla/dom/MediaKeyError.h"
      11             : #include "mozilla/dom/MediaKeySession.h"
      12             : #include "mozilla/dom/MediaKeyStatusMap.h"
      13             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      14             : #include "mozilla/dom/Nullable.h"
      15             : #include "mozilla/dom/PrimitiveConversions.h"
      16             : #include "mozilla/dom/Promise.h"
      17             : #include "mozilla/dom/ToJSValue.h"
      18             : #include "mozilla/dom/UnionConversions.h"
      19             : #include "mozilla/dom/UnionTypes.h"
      20             : #include "mozilla/dom/XrayExpandoClass.h"
      21             : 
      22             : namespace mozilla {
      23             : namespace dom {
      24             : 
      25             : namespace MediaKeySessionBinding {
      26             : 
      27             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
      28             :               "Can't inherit from an interface with a different ownership model.");
      29             : 
      30             : static bool
      31           0 : get_error(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
      32             : {
      33           0 :   auto result(StrongOrRawPtr<mozilla::dom::MediaKeyError>(self->GetError()));
      34           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      35           0 :   if (!result) {
      36           0 :     args.rval().setNull();
      37           0 :     return true;
      38             :   }
      39           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
      40           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      41           0 :     return false;
      42             :   }
      43           0 :   return true;
      44             : }
      45             : 
      46             : static const JSJitInfo error_getterinfo = {
      47             :   { (JSJitGetterOp)get_error },
      48             :   { prototypes::id::MediaKeySession },
      49             :   { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
      50             :   JSJitInfo::Getter,
      51             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      52             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
      53             :   false,  /* isInfallible. False in setters. */
      54             :   false,  /* isMovable.  Not relevant for setters. */
      55             :   false, /* isEliminatable.  Not relevant for setters. */
      56             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      57             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      58             :   false,  /* isTypedMethod.  Only relevant for methods. */
      59             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      60             : };
      61             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      62             : static_assert(0 < 1, "There is no slot for us");
      63             : 
      64             : static bool
      65           0 : get_sessionId(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
      66             : {
      67           0 :   DOMString result;
      68           0 :   self->GetSessionId(result);
      69           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      70           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
      71           0 :     return false;
      72             :   }
      73           0 :   return true;
      74             : }
      75             : 
      76             : static const JSJitInfo sessionId_getterinfo = {
      77             :   { (JSJitGetterOp)get_sessionId },
      78             :   { prototypes::id::MediaKeySession },
      79             :   { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
      80             :   JSJitInfo::Getter,
      81             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      82             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
      83             :   false,  /* isInfallible. False in setters. */
      84             :   false,  /* isMovable.  Not relevant for setters. */
      85             :   false, /* isEliminatable.  Not relevant for setters. */
      86             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      87             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      88             :   false,  /* isTypedMethod.  Only relevant for methods. */
      89             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      90             : };
      91             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      92             : static_assert(0 < 1, "There is no slot for us");
      93             : 
      94             : static bool
      95           0 : get_expiration(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
      96             : {
      97           0 :   double result(self->Expiration());
      98           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      99           0 :   args.rval().set(JS_NumberValue(double(result)));
     100           0 :   return true;
     101             : }
     102             : 
     103             : static const JSJitInfo expiration_getterinfo = {
     104             :   { (JSJitGetterOp)get_expiration },
     105             :   { prototypes::id::MediaKeySession },
     106             :   { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
     107             :   JSJitInfo::Getter,
     108             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     109             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     110             :   true,  /* isInfallible. False in setters. */
     111             :   false,  /* isMovable.  Not relevant for setters. */
     112             :   false, /* isEliminatable.  Not relevant for setters. */
     113             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     114             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     115             :   false,  /* isTypedMethod.  Only relevant for methods. */
     116             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     117             : };
     118             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     119             : static_assert(0 < 1, "There is no slot for us");
     120             : 
     121             : static bool
     122           0 : get_closed(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
     123             : {
     124           0 :   auto result(StrongOrRawPtr<Promise>(self->Closed()));
     125           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     126           0 :   if (!ToJSValue(cx, result, args.rval())) {
     127           0 :     return false;
     128             :   }
     129           0 :   return true;
     130             : }
     131             : 
     132             : static bool
     133           0 : get_closed_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
     134             : {
     135           0 :   bool ok = get_closed(cx, obj, self, args);
     136           0 :   if (ok) {
     137           0 :     return true;
     138             :   }
     139           0 :   JS::Rooted<JSObject*> globalForPromise(cx);
     140             :   // We can't use xpc::XrayAwareCalleeGlobal here because we have no
     141             :   // callee.  Use our hacky version instead.
     142           0 :   if (!xpc::XrayAwareCalleeGlobalForSpecializedGetters(cx, obj,
     143             :                                                        &globalForPromise)) {
     144           0 :     return false;
     145             :   }
     146           0 :   return ConvertExceptionToPromise(cx, globalForPromise, args.rval());
     147             : }
     148             : 
     149             : static const JSJitInfo closed_getterinfo = {
     150             :   { (JSJitGetterOp)get_closed_promiseWrapper },
     151             :   { prototypes::id::MediaKeySession },
     152             :   { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
     153             :   JSJitInfo::Getter,
     154             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     155             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     156             :   false,  /* isInfallible. False in setters. */
     157             :   false,  /* isMovable.  Not relevant for setters. */
     158             :   false, /* isEliminatable.  Not relevant for setters. */
     159             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     160             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     161             :   false,  /* isTypedMethod.  Only relevant for methods. */
     162             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     163             : };
     164             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     165             : static_assert(0 < 1, "There is no slot for us");
     166             : 
     167             : static bool
     168           0 : get_keyStatuses(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
     169             : {
     170           0 :   auto result(StrongOrRawPtr<mozilla::dom::MediaKeyStatusMap>(self->KeyStatuses()));
     171           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     172           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     173           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     174           0 :     return false;
     175             :   }
     176           0 :   return true;
     177             : }
     178             : 
     179             : static const JSJitInfo keyStatuses_getterinfo = {
     180             :   { (JSJitGetterOp)get_keyStatuses },
     181             :   { prototypes::id::MediaKeySession },
     182             :   { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
     183             :   JSJitInfo::Getter,
     184             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     185             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     186             :   false,  /* isInfallible. False in setters. */
     187             :   false,  /* isMovable.  Not relevant for setters. */
     188             :   false, /* isEliminatable.  Not relevant for setters. */
     189             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     190             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     191             :   false,  /* isTypedMethod.  Only relevant for methods. */
     192             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     193             : };
     194             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     195             : static_assert(0 < 1, "There is no slot for us");
     196             : 
     197             : static bool
     198           0 : get_onkeystatuseschange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
     199             : {
     200           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnkeystatuseschange());
     201           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     202           0 :   if (result) {
     203           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     204           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     205           0 :       return false;
     206             :     }
     207           0 :     return true;
     208             :   } else {
     209           0 :     args.rval().setNull();
     210           0 :     return true;
     211             :   }
     212             : }
     213             : 
     214             : static bool
     215           0 : set_onkeystatuseschange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitSetterCallArgs args)
     216             : {
     217           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     218           0 :   if (args[0].isObject()) {
     219             :     { // scope for tempRoot
     220           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     221           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     222             :     }
     223             :   } else {
     224           0 :     arg0 = nullptr;
     225             :   }
     226           0 :   self->SetOnkeystatuseschange(Constify(arg0));
     227           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     228             : 
     229           0 :   return true;
     230             : }
     231             : 
     232             : static const JSJitInfo onkeystatuseschange_getterinfo = {
     233             :   { (JSJitGetterOp)get_onkeystatuseschange },
     234             :   { prototypes::id::MediaKeySession },
     235             :   { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
     236             :   JSJitInfo::Getter,
     237             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     238             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     239             :   false,  /* isInfallible. False in setters. */
     240             :   false,  /* isMovable.  Not relevant for setters. */
     241             :   false, /* isEliminatable.  Not relevant for setters. */
     242             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     243             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     244             :   false,  /* isTypedMethod.  Only relevant for methods. */
     245             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     246             : };
     247             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     248             : static_assert(0 < 1, "There is no slot for us");
     249             : static const JSJitInfo onkeystatuseschange_setterinfo = {
     250             :   { (JSJitGetterOp)set_onkeystatuseschange },
     251             :   { prototypes::id::MediaKeySession },
     252             :   { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
     253             :   JSJitInfo::Setter,
     254             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     255             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     256             :   false,  /* isInfallible. False in setters. */
     257             :   false,  /* isMovable.  Not relevant for setters. */
     258             :   false, /* isEliminatable.  Not relevant for setters. */
     259             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     260             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     261             :   false,  /* isTypedMethod.  Only relevant for methods. */
     262             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     263             : };
     264             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     265             : static_assert(0 < 1, "There is no slot for us");
     266             : 
     267             : static bool
     268           0 : get_onmessage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitGetterCallArgs args)
     269             : {
     270           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnmessage());
     271           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     272           0 :   if (result) {
     273           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     274           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     275           0 :       return false;
     276             :     }
     277           0 :     return true;
     278             :   } else {
     279           0 :     args.rval().setNull();
     280           0 :     return true;
     281             :   }
     282             : }
     283             : 
     284             : static bool
     285           0 : set_onmessage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, JSJitSetterCallArgs args)
     286             : {
     287           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     288           0 :   if (args[0].isObject()) {
     289             :     { // scope for tempRoot
     290           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     291           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     292             :     }
     293             :   } else {
     294           0 :     arg0 = nullptr;
     295             :   }
     296           0 :   self->SetOnmessage(Constify(arg0));
     297           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     298             : 
     299           0 :   return true;
     300             : }
     301             : 
     302             : static const JSJitInfo onmessage_getterinfo = {
     303             :   { (JSJitGetterOp)get_onmessage },
     304             :   { prototypes::id::MediaKeySession },
     305             :   { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
     306             :   JSJitInfo::Getter,
     307             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     308             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     309             :   false,  /* isInfallible. False in setters. */
     310             :   false,  /* isMovable.  Not relevant for setters. */
     311             :   false, /* isEliminatable.  Not relevant for setters. */
     312             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     313             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     314             :   false,  /* isTypedMethod.  Only relevant for methods. */
     315             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     316             : };
     317             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     318             : static_assert(0 < 1, "There is no slot for us");
     319             : static const JSJitInfo onmessage_setterinfo = {
     320             :   { (JSJitGetterOp)set_onmessage },
     321             :   { prototypes::id::MediaKeySession },
     322             :   { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
     323             :   JSJitInfo::Setter,
     324             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     325             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     326             :   false,  /* isInfallible. False in setters. */
     327             :   false,  /* isMovable.  Not relevant for setters. */
     328             :   false, /* isEliminatable.  Not relevant for setters. */
     329             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     330             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     331             :   false,  /* isTypedMethod.  Only relevant for methods. */
     332             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     333             : };
     334             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     335             : static_assert(0 < 1, "There is no slot for us");
     336             : 
     337             : static bool
     338           0 : generateRequest(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
     339             : {
     340           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
     341           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaKeySession.generateRequest");
     342             :   }
     343           0 :   binding_detail::FakeString arg0;
     344           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     345           0 :     return false;
     346             :   }
     347           0 :   ArrayBufferViewOrArrayBuffer arg1;
     348           0 :   ArrayBufferViewOrArrayBufferArgument arg1_holder(arg1);
     349             :   {
     350           0 :     bool done = false, failed = false, tryNext;
     351           0 :     if (args[1].isObject()) {
     352           0 :       done = (failed = !arg1_holder.TrySetToArrayBufferView(cx, args[1], tryNext, false)) || !tryNext ||
     353           0 :              (failed = !arg1_holder.TrySetToArrayBuffer(cx, args[1], tryNext, false)) || !tryNext;
     354             : 
     355             :     }
     356           0 :     if (failed) {
     357           0 :       return false;
     358             :     }
     359           0 :     if (!done) {
     360           0 :       ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of MediaKeySession.generateRequest", "ArrayBufferView, ArrayBuffer");
     361           0 :       return false;
     362             :     }
     363             :   }
     364           0 :   binding_detail::FastErrorResult rv;
     365           0 :   auto result(StrongOrRawPtr<Promise>(self->GenerateRequest(NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
     366           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     367           0 :     return false;
     368             :   }
     369           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     370             :   static_assert(!IsPointer<decltype(result)>::value,
     371             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     372           0 :   if (!ToJSValue(cx, result, args.rval())) {
     373           0 :     return false;
     374             :   }
     375           0 :   return true;
     376             : }
     377             : 
     378             : static bool
     379           0 : generateRequest_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
     380             : {
     381             :   // Make sure to save the callee before someone maybe messes
     382             :   // with rval().
     383           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
     384           0 :   bool ok = generateRequest(cx, obj, self, args);
     385           0 :   if (ok) {
     386           0 :     return true;
     387             :   }
     388           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
     389           0 :                                    args.rval());
     390             : }
     391             : 
     392             : static const JSJitInfo generateRequest_methodinfo = {
     393             :   { (JSJitGetterOp)generateRequest_promiseWrapper },
     394             :   { prototypes::id::MediaKeySession },
     395             :   { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
     396             :   JSJitInfo::Method,
     397             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     398             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     399             :   false,  /* isInfallible. False in setters. */
     400             :   false,  /* isMovable.  Not relevant for setters. */
     401             :   false, /* isEliminatable.  Not relevant for setters. */
     402             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     403             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     404             :   false,  /* isTypedMethod.  Only relevant for methods. */
     405             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     406             : };
     407             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     408             : static_assert(0 < 1, "There is no slot for us");
     409             : 
     410             : static bool
     411           0 : load(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
     412             : {
     413           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     414           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaKeySession.load");
     415             :   }
     416           0 :   binding_detail::FakeString arg0;
     417           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     418           0 :     return false;
     419             :   }
     420           0 :   binding_detail::FastErrorResult rv;
     421           0 :   auto result(StrongOrRawPtr<Promise>(self->Load(NonNullHelper(Constify(arg0)), rv)));
     422           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     423           0 :     return false;
     424             :   }
     425           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     426             :   static_assert(!IsPointer<decltype(result)>::value,
     427             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     428           0 :   if (!ToJSValue(cx, result, args.rval())) {
     429           0 :     return false;
     430             :   }
     431           0 :   return true;
     432             : }
     433             : 
     434             : static bool
     435           0 : load_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
     436             : {
     437             :   // Make sure to save the callee before someone maybe messes
     438             :   // with rval().
     439           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
     440           0 :   bool ok = load(cx, obj, self, args);
     441           0 :   if (ok) {
     442           0 :     return true;
     443             :   }
     444           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
     445           0 :                                    args.rval());
     446             : }
     447             : 
     448             : static const JSJitInfo load_methodinfo = {
     449             :   { (JSJitGetterOp)load_promiseWrapper },
     450             :   { prototypes::id::MediaKeySession },
     451             :   { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
     452             :   JSJitInfo::Method,
     453             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     454             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     455             :   false,  /* isInfallible. False in setters. */
     456             :   false,  /* isMovable.  Not relevant for setters. */
     457             :   false, /* isEliminatable.  Not relevant for setters. */
     458             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     459             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     460             :   false,  /* isTypedMethod.  Only relevant for methods. */
     461             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     462             : };
     463             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     464             : static_assert(0 < 1, "There is no slot for us");
     465             : 
     466             : static bool
     467           0 : update(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
     468             : {
     469           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     470           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaKeySession.update");
     471             :   }
     472           0 :   ArrayBufferViewOrArrayBuffer arg0;
     473           0 :   ArrayBufferViewOrArrayBufferArgument arg0_holder(arg0);
     474             :   {
     475           0 :     bool done = false, failed = false, tryNext;
     476           0 :     if (args[0].isObject()) {
     477           0 :       done = (failed = !arg0_holder.TrySetToArrayBufferView(cx, args[0], tryNext, false)) || !tryNext ||
     478           0 :              (failed = !arg0_holder.TrySetToArrayBuffer(cx, args[0], tryNext, false)) || !tryNext;
     479             : 
     480             :     }
     481           0 :     if (failed) {
     482           0 :       return false;
     483             :     }
     484           0 :     if (!done) {
     485           0 :       ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of MediaKeySession.update", "ArrayBufferView, ArrayBuffer");
     486           0 :       return false;
     487             :     }
     488             :   }
     489           0 :   binding_detail::FastErrorResult rv;
     490           0 :   auto result(StrongOrRawPtr<Promise>(self->Update(Constify(arg0), rv)));
     491           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     492           0 :     return false;
     493             :   }
     494           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     495             :   static_assert(!IsPointer<decltype(result)>::value,
     496             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     497           0 :   if (!ToJSValue(cx, result, args.rval())) {
     498           0 :     return false;
     499             :   }
     500           0 :   return true;
     501             : }
     502             : 
     503             : static bool
     504           0 : update_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
     505             : {
     506             :   // Make sure to save the callee before someone maybe messes
     507             :   // with rval().
     508           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
     509           0 :   bool ok = update(cx, obj, self, args);
     510           0 :   if (ok) {
     511           0 :     return true;
     512             :   }
     513           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
     514           0 :                                    args.rval());
     515             : }
     516             : 
     517             : static const JSJitInfo update_methodinfo = {
     518             :   { (JSJitGetterOp)update_promiseWrapper },
     519             :   { prototypes::id::MediaKeySession },
     520             :   { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
     521             :   JSJitInfo::Method,
     522             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     523             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     524             :   false,  /* isInfallible. False in setters. */
     525             :   false,  /* isMovable.  Not relevant for setters. */
     526             :   false, /* isEliminatable.  Not relevant for setters. */
     527             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     528             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     529             :   false,  /* isTypedMethod.  Only relevant for methods. */
     530             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     531             : };
     532             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     533             : static_assert(0 < 1, "There is no slot for us");
     534             : 
     535             : static bool
     536           0 : close(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
     537             : {
     538           0 :   binding_detail::FastErrorResult rv;
     539           0 :   auto result(StrongOrRawPtr<Promise>(self->Close(rv)));
     540           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     541           0 :     return false;
     542             :   }
     543           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     544             :   static_assert(!IsPointer<decltype(result)>::value,
     545             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     546           0 :   if (!ToJSValue(cx, result, args.rval())) {
     547           0 :     return false;
     548             :   }
     549           0 :   return true;
     550             : }
     551             : 
     552             : static bool
     553           0 : close_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
     554             : {
     555             :   // Make sure to save the callee before someone maybe messes
     556             :   // with rval().
     557           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
     558           0 :   bool ok = close(cx, obj, self, args);
     559           0 :   if (ok) {
     560           0 :     return true;
     561             :   }
     562           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
     563           0 :                                    args.rval());
     564             : }
     565             : 
     566             : static const JSJitInfo close_methodinfo = {
     567             :   { (JSJitGetterOp)close_promiseWrapper },
     568             :   { prototypes::id::MediaKeySession },
     569             :   { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
     570             :   JSJitInfo::Method,
     571             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     572             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     573             :   false,  /* isInfallible. False in setters. */
     574             :   false,  /* isMovable.  Not relevant for setters. */
     575             :   false, /* isEliminatable.  Not relevant for setters. */
     576             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     577             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     578             :   false,  /* isTypedMethod.  Only relevant for methods. */
     579             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     580             : };
     581             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     582             : static_assert(0 < 1, "There is no slot for us");
     583             : 
     584             : static bool
     585           0 : remove(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
     586             : {
     587           0 :   binding_detail::FastErrorResult rv;
     588           0 :   auto result(StrongOrRawPtr<Promise>(self->Remove(rv)));
     589           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     590           0 :     return false;
     591             :   }
     592           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     593             :   static_assert(!IsPointer<decltype(result)>::value,
     594             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     595           0 :   if (!ToJSValue(cx, result, args.rval())) {
     596           0 :     return false;
     597             :   }
     598           0 :   return true;
     599             : }
     600             : 
     601             : static bool
     602           0 : remove_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeySession* self, const JSJitMethodCallArgs& args)
     603             : {
     604             :   // Make sure to save the callee before someone maybe messes
     605             :   // with rval().
     606           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
     607           0 :   bool ok = remove(cx, obj, self, args);
     608           0 :   if (ok) {
     609           0 :     return true;
     610             :   }
     611           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
     612           0 :                                    args.rval());
     613             : }
     614             : 
     615             : static const JSJitInfo remove_methodinfo = {
     616             :   { (JSJitGetterOp)remove_promiseWrapper },
     617             :   { prototypes::id::MediaKeySession },
     618             :   { PrototypeTraits<prototypes::id::MediaKeySession>::Depth },
     619             :   JSJitInfo::Method,
     620             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     621             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     622             :   false,  /* isInfallible. False in setters. */
     623             :   false,  /* isMovable.  Not relevant for setters. */
     624             :   false, /* isEliminatable.  Not relevant for setters. */
     625             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     626             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     627             :   false,  /* isTypedMethod.  Only relevant for methods. */
     628             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     629             : };
     630             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     631             : static_assert(0 < 1, "There is no slot for us");
     632             : 
     633             : static bool
     634           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     635             : {
     636           0 :   mozilla::dom::MediaKeySession* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaKeySession>(obj);
     637             :   // We don't want to preserve if we don't have a wrapper, and we
     638             :   // obviously can't preserve if we're not initialized.
     639           0 :   if (self && self->GetWrapperPreserveColor()) {
     640           0 :     PreserveWrapper(self);
     641             :   }
     642           0 :   return true;
     643             : }
     644             : 
     645             : static void
     646           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     647             : {
     648           0 :   mozilla::dom::MediaKeySession* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaKeySession>(obj);
     649           0 :   if (self) {
     650           0 :     ClearWrapper(self, self, obj);
     651           0 :     AddForDeferredFinalization<mozilla::dom::MediaKeySession>(self);
     652             :   }
     653           0 : }
     654             : 
     655             : static void
     656           0 : _objectMoved(JSObject* obj, const JSObject* old)
     657             : {
     658           0 :   mozilla::dom::MediaKeySession* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaKeySession>(obj);
     659           0 :   if (self) {
     660           0 :     UpdateWrapper(self, self, obj, old);
     661             :   }
     662           0 : }
     663             : 
     664             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     665             : #if defined(__clang__)
     666             : #pragma clang diagnostic push
     667             : #pragma clang diagnostic ignored "-Wmissing-braces"
     668             : #endif
     669             : static const JSFunctionSpec sMethods_specs[] = {
     670             :   JS_FNSPEC("generateRequest", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&generateRequest_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
     671             :   JS_FNSPEC("load", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&load_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     672             :   JS_FNSPEC("update", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&update_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     673             :   JS_FNSPEC("close", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&close_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     674             :   JS_FNSPEC("remove", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&remove_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     675             :   JS_FS_END
     676             : };
     677             : #if defined(__clang__)
     678             : #pragma clang diagnostic pop
     679             : #endif
     680             : 
     681             : 
     682             : // Can't be const because the pref-enabled boolean needs to be writable
     683             : static Prefable<const JSFunctionSpec> sMethods[] = {
     684             :   { nullptr, &sMethods_specs[0] },
     685             :   { nullptr, nullptr }
     686             : };
     687             : 
     688             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     689             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     690             : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     691             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     692             : 
     693             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     694             : #if defined(__clang__)
     695             : #pragma clang diagnostic push
     696             : #pragma clang diagnostic ignored "-Wmissing-braces"
     697             : #endif
     698             : static const JSPropertySpec sAttributes_specs[] = {
     699             :   { "error", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &error_getterinfo, nullptr, nullptr },
     700             :   { "sessionId", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &sessionId_getterinfo, nullptr, nullptr },
     701             :   { "expiration", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &expiration_getterinfo, nullptr, nullptr },
     702             :   { "closed", JSPROP_SHARED | JSPROP_ENUMERATE, GenericPromiseReturningBindingGetter, &closed_getterinfo, nullptr, nullptr },
     703             :   { "keyStatuses", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &keyStatuses_getterinfo, nullptr, nullptr },
     704             :   { "onkeystatuseschange", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onkeystatuseschange_getterinfo, GenericBindingSetter, &onkeystatuseschange_setterinfo },
     705             :   { "onmessage", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onmessage_getterinfo, GenericBindingSetter, &onmessage_setterinfo },
     706             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     707             : };
     708             : #if defined(__clang__)
     709             : #pragma clang diagnostic pop
     710             : #endif
     711             : 
     712             : 
     713             : // Can't be const because the pref-enabled boolean needs to be writable
     714             : static Prefable<const JSPropertySpec> sAttributes[] = {
     715             :   { nullptr, &sAttributes_specs[0] },
     716             :   { nullptr, nullptr }
     717             : };
     718             : 
     719             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     720             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     721             : static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     722             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     723             : 
     724             : 
     725             : static uint16_t sNativeProperties_sortedPropertyIndices[12];
     726             : static PropertyInfo sNativeProperties_propertyInfos[12];
     727             : 
     728             : static const NativePropertiesN<2> sNativeProperties = {
     729             :   false, 0,
     730             :   false, 0,
     731             :   true,  0 /* sMethods */,
     732             :   true,  1 /* sAttributes */,
     733             :   false, 0,
     734             :   false, 0,
     735             :   false, 0,
     736             :   -1,
     737             :   12,
     738             :   sNativeProperties_sortedPropertyIndices,
     739             :   {
     740             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     741             :     { sAttributes, &sNativeProperties_propertyInfos[5] }
     742             :   }
     743             : };
     744             : static_assert(12 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     745             :     "We have a property info count that is oversized");
     746             : 
     747             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     748             :   {
     749             :     "Function",
     750             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     751             :     &sBoringInterfaceObjectClassClassOps,
     752             :     JS_NULL_CLASS_SPEC,
     753             :     JS_NULL_CLASS_EXT,
     754             :     &sInterfaceObjectClassObjectOps
     755             :   },
     756             :   eInterface,
     757             :   true,
     758             :   prototypes::id::MediaKeySession,
     759             :   PrototypeTraits<prototypes::id::MediaKeySession>::Depth,
     760             :   sNativePropertyHooks,
     761             :   "function MediaKeySession() {\n    [native code]\n}",
     762             :   EventTargetBinding::GetConstructorObject
     763             : };
     764             : 
     765             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     766             :   {
     767             :     "MediaKeySessionPrototype",
     768             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     769             :     JS_NULL_CLASS_OPS,
     770             :     JS_NULL_CLASS_SPEC,
     771             :     JS_NULL_CLASS_EXT,
     772             :     JS_NULL_OBJECT_OPS
     773             :   },
     774             :   eInterfacePrototype,
     775             :   false,
     776             :   prototypes::id::MediaKeySession,
     777             :   PrototypeTraits<prototypes::id::MediaKeySession>::Depth,
     778             :   sNativePropertyHooks,
     779             :   "[object MediaKeySessionPrototype]",
     780             :   EventTargetBinding::GetProtoObject
     781             : };
     782             : 
     783             : JSObject*
     784           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     785             : {
     786           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     787             : }
     788             : 
     789             : static const js::ClassOps sClassOps = {
     790             :   _addProperty, /* addProperty */
     791             :   nullptr,               /* delProperty */
     792             :   nullptr,               /* getProperty */
     793             :   nullptr,               /* setProperty */
     794             :   nullptr,               /* enumerate */
     795             :   nullptr, /* newEnumerate */
     796             :   nullptr, /* resolve */
     797             :   nullptr, /* mayResolve */
     798             :   _finalize, /* finalize */
     799             :   nullptr, /* call */
     800             :   nullptr,               /* hasInstance */
     801             :   nullptr,               /* construct */
     802             :   nullptr, /* trace */
     803             : };
     804             : 
     805             : static const js::ClassExtension sClassExtension = {
     806             :   nullptr, /* weakmapKeyDelegateOp */
     807             :   _objectMoved /* objectMovedOp */
     808             : };
     809             : 
     810             : static const DOMJSClass sClass = {
     811             :   { "MediaKeySession",
     812             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     813             :     &sClassOps,
     814             :     JS_NULL_CLASS_SPEC,
     815             :     &sClassExtension,
     816             :     JS_NULL_OBJECT_OPS
     817             :   },
     818             :   { prototypes::id::EventTarget, prototypes::id::MediaKeySession, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     819             :   IsBaseOf<nsISupports, mozilla::dom::MediaKeySession >::value,
     820             :   sNativePropertyHooks,
     821             :   FindAssociatedGlobalForNative<mozilla::dom::MediaKeySession>::Get,
     822             :   GetProtoObjectHandle,
     823             :   GetCCParticipant<mozilla::dom::MediaKeySession>::Get()
     824             : };
     825             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     826             :               "Must have the right minimal number of reserved slots.");
     827             : static_assert(1 >= 1,
     828             :               "Must have enough reserved slots.");
     829             : 
     830             : const JSClass*
     831           0 : GetJSClass()
     832             : {
     833           0 :   return sClass.ToJSClass();
     834             : }
     835             : 
     836             : bool
     837           0 : Wrap(JSContext* aCx, mozilla::dom::MediaKeySession* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     838             : {
     839             :   MOZ_ASSERT(static_cast<mozilla::dom::MediaKeySession*>(aObject) ==
     840             :              reinterpret_cast<mozilla::dom::MediaKeySession*>(aObject),
     841             :              "Multiple inheritance for mozilla::dom::MediaKeySession is broken.");
     842             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     843             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     844             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     845           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     846           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     847           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     848             :              "You should probably not be using Wrap() directly; use "
     849             :              "GetOrCreateDOMReflector instead");
     850             : 
     851           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     852             :              "nsISupports must be on our primary inheritance chain");
     853             : 
     854           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     855           0 :   if (!global) {
     856           0 :     return false;
     857             :   }
     858           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     859           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     860             : 
     861             :   // That might have ended up wrapping us already, due to the wonders
     862             :   // of XBL.  Check for that, and bail out as needed.
     863           0 :   aReflector.set(aCache->GetWrapper());
     864           0 :   if (aReflector) {
     865             : #ifdef DEBUG
     866           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     867             : #endif // DEBUG
     868           0 :     return true;
     869             :   }
     870             : 
     871           0 :   JSAutoCompartment ac(aCx, global);
     872           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     873           0 :   if (!canonicalProto) {
     874           0 :     return false;
     875             :   }
     876           0 :   JS::Rooted<JSObject*> proto(aCx);
     877           0 :   if (aGivenProto) {
     878           0 :     proto = aGivenProto;
     879             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     880             :     // coming in, we changed compartments to that of "parent" so may need
     881             :     // to wrap the proto here.
     882           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     883           0 :       if (!JS_WrapObject(aCx, &proto)) {
     884           0 :         return false;
     885             :       }
     886             :     }
     887             :   } else {
     888           0 :     proto = canonicalProto;
     889             :   }
     890             : 
     891           0 :   BindingJSObjectCreator<mozilla::dom::MediaKeySession> creator(aCx);
     892           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     893           0 :   if (!aReflector) {
     894           0 :     return false;
     895             :   }
     896             : 
     897           0 :   aCache->SetWrapper(aReflector);
     898           0 :   creator.InitializationSucceeded();
     899             : 
     900           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     901             :              aCache->GetWrapperPreserveColor() == aReflector);
     902             :   // If proto != canonicalProto, we have to preserve our wrapper;
     903             :   // otherwise we won't be able to properly recreate it later, since
     904             :   // we won't know what proto to use.  Note that we don't check
     905             :   // aGivenProto here, since it's entirely possible (and even
     906             :   // somewhat common) to have a non-null aGivenProto which is the
     907             :   // same as canonicalProto.
     908           0 :   if (proto != canonicalProto) {
     909           0 :     PreserveWrapper(aObject);
     910             :   }
     911             : 
     912           0 :   return true;
     913             : }
     914             : 
     915             : const NativePropertyHooks sNativePropertyHooks[] = { {
     916             :   nullptr,
     917             :   nullptr,
     918             :   nullptr,
     919             :   { sNativeProperties.Upcast(), nullptr },
     920             :   prototypes::id::MediaKeySession,
     921             :   constructors::id::MediaKeySession,
     922             :   EventTargetBinding::sNativePropertyHooks,
     923             :   &DefaultXrayExpandoObjectClass
     924             : } };
     925             : 
     926             : void
     927           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     928             : {
     929           0 :   JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
     930           0 :   if (!parentProto) {
     931           0 :     return;
     932             :   }
     933             : 
     934           0 :   JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
     935           0 :   if (!constructorProto) {
     936           0 :     return;
     937             :   }
     938             : 
     939             :   static bool sIdsInited = false;
     940           0 :   if (!sIdsInited && NS_IsMainThread()) {
     941           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     942           0 :       return;
     943             :     }
     944           0 :     sIdsInited = true;
     945             :   }
     946             : 
     947           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MediaKeySession);
     948           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::MediaKeySession);
     949           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     950             :                               &sPrototypeClass.mBase, protoCache,
     951             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     952             :                               interfaceCache,
     953             :                               sNativeProperties.Upcast(),
     954             :                               nullptr,
     955             :                               "MediaKeySession", aDefineOnGlobal,
     956             :                               nullptr,
     957           0 :                               false);
     958             : }
     959             : 
     960             : JS::Handle<JSObject*>
     961           0 : GetProtoObjectHandle(JSContext* aCx)
     962             : {
     963             :   /* Get the interface prototype object for this class.  This will create the
     964             :      object as needed. */
     965           0 :   bool aDefineOnGlobal = true;
     966             : 
     967             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     968           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     969           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     970           0 :     return nullptr;
     971             :   }
     972             : 
     973             :   /* Check to see whether the interface objects are already installed */
     974           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     975           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::MediaKeySession)) {
     976           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     977           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     978             :   }
     979             : 
     980             :   /*
     981             :    * The object might _still_ be null, but that's OK.
     982             :    *
     983             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     984             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     985             :    * changed after they have been set.
     986             :    *
     987             :    * Calling address() avoids the read read barrier that does gray
     988             :    * unmarking, but it's not possible for the object to be gray here.
     989             :    */
     990             : 
     991           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::MediaKeySession);
     992           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     993           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     994             : }
     995             : 
     996             : JS::Handle<JSObject*>
     997           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     998             : {
     999             :   /* Get the interface object for this class.  This will create the object as
    1000             :      needed. */
    1001             : 
    1002             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1003           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1004           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1005           0 :     return nullptr;
    1006             :   }
    1007             : 
    1008             :   /* Check to see whether the interface objects are already installed */
    1009           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1010           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::MediaKeySession)) {
    1011           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1012           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1013             :   }
    1014             : 
    1015             :   /*
    1016             :    * The object might _still_ be null, but that's OK.
    1017             :    *
    1018             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1019             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1020             :    * changed after they have been set.
    1021             :    *
    1022             :    * Calling address() avoids the read read barrier that does gray
    1023             :    * unmarking, but it's not possible for the object to be gray here.
    1024             :    */
    1025             : 
    1026           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::MediaKeySession);
    1027           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1028           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1029             : }
    1030             : 
    1031             : JSObject*
    1032           0 : GetConstructorObject(JSContext* aCx)
    1033             : {
    1034           0 :   return GetConstructorObjectHandle(aCx);
    1035             : }
    1036             : 
    1037             : } // namespace MediaKeySessionBinding
    1038             : 
    1039             : 
    1040             : 
    1041             : } // namespace dom
    1042             : } // namespace mozilla

Generated by: LCOV version 1.13