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_StreamBlobImpl_h
8 #define mozilla_dom_StreamBlobImpl_h
10 #include "BaseBlobImpl.h"
11 #include "nsIMemoryReporter.h"
16 class StreamBlobImpl final
: public BaseBlobImpl
, public nsIMemoryReporter
{
17 MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf
)
20 NS_DECL_ISUPPORTS_INHERITED
21 NS_DECL_NSIMEMORYREPORTER
24 static already_AddRefed
<StreamBlobImpl
> Create(
25 already_AddRefed
<nsIInputStream
> aInputStream
,
26 const nsAString
& aContentType
, uint64_t aLength
,
27 const nsAString
& aBlobImplType
);
30 static already_AddRefed
<StreamBlobImpl
> Create(
31 already_AddRefed
<nsIInputStream
> aInputStream
, const nsAString
& aName
,
32 const nsAString
& aContentType
, int64_t aLastModifiedDate
,
33 uint64_t aLength
, const nsAString
& aBlobImplType
);
35 void CreateInputStream(nsIInputStream
** aStream
, ErrorResult
& aRv
) override
;
37 already_AddRefed
<BlobImpl
> CreateSlice(uint64_t aStart
, uint64_t aLength
,
38 const nsAString
& aContentType
,
39 ErrorResult
& aRv
) override
;
41 bool IsMemoryFile() const override
{ return true; }
43 int64_t GetFileId() override
{ return mFileId
; }
45 void SetFileId(int64_t aFileId
) { mFileId
= aFileId
; }
47 void SetFullPath(const nsAString
& aFullPath
) { mFullPath
= aFullPath
; }
49 void GetMozFullPathInternal(nsAString
& aFullPath
, ErrorResult
& aRv
) override
{
50 aFullPath
= mFullPath
;
53 void SetIsDirectory(bool aIsDirectory
) { mIsDirectory
= aIsDirectory
; }
55 bool IsDirectory() const override
{ return mIsDirectory
; }
57 size_t GetAllocationSize() const override
;
59 size_t GetAllocationSize(
60 FallibleTArray
<BlobImpl
*>& aVisitedBlobImpls
) const override
{
61 return GetAllocationSize();
64 void GetBlobImplType(nsAString
& aBlobImplType
) const override
;
68 StreamBlobImpl(already_AddRefed
<nsIInputStream
> aInputStream
,
69 const nsAString
& aContentType
, uint64_t aLength
,
70 const nsAString
& aBlobImplType
);
73 StreamBlobImpl(already_AddRefed
<nsIInputStream
> aInputStream
,
74 const nsAString
& aName
, const nsAString
& aContentType
,
75 int64_t aLastModifiedDate
, uint64_t aLength
,
76 const nsAString
& aBlobImplType
);
80 void MaybeRegisterMemoryReporter();
82 nsCOMPtr
<nsIInputStream
> mInputStream
;
84 nsString mBlobImplType
;
92 } // namespace mozilla
94 #endif // mozilla_dom_StreamBlobImpl_h