2015-05-03 22:32:37 +03: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-07 21:16:11 +04: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/. */
|
|
|
|
|
2015-05-12 15:11:03 +03:00
|
|
|
#ifndef mozilla_dom_MultipartBlobImpl_h
|
|
|
|
#define mozilla_dom_MultipartBlobImpl_h
|
2014-10-07 21:16:11 +04:00
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
2014-10-08 20:15:22 +04:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2016-09-21 04:29:28 +03:00
|
|
|
#include "mozilla/Move.h"
|
2017-02-16 20:26:38 +03:00
|
|
|
#include "mozilla/dom/BaseBlobImpl.h"
|
2014-10-07 21:16:11 +04:00
|
|
|
|
2016-04-11 21:31:34 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2014-10-07 21:16:11 +04:00
|
|
|
|
2017-02-16 20:26:38 +03:00
|
|
|
class MultipartBlobImpl final : public BaseBlobImpl
|
2014-10-07 21:16:11 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
// Create as a file
|
2015-12-05 00:15:46 +03:00
|
|
|
static already_AddRefed<MultipartBlobImpl>
|
2016-09-21 04:29:28 +03:00
|
|
|
Create(nsTArray<RefPtr<BlobImpl>>&& aBlobImpls,
|
2015-12-05 00:15:46 +03:00
|
|
|
const nsAString& aName,
|
|
|
|
const nsAString& aContentType,
|
|
|
|
ErrorResult& aRv);
|
2014-10-07 21:16:11 +04:00
|
|
|
|
|
|
|
// Create as a blob
|
2015-12-05 00:15:46 +03:00
|
|
|
static already_AddRefed<MultipartBlobImpl>
|
2016-09-21 04:29:28 +03:00
|
|
|
Create(nsTArray<RefPtr<BlobImpl>>&& aBlobImpls,
|
2015-12-05 00:15:46 +03:00
|
|
|
const nsAString& aContentType,
|
|
|
|
ErrorResult& aRv);
|
2014-10-07 21:16:11 +04:00
|
|
|
|
|
|
|
// Create as a file to be later initialized
|
2015-05-12 15:11:03 +03:00
|
|
|
explicit MultipartBlobImpl(const nsAString& aName)
|
2017-02-16 20:26:38 +03:00
|
|
|
: BaseBlobImpl(aName, EmptyString(), UINT64_MAX),
|
2014-10-08 20:15:22 +04:00
|
|
|
mIsFromNsIFile(false)
|
2014-10-07 21:16:11 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create as a blob to be later initialized
|
2015-05-12 15:11:03 +03:00
|
|
|
MultipartBlobImpl()
|
2017-02-16 20:26:38 +03:00
|
|
|
: BaseBlobImpl(EmptyString(), UINT64_MAX),
|
2014-10-08 20:15:22 +04:00
|
|
|
mIsFromNsIFile(false)
|
2014-10-07 21:16:11 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-12-05 00:15:46 +03:00
|
|
|
void InitializeBlob(ErrorResult& aRv);
|
2014-10-07 21:16:11 +04:00
|
|
|
|
2017-04-25 23:30:23 +03:00
|
|
|
void InitializeBlob(const Sequence<Blob::BlobPart>& aData,
|
2016-06-01 13:33:09 +03:00
|
|
|
const nsAString& aContentType,
|
|
|
|
bool aNativeEOL,
|
|
|
|
ErrorResult& aRv);
|
2014-10-07 21:16:11 +04:00
|
|
|
|
2017-02-08 12:19:01 +03:00
|
|
|
nsresult InitializeChromeFile(nsIFile* aData,
|
|
|
|
const nsAString& aType,
|
|
|
|
const nsAString& aName,
|
|
|
|
bool aLastModifiedPassed,
|
|
|
|
int64_t aLastModified,
|
|
|
|
bool aIsFromNsIFile);
|
2014-10-07 21:16:11 +04:00
|
|
|
|
2015-05-12 15:11:03 +03:00
|
|
|
virtual already_AddRefed<BlobImpl>
|
2014-10-08 20:15:22 +04:00
|
|
|
CreateSlice(uint64_t aStart, uint64_t aLength,
|
|
|
|
const nsAString& aContentType,
|
2015-03-21 19:28:04 +03:00
|
|
|
ErrorResult& aRv) override;
|
2014-10-07 21:16:11 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual uint64_t GetSize(ErrorResult& aRv) override
|
2014-10-07 21:16:11 +04:00
|
|
|
{
|
2014-10-08 20:15:22 +04:00
|
|
|
return mLength;
|
2014-10-07 21:16:11 +04:00
|
|
|
}
|
|
|
|
|
2015-05-19 17:36:37 +03:00
|
|
|
virtual void GetInternalStream(nsIInputStream** aInputStream,
|
|
|
|
ErrorResult& aRv) override;
|
2014-10-08 20:15:22 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
virtual const nsTArray<RefPtr<BlobImpl>>* GetSubBlobImpls() const override
|
2014-10-07 21:16:11 +04:00
|
|
|
{
|
2015-07-29 01:59:56 +03:00
|
|
|
return mBlobImpls.Length() ? &mBlobImpls : nullptr;
|
2014-10-07 21:16:11 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 20:15:22 +04:00
|
|
|
virtual void GetMozFullPathInternal(nsAString& aFullPath,
|
2015-06-03 03:11:16 +03:00
|
|
|
ErrorResult& aRv) const override;
|
2014-10-08 20:15:22 +04:00
|
|
|
|
2015-01-14 01:15:04 +03:00
|
|
|
virtual nsresult
|
2015-03-21 19:28:04 +03:00
|
|
|
SetMutable(bool aMutable) override;
|
2015-01-14 01:15:04 +03:00
|
|
|
|
2014-10-08 20:15:22 +04:00
|
|
|
void SetName(const nsAString& aName)
|
|
|
|
{
|
|
|
|
mName = aName;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool MayBeClonedToOtherThreads() const override;
|
2015-01-12 00:35:24 +03:00
|
|
|
|
2014-10-07 21:16:11 +04:00
|
|
|
protected:
|
2016-09-21 04:29:28 +03:00
|
|
|
MultipartBlobImpl(nsTArray<RefPtr<BlobImpl>>&& aBlobImpls,
|
2015-12-05 00:15:46 +03:00
|
|
|
const nsAString& aName,
|
|
|
|
const nsAString& aContentType)
|
2017-02-16 20:26:38 +03:00
|
|
|
: BaseBlobImpl(aName, aContentType, UINT64_MAX),
|
2016-09-21 04:29:28 +03:00
|
|
|
mBlobImpls(Move(aBlobImpls)),
|
2015-12-05 00:15:46 +03:00
|
|
|
mIsFromNsIFile(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-09-21 04:29:28 +03:00
|
|
|
MultipartBlobImpl(nsTArray<RefPtr<BlobImpl>>&& aBlobImpls,
|
2015-12-05 00:15:46 +03:00
|
|
|
const nsAString& aContentType)
|
2017-02-16 20:26:38 +03:00
|
|
|
: BaseBlobImpl(aContentType, UINT64_MAX),
|
2016-09-21 04:29:28 +03:00
|
|
|
mBlobImpls(Move(aBlobImpls)),
|
2015-12-05 00:15:46 +03:00
|
|
|
mIsFromNsIFile(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-05-12 15:11:03 +03:00
|
|
|
virtual ~MultipartBlobImpl() {}
|
2014-10-07 21:16:11 +04:00
|
|
|
|
2015-12-05 00:15:46 +03:00
|
|
|
void SetLengthAndModifiedDate(ErrorResult& aRv);
|
2014-10-07 21:16:11 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<BlobImpl>> mBlobImpls;
|
2014-10-08 20:15:22 +04:00
|
|
|
bool mIsFromNsIFile;
|
2014-10-07 21:16:11 +04:00
|
|
|
};
|
|
|
|
|
2016-04-11 21:31:34 +03:00
|
|
|
} // dom namespace
|
|
|
|
} // mozilla namespace
|
|
|
|
|
2015-05-12 15:11:03 +03:00
|
|
|
#endif // mozilla_dom_MultipartBlobImpl_h
|