2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-10-08 16:15:23 +00:00
|
|
|
/* 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 mozilla_dom_BlobSet_h
|
|
|
|
#define mozilla_dom_BlobSet_h
|
|
|
|
|
2016-06-23 09:58:22 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
2014-10-08 16:15:23 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2016-06-23 09:58:22 +00:00
|
|
|
class BlobImpl;
|
|
|
|
|
|
|
|
class BlobSet final
|
|
|
|
{
|
2014-10-08 16:15:23 +00:00
|
|
|
public:
|
|
|
|
BlobSet()
|
2016-06-23 09:58:22 +00:00
|
|
|
: mData(nullptr)
|
|
|
|
, mDataLen(0)
|
|
|
|
, mDataBufferLen(0)
|
2014-10-08 16:15:23 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
~BlobSet()
|
|
|
|
{
|
2015-02-19 04:51:06 +00:00
|
|
|
free(mData);
|
2014-10-08 16:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult AppendVoidPtr(const void* aData, uint32_t aLength);
|
2016-06-23 09:58:22 +00:00
|
|
|
|
|
|
|
nsresult AppendString(const nsAString& aString, bool nativeEOL,
|
|
|
|
JSContext* aCx);
|
|
|
|
|
2015-05-12 12:11:03 +00:00
|
|
|
nsresult AppendBlobImpl(BlobImpl* aBlobImpl);
|
2016-06-23 09:58:22 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
nsresult AppendBlobImpls(const nsTArray<RefPtr<BlobImpl>>& aBlobImpls);
|
2014-10-08 16:15:23 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
nsTArray<RefPtr<BlobImpl>>& GetBlobImpls() { Flush(); return mBlobImpls; }
|
2014-10-08 16:15:23 +00:00
|
|
|
|
2015-05-12 12:09:51 +00:00
|
|
|
already_AddRefed<Blob> GetBlobInternal(nsISupports* aParent,
|
2015-12-04 21:15:46 +00:00
|
|
|
const nsACString& aContentType,
|
|
|
|
ErrorResult& aRv);
|
2014-10-08 16:15:23 +00:00
|
|
|
|
2016-06-23 09:58:22 +00:00
|
|
|
private:
|
|
|
|
bool ExpandBufferSize(uint64_t aSize);
|
2014-10-08 16:15:23 +00:00
|
|
|
|
2016-06-23 09:58:22 +00:00
|
|
|
void Flush();
|
2014-10-08 16:15:23 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
nsTArray<RefPtr<BlobImpl>> mBlobImpls;
|
2014-10-08 16:15:23 +00:00
|
|
|
void* mData;
|
|
|
|
uint64_t mDataLen;
|
|
|
|
uint64_t mDataBufferLen;
|
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2014-10-08 16:15:23 +00:00
|
|
|
|
|
|
|
#endif // mozilla_dom_BlobSet_h
|