зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1619518
- part 4 - FileBlobImpl inherits BlobImpl directly, r=ssengupta,smaug
Differential Revision: https://phabricator.services.mozilla.com/D65166 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8d8aabb99b
Коммит
64ed039230
|
@ -53,40 +53,6 @@ int64_t BaseBlobImpl::GetLastModified(ErrorResult& aRv) {
|
||||||
|
|
||||||
int64_t BaseBlobImpl::GetFileId() { return -1; }
|
int64_t BaseBlobImpl::GetFileId() { return -1; }
|
||||||
|
|
||||||
nsresult BaseBlobImpl::GetSendInfo(nsIInputStream** aBody,
|
|
||||||
uint64_t* aContentLength,
|
|
||||||
nsACString& aContentType,
|
|
||||||
nsACString& aCharset) {
|
|
||||||
MOZ_ASSERT(aContentLength);
|
|
||||||
|
|
||||||
ErrorResult rv;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIInputStream> stream;
|
|
||||||
CreateInputStream(getter_AddRefs(stream), rv);
|
|
||||||
if (NS_WARN_IF(rv.Failed())) {
|
|
||||||
return rv.StealNSResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
*aContentLength = GetSize(rv);
|
|
||||||
if (NS_WARN_IF(rv.Failed())) {
|
|
||||||
return rv.StealNSResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
nsAutoString contentType;
|
|
||||||
GetType(contentType);
|
|
||||||
|
|
||||||
if (contentType.IsEmpty()) {
|
|
||||||
aContentType.SetIsVoid(true);
|
|
||||||
} else {
|
|
||||||
CopyUTF16toUTF8(contentType, aContentType);
|
|
||||||
}
|
|
||||||
|
|
||||||
aCharset.Truncate();
|
|
||||||
|
|
||||||
stream.forget(aBody);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
uint64_t BaseBlobImpl::NextSerialNumber() {
|
uint64_t BaseBlobImpl::NextSerialNumber() {
|
||||||
static Atomic<uint64_t> nextSerialNumber;
|
static Atomic<uint64_t> nextSerialNumber;
|
||||||
|
|
|
@ -12,7 +12,11 @@
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
|
class FileBlobImpl;
|
||||||
|
|
||||||
class BaseBlobImpl : public BlobImpl {
|
class BaseBlobImpl : public BlobImpl {
|
||||||
|
friend class FileBlobImpl;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// File constructor.
|
// File constructor.
|
||||||
BaseBlobImpl(const nsAString& aBlobImplType, const nsAString& aName,
|
BaseBlobImpl(const nsAString& aBlobImplType, const nsAString& aName,
|
||||||
|
@ -104,10 +108,6 @@ class BaseBlobImpl : public BlobImpl {
|
||||||
|
|
||||||
virtual int64_t GetFileId() override;
|
virtual int64_t GetFileId() override;
|
||||||
|
|
||||||
virtual nsresult GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
|
|
||||||
nsACString& aContentType,
|
|
||||||
nsACString& aCharset) override;
|
|
||||||
|
|
||||||
virtual void SetLazyData(const nsAString& aName,
|
virtual void SetLazyData(const nsAString& aName,
|
||||||
const nsAString& aContentType, uint64_t aLength,
|
const nsAString& aContentType, uint64_t aLength,
|
||||||
int64_t aLastModifiedDate) override {
|
int64_t aLastModifiedDate) override {
|
||||||
|
|
|
@ -61,6 +61,38 @@ already_AddRefed<BlobImpl> BlobImpl::Slice(const Optional<int64_t>& aStart,
|
||||||
return CreateSlice((uint64_t)start, (uint64_t)(end - start), type, aRv);
|
return CreateSlice((uint64_t)start, (uint64_t)(end - start), type, aRv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult BlobImpl::GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
|
||||||
|
nsACString& aContentType, nsACString& aCharset) {
|
||||||
|
MOZ_ASSERT(aContentLength);
|
||||||
|
|
||||||
|
ErrorResult rv;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIInputStream> stream;
|
||||||
|
CreateInputStream(getter_AddRefs(stream), rv);
|
||||||
|
if (NS_WARN_IF(rv.Failed())) {
|
||||||
|
return rv.StealNSResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
*aContentLength = GetSize(rv);
|
||||||
|
if (NS_WARN_IF(rv.Failed())) {
|
||||||
|
return rv.StealNSResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
nsAutoString contentType;
|
||||||
|
GetType(contentType);
|
||||||
|
|
||||||
|
if (contentType.IsEmpty()) {
|
||||||
|
aContentType.SetIsVoid(true);
|
||||||
|
} else {
|
||||||
|
CopyUTF16toUTF8(contentType, aContentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
aCharset.Truncate();
|
||||||
|
|
||||||
|
stream.forget(aBody);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(BlobImpl, BlobImpl)
|
NS_IMPL_ISUPPORTS(BlobImpl, BlobImpl)
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
|
|
@ -83,9 +83,8 @@ class BlobImpl : public nsISupports {
|
||||||
|
|
||||||
virtual int64_t GetFileId() = 0;
|
virtual int64_t GetFileId() = 0;
|
||||||
|
|
||||||
virtual nsresult GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
|
nsresult GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
|
||||||
nsACString& aContentType,
|
nsACString& aContentType, nsACString& aCharset);
|
||||||
nsACString& aCharset) = 0;
|
|
||||||
|
|
||||||
virtual void SetLazyData(const nsAString& aName,
|
virtual void SetLazyData(const nsAString& aName,
|
||||||
const nsAString& aContentType, uint64_t aLength,
|
const nsAString& aContentType, uint64_t aLength,
|
||||||
|
|
|
@ -19,14 +19,12 @@ namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
FileBlobImpl::FileBlobImpl(nsIFile* aFile)
|
FileBlobImpl::FileBlobImpl(nsIFile* aFile)
|
||||||
: BaseBlobImpl(NS_LITERAL_STRING("FileBlobImpl"), EmptyString(),
|
: mMutex("FileBlobImpl::mMutex"),
|
||||||
EmptyString(),
|
|
||||||
// We pass 0 as lastModified and length because FileblobImpl
|
|
||||||
// has a different way to compute those values.
|
|
||||||
0, 0),
|
|
||||||
mMutex("FileBlobImpl::mMutex"),
|
|
||||||
mFile(aFile),
|
mFile(aFile),
|
||||||
|
mSerialNumber(BaseBlobImpl::NextSerialNumber()),
|
||||||
|
mStart(0),
|
||||||
mFileId(-1),
|
mFileId(-1),
|
||||||
|
mIsFile(true),
|
||||||
mWholeFile(true) {
|
mWholeFile(true) {
|
||||||
MOZ_ASSERT(mFile, "must have file");
|
MOZ_ASSERT(mFile, "must have file");
|
||||||
MOZ_ASSERT(XRE_IsParentProcess());
|
MOZ_ASSERT(XRE_IsParentProcess());
|
||||||
|
@ -39,14 +37,15 @@ FileBlobImpl::FileBlobImpl(nsIFile* aFile)
|
||||||
FileBlobImpl::FileBlobImpl(const nsAString& aName,
|
FileBlobImpl::FileBlobImpl(const nsAString& aName,
|
||||||
const nsAString& aContentType, uint64_t aLength,
|
const nsAString& aContentType, uint64_t aLength,
|
||||||
nsIFile* aFile)
|
nsIFile* aFile)
|
||||||
: BaseBlobImpl(NS_LITERAL_STRING("FileBlobImpl"), aName, aContentType,
|
: mMutex("FileBlobImpl::mMutex"),
|
||||||
// We pass 0 as lastModified and length because FileblobImpl
|
|
||||||
// has a different way to compute those values.
|
|
||||||
0, 0),
|
|
||||||
mMutex("FileBlobImpl::mMutex"),
|
|
||||||
mFile(aFile),
|
mFile(aFile),
|
||||||
mLength(Some(aLength)),
|
mContentType(aContentType),
|
||||||
|
mName(aName),
|
||||||
|
mSerialNumber(BaseBlobImpl::NextSerialNumber()),
|
||||||
|
mStart(0),
|
||||||
mFileId(-1),
|
mFileId(-1),
|
||||||
|
mLength(Some(aLength)),
|
||||||
|
mIsFile(true),
|
||||||
mWholeFile(true) {
|
mWholeFile(true) {
|
||||||
MOZ_ASSERT(mFile, "must have file");
|
MOZ_ASSERT(mFile, "must have file");
|
||||||
MOZ_ASSERT(XRE_IsParentProcess());
|
MOZ_ASSERT(XRE_IsParentProcess());
|
||||||
|
@ -56,15 +55,16 @@ FileBlobImpl::FileBlobImpl(const nsAString& aName,
|
||||||
FileBlobImpl::FileBlobImpl(const nsAString& aName,
|
FileBlobImpl::FileBlobImpl(const nsAString& aName,
|
||||||
const nsAString& aContentType, uint64_t aLength,
|
const nsAString& aContentType, uint64_t aLength,
|
||||||
nsIFile* aFile, int64_t aLastModificationDate)
|
nsIFile* aFile, int64_t aLastModificationDate)
|
||||||
: BaseBlobImpl(NS_LITERAL_STRING("FileBlobImpl"), aName, aContentType,
|
: mMutex("FileBlobImpl::mMutex"),
|
||||||
// We pass 0 as lastModified and length because FileblobImpl
|
|
||||||
// has a different way to compute those values.
|
|
||||||
0, 0),
|
|
||||||
mMutex("FileBlobImpl::mMutex"),
|
|
||||||
mFile(aFile),
|
mFile(aFile),
|
||||||
|
mContentType(aContentType),
|
||||||
|
mName(aName),
|
||||||
|
mSerialNumber(BaseBlobImpl::NextSerialNumber()),
|
||||||
|
mStart(0),
|
||||||
|
mFileId(-1),
|
||||||
mLength(Some(aLength)),
|
mLength(Some(aLength)),
|
||||||
mLastModified(Some(aLastModificationDate)),
|
mLastModified(Some(aLastModificationDate)),
|
||||||
mFileId(-1),
|
mIsFile(true),
|
||||||
mWholeFile(true) {
|
mWholeFile(true) {
|
||||||
MOZ_ASSERT(mFile, "must have file");
|
MOZ_ASSERT(mFile, "must have file");
|
||||||
MOZ_ASSERT(XRE_IsParentProcess());
|
MOZ_ASSERT(XRE_IsParentProcess());
|
||||||
|
@ -72,15 +72,15 @@ FileBlobImpl::FileBlobImpl(const nsAString& aName,
|
||||||
}
|
}
|
||||||
|
|
||||||
FileBlobImpl::FileBlobImpl(nsIFile* aFile, const nsAString& aName,
|
FileBlobImpl::FileBlobImpl(nsIFile* aFile, const nsAString& aName,
|
||||||
const nsAString& aContentType,
|
const nsAString& aContentType)
|
||||||
const nsAString& aBlobImplType)
|
: mMutex("FileBlobImpl::mMutex"),
|
||||||
: BaseBlobImpl(aBlobImplType, aName, aContentType,
|
|
||||||
// We pass 0 as lastModified and length because FileblobImpl
|
|
||||||
// has a different way to compute those values.
|
|
||||||
0, 0),
|
|
||||||
mMutex("FileBlobImpl::mMutex"),
|
|
||||||
mFile(aFile),
|
mFile(aFile),
|
||||||
|
mContentType(aContentType),
|
||||||
|
mName(aName),
|
||||||
|
mSerialNumber(BaseBlobImpl::NextSerialNumber()),
|
||||||
|
mStart(0),
|
||||||
mFileId(-1),
|
mFileId(-1),
|
||||||
|
mIsFile(true),
|
||||||
mWholeFile(true) {
|
mWholeFile(true) {
|
||||||
MOZ_ASSERT(mFile, "must have file");
|
MOZ_ASSERT(mFile, "must have file");
|
||||||
MOZ_ASSERT(XRE_IsParentProcess());
|
MOZ_ASSERT(XRE_IsParentProcess());
|
||||||
|
@ -94,15 +94,14 @@ FileBlobImpl::FileBlobImpl(nsIFile* aFile, const nsAString& aName,
|
||||||
|
|
||||||
FileBlobImpl::FileBlobImpl(const FileBlobImpl* aOther, uint64_t aStart,
|
FileBlobImpl::FileBlobImpl(const FileBlobImpl* aOther, uint64_t aStart,
|
||||||
uint64_t aLength, const nsAString& aContentType)
|
uint64_t aLength, const nsAString& aContentType)
|
||||||
: BaseBlobImpl(NS_LITERAL_STRING("FileBlobImpl"), aContentType,
|
: mMutex("FileBlobImpl::mMutex"),
|
||||||
aOther->mStart + aStart,
|
|
||||||
// We pass 0 as length because FileblobImpl has a different
|
|
||||||
// way to compute the value.
|
|
||||||
0),
|
|
||||||
mMutex("FileBlobImpl::mMutex"),
|
|
||||||
mFile(aOther->mFile),
|
mFile(aOther->mFile),
|
||||||
mLength(Some(aLength)),
|
mContentType(aContentType),
|
||||||
|
mSerialNumber(BaseBlobImpl::NextSerialNumber()),
|
||||||
|
mStart(aOther->mStart + aStart),
|
||||||
mFileId(-1),
|
mFileId(-1),
|
||||||
|
mLength(Some(aLength)),
|
||||||
|
mIsFile(false),
|
||||||
mWholeFile(false) {
|
mWholeFile(false) {
|
||||||
MOZ_ASSERT(mFile, "must have file");
|
MOZ_ASSERT(mFile, "must have file");
|
||||||
MOZ_ASSERT(XRE_IsParentProcess());
|
MOZ_ASSERT(XRE_IsParentProcess());
|
||||||
|
@ -238,6 +237,10 @@ void FileBlobImpl::GetTypeInternal(nsAString& aType,
|
||||||
aType = mContentType;
|
aType = mContentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileBlobImpl::GetBlobImplType(nsAString& aBlobImplType) const {
|
||||||
|
aBlobImplType = NS_LITERAL_STRING("FileBlobImpl");
|
||||||
|
}
|
||||||
|
|
||||||
int64_t FileBlobImpl::GetLastModified(ErrorResult& aRv) {
|
int64_t FileBlobImpl::GetLastModified(ErrorResult& aRv) {
|
||||||
MOZ_ASSERT(mIsFile, "Should only be called on files");
|
MOZ_ASSERT(mIsFile, "Should only be called on files");
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#ifndef mozilla_dom_FileBlobImpl_h
|
#ifndef mozilla_dom_FileBlobImpl_h
|
||||||
#define mozilla_dom_FileBlobImpl_h
|
#define mozilla_dom_FileBlobImpl_h
|
||||||
|
|
||||||
#include "mozilla/dom/BaseBlobImpl.h"
|
#include "mozilla/dom/BlobImpl.h"
|
||||||
#include "mozilla/Maybe.h"
|
#include "mozilla/Maybe.h"
|
||||||
#include "mozilla/Mutex.h"
|
#include "mozilla/Mutex.h"
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ class nsIFile;
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
class FileBlobImpl : public BaseBlobImpl {
|
class FileBlobImpl : public BlobImpl {
|
||||||
public:
|
public:
|
||||||
NS_INLINE_DECL_REFCOUNTING_INHERITED(FileBlobImpl, BaseBlobImpl)
|
NS_INLINE_DECL_REFCOUNTING_INHERITED(FileBlobImpl, BlobImpl)
|
||||||
|
|
||||||
// Create as a file
|
// Create as a file
|
||||||
explicit FileBlobImpl(nsIFile* aFile);
|
explicit FileBlobImpl(nsIFile* aFile);
|
||||||
|
@ -31,35 +31,78 @@ class FileBlobImpl : public BaseBlobImpl {
|
||||||
uint64_t aLength, nsIFile* aFile, int64_t aLastModificationDate);
|
uint64_t aLength, nsIFile* aFile, int64_t aLastModificationDate);
|
||||||
|
|
||||||
// Create as a file with custom name
|
// Create as a file with custom name
|
||||||
FileBlobImpl(
|
FileBlobImpl(nsIFile* aFile, const nsAString& aName,
|
||||||
nsIFile* aFile, const nsAString& aName, const nsAString& aContentType,
|
const nsAString& aContentType);
|
||||||
const nsAString& aBlobImplType = NS_LITERAL_STRING("FileBlobImpl"));
|
|
||||||
|
|
||||||
// Overrides
|
void GetName(nsAString& aName) const override {
|
||||||
virtual uint64_t GetSize(ErrorResult& aRv) override;
|
MOZ_ASSERT(mIsFile, "Should only be called on files");
|
||||||
virtual void GetType(nsAString& aType) override;
|
aName = mName;
|
||||||
virtual int64_t GetLastModified(ErrorResult& aRv) override;
|
|
||||||
virtual void GetMozFullPathInternal(nsAString& aFullPath,
|
|
||||||
ErrorResult& aRv) override;
|
|
||||||
virtual void CreateInputStream(nsIInputStream** aInputStream,
|
|
||||||
ErrorResult& aRv) override;
|
|
||||||
|
|
||||||
virtual bool IsDirectory() const override;
|
|
||||||
|
|
||||||
virtual void SetLazyData(const nsAString& aName,
|
|
||||||
const nsAString& aContentType, uint64_t aLength,
|
|
||||||
int64_t aLastModifiedDate) override {
|
|
||||||
BaseBlobImpl::SetLazyData(aName, aContentType, 0, 0);
|
|
||||||
mLength.emplace(aLength);
|
|
||||||
mLastModified.emplace(aLastModifiedDate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetName(const nsAString& aName) { mName = aName; }
|
void SetName(const nsAString& aName) { mName = aName; }
|
||||||
|
|
||||||
void SetType(const nsAString& aType) { mContentType = aType; }
|
void GetDOMPath(nsAString& aPath) const override {
|
||||||
|
MOZ_ASSERT(mIsFile, "Should only be called on files");
|
||||||
|
aPath = mPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetDOMPath(const nsAString& aPath) override {
|
||||||
|
MOZ_ASSERT(mIsFile, "Should only be called on files");
|
||||||
|
mPath = aPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t GetLastModified(ErrorResult& aRv) override;
|
||||||
|
|
||||||
|
void GetMozFullPath(nsAString& aFileName, SystemCallerGuarantee /* unused */,
|
||||||
|
ErrorResult& aRv) override {
|
||||||
|
MOZ_ASSERT(mIsFile, "Should only be called on files");
|
||||||
|
|
||||||
|
GetMozFullPathInternal(aFileName, aRv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetMozFullPathInternal(nsAString& aFilename, ErrorResult& aRv) override;
|
||||||
|
|
||||||
|
uint64_t GetSize(ErrorResult& aRv) override;
|
||||||
|
|
||||||
|
void GetType(nsAString& aType) override;
|
||||||
|
|
||||||
|
virtual void GetBlobImplType(nsAString& aBlobImplType) const override;
|
||||||
|
|
||||||
|
size_t GetAllocationSize() const override { return 0; }
|
||||||
|
|
||||||
|
size_t GetAllocationSize(
|
||||||
|
FallibleTArray<BlobImpl*>& aVisitedBlobImpls) const override {
|
||||||
|
return GetAllocationSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t GetSerialNumber() const override { return mSerialNumber; }
|
||||||
|
|
||||||
|
const nsTArray<RefPtr<BlobImpl>>* GetSubBlobImpls() const override {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void CreateInputStream(nsIInputStream** aInputStream,
|
||||||
|
ErrorResult& aRv) override;
|
||||||
|
|
||||||
int64_t GetFileId() override { return mFileId; }
|
int64_t GetFileId() override { return mFileId; }
|
||||||
|
|
||||||
|
void SetLazyData(const nsAString& aName, const nsAString& aContentType,
|
||||||
|
uint64_t aLength, int64_t aLastModifiedDate) override {
|
||||||
|
mName = aName;
|
||||||
|
mContentType = aContentType;
|
||||||
|
mIsFile = !aName.IsVoid();
|
||||||
|
mLength.emplace(aLength);
|
||||||
|
mLastModified.emplace(aLastModifiedDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsMemoryFile() const override { return false; }
|
||||||
|
|
||||||
|
bool IsFile() const override { return mIsFile; }
|
||||||
|
|
||||||
|
bool IsDirectory() const override;
|
||||||
|
|
||||||
|
void SetType(const nsAString& aType) { mContentType = aType; }
|
||||||
|
|
||||||
void SetFileId(int64_t aFileId) { mFileId = aFileId; }
|
void SetFileId(int64_t aFileId) { mFileId = aFileId; }
|
||||||
|
|
||||||
void SetEmptySize() { mLength.emplace(0); }
|
void SetEmptySize() { mLength.emplace(0); }
|
||||||
|
@ -71,34 +114,40 @@ class FileBlobImpl : public BaseBlobImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~FileBlobImpl() = default;
|
~FileBlobImpl() = default;
|
||||||
|
|
||||||
// Create slice
|
// Create slice
|
||||||
FileBlobImpl(const FileBlobImpl* aOther, uint64_t aStart, uint64_t aLength,
|
FileBlobImpl(const FileBlobImpl* aOther, uint64_t aStart, uint64_t aLength,
|
||||||
const nsAString& aContentType);
|
const nsAString& aContentType);
|
||||||
|
|
||||||
virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart,
|
already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||||
uint64_t aLength,
|
const nsAString& aContentType,
|
||||||
const nsAString& aContentType,
|
ErrorResult& aRv) override;
|
||||||
ErrorResult& aRv) override;
|
|
||||||
|
|
||||||
class GetTypeRunnable;
|
class GetTypeRunnable;
|
||||||
void GetTypeInternal(nsAString& aType, const MutexAutoLock& aProofOfLock);
|
void GetTypeInternal(nsAString& aType, const MutexAutoLock& aProofOfLock);
|
||||||
|
|
||||||
// FileBlobImpl is the only BlobImpl with a few getter methods with lazy
|
// FileBlobImpl has getter methods with lazy initialization. Because any
|
||||||
// initialization. Because any BlobImpl must work thread-safe, we use a mutex.
|
// BlobImpl must work thread-safe, we use a mutex.
|
||||||
// This is the list of the getter methods and the corresponding lazy members:
|
|
||||||
// - GetMozFullPathInternal - mMozFullPath
|
|
||||||
// - GetSize - mLength
|
|
||||||
// - GetType - mContentType
|
|
||||||
// - GetLastModified - mLastModifed
|
|
||||||
Mutex mMutex;
|
Mutex mMutex;
|
||||||
|
|
||||||
nsCOMPtr<nsIFile> mFile;
|
nsCOMPtr<nsIFile> mFile;
|
||||||
|
|
||||||
|
nsString mContentType;
|
||||||
|
nsString mName;
|
||||||
|
nsString mPath; // The path relative to a directory chosen by the user
|
||||||
nsString mMozFullPath;
|
nsString mMozFullPath;
|
||||||
Maybe<uint64_t> mLength;
|
|
||||||
Maybe<int64_t> mLastModified;
|
const uint64_t mSerialNumber;
|
||||||
|
uint64_t mStart;
|
||||||
|
|
||||||
int64_t mFileId;
|
int64_t mFileId;
|
||||||
|
|
||||||
|
Maybe<uint64_t> mLength;
|
||||||
|
|
||||||
|
Maybe<int64_t> mLastModified;
|
||||||
|
|
||||||
|
bool mIsFile;
|
||||||
bool mWholeFile;
|
bool mWholeFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -96,8 +96,7 @@ class TemporaryFileInputStream final : public nsFileInputStream {
|
||||||
|
|
||||||
TemporaryFileBlobImpl::TemporaryFileBlobImpl(nsIFile* aFile,
|
TemporaryFileBlobImpl::TemporaryFileBlobImpl(nsIFile* aFile,
|
||||||
const nsAString& aContentType)
|
const nsAString& aContentType)
|
||||||
: FileBlobImpl(aFile, EmptyString(), aContentType,
|
: FileBlobImpl(aFile, EmptyString(), aContentType)
|
||||||
NS_LITERAL_STRING("TemporaryBlobImpl"))
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
,
|
,
|
||||||
mInputStreamCreated(false)
|
mInputStreamCreated(false)
|
||||||
|
|
|
@ -30,6 +30,10 @@ class TemporaryFileBlobImpl final : public FileBlobImpl {
|
||||||
virtual void CreateInputStream(nsIInputStream** aInputStream,
|
virtual void CreateInputStream(nsIInputStream** aInputStream,
|
||||||
ErrorResult& aRv) override;
|
ErrorResult& aRv) override;
|
||||||
|
|
||||||
|
void GetBlobImplType(nsAString& aBlobImplType) const override {
|
||||||
|
aBlobImplType = NS_LITERAL_STRING("TemporaryFileBlobImpl");
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~TemporaryFileBlobImpl();
|
virtual ~TemporaryFileBlobImpl();
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче