Bug 1263556 - Remove EmptyBlobImpl in dom/ipc/Blob.cpp, r=smaug

This commit is contained in:
Andrea Marchesini 2016-04-11 14:31:53 -04:00
Родитель 7281a6ab42
Коммит 911722de11
3 изменённых файлов: 21 добавлений и 53 удалений

Просмотреть файл

@ -1018,6 +1018,11 @@ EmptyBlobImpl::CreateSlice(uint64_t aStart, uint64_t aLength,
{
MOZ_ASSERT(!aStart && !aLength);
RefPtr<BlobImpl> impl = new EmptyBlobImpl(aContentType);
DebugOnly<bool> isMutable;
MOZ_ASSERT(NS_SUCCEEDED(impl->GetMutable(&isMutable)));
MOZ_ASSERT(!isMutable);
return impl.forget();
}
@ -1025,6 +1030,11 @@ void
EmptyBlobImpl::GetInternalStream(nsIInputStream** aStream,
ErrorResult& aRv)
{
if (NS_WARN_IF(!aStream)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
nsresult rv = NS_NewCStringInputStream(aStream, EmptyCString());
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(rv);

Просмотреть файл

@ -754,7 +754,17 @@ public:
explicit EmptyBlobImpl(const nsAString& aContentType)
: BlobImplBase(aContentType, 0 /* aLength */)
{}
{
mImmutable = true;
}
EmptyBlobImpl(const nsAString& aName,
const nsAString& aContentType,
int64_t aLastModifiedDate)
: BlobImplBase(aName, aContentType, 0, aLastModifiedDate)
{
mImmutable = true;
}
virtual void GetInternalStream(nsIInputStream** aStream,
ErrorResult& aRv) override;

Просмотреть файл

@ -657,58 +657,6 @@ private:
}
};
class EmptyBlobImpl final
: public BlobImplBase
{
public:
explicit EmptyBlobImpl(const nsAString& aContentType)
: BlobImplBase(aContentType, 0)
{
mImmutable = true;
}
EmptyBlobImpl(const nsAString& aName,
const nsAString& aContentType,
int64_t aLastModifiedDate)
: BlobImplBase(aName, aContentType, 0, aLastModifiedDate)
{
mImmutable = true;
}
private:
virtual already_AddRefed<BlobImpl>
CreateSlice(uint64_t /* aStart */,
uint64_t aLength,
const nsAString& aContentType,
ErrorResult& /* aRv */) override
{
MOZ_ASSERT(!aLength);
RefPtr<BlobImpl> sliceImpl = new EmptyBlobImpl(aContentType);
DebugOnly<bool> isMutable;
MOZ_ASSERT(NS_SUCCEEDED(sliceImpl->GetMutable(&isMutable)));
MOZ_ASSERT(!isMutable);
return sliceImpl.forget();
}
virtual void
GetInternalStream(nsIInputStream** aStream, ErrorResult& aRv) override
{
if (NS_WARN_IF(!aStream)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
nsString emptyString;
aRv = NS_NewStringInputStream(aStream, emptyString);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
}
};
struct MOZ_STACK_CLASS CreateBlobImplMetadata final
{
nsString mContentType;