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_StringBlobImpl_h
8 #define mozilla_dom_StringBlobImpl_h
10 #include "BaseBlobImpl.h"
11 #include "nsIMemoryReporter.h"
13 namespace mozilla::dom
{
15 class StringBlobImpl final
: public BaseBlobImpl
, public nsIMemoryReporter
{
16 MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf
)
19 NS_DECL_ISUPPORTS_INHERITED
20 NS_DECL_NSIMEMORYREPORTER
22 static already_AddRefed
<StringBlobImpl
> Create(const nsACString
& aData
,
23 const nsAString
& aContentType
);
25 void CreateInputStream(nsIInputStream
** aStream
,
26 ErrorResult
& aRv
) const override
;
28 already_AddRefed
<BlobImpl
> CreateSlice(uint64_t aStart
, uint64_t aLength
,
29 const nsAString
& aContentType
,
30 ErrorResult
& aRv
) const override
;
32 size_t GetAllocationSize() const override
{ return mData
.Length(); }
34 size_t GetAllocationSize(
35 FallibleTArray
<BlobImpl
*>& aVisitedBlobImpls
) const override
{
36 return GetAllocationSize();
39 void GetBlobImplType(nsAString
& aBlobImplType
) const override
{
40 aBlobImplType
= u
"StringBlobImpl"_ns
;
44 StringBlobImpl(const nsACString
& aData
, const nsAString
& aContentType
);
46 ~StringBlobImpl() override
;
51 } // namespace mozilla::dom
53 #endif // mozilla_dom_StringBlobImpl_h