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"
13 #define BLOBIMPL_IID \
15 0xbccb3275, 0x6778, 0x4ac5, { \
16 0xaf, 0x03, 0x90, 0xed, 0x37, 0xad, 0xdf, 0x5d \
27 class SystemCallerGuarantee
;
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
{
35 NS_DECLARE_STATIC_IID_ACCESSOR(BLOBIMPL_IID
)
36 NS_DECL_THREADSAFE_ISUPPORTS
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;
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
,
78 virtual already_AddRefed
<BlobImpl
> CreateSlice(uint64_t aStart
,
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; }
106 virtual ~BlobImpl() = default;
109 NS_DEFINE_STATIC_IID_ACCESSOR(BlobImpl
, BLOBIMPL_IID
)
112 } // namespace mozilla
114 #endif // mozilla_dom_BlobImpl_h