Bug 1883853 [wpt PR 44937] - [wdspec] fix test_set_permission_origin_unknown, a=testonly
[gecko.git] / dom / file / BlobImpl.h
blob720c398cdd082520034c6ba84002dc601b704c02
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_BlobImpl_h
8 #define mozilla_dom_BlobImpl_h
10 #include "nsISupports.h"
11 #include "nsString.h"
13 #define BLOBIMPL_IID \
14 { \
15 0xbccb3275, 0x6778, 0x4ac5, { \
16 0xaf, 0x03, 0x90, 0xed, 0x37, 0xad, 0xdf, 0x5d \
17 } \
20 class nsIInputStream;
22 namespace mozilla {
23 class ErrorResult;
25 namespace dom {
27 class SystemCallerGuarantee;
28 template <typename T>
29 class Optional;
31 // This is the abstract class for any File backend. It must be nsISupports
32 // because this class must be ref-counted and it has to work with IPC.
33 class BlobImpl : public nsISupports {
34 public:
35 NS_DECLARE_STATIC_IID_ACCESSOR(BLOBIMPL_IID)
36 NS_DECL_THREADSAFE_ISUPPORTS
38 BlobImpl() = default;
40 virtual void GetName(nsAString& aName) const = 0;
42 virtual void GetDOMPath(nsAString& aName) const = 0;
44 virtual void SetDOMPath(const nsAString& aName) = 0;
46 virtual int64_t GetLastModified(ErrorResult& aRv) = 0;
48 virtual void GetMozFullPath(nsAString& aName,
49 SystemCallerGuarantee /* unused */,
50 ErrorResult& aRv) = 0;
52 virtual void GetMozFullPathInternal(nsAString& aFileName,
53 ErrorResult& aRv) = 0;
55 virtual uint64_t GetSize(ErrorResult& aRv) = 0;
57 virtual void GetType(nsAString& aType) = 0;
59 virtual void GetBlobImplType(nsAString& aBlobImplType) const = 0;
61 virtual size_t GetAllocationSize() const = 0;
62 virtual size_t GetAllocationSize(
63 FallibleTArray<BlobImpl*>& aVisitedBlobImpls) const = 0;
65 /**
66 * An effectively-unique serial number identifying this instance of FileImpl.
68 * Implementations should obtain a serial number from
69 * FileImplBase::NextSerialNumber().
71 virtual uint64_t GetSerialNumber() const = 0;
73 already_AddRefed<BlobImpl> Slice(const Optional<int64_t>& aStart,
74 const Optional<int64_t>& aEnd,
75 const nsAString& aContentType,
76 ErrorResult& aRv);
78 virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart,
79 uint64_t aLength,
80 const nsAString& aContentType,
81 ErrorResult& aRv) const = 0;
83 virtual const nsTArray<RefPtr<BlobImpl>>* GetSubBlobImpls() const = 0;
85 virtual void CreateInputStream(nsIInputStream** aStream,
86 ErrorResult& aRv) const = 0;
88 virtual int64_t GetFileId() const = 0;
90 nsresult GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
91 nsACString& aContentType, nsACString& aCharset);
93 virtual void SetLazyData(const nsAString& aName,
94 const nsAString& aContentType, uint64_t aLength,
95 int64_t aLastModifiedDate) = 0;
97 virtual bool IsMemoryFile() const = 0;
99 virtual bool IsFile() const = 0;
101 // Returns true if the BlobImpl is backed by an nsIFile and the underlying
102 // file is a directory.
103 virtual bool IsDirectory() const { return false; }
105 protected:
106 virtual ~BlobImpl() = default;
109 NS_DEFINE_STATIC_IID_ACCESSOR(BlobImpl, BLOBIMPL_IID)
111 } // namespace dom
112 } // namespace mozilla
114 #endif // mozilla_dom_BlobImpl_h