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

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

Generated by: LCOV version 1.13