LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - FileSystemFileEntryBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 148 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 FileSystemFileEntry.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "FileSystemBinding.h"
       5             : #include "FileSystemEntryBinding.h"
       6             : #include "FileSystemFileEntryBinding.h"
       7             : #include "WrapperFactory.h"
       8             : #include "mozilla/OwningNonNull.h"
       9             : #include "mozilla/dom/BindingUtils.h"
      10             : #include "mozilla/dom/DOMJSClass.h"
      11             : #include "mozilla/dom/File.h"
      12             : #include "mozilla/dom/FileSystemFileEntry.h"
      13             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      14             : #include "mozilla/dom/XrayExpandoClass.h"
      15             : 
      16             : namespace mozilla {
      17             : namespace dom {
      18             : 
      19             : namespace FileSystemFileEntryBinding {
      20             : 
      21             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<FileSystemEntryBinding::NativeType>::value,
      22             :               "Can't inherit from an interface with a different ownership model.");
      23             : 
      24             : static bool
      25           0 : file(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FileSystemFileEntry* self, const JSJitMethodCallArgs& args)
      26             : {
      27           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
      28           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FileSystemFileEntry.file");
      29             :   }
      30           0 :   RootedCallback<OwningNonNull<binding_detail::FastFileCallback>> arg0(cx);
      31           0 :   if (args[0].isObject()) {
      32             :     { // scope for tempRoot
      33           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
      34           0 :       arg0 = new binding_detail::FastFileCallback(tempRoot);
      35             :     }
      36             :   } else {
      37           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of FileSystemFileEntry.file");
      38           0 :     return false;
      39             :   }
      40           0 :   Optional<OwningNonNull<ErrorCallback>> arg1;
      41           0 :   if (args.hasDefined(1)) {
      42           0 :     arg1.Construct();
      43           0 :     if (args[1].isObject()) {
      44             :       { // scope for tempRoot
      45           0 :         JS::Rooted<JSObject*> tempRoot(cx, &args[1].toObject());
      46           0 :         arg1.Value() = new ErrorCallback(cx, tempRoot, GetIncumbentGlobal());
      47             :       }
      48             :     } else {
      49           0 :       ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of FileSystemFileEntry.file");
      50           0 :       return false;
      51             :     }
      52             :   }
      53           0 :   self->GetFile(NonNullHelper(arg0), NonNullHelper(Constify(arg1)));
      54           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      55           0 :   args.rval().setUndefined();
      56           0 :   return true;
      57             : }
      58             : 
      59             : static const JSJitInfo file_methodinfo = {
      60             :   { (JSJitGetterOp)file },
      61             :   { prototypes::id::FileSystemFileEntry },
      62             :   { PrototypeTraits<prototypes::id::FileSystemFileEntry>::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::FileSystemFileEntry* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FileSystemFileEntry>(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::FileSystemFileEntry* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FileSystemFileEntry>(obj);
      93           0 :   if (self) {
      94           0 :     ClearWrapper(self, self, obj);
      95           0 :     AddForDeferredFinalization<mozilla::dom::FileSystemFileEntry>(self);
      96             :   }
      97           0 : }
      98             : 
      99             : static void
     100           0 : _objectMoved(JSObject* obj, const JSObject* old)
     101             : {
     102           0 :   mozilla::dom::FileSystemFileEntry* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FileSystemFileEntry>(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("file", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&file_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::FileSystemFileEntry,
     167             :   PrototypeTraits<prototypes::id::FileSystemFileEntry>::Depth,
     168             :   sNativePropertyHooks,
     169             :   "function FileSystemFileEntry() {\n    [native code]\n}",
     170             :   FileSystemEntryBinding::GetConstructorObject
     171             : };
     172             : 
     173             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     174             :   {
     175             :     "FileSystemFileEntryPrototype",
     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::FileSystemFileEntry,
     185             :   PrototypeTraits<prototypes::id::FileSystemFileEntry>::Depth,
     186             :   sNativePropertyHooks,
     187             :   "[object FileSystemFileEntryPrototype]",
     188             :   FileSystemEntryBinding::GetProtoObject
     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             :   { "FileSystemFileEntry",
     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::FileSystemEntry, prototypes::id::FileSystemFileEntry, 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::FileSystemFileEntry >::value,
     228             :   sNativePropertyHooks,
     229             :   FindAssociatedGlobalForNative<mozilla::dom::FileSystemFileEntry>::Get,
     230             :   GetProtoObjectHandle,
     231             :   GetCCParticipant<mozilla::dom::FileSystemFileEntry>::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::FileSystemFileEntry* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     246             : {
     247             :   MOZ_ASSERT(static_cast<mozilla::dom::FileSystemFileEntry*>(aObject) ==
     248             :              reinterpret_cast<mozilla::dom::FileSystemFileEntry*>(aObject),
     249             :              "Multiple inheritance for mozilla::dom::FileSystemFileEntry is broken.");
     250             :   MOZ_ASSERT(static_cast<mozilla::dom::FileSystemEntry*>(aObject) ==
     251             :              reinterpret_cast<mozilla::dom::FileSystemEntry*>(aObject),
     252             :              "Multiple inheritance for mozilla::dom::FileSystemEntry is broken.");
     253           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     254           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     255           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     256             :              "You should probably not be using Wrap() directly; use "
     257             :              "GetOrCreateDOMReflector instead");
     258             : 
     259           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     260             :              "nsISupports must be on our primary inheritance chain");
     261             : 
     262           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     263           0 :   if (!global) {
     264           0 :     return false;
     265             :   }
     266           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     267           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     268             : 
     269             :   // That might have ended up wrapping us already, due to the wonders
     270             :   // of XBL.  Check for that, and bail out as needed.
     271           0 :   aReflector.set(aCache->GetWrapper());
     272           0 :   if (aReflector) {
     273             : #ifdef DEBUG
     274           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     275             : #endif // DEBUG
     276           0 :     return true;
     277             :   }
     278             : 
     279           0 :   JSAutoCompartment ac(aCx, global);
     280           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     281           0 :   if (!canonicalProto) {
     282           0 :     return false;
     283             :   }
     284           0 :   JS::Rooted<JSObject*> proto(aCx);
     285           0 :   if (aGivenProto) {
     286           0 :     proto = aGivenProto;
     287             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     288             :     // coming in, we changed compartments to that of "parent" so may need
     289             :     // to wrap the proto here.
     290           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     291           0 :       if (!JS_WrapObject(aCx, &proto)) {
     292           0 :         return false;
     293             :       }
     294             :     }
     295             :   } else {
     296           0 :     proto = canonicalProto;
     297             :   }
     298             : 
     299           0 :   BindingJSObjectCreator<mozilla::dom::FileSystemFileEntry> creator(aCx);
     300           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     301           0 :   if (!aReflector) {
     302           0 :     return false;
     303             :   }
     304             : 
     305           0 :   aCache->SetWrapper(aReflector);
     306           0 :   creator.InitializationSucceeded();
     307             : 
     308           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     309             :              aCache->GetWrapperPreserveColor() == aReflector);
     310             :   // If proto != canonicalProto, we have to preserve our wrapper;
     311             :   // otherwise we won't be able to properly recreate it later, since
     312             :   // we won't know what proto to use.  Note that we don't check
     313             :   // aGivenProto here, since it's entirely possible (and even
     314             :   // somewhat common) to have a non-null aGivenProto which is the
     315             :   // same as canonicalProto.
     316           0 :   if (proto != canonicalProto) {
     317           0 :     PreserveWrapper(aObject);
     318             :   }
     319             : 
     320           0 :   return true;
     321             : }
     322             : 
     323             : const NativePropertyHooks sNativePropertyHooks[] = { {
     324             :   nullptr,
     325             :   nullptr,
     326             :   nullptr,
     327             :   { sNativeProperties.Upcast(), nullptr },
     328             :   prototypes::id::FileSystemFileEntry,
     329             :   constructors::id::FileSystemFileEntry,
     330             :   FileSystemEntryBinding::sNativePropertyHooks,
     331             :   &DefaultXrayExpandoObjectClass
     332             : } };
     333             : 
     334             : void
     335           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     336             : {
     337           0 :   JS::Handle<JSObject*> parentProto(FileSystemEntryBinding::GetProtoObjectHandle(aCx));
     338           0 :   if (!parentProto) {
     339           0 :     return;
     340             :   }
     341             : 
     342           0 :   JS::Handle<JSObject*> constructorProto(FileSystemEntryBinding::GetConstructorObjectHandle(aCx));
     343           0 :   if (!constructorProto) {
     344           0 :     return;
     345             :   }
     346             : 
     347             :   static bool sIdsInited = false;
     348           0 :   if (!sIdsInited && NS_IsMainThread()) {
     349           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     350           0 :       return;
     351             :     }
     352           0 :     sIdsInited = true;
     353             :   }
     354             : 
     355           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::FileSystemFileEntry);
     356           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::FileSystemFileEntry);
     357           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     358             :                               &sPrototypeClass.mBase, protoCache,
     359             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     360             :                               interfaceCache,
     361             :                               sNativeProperties.Upcast(),
     362             :                               nullptr,
     363             :                               "FileSystemFileEntry", aDefineOnGlobal,
     364             :                               nullptr,
     365           0 :                               false);
     366             : }
     367             : 
     368             : JS::Handle<JSObject*>
     369           0 : GetProtoObjectHandle(JSContext* aCx)
     370             : {
     371             :   /* Get the interface prototype object for this class.  This will create the
     372             :      object as needed. */
     373           0 :   bool aDefineOnGlobal = true;
     374             : 
     375             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     376           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     377           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     378           0 :     return nullptr;
     379             :   }
     380             : 
     381             :   /* Check to see whether the interface objects are already installed */
     382           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     383           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::FileSystemFileEntry)) {
     384           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     385           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     386             :   }
     387             : 
     388             :   /*
     389             :    * The object might _still_ be null, but that's OK.
     390             :    *
     391             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     392             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     393             :    * changed after they have been set.
     394             :    *
     395             :    * Calling address() avoids the read read barrier that does gray
     396             :    * unmarking, but it's not possible for the object to be gray here.
     397             :    */
     398             : 
     399           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::FileSystemFileEntry);
     400           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     401           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     402             : }
     403             : 
     404             : JS::Handle<JSObject*>
     405           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     406             : {
     407             :   /* Get the interface object for this class.  This will create the object as
     408             :      needed. */
     409             : 
     410             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     411           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     412           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     413           0 :     return nullptr;
     414             :   }
     415             : 
     416             :   /* Check to see whether the interface objects are already installed */
     417           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     418           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::FileSystemFileEntry)) {
     419           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     420           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     421             :   }
     422             : 
     423             :   /*
     424             :    * The object might _still_ be null, but that's OK.
     425             :    *
     426             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     427             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     428             :    * changed after they have been set.
     429             :    *
     430             :    * Calling address() avoids the read read barrier that does gray
     431             :    * unmarking, but it's not possible for the object to be gray here.
     432             :    */
     433             : 
     434           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::FileSystemFileEntry);
     435           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     436           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     437             : }
     438             : 
     439             : JSObject*
     440           0 : GetConstructorObject(JSContext* aCx)
     441             : {
     442           0 :   return GetConstructorObjectHandle(aCx);
     443             : }
     444             : 
     445             : } // namespace FileSystemFileEntryBinding
     446             : 
     447             : 
     448             : 
     449             : void
     450           0 : FileCallback::HandleEvent(JSContext* cx, JS::Handle<JS::Value> aThisVal, File& file, ErrorResult& aRv)
     451             : {
     452           0 :   JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
     453           0 :   JS::AutoValueVector argv(cx);
     454           0 :   if (!argv.resize(1)) {
     455           0 :     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     456           0 :     return;
     457             :   }
     458           0 :   unsigned argc = 1;
     459             : 
     460             :   do {
     461           0 :     if (!GetOrCreateDOMReflector(cx, file, argv[0])) {
     462           0 :       MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     463           0 :       aRv.Throw(NS_ERROR_UNEXPECTED);
     464           0 :       return;
     465             :     }
     466           0 :     break;
     467             :   } while (0);
     468             : 
     469           0 :   bool isCallable = JS::IsCallable(mCallback);
     470           0 :   JS::Rooted<JS::Value> callable(cx);
     471           0 :   if (isCallable) {
     472           0 :     callable = JS::ObjectValue(*mCallback);
     473             :   } else {
     474           0 :     FileCallbackAtoms* atomsCache = GetAtomCache<FileCallbackAtoms>(cx);
     475           0 :     if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) ||
     476           0 :         !GetCallableProperty(cx, atomsCache->handleEvent_id, &callable)) {
     477           0 :       aRv.Throw(NS_ERROR_UNEXPECTED);
     478           0 :       return;
     479             :     }
     480             :   }
     481           0 :   JS::Rooted<JS::Value> thisValue(cx, isCallable ? aThisVal.get()
     482           0 :                                                  : JS::ObjectValue(*mCallback));
     483           0 :   if (!JS::Call(cx, thisValue, callable,
     484           0 :                 JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
     485           0 :     aRv.NoteJSContextException(cx);
     486           0 :     return;
     487             :   }
     488             : }
     489             : 
     490             : bool
     491           0 : FileCallback::InitIds(JSContext* cx, FileCallbackAtoms* atomsCache)
     492             : {
     493           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
     494             : 
     495             :   // Initialize these in reverse order so that any failure leaves the first one
     496             :   // uninitialized.
     497           0 :   if (!atomsCache->handleEvent_id.init(cx, "handleEvent")) {
     498           0 :     return false;
     499             :   }
     500           0 :   return true;
     501             : }
     502             : 
     503             : 
     504             : 
     505             : namespace binding_detail {
     506             : } // namespace binding_detail
     507             : 
     508             : 
     509             : } // namespace dom
     510             : } // namespace mozilla

Generated by: LCOV version 1.13