Backed out changeset 51d87c2129d2 (bug 1865372) for causing RunWatchdog crashes in...
[gecko.git] / dom / file / FileList.h
blobf36b25ba079052f2bca8e3be195ce156234a01fa
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/. */
7 #ifndef mozilla_dom_FileList_h
8 #define mozilla_dom_FileList_h
10 #include <cstdint>
11 #include "js/TypeDecls.h"
12 #include "mozilla/Assertions.h"
13 #include "nsCOMPtr.h"
14 #include "nsCycleCollectionParticipant.h"
15 #include "nsISupports.h"
16 #include "nsTArray.h"
17 #include "nsWrapperCache.h"
19 class nsCycleCollectionTraversalCallback;
20 template <class T>
21 class RefPtr;
23 namespace mozilla {
24 class ErrorResult;
25 namespace dom {
27 class BlobImpls;
28 class File;
29 template <typename T>
30 class Sequence;
32 class FileList final : public nsISupports, public nsWrapperCache {
33 public:
34 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
35 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(FileList)
37 explicit FileList(nsISupports* aParent);
39 JSObject* WrapObject(JSContext* aCx,
40 JS::Handle<JSObject*> aGivenProto) override;
42 nsISupports* GetParentObject() { return mParent; }
44 bool Append(File* aFile);
46 bool Remove(uint32_t aIndex);
48 void Clear();
50 File* Item(uint32_t aIndex) const;
52 File* IndexedGetter(uint32_t aIndex, bool& aFound) const;
54 uint32_t Length() const { return mFiles.Length(); }
56 void ToSequence(Sequence<RefPtr<File>>& aSequence, ErrorResult& aRv) const;
58 private:
59 ~FileList();
61 FallibleTArray<RefPtr<File>> mFiles;
62 nsCOMPtr<nsISupports> mParent;
65 } // namespace dom
66 } // namespace mozilla
68 #endif // mozilla_dom_FileList_h