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

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

Generated by: LCOV version 1.13