зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1403706 - Remove race conditions in temporary blob - part 7 - Remove TemporaryBlobImpl, r=smaug
This commit is contained in:
Родитель
943e663601
Коммит
6fb25be865
|
@ -11,7 +11,6 @@
|
|||
#include "MultipartBlobImpl.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "TemporaryBlobImpl.h"
|
||||
#include "StreamBlobImpl.h"
|
||||
#include "StringBlobImpl.h"
|
||||
|
||||
|
@ -94,17 +93,6 @@ Blob::CreateMemoryBlob(nsISupports* aParent, void* aMemoryBuffer,
|
|||
return blob.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<Blob>
|
||||
Blob::CreateTemporaryBlob(nsISupports* aParent, PRFileDesc* aFD,
|
||||
uint64_t aStartPos, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
{
|
||||
RefPtr<Blob> blob = Blob::Create(aParent,
|
||||
new TemporaryBlobImpl(aFD, aStartPos, aLength, aContentType));
|
||||
MOZ_ASSERT(!blob->mImpl->IsFile());
|
||||
return blob.forget();
|
||||
}
|
||||
|
||||
Blob::Blob(nsISupports* aParent, BlobImpl* aImpl)
|
||||
: mImpl(aImpl)
|
||||
, mParent(aParent)
|
||||
|
|
|
@ -59,11 +59,6 @@ public:
|
|||
CreateMemoryBlob(nsISupports* aParent, void* aMemoryBuffer, uint64_t aLength,
|
||||
const nsAString& aContentType);
|
||||
|
||||
static already_AddRefed<Blob>
|
||||
CreateTemporaryBlob(nsISupports* aParent, PRFileDesc* aFD,
|
||||
uint64_t aStartPos, uint64_t aLength,
|
||||
const nsAString& aContentType);
|
||||
|
||||
BlobImpl* Impl() const
|
||||
{
|
||||
return mImpl;
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include "TemporaryBlobImpl.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(TemporaryBlobImpl, BlobImpl)
|
||||
|
||||
TemporaryBlobImpl::TemporaryBlobImpl(PRFileDesc* aFD, uint64_t aStartPos,
|
||||
uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
: BaseBlobImpl(aContentType, aLength)
|
||||
, mStartPos(aStartPos)
|
||||
{
|
||||
mFileDescOwner = new nsTemporaryFileInputStream::FileDescOwner(aFD);
|
||||
}
|
||||
|
||||
TemporaryBlobImpl::TemporaryBlobImpl(const TemporaryBlobImpl* aOther,
|
||||
uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
: BaseBlobImpl(aContentType, aLength)
|
||||
, mStartPos(aStart)
|
||||
, mFileDescOwner(aOther->mFileDescOwner)
|
||||
{}
|
||||
|
||||
already_AddRefed<BlobImpl>
|
||||
TemporaryBlobImpl::CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (aStart + aLength > mLength) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<BlobImpl> impl =
|
||||
new TemporaryBlobImpl(this, aStart + mStartPos,
|
||||
aLength, aContentType);
|
||||
return impl.forget();
|
||||
}
|
||||
|
||||
void
|
||||
TemporaryBlobImpl::CreateInputStream(nsIInputStream** aStream,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIInputStream> stream =
|
||||
new nsTemporaryFileInputStream(mFileDescOwner, mStartPos,
|
||||
mStartPos + mLength);
|
||||
stream.forget(aStream);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -1,45 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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_TemporaryBlobImpl_h
|
||||
#define mozilla_dom_TemporaryBlobImpl_h
|
||||
|
||||
#include "BaseBlobImpl.h"
|
||||
#include "nsTemporaryFileInputStream.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class TemporaryBlobImpl final : public BaseBlobImpl
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
TemporaryBlobImpl(PRFileDesc* aFD, uint64_t aStartPos,
|
||||
uint64_t aLength, const nsAString& aContentType);
|
||||
|
||||
virtual void CreateInputStream(nsIInputStream** aStream,
|
||||
ErrorResult& aRv) override;
|
||||
|
||||
virtual already_AddRefed<BlobImpl>
|
||||
CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType, ErrorResult& aRv) override;
|
||||
|
||||
private:
|
||||
TemporaryBlobImpl(const TemporaryBlobImpl* aOther,
|
||||
uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType);
|
||||
|
||||
~TemporaryBlobImpl() = default;
|
||||
|
||||
uint64_t mStartPos;
|
||||
RefPtr<nsTemporaryFileInputStream::FileDescOwner> mFileDescOwner;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_TemporaryBlobImpl_h
|
|
@ -33,7 +33,6 @@
|
|||
* - a memory buffer: MemoryBlobImpl
|
||||
* - a string: StringBlobImpl
|
||||
* - a real OS file: FileBlobImpl
|
||||
* - a temporary OS file: TemporaryBlobImpl
|
||||
* - a generic nsIInputStream: StreamBlobImpl
|
||||
* - an empty blob: EmptyBlobImpl
|
||||
* - more blobs combined together: MultipartBlobImpl
|
||||
|
|
|
@ -57,7 +57,6 @@ UNIFIED_SOURCES += [
|
|||
'nsHostObjectURI.cpp',
|
||||
'StreamBlobImpl.cpp',
|
||||
'StringBlobImpl.cpp',
|
||||
'TemporaryBlobImpl.cpp',
|
||||
'TemporaryFileBlobImpl.cpp',
|
||||
]
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче