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

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

Generated by: LCOV version 1.13