1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DOM_FS_FILESYSTEMHANDLE_H_
#define DOM_FS_FILESYSTEMHANDLE_H_
#include "mozilla/dom/PFileSystemManager.h"
#include "nsCOMPtr.h"
#include "nsISupports.h"
#include "nsWrapperCache.h"
class nsIGlobalObject;
namespace mozilla {
class ErrorResult;
namespace dom {
class FileSystemDirectoryHandle;
class FileSystemFileHandle;
enum class FileSystemHandleKind : uint8_t;
class FileSystemManager;
class FileSystemManagerChild;
class Promise;
namespace fs {
class FileSystemRequestHandler;
} // namespace fs
class FileSystemHandle : public nsISupports, public nsWrapperCache {
public:
FileSystemHandle(nsIGlobalObject* aGlobal,
RefPtr<FileSystemManager>& aManager,
const fs::FileSystemEntryMetadata& aMetadata,
fs::FileSystemRequestHandler* aRequestHandler);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(FileSystemHandle)
const fs::EntryId& GetId() const { return mMetadata.entryId(); }
// WebIDL Boilerplate
nsIGlobalObject* GetParentObject() const;
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
// WebIDL Interface
virtual FileSystemHandleKind Kind() const = 0;
void GetName(nsAString& aResult);
already_AddRefed<Promise> IsSameEntry(FileSystemHandle& aOther,
ErrorResult& aError) const;
// [Serializable] implementation
static already_AddRefed<FileSystemHandle> ReadStructuredClone(
JSContext* aCx, nsIGlobalObject* aGlobal,
JSStructuredCloneReader* aReader);
virtual bool WriteStructuredClone(JSContext* aCx,
JSStructuredCloneWriter* aWriter) const;
already_AddRefed<Promise> Move(const nsAString& aName, ErrorResult& aError);
already_AddRefed<Promise> Move(FileSystemDirectoryHandle& aParent,
ErrorResult& aError);
already_AddRefed<Promise> Move(FileSystemDirectoryHandle& aParent,
const nsAString& aName, ErrorResult& aError);
already_AddRefed<Promise> Move(const fs::EntryId& aParentId,
const nsAString& aName, ErrorResult& aError);
void UpdateMetadata(const fs::FileSystemEntryMetadata& aMetadata) {
mMetadata = aMetadata;
}
protected:
virtual ~FileSystemHandle() = default;
static already_AddRefed<FileSystemFileHandle> ConstructFileHandle(
JSContext* aCx, nsIGlobalObject* aGlobal,
JSStructuredCloneReader* aReader);
static already_AddRefed<FileSystemDirectoryHandle> ConstructDirectoryHandle(
JSContext* aCx, nsIGlobalObject* aGlobal,
JSStructuredCloneReader* aReader);
nsCOMPtr<nsIGlobalObject> mGlobal;
RefPtr<FileSystemManager> mManager;
// move() can change names/directories
fs::FileSystemEntryMetadata mMetadata;
const UniquePtr<fs::FileSystemRequestHandler> mRequestHandler;
};
} // namespace dom
} // namespace mozilla
#endif // DOM_FS_FILESYSTEMHANDLE_H_
|