tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

FileSystemDirectoryIterator.cpp (1781B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "FileSystemDirectoryIterator.h"
      8 
      9 #include "mozilla/ErrorResult.h"
     10 #include "mozilla/dom/FileSystemDirectoryIteratorBinding.h"
     11 #include "mozilla/dom/FileSystemManager.h"
     12 #include "mozilla/dom/Promise.h"
     13 
     14 namespace mozilla::dom {
     15 
     16 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FileSystemDirectoryIterator)
     17  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
     18  NS_INTERFACE_MAP_ENTRY(nsISupports)
     19 NS_INTERFACE_MAP_END
     20 NS_IMPL_CYCLE_COLLECTING_ADDREF(FileSystemDirectoryIterator);
     21 NS_IMPL_CYCLE_COLLECTING_RELEASE(FileSystemDirectoryIterator);
     22 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(FileSystemDirectoryIterator, mGlobal);
     23 
     24 FileSystemDirectoryIterator::FileSystemDirectoryIterator(
     25    nsIGlobalObject* aGlobal, RefPtr<FileSystemManager>& aManager,
     26    RefPtr<Impl>& aImpl)
     27    : mGlobal(aGlobal), mManager(aManager), mImpl(aImpl) {}
     28 
     29 // WebIDL Boilerplate
     30 
     31 nsIGlobalObject* FileSystemDirectoryIterator::GetParentObject() const {
     32  return mGlobal;
     33 }
     34 
     35 JSObject* FileSystemDirectoryIterator::WrapObject(
     36    JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
     37  return FileSystemDirectoryIterator_Binding::Wrap(aCx, this, aGivenProto);
     38 }
     39 
     40 // WebIDL Interface
     41 
     42 already_AddRefed<Promise> FileSystemDirectoryIterator::Next(
     43    ErrorResult& aError) {
     44  RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
     45  if (aError.Failed()) {
     46    return nullptr;
     47  }
     48 
     49  MOZ_ASSERT(mImpl);
     50  return mImpl->Next(mGlobal, mManager, aError);
     51 }
     52 
     53 }  // namespace mozilla::dom