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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM GetUserMediaRequest.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "GetUserMediaRequestBinding.h"
       4             : #include "MediaStreamBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "mozilla/OwningNonNull.h"
       7             : #include "mozilla/dom/BindingUtils.h"
       8             : #include "mozilla/dom/DOMJSClass.h"
       9             : #include "mozilla/dom/GetUserMediaRequest.h"
      10             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      11             : #include "mozilla/dom/PrimitiveConversions.h"
      12             : #include "mozilla/dom/XrayExpandoClass.h"
      13             : 
      14             : namespace mozilla {
      15             : namespace dom {
      16             : 
      17             : namespace GetUserMediaRequestBinding {
      18             : 
      19             : static bool
      20           0 : get_windowID(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GetUserMediaRequest* self, JSJitGetterCallArgs args)
      21             : {
      22           0 :   uint64_t result(self->WindowID());
      23           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      24           0 :   args.rval().set(JS_NumberValue(double(result)));
      25           0 :   return true;
      26             : }
      27             : 
      28             : static const JSJitInfo windowID_getterinfo = {
      29             :   { (JSJitGetterOp)get_windowID },
      30             :   { prototypes::id::GetUserMediaRequest },
      31             :   { PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth },
      32             :   JSJitInfo::Getter,
      33             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      34             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
      35             :   true,  /* isInfallible. False in setters. */
      36             :   false,  /* isMovable.  Not relevant for setters. */
      37             :   false, /* isEliminatable.  Not relevant for setters. */
      38             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      39             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      40             :   false,  /* isTypedMethod.  Only relevant for methods. */
      41             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      42             : };
      43             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      44             : static_assert(0 < 1, "There is no slot for us");
      45             : 
      46             : static bool
      47           0 : get_innerWindowID(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GetUserMediaRequest* self, JSJitGetterCallArgs args)
      48             : {
      49           0 :   uint64_t result(self->InnerWindowID());
      50           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      51           0 :   args.rval().set(JS_NumberValue(double(result)));
      52           0 :   return true;
      53             : }
      54             : 
      55             : static const JSJitInfo innerWindowID_getterinfo = {
      56             :   { (JSJitGetterOp)get_innerWindowID },
      57             :   { prototypes::id::GetUserMediaRequest },
      58             :   { PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth },
      59             :   JSJitInfo::Getter,
      60             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      61             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
      62             :   true,  /* isInfallible. False in setters. */
      63             :   false,  /* isMovable.  Not relevant for setters. */
      64             :   false, /* isEliminatable.  Not relevant for setters. */
      65             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      66             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      67             :   false,  /* isTypedMethod.  Only relevant for methods. */
      68             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      69             : };
      70             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      71             : static_assert(0 < 1, "There is no slot for us");
      72             : 
      73             : static bool
      74           0 : get_callID(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GetUserMediaRequest* self, JSJitGetterCallArgs args)
      75             : {
      76           0 :   DOMString result;
      77           0 :   self->GetCallID(result);
      78           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      79           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
      80           0 :     return false;
      81             :   }
      82           0 :   return true;
      83             : }
      84             : 
      85             : static const JSJitInfo callID_getterinfo = {
      86             :   { (JSJitGetterOp)get_callID },
      87             :   { prototypes::id::GetUserMediaRequest },
      88             :   { PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth },
      89             :   JSJitInfo::Getter,
      90             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      91             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
      92             :   false,  /* isInfallible. False in setters. */
      93             :   false,  /* isMovable.  Not relevant for setters. */
      94             :   false, /* isEliminatable.  Not relevant for setters. */
      95             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      96             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      97             :   false,  /* isTypedMethod.  Only relevant for methods. */
      98             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      99             : };
     100             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     101             : static_assert(0 < 1, "There is no slot for us");
     102             : 
     103             : static bool
     104           0 : get_rawID(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GetUserMediaRequest* self, JSJitGetterCallArgs args)
     105             : {
     106           0 :   DOMString result;
     107           0 :   self->GetRawID(result);
     108           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     109           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     110           0 :     return false;
     111             :   }
     112           0 :   return true;
     113             : }
     114             : 
     115             : static const JSJitInfo rawID_getterinfo = {
     116             :   { (JSJitGetterOp)get_rawID },
     117             :   { prototypes::id::GetUserMediaRequest },
     118             :   { PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth },
     119             :   JSJitInfo::Getter,
     120             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     121             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     122             :   false,  /* isInfallible. False in setters. */
     123             :   false,  /* isMovable.  Not relevant for setters. */
     124             :   false, /* isEliminatable.  Not relevant for setters. */
     125             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     126             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     127             :   false,  /* isTypedMethod.  Only relevant for methods. */
     128             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     129             : };
     130             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     131             : static_assert(0 < 1, "There is no slot for us");
     132             : 
     133             : static bool
     134           0 : get_mediaSource(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GetUserMediaRequest* self, JSJitGetterCallArgs args)
     135             : {
     136           0 :   DOMString result;
     137           0 :   self->GetMediaSource(result);
     138           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     139           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     140           0 :     return false;
     141             :   }
     142           0 :   return true;
     143             : }
     144             : 
     145             : static const JSJitInfo mediaSource_getterinfo = {
     146             :   { (JSJitGetterOp)get_mediaSource },
     147             :   { prototypes::id::GetUserMediaRequest },
     148             :   { PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth },
     149             :   JSJitInfo::Getter,
     150             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     151             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     152             :   false,  /* isInfallible. False in setters. */
     153             :   false,  /* isMovable.  Not relevant for setters. */
     154             :   false, /* isEliminatable.  Not relevant for setters. */
     155             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     156             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     157             :   false,  /* isTypedMethod.  Only relevant for methods. */
     158             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     159             : };
     160             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     161             : static_assert(0 < 1, "There is no slot for us");
     162             : 
     163             : static bool
     164           0 : getConstraints(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GetUserMediaRequest* self, const JSJitMethodCallArgs& args)
     165             : {
     166           0 :   MediaStreamConstraints result;
     167           0 :   self->GetConstraints(result);
     168           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     169           0 :   if (!result.ToObjectInternal(cx, args.rval())) {
     170           0 :     return false;
     171             :   }
     172           0 :   return true;
     173             : }
     174             : 
     175             : static const JSJitInfo getConstraints_methodinfo = {
     176             :   { (JSJitGetterOp)getConstraints },
     177             :   { prototypes::id::GetUserMediaRequest },
     178             :   { PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth },
     179             :   JSJitInfo::Method,
     180             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     181             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     182             :   false,  /* isInfallible. False in setters. */
     183             :   false,  /* isMovable.  Not relevant for setters. */
     184             :   false, /* isEliminatable.  Not relevant for setters. */
     185             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     186             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     187             :   false,  /* isTypedMethod.  Only relevant for methods. */
     188             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     189             : };
     190             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     191             : static_assert(0 < 1, "There is no slot for us");
     192             : 
     193             : static bool
     194           0 : get_isSecure(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GetUserMediaRequest* self, JSJitGetterCallArgs args)
     195             : {
     196           0 :   bool result(self->IsSecure());
     197           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     198           0 :   args.rval().setBoolean(result);
     199           0 :   return true;
     200             : }
     201             : 
     202             : static const JSJitInfo isSecure_getterinfo = {
     203             :   { (JSJitGetterOp)get_isSecure },
     204             :   { prototypes::id::GetUserMediaRequest },
     205             :   { PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth },
     206             :   JSJitInfo::Getter,
     207             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     208             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     209             :   true,  /* isInfallible. False in setters. */
     210             :   false,  /* isMovable.  Not relevant for setters. */
     211             :   false, /* isEliminatable.  Not relevant for setters. */
     212             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     213             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     214             :   false,  /* isTypedMethod.  Only relevant for methods. */
     215             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     216             : };
     217             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     218             : static_assert(0 < 1, "There is no slot for us");
     219             : 
     220             : static bool
     221           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     222             : {
     223           0 :   mozilla::dom::GetUserMediaRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GetUserMediaRequest>(obj);
     224             :   // We don't want to preserve if we don't have a wrapper, and we
     225             :   // obviously can't preserve if we're not initialized.
     226           0 :   if (self && self->GetWrapperPreserveColor()) {
     227           0 :     PreserveWrapper(self);
     228             :   }
     229           0 :   return true;
     230             : }
     231             : 
     232             : static void
     233           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     234             : {
     235           0 :   mozilla::dom::GetUserMediaRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GetUserMediaRequest>(obj);
     236           0 :   if (self) {
     237           0 :     ClearWrapper(self, self, obj);
     238           0 :     AddForDeferredFinalization<mozilla::dom::GetUserMediaRequest>(self);
     239             :   }
     240           0 : }
     241             : 
     242             : static void
     243           0 : _objectMoved(JSObject* obj, const JSObject* old)
     244             : {
     245           0 :   mozilla::dom::GetUserMediaRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GetUserMediaRequest>(obj);
     246           0 :   if (self) {
     247           0 :     UpdateWrapper(self, self, obj, old);
     248             :   }
     249           0 : }
     250             : 
     251             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     252             : #if defined(__clang__)
     253             : #pragma clang diagnostic push
     254             : #pragma clang diagnostic ignored "-Wmissing-braces"
     255             : #endif
     256             : static const JSFunctionSpec sMethods_specs[] = {
     257             :   JS_FNSPEC("getConstraints", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getConstraints_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     258             :   JS_FS_END
     259             : };
     260             : #if defined(__clang__)
     261             : #pragma clang diagnostic pop
     262             : #endif
     263             : 
     264             : 
     265             : // Can't be const because the pref-enabled boolean needs to be writable
     266             : static Prefable<const JSFunctionSpec> sMethods[] = {
     267             :   { nullptr, &sMethods_specs[0] },
     268             :   { nullptr, nullptr }
     269             : };
     270             : 
     271             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     272             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     273             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     274             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     275             : 
     276             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     277             : #if defined(__clang__)
     278             : #pragma clang diagnostic push
     279             : #pragma clang diagnostic ignored "-Wmissing-braces"
     280             : #endif
     281             : static const JSPropertySpec sAttributes_specs[] = {
     282             :   { "windowID", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &windowID_getterinfo, nullptr, nullptr },
     283             :   { "innerWindowID", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &innerWindowID_getterinfo, nullptr, nullptr },
     284             :   { "callID", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &callID_getterinfo, nullptr, nullptr },
     285             :   { "rawID", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &rawID_getterinfo, nullptr, nullptr },
     286             :   { "mediaSource", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mediaSource_getterinfo, nullptr, nullptr },
     287             :   { "isSecure", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &isSecure_getterinfo, nullptr, nullptr },
     288             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     289             : };
     290             : #if defined(__clang__)
     291             : #pragma clang diagnostic pop
     292             : #endif
     293             : 
     294             : 
     295             : // Can't be const because the pref-enabled boolean needs to be writable
     296             : static Prefable<const JSPropertySpec> sAttributes[] = {
     297             :   { nullptr, &sAttributes_specs[0] },
     298             :   { nullptr, nullptr }
     299             : };
     300             : 
     301             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     302             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     303             : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     304             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     305             : 
     306             : 
     307             : static uint16_t sNativeProperties_sortedPropertyIndices[7];
     308             : static PropertyInfo sNativeProperties_propertyInfos[7];
     309             : 
     310             : static const NativePropertiesN<2> sNativeProperties = {
     311             :   false, 0,
     312             :   false, 0,
     313             :   true,  0 /* sMethods */,
     314             :   true,  1 /* sAttributes */,
     315             :   false, 0,
     316             :   false, 0,
     317             :   false, 0,
     318             :   -1,
     319             :   7,
     320             :   sNativeProperties_sortedPropertyIndices,
     321             :   {
     322             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     323             :     { sAttributes, &sNativeProperties_propertyInfos[1] }
     324             :   }
     325             : };
     326             : static_assert(7 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     327             :     "We have a property info count that is oversized");
     328             : 
     329             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     330             :   {
     331             :     "GetUserMediaRequestPrototype",
     332             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     333             :     JS_NULL_CLASS_OPS,
     334             :     JS_NULL_CLASS_SPEC,
     335             :     JS_NULL_CLASS_EXT,
     336             :     JS_NULL_OBJECT_OPS
     337             :   },
     338             :   eInterfacePrototype,
     339             :   false,
     340             :   prototypes::id::GetUserMediaRequest,
     341             :   PrototypeTraits<prototypes::id::GetUserMediaRequest>::Depth,
     342             :   sNativePropertyHooks,
     343             :   "[object GetUserMediaRequestPrototype]",
     344             :   JS::GetRealmObjectPrototype
     345             : };
     346             : 
     347             : static const js::ClassOps sClassOps = {
     348             :   _addProperty, /* addProperty */
     349             :   nullptr,               /* delProperty */
     350             :   nullptr,               /* getProperty */
     351             :   nullptr,               /* setProperty */
     352             :   nullptr,               /* enumerate */
     353             :   nullptr, /* newEnumerate */
     354             :   nullptr, /* resolve */
     355             :   nullptr, /* mayResolve */
     356             :   _finalize, /* finalize */
     357             :   nullptr, /* call */
     358             :   nullptr,               /* hasInstance */
     359             :   nullptr,               /* construct */
     360             :   nullptr, /* trace */
     361             : };
     362             : 
     363             : static const js::ClassExtension sClassExtension = {
     364             :   nullptr, /* weakmapKeyDelegateOp */
     365             :   _objectMoved /* objectMovedOp */
     366             : };
     367             : 
     368             : static const DOMJSClass sClass = {
     369             :   { "GetUserMediaRequest",
     370             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     371             :     &sClassOps,
     372             :     JS_NULL_CLASS_SPEC,
     373             :     &sClassExtension,
     374             :     JS_NULL_OBJECT_OPS
     375             :   },
     376             :   { prototypes::id::GetUserMediaRequest, 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 },
     377             :   IsBaseOf<nsISupports, mozilla::dom::GetUserMediaRequest >::value,
     378             :   sNativePropertyHooks,
     379             :   FindAssociatedGlobalForNative<mozilla::dom::GetUserMediaRequest>::Get,
     380             :   GetProtoObjectHandle,
     381             :   GetCCParticipant<mozilla::dom::GetUserMediaRequest>::Get()
     382             : };
     383             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     384             :               "Must have the right minimal number of reserved slots.");
     385             : static_assert(1 >= 1,
     386             :               "Must have enough reserved slots.");
     387             : 
     388             : const JSClass*
     389           0 : GetJSClass()
     390             : {
     391           0 :   return sClass.ToJSClass();
     392             : }
     393             : 
     394             : bool
     395           0 : Wrap(JSContext* aCx, mozilla::dom::GetUserMediaRequest* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     396             : {
     397             :   MOZ_ASSERT(static_cast<mozilla::dom::GetUserMediaRequest*>(aObject) ==
     398             :              reinterpret_cast<mozilla::dom::GetUserMediaRequest*>(aObject),
     399             :              "Multiple inheritance for mozilla::dom::GetUserMediaRequest is broken.");
     400           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     401           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     402           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     403             :              "You should probably not be using Wrap() directly; use "
     404             :              "GetOrCreateDOMReflector instead");
     405             : 
     406           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     407             :              "nsISupports must be on our primary inheritance chain");
     408             : 
     409           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     410           0 :   if (!global) {
     411           0 :     return false;
     412             :   }
     413           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     414           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     415             : 
     416             :   // That might have ended up wrapping us already, due to the wonders
     417             :   // of XBL.  Check for that, and bail out as needed.
     418           0 :   aReflector.set(aCache->GetWrapper());
     419           0 :   if (aReflector) {
     420             : #ifdef DEBUG
     421           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     422             : #endif // DEBUG
     423           0 :     return true;
     424             :   }
     425             : 
     426           0 :   JSAutoCompartment ac(aCx, global);
     427           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     428           0 :   if (!canonicalProto) {
     429           0 :     return false;
     430             :   }
     431           0 :   JS::Rooted<JSObject*> proto(aCx);
     432           0 :   if (aGivenProto) {
     433           0 :     proto = aGivenProto;
     434             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     435             :     // coming in, we changed compartments to that of "parent" so may need
     436             :     // to wrap the proto here.
     437           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     438           0 :       if (!JS_WrapObject(aCx, &proto)) {
     439           0 :         return false;
     440             :       }
     441             :     }
     442             :   } else {
     443           0 :     proto = canonicalProto;
     444             :   }
     445             : 
     446           0 :   BindingJSObjectCreator<mozilla::dom::GetUserMediaRequest> creator(aCx);
     447           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     448           0 :   if (!aReflector) {
     449           0 :     return false;
     450             :   }
     451             : 
     452           0 :   aCache->SetWrapper(aReflector);
     453           0 :   creator.InitializationSucceeded();
     454             : 
     455           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     456             :              aCache->GetWrapperPreserveColor() == aReflector);
     457             :   // If proto != canonicalProto, we have to preserve our wrapper;
     458             :   // otherwise we won't be able to properly recreate it later, since
     459             :   // we won't know what proto to use.  Note that we don't check
     460             :   // aGivenProto here, since it's entirely possible (and even
     461             :   // somewhat common) to have a non-null aGivenProto which is the
     462             :   // same as canonicalProto.
     463           0 :   if (proto != canonicalProto) {
     464           0 :     PreserveWrapper(aObject);
     465             :   }
     466             : 
     467           0 :   return true;
     468             : }
     469             : 
     470             : const NativePropertyHooks sNativePropertyHooks[] = { {
     471             :   nullptr,
     472             :   nullptr,
     473             :   nullptr,
     474             :   { sNativeProperties.Upcast(), nullptr },
     475             :   prototypes::id::GetUserMediaRequest,
     476             :   constructors::id::_ID_Count,
     477             :   nullptr,
     478             :   &DefaultXrayExpandoObjectClass
     479             : } };
     480             : 
     481             : void
     482           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     483             : {
     484           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
     485           0 :   if (!parentProto) {
     486           0 :     return;
     487             :   }
     488             : 
     489             :   static bool sIdsInited = false;
     490           0 :   if (!sIdsInited && NS_IsMainThread()) {
     491           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     492           0 :       return;
     493             :     }
     494           0 :     sIdsInited = true;
     495             :   }
     496             : 
     497           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GetUserMediaRequest);
     498           0 :   JS::Heap<JSObject*>* interfaceCache = nullptr;
     499           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     500             :                               &sPrototypeClass.mBase, protoCache,
     501             :                               nullptr, nullptr, 0, nullptr,
     502             :                               interfaceCache,
     503             :                               sNativeProperties.Upcast(),
     504             :                               nullptr,
     505             :                               nullptr, aDefineOnGlobal,
     506             :                               nullptr,
     507           0 :                               false);
     508             : }
     509             : 
     510             : JS::Handle<JSObject*>
     511           0 : GetProtoObjectHandle(JSContext* aCx)
     512             : {
     513             :   /* Get the interface prototype object for this class.  This will create the
     514             :      object as needed. */
     515           0 :   bool aDefineOnGlobal = true;
     516             : 
     517             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     518           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     519           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     520           0 :     return nullptr;
     521             :   }
     522             : 
     523             :   /* Check to see whether the interface objects are already installed */
     524           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     525           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::GetUserMediaRequest)) {
     526           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     527           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     528             :   }
     529             : 
     530             :   /*
     531             :    * The object might _still_ be null, but that's OK.
     532             :    *
     533             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     534             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     535             :    * changed after they have been set.
     536             :    *
     537             :    * Calling address() avoids the read read barrier that does gray
     538             :    * unmarking, but it's not possible for the object to be gray here.
     539             :    */
     540             : 
     541           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::GetUserMediaRequest);
     542           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     543           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     544             : }
     545             : 
     546             : } // namespace GetUserMediaRequestBinding
     547             : 
     548             : 
     549             : 
     550             : } // namespace dom
     551             : } // namespace mozilla

Generated by: LCOV version 1.13