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

Generated by: LCOV version 1.13