LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - XMLHttpRequestUploadBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 27 101 26.7 %
Date: 2017-07-14 16:53:18 Functions: 4 11 36.4 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13