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

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

Generated by: LCOV version 1.13