☠☠ backed out by 940bf097d9cf ☠ ☠ | |
author | Andrea Marchesini <amarchesini@mozilla.com> |
Mon, 11 May 2015 18:50:54 +0100 | |
changeset 243378 | 56e4c68dc3dad5701658799c543f5ebfafbb976d |
parent 243377 | adfee1efb1e19048d713d2e5c340038786690367 |
child 243379 | 37b877eb0834147f5437892af25482cc5474aba6 |
push id | 28738 |
push user | cbook@mozilla.com |
push date | Tue, 12 May 2015 14:11:31 +0000 |
treeherder | mozilla-central@bedce1b405a3 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | ehsan |
bugs | 1163387 |
milestone | 40.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/archivereader/ArchiveReader.cpp +++ b/dom/archivereader/ArchiveReader.cpp @@ -43,17 +43,17 @@ ArchiveReader::Constructor(const GlobalO nsRefPtr<ArchiveReader> reader = new ArchiveReader(aBlob, window, encoding); return reader.forget(); } ArchiveReader::ArchiveReader(Blob& aBlob, nsPIDOMWindow* aWindow, const nsACString& aEncoding) - : mFileImpl(aBlob.Impl()) + : mBlobImpl(aBlob.Impl()) , mWindow(aWindow) , mStatus(NOT_STARTED) , mEncoding(aEncoding) { MOZ_ASSERT(aWindow); } ArchiveReader::~ArchiveReader() @@ -90,26 +90,26 @@ ArchiveReader::RegisterRequest(ArchiveRe return NS_OK; } // This returns the input stream nsresult ArchiveReader::GetInputStream(nsIInputStream** aInputStream) { // Getting the input stream - mFileImpl->GetInternalStream(aInputStream); + mBlobImpl->GetInternalStream(aInputStream); NS_ENSURE_TRUE(*aInputStream, NS_ERROR_UNEXPECTED); return NS_OK; } nsresult ArchiveReader::GetSize(uint64_t* aSize) { ErrorResult rv; - *aSize = mFileImpl->GetSize(rv); + *aSize = mBlobImpl->GetSize(rv); return rv.StealNSResult(); } // Here we open the archive: nsresult ArchiveReader::OpenArchive() { mStatus = WORKING; @@ -194,17 +194,17 @@ ArchiveReader::GetFiles() already_AddRefed<ArchiveRequest> ArchiveReader::GenerateArchiveRequest() { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); return ArchiveRequest::Create(mWindow, this); } NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ArchiveReader, - mFileImpl, + mBlobImpl, mWindow, mData.fileList, mRequests) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ArchiveReader) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_END
--- a/dom/archivereader/ArchiveReader.h +++ b/dom/archivereader/ArchiveReader.h @@ -14,18 +14,18 @@ #include "nsCOMArray.h" #include "nsIChannel.h" #include "mozilla/Attributes.h" namespace mozilla { namespace dom { struct ArchiveReaderOptions; class Blob; +class BlobImpl; class File; -class FileImpl; class GlobalObject; } // namespace dom } // namespace mozilla BEGIN_ARCHIVEREADER_NAMESPACE class ArchiveRequest; @@ -59,35 +59,35 @@ public: nsresult GetInputStream(nsIInputStream** aInputStream); nsresult GetSize(uint64_t* aSize); public: // for the ArchiveRequest: nsresult RegisterRequest(ArchiveRequest* aRequest); public: // For events: - FileImpl* GetFileImpl() const + BlobImpl* GetBlobImpl() const { - return mFileImpl; + return mBlobImpl; } void Ready(nsTArray<nsRefPtr<File>>& aFileList, nsresult aStatus); private: ~ArchiveReader(); already_AddRefed<ArchiveRequest> GenerateArchiveRequest(); nsresult OpenArchive(); void RequestReady(ArchiveRequest* aRequest); protected: // The archive blob/file - nsRefPtr<FileImpl> mFileImpl; + nsRefPtr<BlobImpl> mBlobImpl; // The window is needed by the requests nsCOMPtr<nsPIDOMWindow> mWindow; // Are we ready to return data? enum { NOT_STARTED = 0, WORKING,
--- a/dom/archivereader/ArchiveZipEvent.cpp +++ b/dom/archivereader/ArchiveZipEvent.cpp @@ -80,20 +80,20 @@ ArchiveZipItem::GetFile(ArchiveReader* a { nsString filename; if (NS_FAILED(GetFilename(filename))) { return nullptr; } nsRefPtr<dom::File> file = dom::File::Create(aArchiveReader, - new ArchiveZipFileImpl(filename, + new ArchiveZipBlobImpl(filename, NS_ConvertUTF8toUTF16(GetType()), StrToInt32(mCentralStruct.orglen), - mCentralStruct, aArchiveReader->GetFileImpl())); + mCentralStruct, aArchiveReader->GetBlobImpl())); MOZ_ASSERT(file); return file.forget(); } uint32_t ArchiveZipItem::StrToInt32(const uint8_t* aStr) { return (uint32_t)( (aStr [0] << 0) |
--- a/dom/archivereader/ArchiveZipFile.cpp +++ b/dom/archivereader/ArchiveZipFile.cpp @@ -348,53 +348,53 @@ ArchiveInputStream::Tell(int64_t *aResul } NS_IMETHODIMP ArchiveInputStream::SetEOF() { return NS_ERROR_NOT_IMPLEMENTED; } -// ArchiveZipFileImpl +// ArchiveZipBlobImpl nsresult -ArchiveZipFileImpl::GetInternalStream(nsIInputStream** aStream) +ArchiveZipBlobImpl::GetInternalStream(nsIInputStream** aStream) { if (mLength > INT32_MAX) { return NS_ERROR_FAILURE; } ErrorResult rv; - uint64_t size = mFileImpl->GetSize(rv); + uint64_t size = mBlobImpl->GetSize(rv); if (NS_WARN_IF(rv.Failed())) { return rv.StealNSResult(); } nsCOMPtr<nsIInputStream> inputStream; - rv = mFileImpl->GetInternalStream(getter_AddRefs(inputStream)); + rv = mBlobImpl->GetInternalStream(getter_AddRefs(inputStream)); if (NS_WARN_IF(rv.Failed()) || !inputStream) { return NS_ERROR_UNEXPECTED; } nsRefPtr<ArchiveInputStream> stream = new ArchiveInputStream(size, inputStream, mFilename, mStart, mLength, mCentral); stream.forget(aStream); return NS_OK; } -already_AddRefed<mozilla::dom::FileImpl> -ArchiveZipFileImpl::CreateSlice(uint64_t aStart, +already_AddRefed<mozilla::dom::BlobImpl> +ArchiveZipBlobImpl::CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, mozilla::ErrorResult& aRv) { - nsRefPtr<FileImpl> impl = - new ArchiveZipFileImpl(mFilename, mContentType, aStart, mLength, mCentral, - mFileImpl); + nsRefPtr<BlobImpl> impl = + new ArchiveZipBlobImpl(mFilename, mContentType, aStart, mLength, mCentral, + mBlobImpl); return impl.forget(); } -NS_IMPL_ISUPPORTS_INHERITED0(ArchiveZipFileImpl, FileImpl) +NS_IMPL_ISUPPORTS_INHERITED0(ArchiveZipBlobImpl, BlobImpl)
--- a/dom/archivereader/ArchiveZipFile.h +++ b/dom/archivereader/ArchiveZipFile.h @@ -14,66 +14,66 @@ #include "ArchiveReader.h" #include "ArchiveReaderCommon.h" #include "zipstruct.h" BEGIN_ARCHIVEREADER_NAMESPACE /** - * ArchiveZipFileImpl to FileImpl + * ArchiveZipBlobImpl to BlobImpl */ -class ArchiveZipFileImpl : public FileImplBase +class ArchiveZipBlobImpl : public BlobImplBase { public: NS_DECL_ISUPPORTS_INHERITED - ArchiveZipFileImpl(const nsAString& aName, + ArchiveZipBlobImpl(const nsAString& aName, const nsAString& aContentType, uint64_t aLength, ZipCentral& aCentral, - FileImpl* aFileImpl) - : FileImplBase(aName, aContentType, aLength), + BlobImpl* aBlobImpl) + : BlobImplBase(aName, aContentType, aLength), mCentral(aCentral), - mFileImpl(aFileImpl), + mBlobImpl(aBlobImpl), mFilename(aName) { - MOZ_ASSERT(mFileImpl); - MOZ_COUNT_CTOR(ArchiveZipFileImpl); + MOZ_ASSERT(mBlobImpl); + MOZ_COUNT_CTOR(ArchiveZipBlobImpl); } - ArchiveZipFileImpl(const nsAString& aName, + ArchiveZipBlobImpl(const nsAString& aName, const nsAString& aContentType, uint64_t aStart, uint64_t aLength, ZipCentral& aCentral, - FileImpl* aFileImpl) - : FileImplBase(aContentType, aStart, aLength), + BlobImpl* aBlobImpl) + : BlobImplBase(aContentType, aStart, aLength), mCentral(aCentral), - mFileImpl(aFileImpl), + mBlobImpl(aBlobImpl), mFilename(aName) { - MOZ_ASSERT(mFileImpl); - MOZ_COUNT_CTOR(ArchiveZipFileImpl); + MOZ_ASSERT(mBlobImpl); + MOZ_COUNT_CTOR(ArchiveZipBlobImpl); } // Overrides: virtual nsresult GetInternalStream(nsIInputStream**) override; protected: - virtual ~ArchiveZipFileImpl() + virtual ~ArchiveZipBlobImpl() { - MOZ_COUNT_DTOR(ArchiveZipFileImpl); + MOZ_COUNT_DTOR(ArchiveZipBlobImpl); } - virtual already_AddRefed<FileImpl> + virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, mozilla::ErrorResult& aRv) override; private: // Data ZipCentral mCentral; - nsRefPtr<FileImpl> mFileImpl; + nsRefPtr<BlobImpl> mBlobImpl; nsString mFilename; }; END_ARCHIVEREADER_NAMESPACE #endif // mozilla_dom_archivereader_domarchivefile_h__
--- a/dom/base/BlobSet.h +++ b/dom/base/BlobSet.h @@ -21,20 +21,20 @@ public: ~BlobSet() { free(mData); } nsresult AppendVoidPtr(const void* aData, uint32_t aLength); nsresult AppendString(const nsAString& aString, bool nativeEOL, JSContext* aCx); - nsresult AppendBlobImpl(FileImpl* aBlobImpl); - nsresult AppendBlobImpls(const nsTArray<nsRefPtr<FileImpl>>& aBlobImpls); + nsresult AppendBlobImpl(BlobImpl* aBlobImpl); + nsresult AppendBlobImpls(const nsTArray<nsRefPtr<BlobImpl>>& aBlobImpls); - nsTArray<nsRefPtr<FileImpl>>& GetBlobImpls() { Flush(); return mBlobImpls; } + nsTArray<nsRefPtr<BlobImpl>>& GetBlobImpls() { Flush(); return mBlobImpls; } already_AddRefed<Blob> GetBlobInternal(nsISupports* aParent, const nsACString& aContentType); protected: bool ExpandBufferSize(uint64_t aSize) { using mozilla::CheckedUint32; @@ -63,26 +63,26 @@ protected: return true; } void Flush() { if (mData) { // If we have some data, create a blob for it // and put it on the stack - nsRefPtr<FileImpl> blobImpl = - new FileImplMemory(mData, mDataLen, EmptyString()); + nsRefPtr<BlobImpl> blobImpl = + new BlobImplMemory(mData, mDataLen, EmptyString()); mBlobImpls.AppendElement(blobImpl); mData = nullptr; // The nsDOMMemoryFile takes ownership of the buffer mDataLen = 0; mDataBufferLen = 0; } } - nsTArray<nsRefPtr<FileImpl>> mBlobImpls; + nsTArray<nsRefPtr<BlobImpl>> mBlobImpls; void* mData; uint64_t mDataLen; uint64_t mDataBufferLen; }; } // dom namespace } // mozilla namespace
--- a/dom/base/Console.cpp +++ b/dom/base/Console.cpp @@ -55,17 +55,17 @@ using namespace mozilla::dom::workers; namespace mozilla { namespace dom { struct ConsoleStructuredCloneData { nsCOMPtr<nsISupports> mParent; - nsTArray<nsRefPtr<FileImpl>> mFiles; + nsTArray<nsRefPtr<BlobImpl>> mBlobs; }; /** * Console API in workers uses the Structured Clone Algorithm to move any value * from the worker thread to the main-thread. Some object cannot be moved and, * in these cases, we convert them to strings. * It's not the best, but at least we are able to show something. */ @@ -79,22 +79,22 @@ ConsoleStructuredCloneCallbacksRead(JSCo void* aClosure) { AssertIsOnMainThread(); ConsoleStructuredCloneData* data = static_cast<ConsoleStructuredCloneData*>(aClosure); MOZ_ASSERT(data); if (aTag == CONSOLE_TAG_BLOB) { - MOZ_ASSERT(data->mFiles.Length() > aIndex); + MOZ_ASSERT(data->mBlobs.Length() > aIndex); JS::Rooted<JS::Value> val(aCx); { nsRefPtr<Blob> blob = - Blob::Create(data->mParent, data->mFiles.ElementAt(aIndex)); + Blob::Create(data->mParent, data->mBlobs.ElementAt(aIndex)); if (!ToJSValue(aCx, blob, &val)) { return nullptr; } } return &val.toObject(); } @@ -112,21 +112,21 @@ ConsoleStructuredCloneCallbacksWrite(JSC { ConsoleStructuredCloneData* data = static_cast<ConsoleStructuredCloneData*>(aClosure); MOZ_ASSERT(data); nsRefPtr<Blob> blob; if (NS_SUCCEEDED(UNWRAP_OBJECT(Blob, aObj, blob)) && blob->Impl()->MayBeClonedToOtherThreads()) { - if (!JS_WriteUint32Pair(aWriter, CONSOLE_TAG_BLOB, data->mFiles.Length())) { + if (!JS_WriteUint32Pair(aWriter, CONSOLE_TAG_BLOB, data->mBlobs.Length())) { return false; } - data->mFiles.AppendElement(blob->Impl()); + data->mBlobs.AppendElement(blob->Impl()); return true; } JS::Rooted<JS::Value> value(aCx, JS::ObjectOrNullValue(aObj)); JS::Rooted<JSString*> jsString(aCx, JS::ToString(aCx, value)); if (!jsString) { return false; }
--- a/dom/base/File.cpp +++ b/dom/base/File.cpp @@ -1,17 +1,17 @@ /* -*- 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 "mozilla/dom/File.h" -#include "MultipartFileImpl.h" +#include "MultipartBlobImpl.h" #include "nsCExternalHandlerService.h" #include "nsContentCID.h" #include "nsContentUtils.h" #include "nsError.h" #include "nsICharsetDetector.h" #include "nsIConverterInputStream.h" #include "nsIDocument.h" #include "nsIFileStreams.h" @@ -50,17 +50,17 @@ namespace dom { // can outlive the actual File object. Thus, we must // ensure that the buffer underlying the stream we get // from NS_NewByteInputStream is held alive as long as the // stream is. We do that by passing back this class instead. class DataOwnerAdapter final : public nsIInputStream, public nsISeekableStream, public nsIIPCSerializableInputStream { - typedef FileImplMemory::DataOwner DataOwner; + typedef BlobImplMemory::DataOwner DataOwner; public: static nsresult Create(DataOwner* aDataOwner, uint32_t aStart, uint32_t aLength, nsIInputStream** _retval); NS_DECL_THREADSAFE_ISUPPORTS @@ -153,66 +153,66 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION( NS_INTERFACE_MAP_ENTRY(nsIMutable) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_END NS_IMPL_CYCLE_COLLECTING_ADDREF(Blob) NS_IMPL_CYCLE_COLLECTING_RELEASE(Blob) /* static */ Blob* -Blob::Create(nsISupports* aParent, FileImpl* aImpl) +Blob::Create(nsISupports* aParent, BlobImpl* aImpl) { MOZ_ASSERT(aImpl); return aImpl->IsFile() ? new File(aParent, aImpl) : new Blob(aParent, aImpl); } /* static */ already_AddRefed<Blob> Blob::Create(nsISupports* aParent, const nsAString& aContentType, uint64_t aLength) { nsRefPtr<Blob> blob = Blob::Create(aParent, - new FileImplBase(aContentType, aLength)); + new BlobImplBase(aContentType, aLength)); MOZ_ASSERT(!blob->mImpl->IsFile()); return blob.forget(); } /* static */ already_AddRefed<Blob> Blob::Create(nsISupports* aParent, const nsAString& aContentType, uint64_t aStart, uint64_t aLength) { nsRefPtr<Blob> blob = Blob::Create(aParent, - new FileImplBase(aContentType, aStart, aLength)); + new BlobImplBase(aContentType, aStart, aLength)); MOZ_ASSERT(!blob->mImpl->IsFile()); return blob.forget(); } /* static */ already_AddRefed<Blob> Blob::CreateMemoryBlob(nsISupports* aParent, void* aMemoryBuffer, uint64_t aLength, const nsAString& aContentType) { nsRefPtr<Blob> blob = Blob::Create(aParent, - new FileImplMemory(aMemoryBuffer, aLength, aContentType)); + new BlobImplMemory(aMemoryBuffer, aLength, aContentType)); MOZ_ASSERT(!blob->mImpl->IsFile()); return blob.forget(); } /* static */ already_AddRefed<Blob> Blob::CreateTemporaryBlob(nsISupports* aParent, PRFileDesc* aFD, uint64_t aStartPos, uint64_t aLength, const nsAString& aContentType) { nsRefPtr<Blob> blob = Blob::Create(aParent, - new FileImplTemporaryBlob(aFD, aStartPos, aLength, aContentType)); + new BlobImplTemporaryBlob(aFD, aStartPos, aLength, aContentType)); MOZ_ASSERT(!blob->mImpl->IsFile()); return blob.forget(); } -Blob::Blob(nsISupports* aParent, FileImpl* aImpl) +Blob::Blob(nsISupports* aParent, BlobImpl* aImpl) : mImpl(aImpl) , mParent(aParent) { MOZ_ASSERT(mImpl); #ifdef DEBUG { nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aParent); @@ -224,17 +224,17 @@ Blob::Blob(nsISupports* aParent, FileImp } bool Blob::IsFile() const { return mImpl->IsFile(); } -const nsTArray<nsRefPtr<FileImpl>>* +const nsTArray<nsRefPtr<BlobImpl>>* Blob::GetSubBlobImpls() const { return mImpl->GetSubBlobImpls(); } already_AddRefed<File> Blob::ToFile() { @@ -250,35 +250,35 @@ Blob::ToFile() } return file.forget(); } already_AddRefed<File> Blob::ToFile(const nsAString& aName) const { - nsAutoTArray<nsRefPtr<FileImpl>, 1> blobImpls; + nsAutoTArray<nsRefPtr<BlobImpl>, 1> blobImpls; blobImpls.AppendElement(mImpl); nsAutoString contentType; mImpl->GetType(contentType); - nsRefPtr<MultipartFileImpl> impl = - new MultipartFileImpl(blobImpls, aName, contentType); + nsRefPtr<MultipartBlobImpl> impl = + new MultipartBlobImpl(blobImpls, aName, contentType); nsRefPtr<File> file = new File(mParent, impl); return file.forget(); } already_AddRefed<Blob> Blob::CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) { - nsRefPtr<FileImpl> impl = mImpl->CreateSlice(aStart, aLength, + nsRefPtr<BlobImpl> impl = mImpl->CreateSlice(aStart, aLength, aContentType, aRv); if (aRv.Failed()) { return nullptr; } nsRefPtr<Blob> blob = Blob::Create(mParent, impl); return blob.forget(); } @@ -332,17 +332,17 @@ Blob::Slice(int64_t aStart, int64_t aEnd } already_AddRefed<Blob> Blob::Slice(const Optional<int64_t>& aStart, const Optional<int64_t>& aEnd, const nsAString& aContentType, ErrorResult& aRv) { - nsRefPtr<FileImpl> impl = + nsRefPtr<BlobImpl> impl = mImpl->Slice(aStart, aEnd, aContentType, aRv); if (aRv.Failed()) { return nullptr; } nsRefPtr<Blob> blob = Blob::Create(mParent, impl); return blob.forget(); } @@ -372,33 +372,33 @@ JSObject* Blob::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) { return BlobBinding::Wrap(aCx, this, aGivenProto); } /* static */ already_AddRefed<Blob> Blob::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) { - nsRefPtr<MultipartFileImpl> impl = new MultipartFileImpl(); + nsRefPtr<MultipartBlobImpl> impl = new MultipartBlobImpl(); impl->InitializeBlob(); MOZ_ASSERT(!impl->IsFile()); nsRefPtr<Blob> blob = Blob::Create(aGlobal.GetAsSupports(), impl); return blob.forget(); } /* static */ already_AddRefed<Blob> Blob::Constructor( const GlobalObject& aGlobal, const Sequence<OwningArrayBufferOrArrayBufferViewOrBlobOrString>& aData, const BlobPropertyBag& aBag, ErrorResult& aRv) { - nsRefPtr<MultipartFileImpl> impl = new MultipartFileImpl(); + nsRefPtr<MultipartBlobImpl> impl = new MultipartBlobImpl(); impl->InitializeBlob(aGlobal.Context(), aData, aBag.mType, aBag.mEndings == EndingTypes::Native, aRv); if (aRv.Failed()) { return nullptr; } MOZ_ASSERT(!impl->IsFile()); @@ -450,105 +450,105 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(File) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMFile) NS_INTERFACE_MAP_ENTRY(nsIDOMFile) NS_INTERFACE_MAP_END_INHERITING(Blob) NS_IMPL_ADDREF_INHERITED(File, Blob) NS_IMPL_RELEASE_INHERITED(File, Blob) -File::File(nsISupports* aParent, FileImpl* aImpl) +File::File(nsISupports* aParent, BlobImpl* aImpl) : Blob(aParent, aImpl) { MOZ_ASSERT(aImpl->IsFile()); } /* static */ File* -File::Create(nsISupports* aParent, FileImpl* aImpl) +File::Create(nsISupports* aParent, BlobImpl* aImpl) { MOZ_ASSERT(aImpl); MOZ_ASSERT(aImpl->IsFile()); return new File(aParent, aImpl); } /* static */ already_AddRefed<File> File::Create(nsISupports* aParent, const nsAString& aName, const nsAString& aContentType, uint64_t aLength, int64_t aLastModifiedDate) { nsRefPtr<File> file = new File(aParent, - new FileImplBase(aName, aContentType, aLength, aLastModifiedDate)); + new BlobImplBase(aName, aContentType, aLength, aLastModifiedDate)); return file.forget(); } /* static */ already_AddRefed<File> File::Create(nsISupports* aParent, const nsAString& aName, const nsAString& aContentType, uint64_t aLength) { nsRefPtr<File> file = new File(aParent, - new FileImplBase(aName, aContentType, aLength)); + new BlobImplBase(aName, aContentType, aLength)); return file.forget(); } /* static */ already_AddRefed<File> File::CreateMemoryFile(nsISupports* aParent, void* aMemoryBuffer, uint64_t aLength, const nsAString& aName, const nsAString& aContentType, int64_t aLastModifiedDate) { nsRefPtr<File> file = new File(aParent, - new FileImplMemory(aMemoryBuffer, aLength, aName, + new BlobImplMemory(aMemoryBuffer, aLength, aName, aContentType, aLastModifiedDate)); return file.forget(); } /* static */ already_AddRefed<File> File::CreateFromFile(nsISupports* aParent, nsIFile* aFile, bool aTemporary) { - nsRefPtr<File> file = new File(aParent, new FileImplFile(aFile, aTemporary)); + nsRefPtr<File> file = new File(aParent, new BlobImplFile(aFile, aTemporary)); return file.forget(); } /* static */ already_AddRefed<File> File::CreateFromFile(nsISupports* aParent, const nsAString& aContentType, uint64_t aLength, nsIFile* aFile, indexedDB::FileInfo* aFileInfo) { nsRefPtr<File> file = new File(aParent, - new FileImplFile(aContentType, aLength, aFile, aFileInfo)); + new BlobImplFile(aContentType, aLength, aFile, aFileInfo)); return file.forget(); } /* static */ already_AddRefed<File> File::CreateFromFile(nsISupports* aParent, const nsAString& aName, const nsAString& aContentType, uint64_t aLength, nsIFile* aFile, indexedDB::FileInfo* aFileInfo) { nsRefPtr<File> file = new File(aParent, - new FileImplFile(aName, aContentType, aLength, aFile, aFileInfo)); + new BlobImplFile(aName, aContentType, aLength, aFile, aFileInfo)); return file.forget(); } /* static */ already_AddRefed<File> File::CreateFromFile(nsISupports* aParent, nsIFile* aFile, indexedDB::FileInfo* aFileInfo) { nsRefPtr<File> file = new File(aParent, - new FileImplFile(aFile, aFileInfo)); + new BlobImplFile(aFile, aFileInfo)); return file.forget(); } /* static */ already_AddRefed<File> File::CreateFromFile(nsISupports* aParent, nsIFile* aFile, const nsAString& aName, const nsAString& aContentType) { nsRefPtr<File> file = new File(aParent, - new FileImplFile(aFile, aName, aContentType)); + new BlobImplFile(aFile, aName, aContentType)); return file.forget(); } JSObject* File::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) { return FileBinding::Wrap(aCx, this, aGivenProto); } @@ -672,17 +672,17 @@ ParseSize(int64_t aSize, int64_t& aStart /* static */ already_AddRefed<File> File::Constructor( const GlobalObject& aGlobal, const Sequence<OwningArrayBufferOrArrayBufferViewOrBlobOrString>& aData, const nsAString& aName, const FilePropertyBag& aBag, ErrorResult& aRv) { - nsRefPtr<MultipartFileImpl> impl = new MultipartFileImpl(aName); + nsRefPtr<MultipartBlobImpl> impl = new MultipartBlobImpl(aName); impl->InitializeBlob(aGlobal.Context(), aData, aBag.mType, false, aRv); if (aRv.Failed()) { return nullptr; } MOZ_ASSERT(impl->IsFile()); if (aBag.mLastModified.WasPassed()) { @@ -699,17 +699,17 @@ File::Constructor(const GlobalObject& aG const ChromeFilePropertyBag& aBag, ErrorResult& aRv) { if (!nsContentUtils::ThreadsafeIsCallerChrome()) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } - nsRefPtr<MultipartFileImpl> impl = new MultipartFileImpl(EmptyString()); + nsRefPtr<MultipartBlobImpl> impl = new MultipartBlobImpl(EmptyString()); impl->InitializeChromeFile(aData, aBag, aRv); if (aRv.Failed()) { return nullptr; } MOZ_ASSERT(impl->IsFile()); if (aBag.mLastModified.WasPassed()) { impl->SetLastModified(aBag.mLastModified.Value()); @@ -728,17 +728,17 @@ File::Constructor(const GlobalObject& aG MOZ_ASSERT(NS_IsMainThread()); if (!nsContentUtils::IsCallerChrome()) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports()); - nsRefPtr<MultipartFileImpl> impl = new MultipartFileImpl(EmptyString()); + nsRefPtr<MultipartBlobImpl> impl = new MultipartBlobImpl(EmptyString()); impl->InitializeChromeFile(window, aData, aBag, true, aRv); if (aRv.Failed()) { return nullptr; } MOZ_ASSERT(impl->IsFile()); if (aBag.mLastModified.WasPassed()) { impl->SetLastModified(aBag.mLastModified.Value()); @@ -756,36 +756,36 @@ File::Constructor(const GlobalObject& aG { if (!nsContentUtils::ThreadsafeIsCallerChrome()) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports()); - nsRefPtr<MultipartFileImpl> impl = new MultipartFileImpl(EmptyString()); + nsRefPtr<MultipartBlobImpl> impl = new MultipartBlobImpl(EmptyString()); impl->InitializeChromeFile(window, aData, aBag, aRv); if (aRv.Failed()) { return nullptr; } MOZ_ASSERT(impl->IsFile()); if (aBag.mLastModified.WasPassed()) { impl->SetLastModified(aBag.mLastModified.Value()); } nsRefPtr<File> domFile = new File(aGlobal.GetAsSupports(), impl); return domFile.forget(); } //////////////////////////////////////////////////////////////////////////// -// mozilla::dom::FileImpl implementation +// mozilla::dom::BlobImpl implementation -already_AddRefed<FileImpl> -FileImpl::Slice(const Optional<int64_t>& aStart, +already_AddRefed<BlobImpl> +BlobImpl::Slice(const Optional<int64_t>& aStart, const Optional<int64_t>& aEnd, const nsAString& aContentType, ErrorResult& aRv) { // Truncate aStart and aEnd so that we stay within this file. uint64_t thisLength = GetSize(aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr; @@ -796,42 +796,42 @@ FileImpl::Slice(const Optional<int64_t>& ParseSize((int64_t)thisLength, start, end); return CreateSlice((uint64_t)start, (uint64_t)(end - start), aContentType, aRv); } //////////////////////////////////////////////////////////////////////////// -// FileImpl implementation +// BlobImpl implementation -NS_IMPL_ISUPPORTS(FileImpl, FileImpl) +NS_IMPL_ISUPPORTS(BlobImpl, BlobImpl) //////////////////////////////////////////////////////////////////////////// -// FileImplFile implementation +// BlobImplFile implementation -NS_IMPL_ISUPPORTS_INHERITED0(FileImplFile, FileImpl) +NS_IMPL_ISUPPORTS_INHERITED0(BlobImplFile, BlobImpl) void -FileImplBase::GetName(nsAString& aName) +BlobImplBase::GetName(nsAString& aName) { NS_ASSERTION(mIsFile, "Should only be called on files"); aName = mName; } nsresult -FileImplBase::GetPath(nsAString& aPath) +BlobImplBase::GetPath(nsAString& aPath) { NS_ASSERTION(mIsFile, "Should only be called on files"); aPath = mPath; return NS_OK; } void -FileImplBase::GetMozFullPath(nsAString& aFileName, ErrorResult& aRv) +BlobImplBase::GetMozFullPath(nsAString& aFileName, ErrorResult& aRv) { NS_ASSERTION(mIsFile, "Should only be called on files"); aFileName.Truncate(); if (NS_IsMainThread()) { if (nsContentUtils::IsCallerChrome()) { GetMozFullPathInternal(aFileName, aRv); @@ -845,51 +845,51 @@ FileImplBase::GetMozFullPath(nsAString& MOZ_ASSERT(workerPrivate); if (workerPrivate->UsesSystemPrincipal()) { GetMozFullPathInternal(aFileName, aRv); } } void -FileImplBase::GetMozFullPathInternal(nsAString& aFileName, ErrorResult& aRv) +BlobImplBase::GetMozFullPathInternal(nsAString& aFileName, ErrorResult& aRv) { if (!mIsFile) { aRv.Throw(NS_ERROR_FAILURE); return; } aFileName.Truncate(); } void -FileImplBase::GetType(nsAString& aType) +BlobImplBase::GetType(nsAString& aType) { aType = mContentType; } int64_t -FileImplBase::GetLastModified(ErrorResult& aRv) +BlobImplBase::GetLastModified(ErrorResult& aRv) { NS_ASSERTION(mIsFile, "Should only be called on files"); if (IsDateUnknown()) { mLastModificationDate = PR_Now(); } return mLastModificationDate / PR_USEC_PER_MSEC; } void -FileImplBase::SetLastModified(int64_t aLastModified) +BlobImplBase::SetLastModified(int64_t aLastModified) { mLastModificationDate = aLastModified * PR_USEC_PER_MSEC; } int64_t -FileImplBase::GetFileId() +BlobImplBase::GetFileId() { int64_t id = -1; if (IsStoredFile() && IsWholeFile() && !IsSnapshot()) { if (!indexedDB::IndexedDatabaseManager::IsClosed()) { indexedDB::IndexedDatabaseManager::FileMutex().Lock(); } @@ -905,17 +905,17 @@ FileImplBase::GetFileId() indexedDB::IndexedDatabaseManager::FileMutex().Unlock(); } } return id; } void -FileImplBase::AddFileInfo(indexedDB::FileInfo* aFileInfo) +BlobImplBase::AddFileInfo(indexedDB::FileInfo* aFileInfo) { if (indexedDB::IndexedDatabaseManager::IsClosed()) { NS_ERROR("Shouldn't be called after shutdown!"); return; } nsRefPtr<indexedDB::FileInfo> fileInfo = aFileInfo; @@ -924,17 +924,17 @@ FileImplBase::AddFileInfo(indexedDB::Fil NS_ASSERTION(!mFileInfos.Contains(aFileInfo), "Adding the same file info agan?!"); nsRefPtr<indexedDB::FileInfo>* element = mFileInfos.AppendElement(); element->swap(fileInfo); } indexedDB::FileInfo* -FileImplBase::GetFileInfo(indexedDB::FileManager* aFileManager) +BlobImplBase::GetFileInfo(indexedDB::FileManager* aFileManager) { if (indexedDB::IndexedDatabaseManager::IsClosed()) { NS_ERROR("Shouldn't be called after shutdown!"); return nullptr; } // A slice created from a stored file must keep the file info alive. // However, we don't support sharing of slices yet, so the slice must be @@ -956,17 +956,17 @@ FileImplBase::GetFileInfo(indexedDB::Fil return fileInfo; } } return nullptr; } nsresult -FileImplBase::GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength, +BlobImplBase::GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength, nsACString& aContentType, nsACString& aCharset) { MOZ_ASSERT(aContentLength); nsresult rv; nsCOMPtr<nsIInputStream> stream; rv = GetInternalStream(getter_AddRefs(stream)); @@ -985,24 +985,24 @@ FileImplBase::GetSendInfo(nsIInputStream aCharset.Truncate(); stream.forget(aBody); return NS_OK; } nsresult -FileImplBase::GetMutable(bool* aMutable) const +BlobImplBase::GetMutable(bool* aMutable) const { *aMutable = !mImmutable; return NS_OK; } nsresult -FileImplBase::SetMutable(bool aMutable) +BlobImplBase::SetMutable(bool aMutable) { nsresult rv = NS_OK; NS_ENSURE_ARG(!mImmutable || !aMutable); if (!mImmutable && !aMutable) { // Force the content type and size to be cached nsAutoString dummyString; @@ -1015,37 +1015,37 @@ FileImplBase::SetMutable(bool aMutable) } } mImmutable = !aMutable; return rv; } //////////////////////////////////////////////////////////////////////////// -// FileImplFile implementation +// BlobImplFile implementation -already_AddRefed<FileImpl> -FileImplFile::CreateSlice(uint64_t aStart, uint64_t aLength, +already_AddRefed<BlobImpl> +BlobImplFile::CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) { - nsRefPtr<FileImpl> impl = - new FileImplFile(this, aStart, aLength, aContentType); + nsRefPtr<BlobImpl> impl = + new BlobImplFile(this, aStart, aLength, aContentType); return impl.forget(); } void -FileImplFile::GetMozFullPathInternal(nsAString& aFilename, ErrorResult& aRv) +BlobImplFile::GetMozFullPathInternal(nsAString& aFilename, ErrorResult& aRv) { NS_ASSERTION(mIsFile, "Should only be called on files"); aRv = mFile->GetPath(aFilename); } uint64_t -FileImplFile::GetSize(ErrorResult& aRv) +BlobImplFile::GetSize(ErrorResult& aRv) { if (IsSizeUnknown()) { NS_ASSERTION(mWholeFile, "Should only use lazy size when using the whole file"); int64_t fileSize; aRv = mFile->GetFileSize(&fileSize); if (NS_WARN_IF(aRv.Failed())) { return 0; @@ -1058,17 +1058,17 @@ FileImplFile::GetSize(ErrorResult& aRv) mLength = fileSize; } return mLength; } void -FileImplFile::GetType(nsAString& aType) +BlobImplFile::GetType(nsAString& aType) { if (mContentType.IsVoid()) { NS_ASSERTION(mWholeFile, "Should only use lazy ContentType when using the whole file"); nsresult rv; nsCOMPtr<nsIMIMEService> mimeService = do_GetService(NS_MIMESERVICE_CONTRACTID, &rv); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -1085,109 +1085,109 @@ FileImplFile::GetType(nsAString& aType) AppendUTF8toUTF16(mimeType, mContentType); mContentType.SetIsVoid(false); } aType = mContentType; } int64_t -FileImplFile::GetLastModified(ErrorResult& aRv) +BlobImplFile::GetLastModified(ErrorResult& aRv) { NS_ASSERTION(mIsFile, "Should only be called on files"); if (IsDateUnknown()) { PRTime msecs; aRv = mFile->GetLastModifiedTime(&msecs); if (NS_WARN_IF(aRv.Failed())) { return 0; } mLastModificationDate = msecs; } return mLastModificationDate; } void -FileImplFile::SetLastModified(int64_t aLastModified) +BlobImplFile::SetLastModified(int64_t aLastModified) { MOZ_CRASH("SetLastModified of a real file is not allowed!"); } const uint32_t sFileStreamFlags = nsIFileInputStream::CLOSE_ON_EOF | nsIFileInputStream::REOPEN_ON_REWIND | nsIFileInputStream::DEFER_OPEN | nsIFileInputStream::SHARE_DELETE; nsresult -FileImplFile::GetInternalStream(nsIInputStream** aStream) +BlobImplFile::GetInternalStream(nsIInputStream** aStream) { return mWholeFile ? NS_NewLocalFileInputStream(aStream, mFile, -1, -1, sFileStreamFlags) : NS_NewPartialLocalFileInputStream(aStream, mFile, mStart, mLength, -1, -1, sFileStreamFlags); } void -FileImplFile::SetPath(const nsAString& aPath) +BlobImplFile::SetPath(const nsAString& aPath) { MOZ_ASSERT(aPath.IsEmpty() || aPath[aPath.Length() - 1] == char16_t('/'), "Path must end with a path separator"); mPath = aPath; } //////////////////////////////////////////////////////////////////////////// -// FileImplMemory implementation +// BlobImplMemory implementation -NS_IMPL_ISUPPORTS_INHERITED0(FileImplMemory, FileImpl) +NS_IMPL_ISUPPORTS_INHERITED0(BlobImplMemory, BlobImpl) -already_AddRefed<FileImpl> -FileImplMemory::CreateSlice(uint64_t aStart, uint64_t aLength, +already_AddRefed<BlobImpl> +BlobImplMemory::CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) { - nsRefPtr<FileImpl> impl = - new FileImplMemory(this, aStart, aLength, aContentType); + nsRefPtr<BlobImpl> impl = + new BlobImplMemory(this, aStart, aLength, aContentType); return impl.forget(); } nsresult -FileImplMemory::GetInternalStream(nsIInputStream** aStream) +BlobImplMemory::GetInternalStream(nsIInputStream** aStream) { if (mLength > INT32_MAX) return NS_ERROR_FAILURE; return DataOwnerAdapter::Create(mDataOwner, mStart, mLength, aStream); } /* static */ StaticMutex -FileImplMemory::DataOwner::sDataOwnerMutex; +BlobImplMemory::DataOwner::sDataOwnerMutex; -/* static */ StaticAutoPtr<LinkedList<FileImplMemory::DataOwner>> -FileImplMemory::DataOwner::sDataOwners; +/* static */ StaticAutoPtr<LinkedList<BlobImplMemory::DataOwner>> +BlobImplMemory::DataOwner::sDataOwners; /* static */ bool -FileImplMemory::DataOwner::sMemoryReporterRegistered = false; +BlobImplMemory::DataOwner::sMemoryReporterRegistered = false; MOZ_DEFINE_MALLOC_SIZE_OF(MemoryFileDataOwnerMallocSizeOf) -class FileImplMemoryDataOwnerMemoryReporter final +class BlobImplMemoryDataOwnerMemoryReporter final : public nsIMemoryReporter { - ~FileImplMemoryDataOwnerMemoryReporter() {} + ~BlobImplMemoryDataOwnerMemoryReporter() {} public: NS_DECL_THREADSAFE_ISUPPORTS NS_IMETHOD CollectReports(nsIMemoryReporterCallback *aCallback, nsISupports *aClosure, bool aAnonymize) override { - typedef FileImplMemory::DataOwner DataOwner; + typedef BlobImplMemory::DataOwner DataOwner; StaticMutexAutoLock lock(DataOwner::sDataOwnerMutex); if (!DataOwner::sDataOwners) { return NS_OK; } const size_t LARGE_OBJECT_MIN_SIZE = 8 * 1024; @@ -1242,54 +1242,54 @@ public: aClosure); NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; } }; -NS_IMPL_ISUPPORTS(FileImplMemoryDataOwnerMemoryReporter, nsIMemoryReporter) +NS_IMPL_ISUPPORTS(BlobImplMemoryDataOwnerMemoryReporter, nsIMemoryReporter) /* static */ void -FileImplMemory::DataOwner::EnsureMemoryReporterRegistered() +BlobImplMemory::DataOwner::EnsureMemoryReporterRegistered() { sDataOwnerMutex.AssertCurrentThreadOwns(); if (sMemoryReporterRegistered) { return; } - RegisterStrongMemoryReporter(new FileImplMemoryDataOwnerMemoryReporter()); + RegisterStrongMemoryReporter(new BlobImplMemoryDataOwnerMemoryReporter()); sMemoryReporterRegistered = true; } //////////////////////////////////////////////////////////////////////////// -// FileImplTemporaryBlob implementation +// BlobImplTemporaryBlob implementation -NS_IMPL_ISUPPORTS_INHERITED0(FileImplTemporaryBlob, FileImpl) +NS_IMPL_ISUPPORTS_INHERITED0(BlobImplTemporaryBlob, BlobImpl) -already_AddRefed<FileImpl> -FileImplTemporaryBlob::CreateSlice(uint64_t aStart, uint64_t aLength, +already_AddRefed<BlobImpl> +BlobImplTemporaryBlob::CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) { if (aStart + aLength > mLength) { aRv.Throw(NS_ERROR_UNEXPECTED); return nullptr; } - nsRefPtr<FileImpl> impl = - new FileImplTemporaryBlob(this, aStart + mStartPos, + nsRefPtr<BlobImpl> impl = + new BlobImplTemporaryBlob(this, aStart + mStartPos, aLength, aContentType); return impl.forget(); } nsresult -FileImplTemporaryBlob::GetInternalStream(nsIInputStream** aStream) +BlobImplTemporaryBlob::GetInternalStream(nsIInputStream** aStream) { nsCOMPtr<nsIInputStream> stream = new nsTemporaryFileInputStream(mFileDescOwner, mStartPos, mStartPos + mLength); stream.forget(aStream); return NS_OK; } //////////////////////////////////////////////////////////////////////////// @@ -1330,17 +1330,17 @@ FileList::Item(uint32_t aIndex, nsIDOMFi //////////////////////////////////////////////////////////////////////////// // BlobSet implementation already_AddRefed<Blob> BlobSet::GetBlobInternal(nsISupports* aParent, const nsACString& aContentType) { nsRefPtr<Blob> blob = Blob::Create(aParent, - new MultipartFileImpl(GetBlobImpls(), + new MultipartBlobImpl(GetBlobImpls(), NS_ConvertASCIItoUTF16(aContentType))); return blob.forget(); } nsresult BlobSet::AppendVoidPtr(const void* aData, uint32_t aLength) { NS_ENSURE_ARG_POINTER(aData); @@ -1369,28 +1369,28 @@ BlobSet::AppendString(const nsAString& a #endif } return AppendVoidPtr((void*)utf8Str.Data(), utf8Str.Length()); } nsresult -BlobSet::AppendBlobImpl(FileImpl* aBlobImpl) +BlobSet::AppendBlobImpl(BlobImpl* aBlobImpl) { NS_ENSURE_ARG_POINTER(aBlobImpl); Flush(); mBlobImpls.AppendElement(aBlobImpl); return NS_OK; } nsresult -BlobSet::AppendBlobImpls(const nsTArray<nsRefPtr<FileImpl>>& aBlobImpls) +BlobSet::AppendBlobImpls(const nsTArray<nsRefPtr<BlobImpl>>& aBlobImpls) { Flush(); mBlobImpls.AppendElements(aBlobImpls); return NS_OK; } } // dom namespace
--- a/dom/base/File.h +++ b/dom/base/File.h @@ -42,18 +42,18 @@ namespace dom { namespace indexedDB { class FileInfo; }; struct BlobPropertyBag; struct ChromeFilePropertyBag; struct FilePropertyBag; +class BlobImpl; class File; -class FileImpl; class OwningArrayBufferOrArrayBufferViewOrBlobOrString; class Blob : public nsIDOMBlob , public nsIXHRSendable , public nsIMutable , public nsSupportsWeakReference , public nsWrapperCache { @@ -61,17 +61,17 @@ public: NS_DECL_NSIDOMBLOB NS_DECL_NSIXHRSENDABLE NS_DECL_NSIMUTABLE NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Blob, nsIDOMBlob) static Blob* - Create(nsISupports* aParent, FileImpl* aImpl); + Create(nsISupports* aParent, BlobImpl* aImpl); static already_AddRefed<Blob> Create(nsISupports* aParent, const nsAString& aContentType, uint64_t aLength); static already_AddRefed<Blob> Create(nsISupports* aParent, const nsAString& aContentType, uint64_t aStart, uint64_t aLength); @@ -83,32 +83,32 @@ 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); - FileImpl* Impl() const + BlobImpl* Impl() const { return mImpl; } bool IsFile() const; - const nsTArray<nsRefPtr<FileImpl>>* GetSubBlobImpls() const; + const nsTArray<nsRefPtr<BlobImpl>>* GetSubBlobImpls() const; // This method returns null if this Blob is not a File; it returns // the same object in case this Blob already implements the File interface; - // otherwise it returns a new File object with the same FileImpl. + // otherwise it returns a new File object with the same BlobImpl. already_AddRefed<File> ToFile(); // This method creates a new File object with the given name and the same - // FileImpl. + // BlobImpl. already_AddRefed<File> ToFile(const nsAString& aName) const; already_AddRefed<Blob> CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv); // WebIDL methods nsISupports* GetParentObject() const @@ -136,26 +136,26 @@ public: already_AddRefed<Blob> Slice(const Optional<int64_t>& aStart, const Optional<int64_t>& aEnd, const nsAString& aContentType, ErrorResult& aRv); protected: // File constructor should never be used directly. Use Blob::Create instead. - Blob(nsISupports* aParent, FileImpl* aImpl); + Blob(nsISupports* aParent, BlobImpl* aImpl); virtual ~Blob() {}; virtual bool HasFileInterface() const { return false; } // The member is the real backend implementation of this File/Blob. // It's thread-safe and not CC-able and it's the only element that is moved // between threads. // Note: we should not store any other state in this class! - nsRefPtr<FileImpl> mImpl; + nsRefPtr<BlobImpl> mImpl; private: nsCOMPtr<nsISupports> mParent; }; class File final : public Blob , public nsIDOMFile { @@ -163,20 +163,20 @@ class File final : public Blob public: NS_DECL_NSIDOMFILE NS_FORWARD_NSIDOMBLOB(Blob::) NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(File, Blob); - // Note: FileImpl must be a File in order to use this method. + // Note: BlobImpl must be a File in order to use this method. // Check impl->IsFile(). static File* - Create(nsISupports* aParent, FileImpl* aImpl); + Create(nsISupports* aParent, BlobImpl* aImpl); static already_AddRefed<File> Create(nsISupports* aParent, const nsAString& aName, const nsAString& aContentType, uint64_t aLength, int64_t aLastModifiedDate); static already_AddRefed<File> Create(nsISupports* aParent, const nsAString& aName, @@ -255,29 +255,29 @@ public: void GetMozFullPath(nsAString& aFilename, ErrorResult& aRv); protected: virtual bool HasFileInterface() const override { return true; } private: // File constructor should never be used directly. Use Blob::Create or // File::Create. - File(nsISupports* aParent, FileImpl* aImpl); + File(nsISupports* aParent, BlobImpl* aImpl); ~File() {}; }; // This is the abstract class for any File backend. It must be nsISupports // because this class must be ref-counted and it has to work with IPC. -class FileImpl : public nsISupports +class BlobImpl : public nsISupports { public: NS_DECLARE_STATIC_IID_ACCESSOR(FILEIMPL_IID) NS_DECL_THREADSAFE_ISUPPORTS - FileImpl() {} + BlobImpl() {} virtual void GetName(nsAString& aName) = 0; virtual nsresult GetPath(nsAString& aName) = 0; virtual int64_t GetLastModified(ErrorResult& aRv) = 0; virtual void SetLastModified(int64_t aLastModified) = 0; @@ -285,25 +285,25 @@ public: virtual void GetMozFullPath(nsAString& aName, ErrorResult& aRv) = 0; virtual void GetMozFullPathInternal(nsAString& aFileName, ErrorResult& aRv) = 0; virtual uint64_t GetSize(ErrorResult& aRv) = 0; virtual void GetType(nsAString& aType) = 0; - already_AddRefed<FileImpl> + already_AddRefed<BlobImpl> Slice(const Optional<int64_t>& aStart, const Optional<int64_t>& aEnd, const nsAString& aContentType, ErrorResult& aRv); - virtual already_AddRefed<FileImpl> + virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) = 0; - virtual const nsTArray<nsRefPtr<FileImpl>>* + virtual const nsTArray<nsRefPtr<BlobImpl>>* GetSubBlobImpls() const = 0; virtual nsresult GetInternalStream(nsIInputStream** aStream) = 0; virtual int64_t GetFileId() = 0; virtual void AddFileInfo(indexedDB::FileInfo* aFileInfo) = 0; @@ -334,65 +334,65 @@ public: // True if this implementation can be sent to other threads. virtual bool MayBeClonedToOtherThreads() const { return true; } protected: - virtual ~FileImpl() {} + virtual ~BlobImpl() {} }; -NS_DEFINE_STATIC_IID_ACCESSOR(FileImpl, FILEIMPL_IID) +NS_DEFINE_STATIC_IID_ACCESSOR(BlobImpl, FILEIMPL_IID) -class FileImplBase : public FileImpl +class BlobImplBase : public BlobImpl { public: - FileImplBase(const nsAString& aName, const nsAString& aContentType, + BlobImplBase(const nsAString& aName, const nsAString& aContentType, uint64_t aLength, int64_t aLastModifiedDate) : mIsFile(true) , mImmutable(false) , mContentType(aContentType) , mName(aName) , mStart(0) , mLength(aLength) , mLastModificationDate(aLastModifiedDate) { // Ensure non-null mContentType by default mContentType.SetIsVoid(false); } - FileImplBase(const nsAString& aName, const nsAString& aContentType, + BlobImplBase(const nsAString& aName, const nsAString& aContentType, uint64_t aLength) : mIsFile(true) , mImmutable(false) , mContentType(aContentType) , mName(aName) , mStart(0) , mLength(aLength) , mLastModificationDate(INT64_MAX) { // Ensure non-null mContentType by default mContentType.SetIsVoid(false); } - FileImplBase(const nsAString& aContentType, uint64_t aLength) + BlobImplBase(const nsAString& aContentType, uint64_t aLength) : mIsFile(false) , mImmutable(false) , mContentType(aContentType) , mStart(0) , mLength(aLength) , mLastModificationDate(INT64_MAX) { // Ensure non-null mContentType by default mContentType.SetIsVoid(false); } - FileImplBase(const nsAString& aContentType, uint64_t aStart, + BlobImplBase(const nsAString& aContentType, uint64_t aStart, uint64_t aLength) : mIsFile(false) , mImmutable(false) , mContentType(aContentType) , mStart(aStart) , mLength(aLength) , mLastModificationDate(INT64_MAX) { @@ -417,24 +417,24 @@ public: virtual uint64_t GetSize(ErrorResult& aRv) override { return mLength; } virtual void GetType(nsAString& aType) override; - virtual already_AddRefed<FileImpl> + virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) override { return nullptr; } - virtual const nsTArray<nsRefPtr<FileImpl>>* + virtual const nsTArray<nsRefPtr<BlobImpl>>* GetSubBlobImpls() const override { return nullptr; } virtual nsresult GetInternalStream(nsIInputStream** aStream) override { return NS_ERROR_NOT_IMPLEMENTED; @@ -501,17 +501,17 @@ public: } virtual bool IsSizeUnknown() const override { return mLength == UINT64_MAX; } protected: - virtual ~FileImplBase() {} + virtual ~BlobImplBase() {} indexedDB::FileInfo* GetFileInfo() const { NS_ASSERTION(IsStoredFile(), "Should only be called on stored files!"); NS_ASSERTION(!mFileInfos.IsEmpty(), "Must have at least one file info!"); return mFileInfos.ElementAt(0); } @@ -531,40 +531,40 @@ protected: // Protected by IndexedDatabaseManager::FileMutex() nsTArray<nsRefPtr<indexedDB::FileInfo>> mFileInfos; }; /** * This class may be used off the main thread, and in particular, its * constructor and destructor may not run on the same thread. Be careful! */ -class FileImplMemory final : public FileImplBase +class BlobImplMemory final : public BlobImplBase { public: NS_DECL_ISUPPORTS_INHERITED - FileImplMemory(void* aMemoryBuffer, uint64_t aLength, const nsAString& aName, + BlobImplMemory(void* aMemoryBuffer, uint64_t aLength, const nsAString& aName, const nsAString& aContentType, int64_t aLastModifiedDate) - : FileImplBase(aName, aContentType, aLength, aLastModifiedDate) + : BlobImplBase(aName, aContentType, aLength, aLastModifiedDate) , mDataOwner(new DataOwner(aMemoryBuffer, aLength)) { NS_ASSERTION(mDataOwner && mDataOwner->mData, "must have data"); } - FileImplMemory(void* aMemoryBuffer, uint64_t aLength, + BlobImplMemory(void* aMemoryBuffer, uint64_t aLength, const nsAString& aContentType) - : FileImplBase(aContentType, aLength) + : BlobImplBase(aContentType, aLength) , mDataOwner(new DataOwner(aMemoryBuffer, aLength)) { NS_ASSERTION(mDataOwner && mDataOwner->mData, "must have data"); } virtual nsresult GetInternalStream(nsIInputStream** aStream) override; - virtual already_AddRefed<FileImpl> + virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) override; virtual bool IsMemoryFile() const override { return true; } @@ -610,170 +610,170 @@ public: static bool sMemoryReporterRegistered; void* mData; uint64_t mLength; }; private: // Create slice - FileImplMemory(const FileImplMemory* aOther, uint64_t aStart, + BlobImplMemory(const BlobImplMemory* aOther, uint64_t aStart, uint64_t aLength, const nsAString& aContentType) - : FileImplBase(aContentType, aOther->mStart + aStart, aLength) + : BlobImplBase(aContentType, aOther->mStart + aStart, aLength) , mDataOwner(aOther->mDataOwner) { NS_ASSERTION(mDataOwner && mDataOwner->mData, "must have data"); mImmutable = aOther->mImmutable; } - ~FileImplMemory() {} + ~BlobImplMemory() {} // Used when backed by a memory store nsRefPtr<DataOwner> mDataOwner; }; -class FileImplTemporaryBlob final : public FileImplBase +class BlobImplTemporaryBlob final : public BlobImplBase { public: NS_DECL_ISUPPORTS_INHERITED - FileImplTemporaryBlob(PRFileDesc* aFD, uint64_t aStartPos, + BlobImplTemporaryBlob(PRFileDesc* aFD, uint64_t aStartPos, uint64_t aLength, const nsAString& aContentType) - : FileImplBase(aContentType, aLength) + : BlobImplBase(aContentType, aLength) , mStartPos(aStartPos) { mFileDescOwner = new nsTemporaryFileInputStream::FileDescOwner(aFD); } virtual nsresult GetInternalStream(nsIInputStream** aStream) override; - virtual already_AddRefed<FileImpl> + virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) override; private: - FileImplTemporaryBlob(const FileImplTemporaryBlob* aOther, + BlobImplTemporaryBlob(const BlobImplTemporaryBlob* aOther, uint64_t aStart, uint64_t aLength, const nsAString& aContentType) - : FileImplBase(aContentType, aLength) + : BlobImplBase(aContentType, aLength) , mStartPos(aStart) , mFileDescOwner(aOther->mFileDescOwner) {} - ~FileImplTemporaryBlob() {} + ~BlobImplTemporaryBlob() {} uint64_t mStartPos; nsRefPtr<nsTemporaryFileInputStream::FileDescOwner> mFileDescOwner; }; -class FileImplFile : public FileImplBase +class BlobImplFile : public BlobImplBase { public: NS_DECL_ISUPPORTS_INHERITED // Create as a file - explicit FileImplFile(nsIFile* aFile, bool aTemporary = false) - : FileImplBase(EmptyString(), EmptyString(), UINT64_MAX, INT64_MAX) + explicit BlobImplFile(nsIFile* aFile, bool aTemporary = false) + : BlobImplBase(EmptyString(), EmptyString(), UINT64_MAX, INT64_MAX) , mFile(aFile) , mWholeFile(true) , mStoredFile(false) , mIsTemporary(aTemporary) { NS_ASSERTION(mFile, "must have file"); // Lazily get the content type and size mContentType.SetIsVoid(true); mFile->GetLeafName(mName); } - FileImplFile(nsIFile* aFile, indexedDB::FileInfo* aFileInfo) - : FileImplBase(EmptyString(), EmptyString(), UINT64_MAX, INT64_MAX) + BlobImplFile(nsIFile* aFile, indexedDB::FileInfo* aFileInfo) + : BlobImplBase(EmptyString(), EmptyString(), UINT64_MAX, INT64_MAX) , mFile(aFile) , mWholeFile(true) , mStoredFile(true) , mIsTemporary(false) { NS_ASSERTION(mFile, "must have file"); NS_ASSERTION(aFileInfo, "must have file info"); // Lazily get the content type and size mContentType.SetIsVoid(true); mFile->GetLeafName(mName); mFileInfos.AppendElement(aFileInfo); } // Create as a file - FileImplFile(const nsAString& aName, const nsAString& aContentType, + BlobImplFile(const nsAString& aName, const nsAString& aContentType, uint64_t aLength, nsIFile* aFile) - : FileImplBase(aName, aContentType, aLength, UINT64_MAX) + : BlobImplBase(aName, aContentType, aLength, UINT64_MAX) , mFile(aFile) , mWholeFile(true) , mStoredFile(false) , mIsTemporary(false) { NS_ASSERTION(mFile, "must have file"); } - FileImplFile(const nsAString& aName, const nsAString& aContentType, + BlobImplFile(const nsAString& aName, const nsAString& aContentType, uint64_t aLength, nsIFile* aFile, int64_t aLastModificationDate) - : FileImplBase(aName, aContentType, aLength, aLastModificationDate) + : BlobImplBase(aName, aContentType, aLength, aLastModificationDate) , mFile(aFile) , mWholeFile(true) , mStoredFile(false) , mIsTemporary(false) { NS_ASSERTION(mFile, "must have file"); } // Create as a file with custom name - FileImplFile(nsIFile* aFile, const nsAString& aName, + BlobImplFile(nsIFile* aFile, const nsAString& aName, const nsAString& aContentType) - : FileImplBase(aName, aContentType, UINT64_MAX, INT64_MAX) + : BlobImplBase(aName, aContentType, UINT64_MAX, INT64_MAX) , mFile(aFile) , mWholeFile(true) , mStoredFile(false) , mIsTemporary(false) { NS_ASSERTION(mFile, "must have file"); if (aContentType.IsEmpty()) { // Lazily get the content type and size mContentType.SetIsVoid(true); } } // Create as a stored file - FileImplFile(const nsAString& aName, const nsAString& aContentType, + BlobImplFile(const nsAString& aName, const nsAString& aContentType, uint64_t aLength, nsIFile* aFile, indexedDB::FileInfo* aFileInfo) - : FileImplBase(aName, aContentType, aLength, UINT64_MAX) + : BlobImplBase(aName, aContentType, aLength, UINT64_MAX) , mFile(aFile) , mWholeFile(true) , mStoredFile(true) , mIsTemporary(false) { NS_ASSERTION(mFile, "must have file"); mFileInfos.AppendElement(aFileInfo); } // Create as a stored blob - FileImplFile(const nsAString& aContentType, uint64_t aLength, + BlobImplFile(const nsAString& aContentType, uint64_t aLength, nsIFile* aFile, indexedDB::FileInfo* aFileInfo) - : FileImplBase(aContentType, aLength) + : BlobImplBase(aContentType, aLength) , mFile(aFile) , mWholeFile(true) , mStoredFile(true) , mIsTemporary(false) { NS_ASSERTION(mFile, "must have file"); mFileInfos.AppendElement(aFileInfo); } // Create as a file to be later initialized - FileImplFile() - : FileImplBase(EmptyString(), EmptyString(), UINT64_MAX, INT64_MAX) + BlobImplFile() + : BlobImplBase(EmptyString(), EmptyString(), UINT64_MAX, INT64_MAX) , mWholeFile(true) , mStoredFile(false) , mIsTemporary(false) { // Lazily get the content type and size mContentType.SetIsVoid(true); mName.SetIsVoid(true); } @@ -785,34 +785,34 @@ public: virtual void SetLastModified(int64_t aLastModified) override; virtual void GetMozFullPathInternal(nsAString& aFullPath, ErrorResult& aRv) override; virtual nsresult GetInternalStream(nsIInputStream**) override; void SetPath(const nsAString& aFullPath); protected: - virtual ~FileImplFile() { + virtual ~BlobImplFile() { if (mFile && mIsTemporary) { - NS_WARNING("In temporary ~FileImplFile"); + NS_WARNING("In temporary ~BlobImplFile"); // Ignore errors if any, not much we can do. Clean-up will be done by // https://mxr.mozilla.org/mozilla-central/source/xpcom/io/nsAnonymousTemporaryFile.cpp?rev=6c1c7e45c902#127 #ifdef DEBUG nsresult rv = #endif mFile->Remove(false); NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to remove temporary DOMFile."); } } private: // Create slice - FileImplFile(const FileImplFile* aOther, uint64_t aStart, + BlobImplFile(const BlobImplFile* aOther, uint64_t aStart, uint64_t aLength, const nsAString& aContentType) - : FileImplBase(aContentType, aOther->mStart + aStart, aLength) + : BlobImplBase(aContentType, aOther->mStart + aStart, aLength) , mFile(aOther->mFile) , mWholeFile(false) , mStoredFile(aOther->mStoredFile) , mIsTemporary(false) { NS_ASSERTION(mFile, "must have file"); mImmutable = aOther->mImmutable; @@ -828,17 +828,17 @@ private: mozilla::MutexAutoLock lock(IndexedDatabaseManager::FileMutex()); fileInfo = aOther->GetFileInfo(); } mFileInfos.AppendElement(fileInfo); } } - virtual already_AddRefed<FileImpl> + virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) override; virtual bool IsStoredFile() const override { return mStoredFile; }
--- a/dom/base/MessagePort.cpp +++ b/dom/base/MessagePort.cpp @@ -106,19 +106,19 @@ PostMessageReadStructuredClone(JSContext void* closure) { StructuredCloneInfo* scInfo = static_cast<StructuredCloneInfo*>(closure); NS_ASSERTION(scInfo, "Must have scInfo!"); if (tag == SCTAG_DOM_BLOB) { NS_ASSERTION(!data, "Data should be empty"); - // What we get back from the reader is a FileImpl. + // What we get back from the reader is a BlobImpl. // From that we create a new File. - FileImpl* blobImpl; + BlobImpl* blobImpl; if (JS_ReadBytes(reader, &blobImpl, sizeof(blobImpl))) { MOZ_ASSERT(blobImpl); // nsRefPtr<File> needs to go out of scope before toObjectOrNull() is // called because the static analysis thinks dereferencing XPCOM objects // can GC (because in some cases it can!), and a return statement with a // JSObject* type means that JSObject* is on the stack as a raw pointer // while destructors are running. @@ -165,17 +165,17 @@ PostMessageWriteStructuredClone(JSContex { StructuredCloneInfo* scInfo = static_cast<StructuredCloneInfo*>(closure); NS_ASSERTION(scInfo, "Must have scInfo!"); // See if this is a File/Blob object. { Blob* blob = nullptr; if (NS_SUCCEEDED(UNWRAP_OBJECT(Blob, obj, blob))) { - FileImpl* blobImpl = blob->Impl(); + BlobImpl* blobImpl = blob->Impl(); if (JS_WriteUint32Pair(writer, SCTAG_DOM_BLOB, 0) && JS_WriteBytes(writer, &blobImpl, sizeof(blobImpl))) { scInfo->mEvent->StoreISupports(blobImpl); return true; } } }
rename from dom/base/MultipartFileImpl.cpp rename to dom/base/MultipartBlobImpl.cpp --- a/dom/base/MultipartFileImpl.cpp +++ b/dom/base/MultipartBlobImpl.cpp @@ -1,15 +1,15 @@ /* -*- 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 "MultipartFileImpl.h" +#include "MultipartBlobImpl.h" #include "jsfriendapi.h" #include "mozilla/dom/BlobSet.h" #include "mozilla/dom/FileBinding.h" #include "mozilla/dom/UnionTypes.h" #include "nsAutoPtr.h" #include "nsDOMClassInfoID.h" #include "nsIMultiplexInputStream.h" #include "nsStringStream.h" @@ -18,125 +18,125 @@ #include "nsContentUtils.h" #include "nsIScriptError.h" #include "nsIXPConnect.h" #include <algorithm> using namespace mozilla; using namespace mozilla::dom; -NS_IMPL_ISUPPORTS_INHERITED0(MultipartFileImpl, FileImpl) +NS_IMPL_ISUPPORTS_INHERITED0(MultipartBlobImpl, BlobImpl) nsresult -MultipartFileImpl::GetInternalStream(nsIInputStream** aStream) +MultipartBlobImpl::GetInternalStream(nsIInputStream** aStream) { nsresult rv; *aStream = nullptr; nsCOMPtr<nsIMultiplexInputStream> stream = do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1"); NS_ENSURE_TRUE(stream, NS_ERROR_FAILURE); uint32_t i; for (i = 0; i < mBlobImpls.Length(); i++) { nsCOMPtr<nsIInputStream> scratchStream; - FileImpl* blobImpl = mBlobImpls.ElementAt(i).get(); + BlobImpl* blobImpl = mBlobImpls.ElementAt(i).get(); rv = blobImpl->GetInternalStream(getter_AddRefs(scratchStream)); NS_ENSURE_SUCCESS(rv, rv); rv = stream->AppendStream(scratchStream); NS_ENSURE_SUCCESS(rv, rv); } stream.forget(aStream); return NS_OK; } -already_AddRefed<FileImpl> -MultipartFileImpl::CreateSlice(uint64_t aStart, uint64_t aLength, +already_AddRefed<BlobImpl> +MultipartBlobImpl::CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) { // If we clamped to nothing we create an empty blob - nsTArray<nsRefPtr<FileImpl>> blobImpls; + nsTArray<nsRefPtr<BlobImpl>> blobImpls; uint64_t length = aLength; uint64_t skipStart = aStart; // Prune the list of blobs if we can uint32_t i; for (i = 0; length && skipStart && i < mBlobImpls.Length(); i++) { - FileImpl* blobImpl = mBlobImpls[i].get(); + BlobImpl* blobImpl = mBlobImpls[i].get(); uint64_t l = blobImpl->GetSize(aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr; } if (skipStart < l) { uint64_t upperBound = std::min<uint64_t>(l - skipStart, length); - nsRefPtr<FileImpl> firstBlobImpl = + nsRefPtr<BlobImpl> firstBlobImpl = blobImpl->CreateSlice(skipStart, upperBound, aContentType, aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr; } - // Avoid wrapping a single blob inside an MultipartFileImpl + // Avoid wrapping a single blob inside an MultipartBlobImpl if (length == upperBound) { return firstBlobImpl.forget(); } blobImpls.AppendElement(firstBlobImpl); length -= upperBound; i++; break; } skipStart -= l; } // Now append enough blobs until we're done for (; length && i < mBlobImpls.Length(); i++) { - FileImpl* blobImpl = mBlobImpls[i].get(); + BlobImpl* blobImpl = mBlobImpls[i].get(); uint64_t l = blobImpl->GetSize(aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr; } if (length < l) { - nsRefPtr<FileImpl> lastBlobImpl = + nsRefPtr<BlobImpl> lastBlobImpl = blobImpl->CreateSlice(0, length, aContentType, aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr; } blobImpls.AppendElement(lastBlobImpl); } else { blobImpls.AppendElement(blobImpl); } length -= std::min<uint64_t>(l, length); } // we can create our blob now - nsRefPtr<FileImpl> impl = - new MultipartFileImpl(blobImpls, aContentType); + nsRefPtr<BlobImpl> impl = + new MultipartBlobImpl(blobImpls, aContentType); return impl.forget(); } void -MultipartFileImpl::InitializeBlob() +MultipartBlobImpl::InitializeBlob() { SetLengthAndModifiedDate(); } void -MultipartFileImpl::InitializeBlob( +MultipartBlobImpl::InitializeBlob( JSContext* aCx, const Sequence<OwningArrayBufferOrArrayBufferViewOrBlobOrString>& aData, const nsAString& aContentType, bool aNativeEOL, ErrorResult& aRv) { mContentType = aContentType; BlobSet blobSet; @@ -180,27 +180,27 @@ MultipartFileImpl::InitializeBlob( } mBlobImpls = blobSet.GetBlobImpls(); SetLengthAndModifiedDate(); } void -MultipartFileImpl::SetLengthAndModifiedDate() +MultipartBlobImpl::SetLengthAndModifiedDate() { MOZ_ASSERT(mLength == UINT64_MAX); MOZ_ASSERT(mLastModificationDate == INT64_MAX); uint64_t totalLength = 0; int64_t lastModified = 0; bool lastModifiedSet = false; for (uint32_t index = 0, count = mBlobImpls.Length(); index < count; index++) { - nsRefPtr<FileImpl>& blob = mBlobImpls[index]; + nsRefPtr<BlobImpl>& blob = mBlobImpls[index]; #ifdef DEBUG MOZ_ASSERT(!blob->IsSizeUnknown()); MOZ_ASSERT(!blob->IsDateUnknown()); #endif ErrorResult error; uint64_t subBlobLength = blob->GetSize(error); @@ -228,65 +228,65 @@ MultipartFileImpl::SetLengthAndModifiedD // x.getTime() < f.dateModified.getTime() // could fail. mLastModificationDate = lastModifiedSet ? lastModified * PR_USEC_PER_MSEC : JS_Now(); } } void -MultipartFileImpl::GetMozFullPathInternal(nsAString& aFilename, +MultipartBlobImpl::GetMozFullPathInternal(nsAString& aFilename, ErrorResult& aRv) { if (!mIsFromNsIFile || mBlobImpls.Length() == 0) { - FileImplBase::GetMozFullPathInternal(aFilename, aRv); + BlobImplBase::GetMozFullPathInternal(aFilename, aRv); return; } - FileImpl* blobImpl = mBlobImpls.ElementAt(0).get(); + BlobImpl* blobImpl = mBlobImpls.ElementAt(0).get(); if (!blobImpl) { - FileImplBase::GetMozFullPathInternal(aFilename, aRv); + BlobImplBase::GetMozFullPathInternal(aFilename, aRv); return; } blobImpl->GetMozFullPathInternal(aFilename, aRv); } nsresult -MultipartFileImpl::SetMutable(bool aMutable) +MultipartBlobImpl::SetMutable(bool aMutable) { nsresult rv; - // This looks a little sketchy since FileImpl objects are supposed to be - // threadsafe. However, we try to enforce that all FileImpl objects must be + // This looks a little sketchy since BlobImpl objects are supposed to be + // threadsafe. However, we try to enforce that all BlobImpl objects must be // set to immutable *before* being passed to another thread, so this should // be safe. if (!aMutable && !mImmutable && !mBlobImpls.IsEmpty()) { for (uint32_t index = 0, count = mBlobImpls.Length(); index < count; index++) { rv = mBlobImpls[index]->SetMutable(aMutable); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } } } - rv = FileImplBase::SetMutable(aMutable); + rv = BlobImplBase::SetMutable(aMutable); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } MOZ_ASSERT_IF(!aMutable, mImmutable); return NS_OK; } void -MultipartFileImpl::InitializeChromeFile(Blob& aBlob, +MultipartBlobImpl::InitializeChromeFile(Blob& aBlob, const ChromeFilePropertyBag& aBag, ErrorResult& aRv) { NS_ASSERTION(!mImmutable, "Something went wrong ..."); if (mImmutable) { aRv.Throw(NS_ERROR_UNEXPECTED); return; @@ -307,17 +307,17 @@ MultipartFileImpl::InitializeChromeFile( BlobSet blobSet; blobSet.AppendBlobImpl(aBlob.Impl()); mBlobImpls = blobSet.GetBlobImpls(); SetLengthAndModifiedDate(); } void -MultipartFileImpl::InitializeChromeFile(nsPIDOMWindow* aWindow, +MultipartBlobImpl::InitializeChromeFile(nsPIDOMWindow* aWindow, nsIFile* aFile, const ChromeFilePropertyBag& aBag, bool aIsFromNsIFile, ErrorResult& aRv) { NS_ASSERTION(!mImmutable, "Something went wrong ..."); if (mImmutable) { aRv.Throw(NS_ERROR_UNEXPECTED); @@ -380,32 +380,32 @@ MultipartFileImpl::InitializeChromeFile( BlobSet blobSet; blobSet.AppendBlobImpl(static_cast<File*>(blob.get())->Impl()); mBlobImpls = blobSet.GetBlobImpls(); SetLengthAndModifiedDate(); } void -MultipartFileImpl::InitializeChromeFile(nsPIDOMWindow* aWindow, +MultipartBlobImpl::InitializeChromeFile(nsPIDOMWindow* aWindow, const nsAString& aData, const ChromeFilePropertyBag& aBag, ErrorResult& aRv) { nsCOMPtr<nsIFile> file; aRv = NS_NewLocalFile(aData, false, getter_AddRefs(file)); if (NS_WARN_IF(aRv.Failed())) { return; } InitializeChromeFile(aWindow, file, aBag, false, aRv); } bool -MultipartFileImpl::MayBeClonedToOtherThreads() const +MultipartBlobImpl::MayBeClonedToOtherThreads() const { for (uint32_t i = 0; i < mBlobImpls.Length(); ++i) { if (!mBlobImpls[i]->MayBeClonedToOtherThreads()) { return false; } } return true;
rename from dom/base/MultipartFileImpl.h rename to dom/base/MultipartBlobImpl.h --- a/dom/base/MultipartFileImpl.h +++ b/dom/base/MultipartBlobImpl.h @@ -1,64 +1,64 @@ /* -*- 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_MultipartFileImpl_h -#define mozilla_dom_MultipartFileImpl_h +#ifndef mozilla_dom_MultipartBlobImpl_h +#define mozilla_dom_MultipartBlobImpl_h #include "mozilla/Attributes.h" #include "mozilla/CheckedInt.h" #include "mozilla/ErrorResult.h" #include "mozilla/dom/File.h" #include "mozilla/dom/BlobBinding.h" #include "mozilla/dom/FileBinding.h" #include <algorithm> using namespace mozilla; using namespace mozilla::dom; -class MultipartFileImpl final : public FileImplBase +class MultipartBlobImpl final : public BlobImplBase { public: NS_DECL_ISUPPORTS_INHERITED // Create as a file - MultipartFileImpl(const nsTArray<nsRefPtr<FileImpl>>& aBlobImpls, + MultipartBlobImpl(const nsTArray<nsRefPtr<BlobImpl>>& aBlobImpls, const nsAString& aName, const nsAString& aContentType) - : FileImplBase(aName, aContentType, UINT64_MAX), + : BlobImplBase(aName, aContentType, UINT64_MAX), mBlobImpls(aBlobImpls), mIsFromNsIFile(false) { SetLengthAndModifiedDate(); } // Create as a blob - MultipartFileImpl(const nsTArray<nsRefPtr<FileImpl>>& aBlobImpls, + MultipartBlobImpl(const nsTArray<nsRefPtr<BlobImpl>>& aBlobImpls, const nsAString& aContentType) - : FileImplBase(aContentType, UINT64_MAX), + : BlobImplBase(aContentType, UINT64_MAX), mBlobImpls(aBlobImpls), mIsFromNsIFile(false) { SetLengthAndModifiedDate(); } // Create as a file to be later initialized - explicit MultipartFileImpl(const nsAString& aName) - : FileImplBase(aName, EmptyString(), UINT64_MAX), + explicit MultipartBlobImpl(const nsAString& aName) + : BlobImplBase(aName, EmptyString(), UINT64_MAX), mIsFromNsIFile(false) { } // Create as a blob to be later initialized - MultipartFileImpl() - : FileImplBase(EmptyString(), UINT64_MAX), + MultipartBlobImpl() + : BlobImplBase(EmptyString(), UINT64_MAX), mIsFromNsIFile(false) { } void InitializeBlob(); void InitializeBlob( JSContext* aCx, @@ -77,29 +77,29 @@ public: ErrorResult& aRv); void InitializeChromeFile(nsPIDOMWindow* aWindow, nsIFile* aData, const ChromeFilePropertyBag& aBag, bool aIsFromNsIFile, ErrorResult& aRv); - virtual already_AddRefed<FileImpl> + virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) override; virtual uint64_t GetSize(ErrorResult& aRv) override { return mLength; } virtual nsresult GetInternalStream(nsIInputStream** aInputStream) override; - virtual const nsTArray<nsRefPtr<FileImpl>>* GetSubBlobImpls() const override + virtual const nsTArray<nsRefPtr<BlobImpl>>* GetSubBlobImpls() const override { return &mBlobImpls; } virtual void GetMozFullPathInternal(nsAString& aFullPath, ErrorResult& aRv) override; virtual nsresult @@ -113,17 +113,17 @@ public: void SetFromNsIFile(bool aValue) { mIsFromNsIFile = aValue; } virtual bool MayBeClonedToOtherThreads() const override; protected: - virtual ~MultipartFileImpl() {} + virtual ~MultipartBlobImpl() {} void SetLengthAndModifiedDate(); - nsTArray<nsRefPtr<FileImpl>> mBlobImpls; + nsTArray<nsRefPtr<BlobImpl>> mBlobImpls; bool mIsFromNsIFile; }; -#endif // mozilla_dom_MultipartFileImpl_h +#endif // mozilla_dom_MultipartBlobImpl_h
--- a/dom/base/moz.build +++ b/dom/base/moz.build @@ -232,17 +232,17 @@ UNIFIED_SOURCES += [ 'File.cpp', 'FileIOObject.cpp', 'FragmentOrElement.cpp', 'ImageEncoder.cpp', 'ImportManager.cpp', 'Link.cpp', 'MessageChannel.cpp', 'MessagePortList.cpp', - 'MultipartFileImpl.cpp', + 'MultipartBlobImpl.cpp', 'Navigator.cpp', 'NodeInfo.cpp', 'NodeIterator.cpp', 'nsAtomListUtils.cpp', 'nsAttrAndChildArray.cpp', 'nsAttrValue.cpp', 'nsAttrValueOrString.cpp', 'nsCCUncollectableMarker.cpp',
--- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -7342,37 +7342,37 @@ nsContentUtils::TransferableToIPCTransfe imageDetails.stride() = stride; imageDetails.format() = static_cast<uint8_t>(dataSurface->GetFormat()); } continue; } // Otherwise, handle this as a file. - nsCOMPtr<FileImpl> fileImpl; + nsCOMPtr<BlobImpl> blobImpl; nsCOMPtr<nsIFile> file = do_QueryInterface(data); if (file) { - fileImpl = new FileImplFile(file, false); + blobImpl = new BlobImplFile(file, false); ErrorResult rv; - fileImpl->GetSize(rv); - fileImpl->GetLastModified(rv); + blobImpl->GetSize(rv); + blobImpl->GetLastModified(rv); } else { - fileImpl = do_QueryInterface(data); + blobImpl = do_QueryInterface(data); } - if (fileImpl) { + if (blobImpl) { IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement(); item->flavor() = nsCString(flavorStr); if (aChild) { item->data() = mozilla::dom::BlobChild::GetOrCreate(aChild, - static_cast<FileImpl*>(fileImpl.get())); + static_cast<BlobImpl*>(blobImpl.get())); } else if (aParent) { item->data() = mozilla::dom::BlobParent::GetOrCreate(aParent, - static_cast<FileImpl*>(fileImpl.get())); + static_cast<BlobImpl*>(blobImpl.get())); } } else { // This is a hack to support kFilePromiseMime. // On Windows there just needs to be an entry for it, // and for OSX we need to create // nsContentAreaDragDropDataProvider as nsIFlavorDataProvider. if (flavorStr.EqualsLiteral(kFilePromiseMime)) { IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
--- a/dom/base/nsFormData.cpp +++ b/dom/base/nsFormData.cpp @@ -5,17 +5,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsFormData.h" #include "nsIVariant.h" #include "nsIInputStream.h" #include "mozilla/dom/File.h" #include "mozilla/dom/HTMLFormElement.h" -#include "MultipartFileImpl.h" +#include "MultipartBlobImpl.h" using namespace mozilla; using namespace mozilla::dom; nsFormData::nsFormData(nsISupports* aOwner) : nsFormSubmission(NS_LITERAL_CSTRING("UTF-8"), nullptr) , mOwner(aOwner) {
--- a/dom/base/nsFrameMessageManager.cpp +++ b/dom/base/nsFrameMessageManager.cpp @@ -259,17 +259,17 @@ UnpackClonedMessageData(const ClonedMess if (!blobs.IsEmpty()) { uint32_t length = blobs.Length(); cloneData.mClosure.mBlobs.SetCapacity(length); for (uint32_t i = 0; i < length; ++i) { auto* blob = static_cast<typename BlobTraits<Flavor>::BlobType*>(blobs[i]); MOZ_ASSERT(blob); - nsRefPtr<FileImpl> blobImpl = blob->GetBlobImpl(); + nsRefPtr<BlobImpl> blobImpl = blob->GetBlobImpl(); MOZ_ASSERT(blobImpl); // This object will be duplicated with a correct parent before being // exposed to JS. nsRefPtr<Blob> domBlob = Blob::Create(nullptr, blobImpl); cloneData.mClosure.mBlobs.AppendElement(domBlob); } }
--- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -8045,19 +8045,19 @@ PostMessageReadStructuredClone(JSContext void* closure) { StructuredCloneInfo* scInfo = static_cast<StructuredCloneInfo*>(closure); NS_ASSERTION(scInfo, "Must have scInfo!"); if (tag == SCTAG_DOM_BLOB) { NS_ASSERTION(!data, "Data should be empty"); - // What we get back from the reader is a FileImpl. + // What we get back from the reader is a BlobImpl. // From that we create a new File. - FileImpl* blobImpl; + BlobImpl* blobImpl; if (JS_ReadBytes(reader, &blobImpl, sizeof(blobImpl))) { MOZ_ASSERT(blobImpl); // nsRefPtr<File> needs to go out of scope before toObjectOrNull() is // called because the static analysis thinks dereferencing XPCOM objects // can GC (because in some cases it can!), and a return statement with a // JSObject* type means that JSObject* is on the stack as a raw pointer // while destructors are running. @@ -8103,17 +8103,17 @@ PostMessageWriteStructuredClone(JSContex { StructuredCloneInfo* scInfo = static_cast<StructuredCloneInfo*>(closure); NS_ASSERTION(scInfo, "Must have scInfo!"); // See if this is a File/Blob object. { Blob* blob = nullptr; if (scInfo->subsumes && NS_SUCCEEDED(UNWRAP_OBJECT(Blob, obj, blob))) { - FileImpl* blobImpl = blob->Impl(); + BlobImpl* blobImpl = blob->Impl(); if (JS_WriteUint32Pair(writer, SCTAG_DOM_BLOB, 0) && JS_WriteBytes(writer, &blobImpl, sizeof(blobImpl))) { scInfo->event->StoreISupports(blobImpl); return true; } } }
--- a/dom/base/nsHostObjectProtocolHandler.cpp +++ b/dom/base/nsHostObjectProtocolHandler.cpp @@ -12,17 +12,17 @@ #include "nsIPrincipal.h" #include "DOMMediaStream.h" #include "mozilla/dom/MediaSource.h" #include "nsIMemoryReporter.h" #include "mozilla/dom/File.h" #include "mozilla/Preferences.h" #include "mozilla/LoadInfo.h" -using mozilla::dom::FileImpl; +using mozilla::dom::BlobImpl; using mozilla::ErrorResult; using mozilla::LoadInfo; // ----------------------------------------------------------------------- // Hash table struct DataInfo { // mObject is expected to be an nsIDOMBlob, DOMMediaStream, or MediaSource @@ -525,17 +525,17 @@ nsHostObjectProtocolHandler::NewChannel2 uri->GetSpec(spec); DataInfo* info = GetDataInfo(spec); if (!info) { return NS_ERROR_DOM_BAD_URI; } - nsCOMPtr<FileImpl> blob = do_QueryInterface(info->mObject); + nsCOMPtr<BlobImpl> blob = do_QueryInterface(info->mObject); if (!blob) { return NS_ERROR_DOM_BAD_URI; } #ifdef DEBUG { nsCOMPtr<nsIURIWithPrincipal> uriPrinc = do_QueryInterface(uri); nsCOMPtr<nsIPrincipal> principal; @@ -620,35 +620,35 @@ nsMediaSourceProtocolHandler::GetScheme( NS_IMETHODIMP nsFontTableProtocolHandler::GetScheme(nsACString &result) { result.AssignLiteral(FONTTABLEURI_SCHEME); return NS_OK; } nsresult -NS_GetBlobForBlobURI(nsIURI* aURI, FileImpl** aBlob) +NS_GetBlobForBlobURI(nsIURI* aURI, BlobImpl** aBlob) { NS_ASSERTION(IsBlobURI(aURI), "Only call this with blob URIs"); *aBlob = nullptr; - nsCOMPtr<FileImpl> blob = do_QueryInterface(GetDataObject(aURI)); + nsCOMPtr<BlobImpl> blob = do_QueryInterface(GetDataObject(aURI)); if (!blob) { return NS_ERROR_DOM_BAD_URI; } blob.forget(aBlob); return NS_OK; } nsresult NS_GetStreamForBlobURI(nsIURI* aURI, nsIInputStream** aStream) { - nsRefPtr<FileImpl> blobImpl; + nsRefPtr<BlobImpl> blobImpl; nsresult rv = NS_GetBlobForBlobURI(aURI, getter_AddRefs(blobImpl)); if (NS_FAILED(rv)) { return rv; } return blobImpl->GetInternalStream(aStream); }
--- a/dom/base/nsHostObjectProtocolHandler.h +++ b/dom/base/nsHostObjectProtocolHandler.h @@ -19,17 +19,17 @@ #define FONTTABLEURI_SCHEME "moz-fonttable" #define RTSPURI_SCHEME "rtsp" class nsIPrincipal; namespace mozilla { class DOMMediaStream; namespace dom { -class FileImpl; +class BlobImpl; class MediaSource; } } class nsHostObjectProtocolHandler : public nsIProtocolHandler { public: nsHostObjectProtocolHandler(); @@ -117,17 +117,17 @@ inline bool IsMediaSourceURI(nsIURI* aUr inline bool IsFontTableURI(nsIURI* aUri) { bool isFont; return NS_SUCCEEDED(aUri->SchemeIs(FONTTABLEURI_SCHEME, &isFont)) && isFont; } extern nsresult -NS_GetBlobForBlobURI(nsIURI* aURI, mozilla::dom::FileImpl** aBlob); +NS_GetBlobForBlobURI(nsIURI* aURI, mozilla::dom::BlobImpl** aBlob); extern nsresult NS_GetStreamForBlobURI(nsIURI* aURI, nsIInputStream** aStream); extern nsresult NS_GetStreamForMediaStreamURI(nsIURI* aURI, mozilla::DOMMediaStream** aStream); extern nsresult
--- a/dom/base/nsIGlobalObject.cpp +++ b/dom/base/nsIGlobalObject.cpp @@ -94,17 +94,17 @@ nsIGlobalObject::UnlinkHostObjectURIs() void nsIGlobalObject::TraverseHostObjectURIs(nsCycleCollectionTraversalCallback &aCb) { if (mHostObjectURIs.IsEmpty()) { return; } - // Currently we only store FileImpl objects off the the main-thread and they + // Currently we only store BlobImpl objects off the the main-thread and they // are not CCed. if (!NS_IsMainThread()) { return; } for (uint32_t index = 0; index < mHostObjectURIs.Length(); ++index) { nsHostObjectProtocolHandler::Traverse(mHostObjectURIs[index], aCb); }
--- a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp @@ -407,17 +407,17 @@ BluetoothOppManager::StartSendingNextFil } bool BluetoothOppManager::SendFile(const nsAString& aDeviceAddress, BlobParent* aActor) { MOZ_ASSERT(NS_IsMainThread()); - nsRefPtr<FileImpl> impl = aActor->GetBlobImpl(); + nsRefPtr<BlobImpl> impl = aActor->GetBlobImpl(); nsRefPtr<Blob> blob = Blob::Create(nullptr, impl); return SendFile(aDeviceAddress, blob.get()); } bool BluetoothOppManager::SendFile(const nsAString& aDeviceAddress, nsIDOMBlob* aBlob)
--- a/dom/bluetooth/bluez/BluetoothOppManager.cpp +++ b/dom/bluetooth/bluez/BluetoothOppManager.cpp @@ -379,17 +379,17 @@ BluetoothOppManager::StartSendingNextFil } bool BluetoothOppManager::SendFile(const nsAString& aDeviceAddress, BlobParent* aActor) { MOZ_ASSERT(NS_IsMainThread()); - nsRefPtr<FileImpl> impl = aActor->GetBlobImpl(); + nsRefPtr<BlobImpl> impl = aActor->GetBlobImpl(); nsCOMPtr<nsIDOMBlob> blob = new File(nullptr, impl); return SendFile(aDeviceAddress, blob.get()); } bool BluetoothOppManager::SendFile(const nsAString& aDeviceAddress, nsIDOMBlob* aBlob)
--- a/dom/broadcastchannel/BroadcastChannelChild.cpp +++ b/dom/broadcastchannel/BroadcastChannelChild.cpp @@ -42,17 +42,17 @@ BroadcastChannelChild::RecvNotify(const { // Make sure to retrieve all blobs from the message before returning to avoid // leaking their actors. nsTArray<nsRefPtr<Blob>> blobs; if (!aData.blobsChild().IsEmpty()) { blobs.SetCapacity(aData.blobsChild().Length()); for (uint32_t i = 0, len = aData.blobsChild().Length(); i < len; ++i) { - nsRefPtr<FileImpl> impl = + nsRefPtr<BlobImpl> impl = static_cast<BlobChild*>(aData.blobsChild()[i])->GetBlobImpl(); nsRefPtr<Blob> blob = Blob::Create(mBC ? mBC->GetOwner() : nullptr, impl); blobs.AppendElement(blob); } } nsCOMPtr<DOMEventTargetHelper> helper = mBC;
--- a/dom/broadcastchannel/BroadcastChannelParent.cpp +++ b/dom/broadcastchannel/BroadcastChannelParent.cpp @@ -112,17 +112,17 @@ BroadcastChannelParent::CheckAndDeliver( return; } // Duplicate the data for this parent. ClonedMessageData newData(aData); // Ricreate the BlobParent for this new message. for (uint32_t i = 0, len = newData.blobsParent().Length(); i < len; ++i) { - nsRefPtr<FileImpl> impl = + nsRefPtr<BlobImpl> impl = static_cast<BlobParent*>(newData.blobsParent()[i])->GetBlobImpl(); PBlobParent* blobParent = BackgroundParent::GetOrCreateActorForBlobImpl(Manager(), impl); if (!blobParent) { return; }
--- a/dom/broadcastchannel/BroadcastChannelService.cpp +++ b/dom/broadcastchannel/BroadcastChannelService.cpp @@ -97,35 +97,35 @@ struct MOZ_STACK_CLASS PostMessageData f , mPrivateBrowsing(aPrivateBrowsing) { MOZ_ASSERT(aParent); MOZ_COUNT_CTOR(PostMessageData); // We need to keep the array alive for the life-time of this // PostMessageData. if (!aData.blobsParent().IsEmpty()) { - mFiles.SetCapacity(aData.blobsParent().Length()); + mBlobs.SetCapacity(aData.blobsParent().Length()); for (uint32_t i = 0, len = aData.blobsParent().Length(); i < len; ++i) { - nsRefPtr<FileImpl> impl = + nsRefPtr<BlobImpl> impl = static_cast<BlobParent*>(aData.blobsParent()[i])->GetBlobImpl(); MOZ_ASSERT(impl); - mFiles.AppendElement(impl); + mBlobs.AppendElement(impl); } } } ~PostMessageData() { MOZ_COUNT_DTOR(PostMessageData); } BroadcastChannelParent* mParent; const ClonedMessageData& mData; - nsTArray<nsRefPtr<FileImpl>> mFiles; + nsTArray<nsRefPtr<BlobImpl>> mBlobs; const nsString mOrigin; const nsString mChannel; uint64_t mAppId; bool mIsInBrowserElement; bool mPrivateBrowsing; }; PLDHashOperator
--- a/dom/devicestorage/DeviceStorageRequestChild.cpp +++ b/dom/devicestorage/DeviceStorageRequestChild.cpp @@ -99,17 +99,17 @@ DeviceStorageRequestChild:: mRequest->FireSuccess(result); break; } case DeviceStorageResponseValue::TBlobResponse: { BlobResponse r = aValue; BlobChild* actor = static_cast<BlobChild*>(r.blobChild()); - nsRefPtr<FileImpl> bloblImpl = actor->GetBlobImpl(); + nsRefPtr<BlobImpl> bloblImpl = actor->GetBlobImpl(); nsRefPtr<Blob> blob = Blob::Create(mRequest->GetParentObject(), bloblImpl); AutoJSContext cx; JS::Rooted<JSObject*> obj(cx, blob->WrapObject(cx, JS::NullPtr())); MOZ_ASSERT(obj);
--- a/dom/devicestorage/DeviceStorageRequestParent.cpp +++ b/dom/devicestorage/DeviceStorageRequestParent.cpp @@ -40,17 +40,17 @@ DeviceStorageRequestParent::Dispatch() case DeviceStorageParams::TDeviceStorageAddParams: { DeviceStorageAddParams p = mParams; nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(p.type(), p.storageName(), p.relpath()); BlobParent* bp = static_cast<BlobParent*>(p.blobParent()); - nsRefPtr<FileImpl> blobImpl = bp->GetBlobImpl(); + nsRefPtr<BlobImpl> blobImpl = bp->GetBlobImpl(); nsCOMPtr<nsIInputStream> stream; blobImpl->GetInternalStream(getter_AddRefs(stream)); nsRefPtr<CancelableRunnable> r = new WriteFileEvent(this, dsf, stream, DEVICE_STORAGE_REQUEST_CREATE); nsCOMPtr<nsIEventTarget> target @@ -63,17 +63,17 @@ DeviceStorageRequestParent::Dispatch() case DeviceStorageParams::TDeviceStorageAppendParams: { DeviceStorageAppendParams p = mParams; nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(p.type(), p.storageName(), p.relpath()); BlobParent* bp = static_cast<BlobParent*>(p.blobParent()); - nsRefPtr<FileImpl> blobImpl = bp->GetBlobImpl(); + nsRefPtr<BlobImpl> blobImpl = bp->GetBlobImpl(); nsCOMPtr<nsIInputStream> stream; blobImpl->GetInternalStream(getter_AddRefs(stream)); nsRefPtr<CancelableRunnable> r = new WriteFileEvent(this, dsf, stream, DEVICE_STORAGE_REQUEST_APPEND); nsCOMPtr<nsIEventTarget> target @@ -518,22 +518,22 @@ nsresult DeviceStorageRequestParent::PostBlobSuccessEvent::CancelableRun() { MOZ_ASSERT(NS_IsMainThread()); nsString mime; CopyASCIItoUTF16(mMimeType, mime); nsString fullPath; mFile->GetFullPath(fullPath); - nsRefPtr<FileImpl> blob = - new FileImplFile(fullPath, mime, mLength, mFile->mFile, + nsRefPtr<BlobImpl> blob = + new BlobImplFile(fullPath, mime, mLength, mFile->mFile, mLastModificationDate); ContentParent* cp = static_cast<ContentParent*>(mParent->Manager()); - BlobParent* actor = cp->GetOrCreateActorForFileImpl(blob); + BlobParent* actor = cp->GetOrCreateActorForBlobImpl(blob); if (!actor) { ErrorResponse response(NS_LITERAL_STRING(POST_ERROR_EVENT_UNKNOWN)); unused << mParent->Send__delete__(mParent, response); return NS_OK; } BlobResponse response; response.blobParent() = actor;
--- a/dom/devicestorage/nsDeviceStorage.cpp +++ b/dom/devicestorage/nsDeviceStorage.cpp @@ -1920,17 +1920,17 @@ nsIFileToJsval(nsPIDOMWindow* aWindow, D // This check is useful to know if somewhere the DeviceStorageFile // has not been properly set. Mimetype is not checked because it can be // empty. MOZ_ASSERT(aFile->mLength != UINT64_MAX); MOZ_ASSERT(aFile->mLastModifiedDate != UINT64_MAX); nsCOMPtr<nsIDOMBlob> blob = Blob::Create(aWindow, - new FileImplFile(fullPath, aFile->mMimeType, + new BlobImplFile(fullPath, aFile->mMimeType, aFile->mLength, aFile->mFile, aFile->mLastModifiedDate)); return InterfaceToJsval(aWindow, blob, &NS_GET_IID(nsIDOMBlob)); } bool StringToJsval(nsPIDOMWindow* aWindow, nsAString& aString, JS::MutableHandle<JS::Value> result) @@ -2605,17 +2605,17 @@ public: private: nsRefPtr<DeviceStorageFileDescriptor> mDSFileDescriptor; nsRefPtr<DOMRequest> mRequest; }; class WriteFileEvent : public nsRunnable { public: - WriteFileEvent(FileImpl* aBlobImpl, + WriteFileEvent(BlobImpl* aBlobImpl, DeviceStorageFile *aFile, already_AddRefed<DOMRequest> aRequest, int32_t aRequestType) : mBlobImpl(aBlobImpl) , mFile(aFile) , mRequest(aRequest) , mRequestType(aRequestType) { @@ -2671,17 +2671,17 @@ public: nsString fullPath; mFile->GetFullPath(fullPath); nsCOMPtr<nsIRunnable> event = new PostResultEvent(mRequest.forget(), fullPath); return NS_DispatchToMainThread(event); } private: - nsRefPtr<FileImpl> mBlobImpl; + nsRefPtr<BlobImpl> mBlobImpl; nsRefPtr<DeviceStorageFile> mFile; nsRefPtr<DOMRequest> mRequest; int32_t mRequestType; }; class ReadFileEvent : public nsRunnable {
--- a/dom/events/DataTransfer.cpp +++ b/dom/events/DataTransfer.cpp @@ -299,24 +299,24 @@ DataTransfer::GetFiles(ErrorResult& aRv) continue; nsCOMPtr<nsIFile> file = do_QueryInterface(supports); nsRefPtr<File> domFile; if (file) { domFile = File::CreateFromFile(GetParentObject(), file); } else { - nsCOMPtr<FileImpl> fileImpl = do_QueryInterface(supports); - if (!fileImpl) { + nsCOMPtr<BlobImpl> blobImpl = do_QueryInterface(supports); + if (!blobImpl) { continue; } - MOZ_ASSERT(fileImpl->IsFile()); + MOZ_ASSERT(blobImpl->IsFile()); - domFile = File::Create(GetParentObject(), fileImpl); + domFile = File::Create(GetParentObject(), blobImpl); MOZ_ASSERT(domFile); } if (!mFiles->Append(domFile)) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } }
--- a/dom/fetch/Fetch.cpp +++ b/dom/fetch/Fetch.cpp @@ -444,17 +444,17 @@ ExtractFromArrayBufferView(const ArrayBu reinterpret_cast<char*>(aBuffer.Data()), aBuffer.Length(), NS_ASSIGNMENT_COPY); } nsresult ExtractFromBlob(const Blob& aBlob, nsIInputStream** aStream, nsCString& aContentType) { - nsRefPtr<FileImpl> impl = aBlob.Impl(); + nsRefPtr<BlobImpl> impl = aBlob.Impl(); nsresult rv = impl->GetInternalStream(aStream); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } nsAutoString type; impl->GetType(type); aContentType = NS_ConvertUTF16toUTF8(type);
--- a/dom/fetch/FetchDriver.cpp +++ b/dom/fetch/FetchDriver.cpp @@ -203,19 +203,19 @@ FetchDriver::BasicFetch() response->SetBody(body); BeginResponse(response); return SucceedWithResponse(); } return FailWithNetworkError(); } if (scheme.LowerCaseEqualsLiteral("blob")) { - nsRefPtr<FileImpl> blobImpl; + nsRefPtr<BlobImpl> blobImpl; rv = NS_GetBlobForBlobURI(uri, getter_AddRefs(blobImpl)); - FileImpl* blob = static_cast<FileImpl*>(blobImpl.get()); + BlobImpl* blob = static_cast<BlobImpl*>(blobImpl.get()); if (NS_WARN_IF(NS_FAILED(rv))) { FailWithNetworkError(); return rv; } nsRefPtr<InternalResponse> response = new InternalResponse(200, NS_LITERAL_CSTRING("OK")); { ErrorResult result;
--- a/dom/filesystem/CreateFileTask.cpp +++ b/dom/filesystem/CreateFileTask.cpp @@ -74,17 +74,17 @@ CreateFileTask::CreateFileTask(FileSyste auto& data = aParam.data(); if (data.type() == FileSystemFileDataValue::TArrayOfuint8_t) { mArrayData = data; return; } BlobParent* bp = static_cast<BlobParent*>(static_cast<PBlobParent*>(data)); - nsRefPtr<FileImpl> blobImpl = bp->GetBlobImpl(); + nsRefPtr<BlobImpl> blobImpl = bp->GetBlobImpl(); MOZ_ASSERT(blobImpl, "blobData should not be null."); nsresult rv = blobImpl->GetInternalStream(getter_AddRefs(mBlobStream)); NS_WARN_IF(NS_FAILED(rv)); } CreateFileTask::~CreateFileTask() { @@ -122,32 +122,32 @@ CreateFileTask::GetRequestParams(const n } return param; } FileSystemResponseValue CreateFileTask::GetSuccessRequestResult() const { MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); - BlobParent* actor = GetBlobParent(mTargetFileImpl); + BlobParent* actor = GetBlobParent(mTargetBlobImpl); if (!actor) { return FileSystemErrorResponse(NS_ERROR_DOM_FILESYSTEM_UNKNOWN_ERR); } FileSystemFileResponse response; response.blobParent() = actor; return response; } void CreateFileTask::SetSuccessRequestResult(const FileSystemResponseValue& aValue) { MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); FileSystemFileResponse r = aValue; BlobChild* actor = static_cast<BlobChild*>(r.blobChild()); - mTargetFileImpl = actor->GetBlobImpl(); + mTargetBlobImpl = actor->GetBlobImpl(); } nsresult CreateFileTask::Work() { class AutoClose { public: @@ -254,17 +254,17 @@ CreateFileTask::Work() mBlobStream->Close(); mBlobStream = nullptr; if (mFileSystem->IsShutdown()) { return NS_ERROR_FAILURE; } - mTargetFileImpl = new FileImplFile(file); + mTargetBlobImpl = new BlobImplFile(file); return NS_OK; } // Write file content from array data. uint32_t written; rv = bufferedOutputStream->Write( reinterpret_cast<char*>(mArrayData.Elements()), @@ -273,17 +273,17 @@ CreateFileTask::Work() if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } if (mArrayData.Length() != written) { return NS_ERROR_DOM_FILESYSTEM_UNKNOWN_ERR; } - mTargetFileImpl = new FileImplFile(file); + mTargetBlobImpl = new BlobImplFile(file); return NS_OK; } void CreateFileTask::HandlerCallback() { MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); if (mFileSystem->IsShutdown()) { @@ -296,17 +296,17 @@ CreateFileTask::HandlerCallback() nsRefPtr<DOMError> domError = new DOMError(mFileSystem->GetWindow(), mErrorValue); mPromise->MaybeRejectBrokenly(domError); mPromise = nullptr; mBlobData = nullptr; return; } - nsRefPtr<Blob> blob = Blob::Create(mFileSystem->GetWindow(), mTargetFileImpl); + nsRefPtr<Blob> blob = Blob::Create(mFileSystem->GetWindow(), mTargetBlobImpl); mPromise->MaybeResolve(blob); mPromise = nullptr; mBlobData = nullptr; } void CreateFileTask::GetPermissionAccessType(nsCString& aAccess) const {
--- a/dom/filesystem/CreateFileTask.h +++ b/dom/filesystem/CreateFileTask.h @@ -12,17 +12,17 @@ #include "mozilla/ErrorResult.h" class nsIInputStream; namespace mozilla { namespace dom { class Blob; -class FileImpl; +class BlobImpl; class Promise; class CreateFileTask final : public FileSystemTaskBase { public: CreateFileTask(FileSystemBase* aFileSystem, const nsAString& aPath, @@ -70,16 +70,16 @@ private: // Not thread-safe and should be released on main thread. nsRefPtr<Blob> mBlobData; nsCOMPtr<nsIInputStream> mBlobStream; InfallibleTArray<uint8_t> mArrayData; bool mReplace; // This cannot be a File because this object is created on a different - // thread and File is not thread-safe. Let's use the FileImpl instead. - nsRefPtr<FileImpl> mTargetFileImpl; + // thread and File is not thread-safe. Let's use the BlobImpl instead. + nsRefPtr<BlobImpl> mTargetBlobImpl; }; } // namespace dom } // namespace mozilla #endif // mozilla_dom_CreateFileTask_h
--- a/dom/filesystem/DeviceStorageFileSystem.cpp +++ b/dom/filesystem/DeviceStorageFileSystem.cpp @@ -109,17 +109,17 @@ DeviceStorageFileSystem::GetLocalFile(co nsresult rv = NS_NewLocalFile(localPath, false, getter_AddRefs(file)); if (NS_WARN_IF(NS_FAILED(rv))) { return nullptr; } return file.forget(); } bool -DeviceStorageFileSystem::GetRealPath(FileImpl* aFile, nsAString& aRealPath) const +DeviceStorageFileSystem::GetRealPath(BlobImpl* aFile, nsAString& aRealPath) const { MOZ_ASSERT(FileSystemUtils::IsParentProcess(), "Should be on parent process!"); MOZ_ASSERT(aFile, "aFile Should not be null."); aRealPath.Truncate(); nsAutoString filePath;
--- a/dom/filesystem/DeviceStorageFileSystem.h +++ b/dom/filesystem/DeviceStorageFileSystem.h @@ -32,17 +32,17 @@ public: virtual nsPIDOMWindow* GetWindow() const override; virtual already_AddRefed<nsIFile> GetLocalFile(const nsAString& aRealPath) const override; virtual bool - GetRealPath(FileImpl* aFile, nsAString& aRealPath) const override; + GetRealPath(BlobImpl* aFile, nsAString& aRealPath) const override; virtual const nsAString& GetRootName() const override; virtual bool IsSafeFile(nsIFile* aFile) const override; virtual bool
--- a/dom/filesystem/Directory.cpp +++ b/dom/filesystem/Directory.cpp @@ -187,37 +187,37 @@ Directory::RemoveDeep(const StringOrFile } already_AddRefed<Promise> Directory::RemoveInternal(const StringOrFileOrDirectory& aPath, bool aRecursive, ErrorResult& aRv) { nsresult error = NS_OK; nsString realPath; - nsRefPtr<FileImpl> file; + nsRefPtr<BlobImpl> blob; // Check and get the target path. if (aPath.IsFile()) { - file = aPath.GetAsFile().Impl(); + blob = aPath.GetAsFile().Impl(); } else if (aPath.IsString()) { if (!DOMPathToRealPath(aPath.GetAsString(), realPath)) { error = NS_ERROR_DOM_FILESYSTEM_INVALID_PATH_ERR; } } else if (!mFileSystem->IsSafeDirectory(&aPath.GetAsDirectory())) { error = NS_ERROR_DOM_SECURITY_ERR; } else { realPath = aPath.GetAsDirectory().mPath; // The target must be a descendant of this directory. if (!FileSystemUtils::IsDescendantPath(mPath, realPath)) { error = NS_ERROR_DOM_FILESYSTEM_NO_MODIFICATION_ALLOWED_ERR; } } - nsRefPtr<RemoveTask> task = new RemoveTask(mFileSystem, mPath, file, realPath, + nsRefPtr<RemoveTask> task = new RemoveTask(mFileSystem, mPath, blob, realPath, aRecursive, aRv); if (aRv.Failed()) { return nullptr; } task->SetError(error); FileSystemPermissionRequest::RequestForTask(task); return task->GetPromise(); }
--- a/dom/filesystem/FileSystemBase.h +++ b/dom/filesystem/FileSystemBase.h @@ -10,18 +10,18 @@ #include "nsAutoPtr.h" #include "nsString.h" class nsPIDOMWindow; namespace mozilla { namespace dom { +class BlobImpl; class Directory; -class FileImpl; class FileSystemBase { NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileSystemBase) public: // Create file system object from its string representation. static already_AddRefed<FileSystemBase> @@ -68,17 +68,17 @@ public: IsSafeDirectory(Directory* aDir) const; /* * Get the real path (absolute DOM path) of the DOM file in the file system. * If succeeded, returns true. Otherwise, returns false and set aRealPath to * empty string. */ virtual bool - GetRealPath(FileImpl* aFile, nsAString& aRealPath) const = 0; + GetRealPath(BlobImpl* aFile, nsAString& aRealPath) const = 0; /* * Get the permission name required to access this file system. */ const nsCString& GetPermission() const { return mPermission;
--- a/dom/filesystem/FileSystemTaskBase.cpp +++ b/dom/filesystem/FileSystemTaskBase.cpp @@ -149,43 +149,43 @@ bool FileSystemTaskBase::Recv__delete__(const FileSystemResponseValue& aValue) { SetRequestResult(aValue); HandlerCallback(); return true; } BlobParent* -FileSystemTaskBase::GetBlobParent(FileImpl* aFile) const +FileSystemTaskBase::GetBlobParent(BlobImpl* aFile) const { MOZ_ASSERT(FileSystemUtils::IsParentProcess(), "Only call from parent process!"); MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); MOZ_ASSERT(aFile); // Load the lazy dom file data from the parent before sending to the child. nsString mimeType; aFile->GetType(mimeType); // We call GetSize and GetLastModified to prepopulate the value in the - // FileImpl. + // BlobImpl. { ErrorResult rv; aFile->GetSize(rv); rv.SuppressException(); } { ErrorResult rv; aFile->GetLastModified(rv); rv.SuppressException(); } ContentParent* cp = static_cast<ContentParent*>(mRequestParent->Manager()); - return cp->GetOrCreateActorForFileImpl(aFile); + return cp->GetOrCreateActorForBlobImpl(aFile); } void FileSystemTaskBase::SetError(const nsresult& aErrorValue) { uint16_t module = NS_ERROR_GET_MODULE(aErrorValue); if (module == NS_ERROR_MODULE_DOM_FILESYSTEM || module == NS_ERROR_MODULE_DOM_FILE ||
--- a/dom/filesystem/FileSystemTaskBase.h +++ b/dom/filesystem/FileSystemTaskBase.h @@ -9,18 +9,18 @@ #include "mozilla/ErrorResult.h" #include "mozilla/dom/FileSystemRequestParent.h" #include "mozilla/dom/PFileSystemRequestChild.h" namespace mozilla { namespace dom { +class BlobImpl; class BlobParent; -class FileImpl; class FileSystemBase; class FileSystemParams; /* * The base class to implement a Task class. * The task is used to handle the OOP (out of process) operations. * The file system operations can only be performed in the parent process. When * performing such a parent-process-only operation, a task will delivered the @@ -199,17 +199,17 @@ protected: bool HasError() const { return mErrorValue != NS_OK; } // Overrides PFileSystemRequestChild virtual bool Recv__delete__(const FileSystemResponseValue& value) override; BlobParent* - GetBlobParent(FileImpl* aFile) const; + GetBlobParent(BlobImpl* aBlob) const; nsresult mErrorValue; nsRefPtr<FileSystemBase> mFileSystem; nsRefPtr<FileSystemRequestParent> mRequestParent; private: /* * After finishing the task operation, handle the task result.
--- a/dom/filesystem/GetFileOrDirectoryTask.cpp +++ b/dom/filesystem/GetFileOrDirectoryTask.cpp @@ -77,34 +77,34 @@ GetFileOrDirectoryTask::GetRequestParams FileSystemResponseValue GetFileOrDirectoryTask::GetSuccessRequestResult() const { MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); if (mIsDirectory) { return FileSystemDirectoryResponse(mTargetRealPath); } - BlobParent* actor = GetBlobParent(mTargetFileImpl); + BlobParent* actor = GetBlobParent(mTargetBlobImpl); if (!actor) { return FileSystemErrorResponse(NS_ERROR_DOM_FILESYSTEM_UNKNOWN_ERR); } FileSystemFileResponse response; response.blobParent() = actor; return response; } void GetFileOrDirectoryTask::SetSuccessRequestResult(const FileSystemResponseValue& aValue) { MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); switch (aValue.type()) { case FileSystemResponseValue::TFileSystemFileResponse: { FileSystemFileResponse r = aValue; BlobChild* actor = static_cast<BlobChild*>(r.blobChild()); - mTargetFileImpl = actor->GetBlobImpl(); + mTargetBlobImpl = actor->GetBlobImpl(); mIsDirectory = false; break; } case FileSystemResponseValue::TFileSystemDirectoryResponse: { FileSystemDirectoryResponse r = aValue; mTargetRealPath = r.realPath(); mIsDirectory = true; break; @@ -179,17 +179,17 @@ GetFileOrDirectoryTask::Work() // Neither directory or file. return NS_ERROR_DOM_FILESYSTEM_TYPE_MISMATCH_ERR; } if (!mFileSystem->IsSafeFile(file)) { return NS_ERROR_DOM_SECURITY_ERR; } - mTargetFileImpl = new FileImplFile(file); + mTargetBlobImpl = new BlobImplFile(file); return NS_OK; } void GetFileOrDirectoryTask::HandlerCallback() { MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); @@ -208,17 +208,17 @@ GetFileOrDirectoryTask::HandlerCallback( if (mIsDirectory) { nsRefPtr<Directory> dir = new Directory(mFileSystem, mTargetRealPath); mPromise->MaybeResolve(dir); mPromise = nullptr; return; } - nsRefPtr<Blob> blob = Blob::Create(mFileSystem->GetWindow(), mTargetFileImpl); + nsRefPtr<Blob> blob = Blob::Create(mFileSystem->GetWindow(), mTargetBlobImpl); mPromise->MaybeResolve(blob); mPromise = nullptr; } void GetFileOrDirectoryTask::GetPermissionAccessType(nsCString& aAccess) const { aAccess.AssignLiteral("read");
--- a/dom/filesystem/GetFileOrDirectoryTask.h +++ b/dom/filesystem/GetFileOrDirectoryTask.h @@ -9,17 +9,17 @@ #include "mozilla/dom/FileSystemTaskBase.h" #include "nsAutoPtr.h" #include "mozilla/ErrorResult.h" namespace mozilla { namespace dom { -class FileImpl; +class BlobImpl; class GetFileOrDirectoryTask final : public FileSystemTaskBase { public: // If aDirectoryOnly is set, we should ensure that the target is a directory. GetFileOrDirectoryTask(FileSystemBase* aFileSystem, const nsAString& aTargetPath, @@ -55,16 +55,16 @@ protected: private: nsRefPtr<Promise> mPromise; nsString mTargetRealPath; // Whether we get a directory. bool mIsDirectory; // This cannot be a File bacause this object is created on a different - // thread and File is not thread-safe. Let's use the FileImpl instead. - nsRefPtr<FileImpl> mTargetFileImpl; + // thread and File is not thread-safe. Let's use the BlobImpl instead. + nsRefPtr<BlobImpl> mTargetBlobImpl; }; } // namespace dom } // namespace mozilla #endif // mozilla_dom_GetFileOrDirectory_h
--- a/dom/filesystem/RemoveTask.cpp +++ b/dom/filesystem/RemoveTask.cpp @@ -16,23 +16,23 @@ #include "nsIFile.h" #include "nsStringGlue.h" namespace mozilla { namespace dom { RemoveTask::RemoveTask(FileSystemBase* aFileSystem, const nsAString& aDirPath, - FileImpl* aTargetFile, + BlobImpl* aTargetBlob, const nsAString& aTargetPath, bool aRecursive, ErrorResult& aRv) : FileSystemTaskBase(aFileSystem) , mDirRealPath(aDirPath) - , mTargetFileImpl(aTargetFile) + , mTargetBlobImpl(aTargetBlob) , mTargetRealPath(aTargetPath) , mRecursive(aRecursive) , mReturnValue(false) { MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); MOZ_ASSERT(aFileSystem); nsCOMPtr<nsIGlobalObject> globalObject = do_QueryInterface(aFileSystem->GetWindow()); @@ -61,18 +61,18 @@ RemoveTask::RemoveTask(FileSystemBase* a const FileSystemPathOrFileValue& target = aParam.target(); if (target.type() == FileSystemPathOrFileValue::TnsString) { mTargetRealPath = target; return; } BlobParent* bp = static_cast<BlobParent*>(static_cast<PBlobParent*>(target)); - mTargetFileImpl = bp->GetBlobImpl(); - MOZ_ASSERT(mTargetFileImpl); + mTargetBlobImpl = bp->GetBlobImpl(); + MOZ_ASSERT(mTargetBlobImpl); } RemoveTask::~RemoveTask() { MOZ_ASSERT(!mPromise || NS_IsMainThread(), "mPromise should be released on main thread!"); } @@ -86,19 +86,19 @@ RemoveTask::GetPromise() FileSystemParams RemoveTask::GetRequestParams(const nsString& aFileSystem) const { MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); FileSystemRemoveParams param; param.filesystem() = aFileSystem; param.directory() = mDirRealPath; param.recursive() = mRecursive; - if (mTargetFileImpl) { + if (mTargetBlobImpl) { nsRefPtr<Blob> blob = Blob::Create(mFileSystem->GetWindow(), - mTargetFileImpl); + mTargetBlobImpl); BlobChild* actor = ContentChild::GetSingleton()->GetOrCreateActorForBlob(blob); if (actor) { param.target() = actor; } } else { param.target() = mTargetRealPath; } @@ -127,18 +127,18 @@ RemoveTask::Work() "Only call from parent process!"); MOZ_ASSERT(!NS_IsMainThread(), "Only call on worker thread!"); if (mFileSystem->IsShutdown()) { return NS_ERROR_FAILURE; } // Get the DOM path if a File is passed as the target. - if (mTargetFileImpl) { - if (!mFileSystem->GetRealPath(mTargetFileImpl, mTargetRealPath)) { + if (mTargetBlobImpl) { + if (!mFileSystem->GetRealPath(mTargetBlobImpl, mTargetRealPath)) { return NS_ERROR_DOM_SECURITY_ERR; } if (!FileSystemUtils::IsDescendantPath(mDirRealPath, mTargetRealPath)) { return NS_ERROR_DOM_FILESYSTEM_NO_MODIFICATION_ALLOWED_ERR; } } nsCOMPtr<nsIFile> file = mFileSystem->GetLocalFile(mTargetRealPath);
--- a/dom/filesystem/RemoveTask.h +++ b/dom/filesystem/RemoveTask.h @@ -9,26 +9,26 @@ #include "mozilla/dom/FileSystemTaskBase.h" #include "nsAutoPtr.h" #include "mozilla/ErrorResult.h" namespace mozilla { namespace dom { -class FileImpl; +class BlobImpl; class Promise; class RemoveTask final : public FileSystemTaskBase { public: RemoveTask(FileSystemBase* aFileSystem, const nsAString& aDirPath, - FileImpl* aTargetFile, + BlobImpl* aTargetBlob, const nsAString& aTargetPath, bool aRecursive, ErrorResult& aRv); RemoveTask(FileSystemBase* aFileSystem, const FileSystemRemoveParams& aParam, FileSystemRequestParent* aParent); virtual @@ -55,18 +55,18 @@ protected: virtual void HandlerCallback() override; private: nsRefPtr<Promise> mPromise; nsString mDirRealPath; // This cannot be a File because this object will be used on a different - // thread and File is not thread-safe. Let's use the FileImpl instead. - nsRefPtr<FileImpl> mTargetFileImpl; + // thread and File is not thread-safe. Let's use the BlobImpl instead. + nsRefPtr<BlobImpl> mTargetBlobImpl; nsString mTargetRealPath; bool mRecursive; bool mReturnValue; }; } // namespace dom } // namespace mozilla
--- a/dom/html/HTMLCanvasElement.cpp +++ b/dom/html/HTMLCanvasElement.cpp @@ -613,21 +613,21 @@ HTMLCanvasElement::MozGetAsFile(const ns OwnerDoc()->WarnOnceAbout(nsIDocument::eMozGetAsFile); // do a trust check if this is a write-only canvas if ((mWriteOnly) && !nsContentUtils::IsCallerChrome()) { return NS_ERROR_DOM_SECURITY_ERR; } - return MozGetAsFileImpl(aName, aType, aResult); + return MozGetAsBlobImpl(aName, aType, aResult); } nsresult -HTMLCanvasElement::MozGetAsFileImpl(const nsAString& aName, +HTMLCanvasElement::MozGetAsBlobImpl(const nsAString& aName, const nsAString& aType, nsIDOMFile** aResult) { nsCOMPtr<nsIInputStream> stream; nsAutoString type(aType); nsresult rv = ExtractData(type, EmptyString(), getter_AddRefs(stream)); NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/html/HTMLCanvasElement.h +++ b/dom/html/HTMLCanvasElement.h @@ -227,17 +227,17 @@ protected: bool* usingCustomParseOptions); nsresult ExtractData(nsAString& aType, const nsAString& aOptions, nsIInputStream** aStream); nsresult ToDataURLImpl(JSContext* aCx, const nsAString& aMimeType, const JS::Value& aEncoderOptions, nsAString& aDataURL); - nsresult MozGetAsFileImpl(const nsAString& aName, + nsresult MozGetAsBlobImpl(const nsAString& aName, const nsAString& aType, nsIDOMFile** aResult); void CallPrintCallback(); CanvasContextType mCurrentContextType; nsRefPtr<HTMLCanvasElement> mOriginalCanvas; nsRefPtr<PrintCallback> mPrintCallback; nsCOMPtr<nsICanvasRenderingContextInternal> mCurrentContext;
--- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -213,59 +213,66 @@ const Decimal HTMLInputElement::kStepAny static const uint32_t kProgressEventInterval = 50; // ms class HTMLInputElementState final : public nsISupports { public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_INPUT_ELEMENT_STATE_IID) NS_DECL_ISUPPORTS - bool IsCheckedSet() { + bool IsCheckedSet() + { return mCheckedSet; } - bool GetChecked() { + bool GetChecked() + { return mChecked; } - void SetChecked(bool aChecked) { + void SetChecked(bool aChecked) + { mChecked = aChecked; mCheckedSet = true; } - const nsString& GetValue() { + const nsString& GetValue() + { return mValue; } - void SetValue(const nsAString& aValue) { + void SetValue(const nsAString& aValue) + { mValue = aValue; } - const nsTArray<nsRefPtr<FileImpl>>& GetFileImpls() { - return mFileImpls; - } - - void SetFileImpls(const nsTArray<nsRefPtr<File>>& aFile) { - mFileImpls.Clear(); + const nsTArray<nsRefPtr<BlobImpl>>& GetBlobImpls() + { + return mBlobImpls; + } + + void SetBlobImpls(const nsTArray<nsRefPtr<File>>& aFile) + { + mBlobImpls.Clear(); for (uint32_t i = 0, len = aFile.Length(); i < len; ++i) { - mFileImpls.AppendElement(aFile[i]->Impl()); + mBlobImpls.AppendElement(aFile[i]->Impl()); } } HTMLInputElementState() : mValue() , mChecked(false) , mCheckedSet(false) - {}; + {} protected: ~HTMLInputElementState() {} nsString mValue; - nsTArray<nsRefPtr<FileImpl>> mFileImpls; + nsTArray<nsRefPtr<BlobImpl>> mBlobImpls; bool mChecked; bool mCheckedSet; }; NS_DEFINE_STATIC_IID_ACCESSOR(HTMLInputElementState, NS_INPUT_ELEMENT_STATE_IID) NS_IMPL_ISUPPORTS(HTMLInputElementState, HTMLInputElementState) @@ -389,19 +396,19 @@ public: NS_ConvertUTF8toUTF16 path(relDescriptor); nsAutoString leafName; mNextFile->GetLeafName(leafName); MOZ_ASSERT(leafName.Length() <= path.Length()); int32_t length = path.Length() - leafName.Length(); MOZ_ASSERT(length >= 0); if (length > 0) { // Note that we leave the trailing "/" on the path. - FileImplFile* fileImpl = static_cast<FileImplFile*>(domFile->Impl()); - MOZ_ASSERT(fileImpl); - fileImpl->SetPath(Substring(path, 0, uint32_t(length))); + BlobImplFile* blobImpl = static_cast<BlobImplFile*>(domFile->Impl()); + MOZ_ASSERT(blobImpl); + blobImpl->SetPath(Substring(path, 0, uint32_t(length))); } *aResult = domFile.forget().downcast<nsIDOMFile>().take(); LookupAndCacheNext(); return NS_OK; } NS_IMETHOD HasMoreElements(bool* aResult) override @@ -5804,17 +5811,17 @@ HTMLInputElement::SaveState() if (mCheckedChanged) { inputState = new HTMLInputElementState(); inputState->SetChecked(mChecked); } break; case VALUE_MODE_FILENAME: if (!mFiles.IsEmpty()) { inputState = new HTMLInputElementState(); - inputState->SetFileImpls(mFiles); + inputState->SetBlobImpls(mFiles); } break; case VALUE_MODE_VALUE: case VALUE_MODE_DEFAULT: // VALUE_MODE_DEFAULT shouldn't have their value saved except 'hidden', // mType shouldn't be NS_FORM_INPUT_PASSWORD and value should have changed. if ((GetValueMode() == VALUE_MODE_DEFAULT && mType != NS_FORM_INPUT_HIDDEN) || @@ -6010,24 +6017,24 @@ HTMLInputElement::RestoreState(nsPresSta case VALUE_MODE_DEFAULT_ON: if (inputState->IsCheckedSet()) { restoredCheckedState = true; DoSetChecked(inputState->GetChecked(), true, true); } break; case VALUE_MODE_FILENAME: { - const nsTArray<nsRefPtr<FileImpl>>& fileImpls = inputState->GetFileImpls(); + const nsTArray<nsRefPtr<BlobImpl>>& blobImpls = inputState->GetBlobImpls(); nsCOMPtr<nsIGlobalObject> global = OwnerDoc()->GetScopeObject(); MOZ_ASSERT(global); nsTArray<nsRefPtr<File>> files; - for (uint32_t i = 0, len = fileImpls.Length(); i < len; ++i) { - nsRefPtr<File> file = File::Create(global, fileImpls[i]); + for (uint32_t i = 0, len = blobImpls.Length(); i < len; ++i) { + nsRefPtr<File> file = File::Create(global, blobImpls[i]); MOZ_ASSERT(file); files.AppendElement(file); } SetFiles(files, true); } break;
--- a/dom/indexedDB/ActorsChild.cpp +++ b/dom/indexedDB/ActorsChild.cpp @@ -606,17 +606,17 @@ ConvertActorsToBlobs(IDBDatabase* aDatab if (!blobs.IsEmpty()) { const uint32_t count = blobs.Length(); aFiles.SetCapacity(count); for (uint32_t index = 0; index < count; index++) { BlobChild* actor = static_cast<BlobChild*>(blobs[index]); - nsRefPtr<FileImpl> blobImpl = actor->GetBlobImpl(); + nsRefPtr<BlobImpl> blobImpl = actor->GetBlobImpl(); MOZ_ASSERT(blobImpl); nsRefPtr<Blob> blob = Blob::Create(aDatabase->GetOwner(), blobImpl); nsRefPtr<FileInfo> fileInfo; if (!fileInfos.IsEmpty()) { fileInfo = dont_AddRef(reinterpret_cast<FileInfo*>(fileInfos[index]));
--- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -5833,17 +5833,17 @@ private: Cleanup() override; }; class DatabaseFile final : public PBackgroundIDBDatabaseFileParent { friend class Database; - nsRefPtr<FileImpl> mBlobImpl; + nsRefPtr<BlobImpl> mBlobImpl; nsRefPtr<FileInfo> mFileInfo; public: NS_INLINE_DECL_THREADSAFE_REFCOUNTING(mozilla::dom::indexedDB::DatabaseFile); FileInfo* GetFileInfo() const { @@ -5879,17 +5879,17 @@ private: explicit DatabaseFile(FileInfo* aFileInfo) : mFileInfo(aFileInfo) { AssertIsOnBackgroundThread(); MOZ_ASSERT(aFileInfo); } // Called when receiving from the child. - DatabaseFile(FileImpl* aBlobImpl, FileInfo* aFileInfo) + DatabaseFile(BlobImpl* aBlobImpl, FileInfo* aFileInfo) : mBlobImpl(aBlobImpl) , mFileInfo(aFileInfo) { AssertIsOnBackgroundThread(); MOZ_ASSERT(aBlobImpl); MOZ_ASSERT(aFileInfo); } @@ -7693,21 +7693,21 @@ public: NS_INLINE_DECL_REFCOUNTING(DatabaseLoggingInfo) private: ~DatabaseLoggingInfo(); }; class NonMainThreadHackBlobImpl final - : public FileImplFile + : public BlobImplFile { public: NonMainThreadHackBlobImpl(nsIFile* aFile, FileInfo* aFileInfo) - : FileImplFile(aFile, aFileInfo) + : BlobImplFile(aFile, aFileInfo) { // Getting the content type is not currently supported off the main thread. // This isn't a problem here because: // // 1. The real content type is stored in the structured clone data and // that's all that the DOM will see. This blob's data will be updated // during RecvSetMysteryBlobInfo(). // 2. The nsExternalHelperAppService guesses the content type based only @@ -8152,17 +8152,17 @@ ConvertBlobsToActors(PBackgroundParent* MOZ_ASSERT(NS_SUCCEEDED(nativeFile->Exists(&exists))); MOZ_ASSERT(exists); DebugOnly<bool> isFile; MOZ_ASSERT(NS_SUCCEEDED(nativeFile->IsFile(&isFile))); MOZ_ASSERT(isFile); - nsRefPtr<FileImpl> impl = + nsRefPtr<BlobImpl> impl = new NonMainThreadHackBlobImpl(nativeFile, file.mFileInfo); PBlobParent* actor = BackgroundParent::GetOrCreateActorForBlobImpl(aBackgroundActor, impl); if (!actor) { // This can only fail if the child has crashed. IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; @@ -11836,17 +11836,17 @@ Database::ActorDestroy(ActorDestroyReaso } PBackgroundIDBDatabaseFileParent* Database::AllocPBackgroundIDBDatabaseFileParent(PBlobParent* aBlobParent) { AssertIsOnBackgroundThread(); MOZ_ASSERT(aBlobParent); - nsRefPtr<FileImpl> blobImpl = + nsRefPtr<BlobImpl> blobImpl = static_cast<BlobParent*>(aBlobParent)->GetBlobImpl(); MOZ_ASSERT(blobImpl); nsRefPtr<DatabaseFile> actor; if (nsRefPtr<FileInfo> fileInfo = blobImpl->GetFileInfo(mFileManager)) { // This blob was previously shared with the child. actor = new DatabaseFile(fileInfo);
--- a/dom/indexedDB/FileSnapshot.cpp +++ b/dom/indexedDB/FileSnapshot.cpp @@ -15,23 +15,23 @@ #include "nsXULAppAPI.h" #endif namespace mozilla { namespace dom { namespace indexedDB { // Create as a stored file -FileImplSnapshot::FileImplSnapshot(const nsAString& aName, +BlobImplSnapshot::BlobImplSnapshot(const nsAString& aName, const nsAString& aContentType, MetadataParameters* aMetadataParams, nsIFile* aFile, IDBFileHandle* aFileHandle, FileInfo* aFileInfo) - : FileImplBase(aName, + : BlobImplBase(aName, aContentType, aMetadataParams->Size(), aMetadataParams->LastModified()) , mFile(aFile) , mWholeFile(true) { AssertSanity(); MOZ_ASSERT(aMetadataParams); @@ -43,21 +43,21 @@ FileImplSnapshot::FileImplSnapshot(const mFileInfos.AppendElement(aFileInfo); mFileHandle = do_GetWeakReference(NS_ISUPPORTS_CAST(EventTarget*, aFileHandle)); } // Create slice -FileImplSnapshot::FileImplSnapshot(const FileImplSnapshot* aOther, +BlobImplSnapshot::BlobImplSnapshot(const BlobImplSnapshot* aOther, uint64_t aStart, uint64_t aLength, const nsAString& aContentType) - : FileImplBase(aContentType, aOther->mStart + aStart, aLength) + : BlobImplBase(aContentType, aOther->mStart + aStart, aLength) , mFile(aOther->mFile) , mFileHandle(aOther->mFileHandle) , mWholeFile(false) { AssertSanity(); MOZ_ASSERT(aOther); FileInfo* fileInfo; @@ -67,36 +67,36 @@ FileImplSnapshot::FileImplSnapshot(const } else { MutexAutoLock lock(IndexedDatabaseManager::FileMutex()); fileInfo = aOther->GetFileInfo(); } mFileInfos.AppendElement(fileInfo); } -FileImplSnapshot::~FileImplSnapshot() +BlobImplSnapshot::~BlobImplSnapshot() { } #ifdef DEBUG // static void -FileImplSnapshot::AssertSanity() +BlobImplSnapshot::AssertSanity() { MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); MOZ_ASSERT(NS_IsMainThread()); } #endif // DEBUG -NS_IMPL_ISUPPORTS_INHERITED(FileImplSnapshot, FileImpl, PIFileImplSnapshot) +NS_IMPL_ISUPPORTS_INHERITED(BlobImplSnapshot, BlobImpl, PIBlobImplSnapshot) nsresult -FileImplSnapshot::GetInternalStream(nsIInputStream** aStream) +BlobImplSnapshot::GetInternalStream(nsIInputStream** aStream) { AssertSanity(); nsCOMPtr<EventTarget> et = do_QueryReferent(mFileHandle); nsRefPtr<IDBFileHandle> fileHandle = static_cast<IDBFileHandle*>(et.get()); if (!fileHandle) { return NS_ERROR_DOM_FILEHANDLE_INACTIVE_ERR; } @@ -105,58 +105,58 @@ FileImplSnapshot::GetInternalStream(nsII aStream); if (NS_FAILED(rv)) { return rv; } return NS_OK; } -already_AddRefed<FileImpl> -FileImplSnapshot::CreateSlice(uint64_t aStart, +already_AddRefed<BlobImpl> +BlobImplSnapshot::CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) { AssertSanity(); - nsRefPtr<FileImpl> impl = - new FileImplSnapshot(this, aStart, aLength, aContentType); + nsRefPtr<BlobImpl> impl = + new BlobImplSnapshot(this, aStart, aLength, aContentType); return impl.forget(); } void -FileImplSnapshot::GetMozFullPathInternal(nsAString& aFilename, +BlobImplSnapshot::GetMozFullPathInternal(nsAString& aFilename, ErrorResult& aRv) { AssertSanity(); MOZ_ASSERT(mIsFile); aRv = mFile->GetPath(aFilename); } bool -FileImplSnapshot::IsStoredFile() const +BlobImplSnapshot::IsStoredFile() const { AssertSanity(); return true; } bool -FileImplSnapshot::IsWholeFile() const +BlobImplSnapshot::IsWholeFile() const { AssertSanity(); return mWholeFile; } bool -FileImplSnapshot::IsSnapshot() const +BlobImplSnapshot::IsSnapshot() const { AssertSanity(); return true; } } // namespace indexedDB } // namespace dom
--- a/dom/indexedDB/FileSnapshot.h +++ b/dom/indexedDB/FileSnapshot.h @@ -12,63 +12,63 @@ #include "nsAutoPtr.h" #include "nsCOMPtr.h" #include "nsISupports.h" #include "nsWeakPtr.h" #define FILEIMPLSNAPSHOT_IID \ {0x0dfc11b1, 0x75d3, 0x473b, {0x8c, 0x67, 0xb7, 0x23, 0xf4, 0x67, 0xd6, 0x73}} -class PIFileImplSnapshot : public nsISupports +class PIBlobImplSnapshot : public nsISupports { public: NS_DECLARE_STATIC_IID_ACCESSOR(FILEIMPLSNAPSHOT_IID) }; -NS_DEFINE_STATIC_IID_ACCESSOR(PIFileImplSnapshot, FILEIMPLSNAPSHOT_IID) +NS_DEFINE_STATIC_IID_ACCESSOR(PIBlobImplSnapshot, FILEIMPLSNAPSHOT_IID) namespace mozilla { namespace dom { class MetadataParameters; namespace indexedDB { class IDBFileHandle; -class FileImplSnapshot final - : public FileImplBase - , public PIFileImplSnapshot +class BlobImplSnapshot final + : public BlobImplBase + , public PIBlobImplSnapshot { typedef mozilla::dom::MetadataParameters MetadataParameters; nsCOMPtr<nsIFile> mFile; nsWeakPtr mFileHandle; bool mWholeFile; public: // Create as a stored file - FileImplSnapshot(const nsAString& aName, + BlobImplSnapshot(const nsAString& aName, const nsAString& aContentType, MetadataParameters* aMetadataParams, nsIFile* aFile, IDBFileHandle* aFileHandle, FileInfo* aFileInfo); NS_DECL_ISUPPORTS_INHERITED private: // Create slice - FileImplSnapshot(const FileImplSnapshot* aOther, + BlobImplSnapshot(const BlobImplSnapshot* aOther, uint64_t aStart, uint64_t aLength, const nsAString& aContentType); - ~FileImplSnapshot(); + ~BlobImplSnapshot(); static void AssertSanity() #ifdef DEBUG ; #else { } #endif @@ -79,17 +79,17 @@ private: virtual nsresult GetInternalStream(nsIInputStream** aStream) override; virtual bool MayBeClonedToOtherThreads() const override { return false; } - virtual already_AddRefed<FileImpl> + virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) override; virtual bool IsStoredFile() const override;
--- a/dom/indexedDB/IDBDatabase.cpp +++ b/dom/indexedDB/IDBDatabase.cpp @@ -971,17 +971,17 @@ IDBDatabase::GetOrCreateFileActorForBlob // alive. nsCOMPtr<nsIDOMBlob> blob = aBlob; nsCOMPtr<nsIWeakReference> weakRef = do_GetWeakReference(blob); MOZ_ASSERT(weakRef); PBackgroundIDBDatabaseFileChild* actor = nullptr; if (!mFileActors.Get(weakRef, &actor)) { - FileImpl* blobImpl = aBlob->Impl(); + BlobImpl* blobImpl = aBlob->Impl(); MOZ_ASSERT(blobImpl); if (mReceivedBlobs.GetEntry(weakRef)) { // This blob was previously retrieved from the database. nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryObject(blobImpl); MOZ_ASSERT(remoteBlob); BlobChild* blobChild = remoteBlob->GetBlobChild(); @@ -1071,17 +1071,17 @@ void IDBDatabase::NoteReceivedBlob(Blob* aBlob) { AssertIsOnOwningThread(); MOZ_ASSERT(aBlob); MOZ_ASSERT(mBackgroundActor); #ifdef DEBUG { - nsRefPtr<FileImpl> blobImpl = aBlob->Impl(); + nsRefPtr<BlobImpl> blobImpl = aBlob->Impl(); MOZ_ASSERT(blobImpl); nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryObject(blobImpl); MOZ_ASSERT(remoteBlob); BlobChild* blobChild = remoteBlob->GetBlobChild(); MOZ_ASSERT(blobChild);
--- a/dom/indexedDB/IDBMutableFile.cpp +++ b/dom/indexedDB/IDBMutableFile.cpp @@ -327,18 +327,18 @@ IDBMutableFile::GetFileId() const return mFileInfo->Id(); } already_AddRefed<nsIDOMFile> IDBMutableFile::CreateFileObject(IDBFileHandle* aFileHandle, MetadataParameters* aMetadataParams) { - nsRefPtr<FileImpl> impl = - new FileImplSnapshot(mName, + nsRefPtr<BlobImpl> impl = + new BlobImplSnapshot(mName, mType, aMetadataParams, mFile, aFileHandle, mFileInfo); nsRefPtr<File> file = File::Create(GetOwner(), impl); MOZ_ASSERT(file);
--- a/dom/indexedDB/IDBObjectStore.cpp +++ b/dom/indexedDB/IDBObjectStore.cpp @@ -398,17 +398,17 @@ GetAddInfoCallback(JSContext* aCx, void* &data->mCloneWriteInfo)) { return NS_ERROR_DOM_DATA_CLONE_ERR; } return NS_OK; } BlobChild* -ActorFromRemoteFileImpl(FileImpl* aImpl) +ActorFromRemoteBlobImpl(BlobImpl* aImpl) { MOZ_ASSERT(aImpl); nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(aImpl); if (remoteBlob) { BlobChild* actor = remoteBlob->GetBlobChild(); MOZ_ASSERT(actor); @@ -424,36 +424,36 @@ ActorFromRemoteFileImpl(FileImpl* aImpl) return actor; } return nullptr; } bool -ResolveMysteryFile(FileImpl* aImpl, +ResolveMysteryFile(BlobImpl* aImpl, const nsString& aName, const nsString& aContentType, uint64_t aSize, uint64_t aLastModifiedDate) { - BlobChild* actor = ActorFromRemoteFileImpl(aImpl); + BlobChild* actor = ActorFromRemoteBlobImpl(aImpl); if (actor) { return actor->SetMysteryBlobInfo(aName, aContentType, aSize, aLastModifiedDate); } return true; } bool -ResolveMysteryBlob(FileImpl* aImpl, +ResolveMysteryBlob(BlobImpl* aImpl, const nsString& aContentType, uint64_t aSize) { - BlobChild* actor = ActorFromRemoteFileImpl(aImpl); + BlobChild* actor = ActorFromRemoteBlobImpl(aImpl); if (actor) { return actor->SetMysteryBlobInfo(aContentType, aSize); } return true; } bool StructuredCloneReadString(JSStructuredCloneReader* aReader,
--- a/dom/indexedDB/IndexedDatabaseManager.h +++ b/dom/indexedDB/IndexedDatabaseManager.h @@ -183,17 +183,17 @@ private: static void LoggingModePrefChangedCallback(const char* aPrefName, void* aClosure); // Maintains a list of all file managers per origin. This list isn't // protected by any mutex but it is only ever touched on the IO thread. nsClassHashtable<nsCStringHashKey, FileManagerInfo> mFileManagerInfos; - // Lock protecting FileManager.mFileInfos and FileImplBase.mFileInfos + // Lock protecting FileManager.mFileInfos and BlobImplBase.mFileInfos // It's s also used to atomically update FileInfo.mRefCnt, FileInfo.mDBRefCnt // and FileInfo.mSliceRefCnt mozilla::Mutex mFileMutex; static bool sIsMainProcess; static bool sFullSynchronousMode; static PRLogModuleInfo* sLoggingModule; static Atomic<LoggingMode> sLoggingMode;
--- a/dom/ipc/Blob.cpp +++ b/dom/ipc/Blob.cpp @@ -24,17 +24,17 @@ #include "mozilla/dom/PBlobStreamChild.h" #include "mozilla/dom/PBlobStreamParent.h" #include "mozilla/dom/indexedDB/FileSnapshot.h" #include "mozilla/dom/indexedDB/IndexedDatabaseManager.h" #include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/ipc/PBackgroundChild.h" #include "mozilla/ipc/PBackgroundParent.h" #include "mozilla/ipc/PFileDescriptorSetParent.h" -#include "MultipartFileImpl.h" +#include "MultipartBlobImpl.h" #include "nsDataHashtable.h" #include "nsHashKeys.h" #include "nsID.h" #include "nsIInputStream.h" #include "nsIIPCSerializableInputStream.h" #include "nsIMultiplexInputStream.h" #include "nsIRemoteBlob.h" #include "nsISeekableStream.h" @@ -400,30 +400,30 @@ NS_DEFINE_STATIC_IID_ACCESSOR(IPrivateRe // This class exists to keep a blob alive at least as long as its internal // stream. class BlobInputStreamTether final : public nsIMultiplexInputStream , public nsISeekableStream , public nsIIPCSerializableInputStream { nsCOMPtr<nsIInputStream> mStream; - nsRefPtr<FileImpl> mBlobImpl; + nsRefPtr<BlobImpl> mBlobImpl; nsIMultiplexInputStream* mWeakMultiplexStream; nsISeekableStream* mWeakSeekableStream; nsIIPCSerializableInputStream* mWeakSerializableStream; public: NS_DECL_THREADSAFE_ISUPPORTS NS_FORWARD_NSIINPUTSTREAM(mStream->) NS_FORWARD_SAFE_NSIMULTIPLEXINPUTSTREAM(mWeakMultiplexStream) NS_FORWARD_SAFE_NSISEEKABLESTREAM(mWeakSeekableStream) NS_FORWARD_SAFE_NSIIPCSERIALIZABLEINPUTSTREAM(mWeakSerializableStream) - BlobInputStreamTether(nsIInputStream* aStream, FileImpl* aBlobImpl) + BlobInputStreamTether(nsIInputStream* aStream, BlobImpl* aBlobImpl) : mStream(aStream) , mBlobImpl(aBlobImpl) , mWeakMultiplexStream(nullptr) , mWeakSeekableStream(nullptr) , mWeakSerializableStream(nullptr) { MOZ_ASSERT(aStream); MOZ_ASSERT(aBlobImpl); @@ -471,29 +471,29 @@ class RemoteInputStream final : public nsIInputStream , public nsISeekableStream , public nsIIPCSerializableInputStream , public IPrivateRemoteInputStream { Monitor mMonitor; BlobChild* mActor; nsCOMPtr<nsIInputStream> mStream; - nsRefPtr<FileImpl> mBlobImpl; + nsRefPtr<BlobImpl> mBlobImpl; nsCOMPtr<nsIEventTarget> mEventTarget; nsISeekableStream* mWeakSeekableStream; uint64_t mStart; uint64_t mLength; public: - RemoteInputStream(FileImpl* aBlobImpl, + RemoteInputStream(BlobImpl* aBlobImpl, uint64_t aStart, uint64_t aLength); RemoteInputStream(BlobChild* aActor, - FileImpl* aBlobImpl, + BlobImpl* aBlobImpl, uint64_t aStart, uint64_t aLength); bool IsOnOwningThread() const { return EventTargetIsOnCurrentThread(mEventTarget); } @@ -653,43 +653,43 @@ private: virtual void ActorDestroy(ActorDestroyReason aWhy) override { // Nothing needs to be done here. } }; class EmptyBlobImpl final - : public FileImplBase + : public BlobImplBase { public: explicit EmptyBlobImpl(const nsAString& aContentType) - : FileImplBase(aContentType, 0) + : BlobImplBase(aContentType, 0) { mImmutable = true; } EmptyBlobImpl(const nsAString& aName, const nsAString& aContentType, int64_t aLastModifiedDate) - : FileImplBase(aName, aContentType, 0, aLastModifiedDate) + : BlobImplBase(aName, aContentType, 0, aLastModifiedDate) { mImmutable = true; } private: - virtual already_AddRefed<FileImpl> + virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t /* aStart */, uint64_t aLength, const nsAString& aContentType, ErrorResult& /* aRv */) override { MOZ_ASSERT(!aLength); - nsRefPtr<FileImpl> sliceImpl = new EmptyBlobImpl(aContentType); + nsRefPtr<BlobImpl> sliceImpl = new EmptyBlobImpl(aContentType); DebugOnly<bool> isMutable; MOZ_ASSERT(NS_SUCCEEDED(sliceImpl->GetMutable(&isMutable))); MOZ_ASSERT(!isMutable); return sliceImpl.forget(); } @@ -703,52 +703,52 @@ private: if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } return NS_OK; } }; -// This is only needed for IndexedDB FileImplSnapshot. +// This is only needed for IndexedDB BlobImplSnapshot. class SameProcessInputStreamBlobImpl final - : public FileImplBase + : public BlobImplBase { nsCOMPtr<nsIInputStream> mInputStream; public: SameProcessInputStreamBlobImpl(const nsAString& aContentType, uint64_t aLength, nsIInputStream* aInputStream) - : FileImplBase(aContentType, aLength) + : BlobImplBase(aContentType, aLength) , mInputStream(aInputStream) { MOZ_ASSERT(aLength != UINT64_MAX); MOZ_ASSERT(aInputStream); mImmutable = true; } SameProcessInputStreamBlobImpl(const nsAString& aName, const nsAString& aContentType, uint64_t aLength, int64_t aLastModifiedDate, nsIInputStream* aInputStream) - : FileImplBase(aName, aContentType, aLength, aLastModifiedDate) + : BlobImplBase(aName, aContentType, aLength, aLastModifiedDate) , mInputStream(aInputStream) { MOZ_ASSERT(aLength != UINT64_MAX); MOZ_ASSERT(aLastModifiedDate != INT64_MAX); MOZ_ASSERT(aInputStream); mImmutable = true; } private: - virtual already_AddRefed<FileImpl> + virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t /* aStart */, uint64_t /* aLength */, const nsAString& /* aContentType */, ErrorResult& /* aRv */) override { MOZ_CRASH("Not implemented"); } @@ -790,48 +790,48 @@ struct MOZ_STACK_CLASS CreateBlobImplMet bool IsFile() const { return !mName.IsVoid(); } }; -already_AddRefed<FileImpl> +already_AddRefed<BlobImpl> CreateBlobImpl(const nsID& aKnownBlobIDData, const CreateBlobImplMetadata& aMetadata) { MOZ_ASSERT(gProcessType == GeckoProcessType_Default); MOZ_ASSERT(aMetadata.mHasRecursed); - nsRefPtr<FileImpl> blobImpl = BlobParent::GetBlobImplForID(aKnownBlobIDData); + nsRefPtr<BlobImpl> blobImpl = BlobParent::GetBlobImplForID(aKnownBlobIDData); if (NS_WARN_IF(!blobImpl)) { ASSERT_UNLESS_FUZZING(); return nullptr; } DebugOnly<bool> isMutable; MOZ_ASSERT(NS_SUCCEEDED(blobImpl->GetMutable(&isMutable))); MOZ_ASSERT(!isMutable); return blobImpl.forget(); } -already_AddRefed<FileImpl> +already_AddRefed<BlobImpl> CreateBlobImpl(const nsTArray<uint8_t>& aMemoryData, const CreateBlobImplMetadata& aMetadata) { static_assert(sizeof(aMemoryData.Length()) <= sizeof(size_t), "String length won't fit in size_t!"); static_assert(sizeof(size_t) <= sizeof(uint64_t), "size_t won't fit in uint64_t!"); MOZ_ASSERT(gProcessType == GeckoProcessType_Default); - nsRefPtr<FileImpl> blobImpl; + nsRefPtr<BlobImpl> blobImpl; if (auto length = static_cast<size_t>(aMemoryData.Length())) { static MOZ_CONSTEXPR_VAR size_t elementSizeMultiplier = sizeof(aMemoryData[0]) / sizeof(char); if (!aMetadata.mHasRecursed && NS_WARN_IF(aMetadata.mLength != uint64_t(length))) { ASSERT_UNLESS_FUZZING(); @@ -842,52 +842,52 @@ CreateBlobImpl(const nsTArray<uint8_t>& if (NS_WARN_IF(!buffer)) { return nullptr; } memcpy(buffer, aMemoryData.Elements(), length * elementSizeMultiplier); if (!aMetadata.mHasRecursed && aMetadata.IsFile()) { blobImpl = - new FileImplMemory(buffer, + new BlobImplMemory(buffer, uint64_t(length), aMetadata.mName, aMetadata.mContentType, aMetadata.mLastModifiedDate); } else { blobImpl = - new FileImplMemory(buffer, uint64_t(length), aMetadata.mContentType); + new BlobImplMemory(buffer, uint64_t(length), aMetadata.mContentType); } } else if (!aMetadata.mHasRecursed && aMetadata.IsFile()) { blobImpl = new EmptyBlobImpl(aMetadata.mName, aMetadata.mContentType, aMetadata.mLastModifiedDate); } else { blobImpl = new EmptyBlobImpl(aMetadata.mContentType); } MOZ_ALWAYS_TRUE(NS_SUCCEEDED(blobImpl->SetMutable(false))); return blobImpl.forget(); } -already_AddRefed<FileImpl> +already_AddRefed<BlobImpl> CreateBlobImpl(intptr_t aAddRefedInputStream, const CreateBlobImplMetadata& aMetadata) { MOZ_ASSERT(gProcessType == GeckoProcessType_Default); MOZ_ASSERT(aMetadata.mIsSameProcessActor); MOZ_ASSERT(aAddRefedInputStream); nsCOMPtr<nsIInputStream> inputStream = dont_AddRef( reinterpret_cast<nsIInputStream*>(aAddRefedInputStream)); - nsRefPtr<FileImpl> blobImpl; + nsRefPtr<BlobImpl> blobImpl; if (!aMetadata.mHasRecursed && aMetadata.IsFile()) { blobImpl = new SameProcessInputStreamBlobImpl(aMetadata.mName, aMetadata.mContentType, aMetadata.mLength, aMetadata.mLastModifiedDate, inputStream); } else { @@ -899,27 +899,27 @@ CreateBlobImpl(intptr_t aAddRefedInputSt DebugOnly<bool> isMutable; MOZ_ASSERT(NS_SUCCEEDED(blobImpl->GetMutable(&isMutable))); MOZ_ASSERT(!isMutable); return blobImpl.forget(); } -already_AddRefed<FileImpl> +already_AddRefed<BlobImpl> CreateBlobImpl(const nsTArray<BlobData>& aBlobData, CreateBlobImplMetadata& aMetadata); -already_AddRefed<FileImpl> +already_AddRefed<BlobImpl> CreateBlobImplFromBlobData(const BlobData& aBlobData, CreateBlobImplMetadata& aMetadata) { MOZ_ASSERT(gProcessType == GeckoProcessType_Default); - nsRefPtr<FileImpl> blobImpl; + nsRefPtr<BlobImpl> blobImpl; switch (aBlobData.type()) { case BlobData::TnsID: { blobImpl = CreateBlobImpl(aBlobData.get_nsID(), aMetadata); break; } case BlobData::TArrayOfuint8_t: { @@ -939,81 +939,81 @@ CreateBlobImplFromBlobData(const BlobDat default: MOZ_CRASH("Unknown params!"); } return blobImpl.forget(); } -already_AddRefed<FileImpl> +already_AddRefed<BlobImpl> CreateBlobImpl(const nsTArray<BlobData>& aBlobDatas, CreateBlobImplMetadata& aMetadata) { MOZ_ASSERT(gProcessType == GeckoProcessType_Default); // Special case for a multipart blob with only one part. if (aBlobDatas.Length() == 1) { const BlobData& blobData = aBlobDatas[0]; - nsRefPtr<FileImpl> blobImpl = + nsRefPtr<BlobImpl> blobImpl = CreateBlobImplFromBlobData(blobData, aMetadata); if (NS_WARN_IF(!blobImpl)) { return nullptr; } DebugOnly<bool> isMutable; MOZ_ASSERT(NS_SUCCEEDED(blobImpl->GetMutable(&isMutable))); MOZ_ASSERT(!isMutable); return blobImpl.forget(); } - FallibleTArray<nsRefPtr<FileImpl>> fallibleBlobImpls; + FallibleTArray<nsRefPtr<BlobImpl>> fallibleBlobImpls; if (NS_WARN_IF(!fallibleBlobImpls.SetLength(aBlobDatas.Length()))) { return nullptr; } - nsTArray<nsRefPtr<FileImpl>> blobImpls; + nsTArray<nsRefPtr<BlobImpl>> blobImpls; fallibleBlobImpls.SwapElements(blobImpls); const bool hasRecursed = aMetadata.mHasRecursed; aMetadata.mHasRecursed = true; for (uint32_t count = aBlobDatas.Length(), index = 0; index < count; index++) { const BlobData& blobData = aBlobDatas[index]; - nsRefPtr<FileImpl>& blobImpl = blobImpls[index]; + nsRefPtr<BlobImpl>& blobImpl = blobImpls[index]; blobImpl = CreateBlobImplFromBlobData(blobData, aMetadata); if (NS_WARN_IF(!blobImpl)) { return nullptr; } DebugOnly<bool> isMutable; MOZ_ASSERT(NS_SUCCEEDED(blobImpl->GetMutable(&isMutable))); MOZ_ASSERT(!isMutable); } - nsRefPtr<FileImpl> blobImpl; + nsRefPtr<BlobImpl> blobImpl; if (!hasRecursed && aMetadata.IsFile()) { blobImpl = - new MultipartFileImpl(blobImpls, aMetadata.mName, aMetadata.mContentType); + new MultipartBlobImpl(blobImpls, aMetadata.mName, aMetadata.mContentType); } else { blobImpl = - new MultipartFileImpl(blobImpls, aMetadata.mContentType); + new MultipartBlobImpl(blobImpls, aMetadata.mContentType); } MOZ_ALWAYS_TRUE(NS_SUCCEEDED(blobImpl->SetMutable(false))); return blobImpl.forget(); } -already_AddRefed<FileImpl> +already_AddRefed<BlobImpl> CreateBlobImpl(const ParentBlobConstructorParams& aParams, const BlobData& aBlobData, bool aIsSameProcessActor) { MOZ_ASSERT(gProcessType == GeckoProcessType_Default); MOZ_ASSERT(aParams.blobParams().type() == AnyBlobConstructorParams::TNormalBlobConstructorParams || aParams.blobParams().type() == @@ -1048,28 +1048,28 @@ CreateBlobImpl(const ParentBlobConstruct } metadata.mContentType = params.contentType(); metadata.mName = params.name(); metadata.mLength = params.length(); metadata.mLastModifiedDate = params.modDate(); } - nsRefPtr<FileImpl> blobImpl = + nsRefPtr<BlobImpl> blobImpl = CreateBlobImplFromBlobData(aBlobData, metadata); return blobImpl.forget(); } void -BlobDataFromBlobImpl(FileImpl* aBlobImpl, BlobData& aBlobData) +BlobDataFromBlobImpl(BlobImpl* aBlobImpl, BlobData& aBlobData) { MOZ_ASSERT(gProcessType != GeckoProcessType_Default); MOZ_ASSERT(aBlobImpl); - const nsTArray<nsRefPtr<FileImpl>>* subBlobs = aBlobImpl->GetSubBlobImpls(); + const nsTArray<nsRefPtr<BlobImpl>>* subBlobs = aBlobImpl->GetSubBlobImpls(); if (subBlobs) { aBlobData = nsTArray<BlobData>(); nsTArray<BlobData>& subBlobDatas = aBlobData.get_ArrayOfBlobData(); subBlobDatas.SetLength(subBlobs->Length()); for (uint32_t count = subBlobs->Length(), index = 0; @@ -1113,17 +1113,17 @@ BlobDataFromBlobImpl(FileImpl* aBlobImpl uint32_t readCount; MOZ_ALWAYS_TRUE(NS_SUCCEEDED( inputStream->Read(reinterpret_cast<char*>(blobData.Elements()), uint32_t(available), &readCount))); } -RemoteInputStream::RemoteInputStream(FileImpl* aBlobImpl, +RemoteInputStream::RemoteInputStream(BlobImpl* aBlobImpl, uint64_t aStart, uint64_t aLength) : mMonitor("RemoteInputStream.mMonitor") , mActor(nullptr) , mBlobImpl(aBlobImpl) , mWeakSeekableStream(nullptr) , mStart(aStart) , mLength(aLength) @@ -1134,17 +1134,17 @@ RemoteInputStream::RemoteInputStream(Fil mEventTarget = do_GetCurrentThread(); MOZ_ASSERT(mEventTarget); } MOZ_ASSERT(IsOnOwningThread()); } RemoteInputStream::RemoteInputStream(BlobChild* aActor, - FileImpl* aBlobImpl, + BlobImpl* aBlobImpl, uint64_t aStart, uint64_t aLength) : mMonitor("RemoteInputStream.mMonitor") , mActor(aActor) , mBlobImpl(aBlobImpl) , mEventTarget(NS_GetCurrentThread()) , mWeakSeekableStream(nullptr) , mStart(aStart) @@ -1283,17 +1283,17 @@ NS_INTERFACE_MAP_BEGIN(RemoteInputStream NS_INTERFACE_MAP_END NS_IMETHODIMP RemoteInputStream::Close() { nsresult rv = BlockAndWaitForStream(); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr<FileImpl> blobImpl; + nsRefPtr<BlobImpl> blobImpl; mBlobImpl.swap(blobImpl); rv = mStream->Close(); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } @@ -1488,21 +1488,21 @@ StaticAutoPtr<Mutex> BlobParent::sIDTabl /******************************************************************************* * BlobParent::IDTableEntry Declaration ******************************************************************************/ class BlobParent::IDTableEntry final { const nsID mID; const intptr_t mProcessID; - const nsRefPtr<FileImpl> mBlobImpl; + const nsRefPtr<BlobImpl> mBlobImpl; public: static already_AddRefed<IDTableEntry> - Create(const nsID& aID, intptr_t aProcessID, FileImpl* aBlobImpl) + Create(const nsID& aID, intptr_t aProcessID, BlobImpl* aBlobImpl) { MOZ_ASSERT(aBlobImpl); DebugOnly<bool> isMutable; MOZ_ASSERT(NS_SUCCEEDED(aBlobImpl->GetMutable(&isMutable))); MOZ_ASSERT(!isMutable); return GetOrCreateInternal(aID, @@ -1531,17 +1531,17 @@ public: 0, nullptr, /* aMayCreate */ false, /* aMayGet */ true, /* aIgnoreProcessID */ true); } static already_AddRefed<IDTableEntry> - GetOrCreate(const nsID& aID, intptr_t aProcessID, FileImpl* aBlobImpl) + GetOrCreate(const nsID& aID, intptr_t aProcessID, BlobImpl* aBlobImpl) { MOZ_ASSERT(aBlobImpl); DebugOnly<bool> isMutable; MOZ_ASSERT(NS_SUCCEEDED(aBlobImpl->GetMutable(&isMutable))); MOZ_ASSERT(!isMutable); return GetOrCreateInternal(aID, @@ -1559,32 +1559,32 @@ public: } intptr_t ProcessID() const { return mProcessID; } - FileImpl* - BlobImpl() const + BlobImpl* + GetBlobImpl() const { return mBlobImpl; } NS_INLINE_DECL_THREADSAFE_REFCOUNTING(IDTableEntry) private: - IDTableEntry(const nsID& aID, intptr_t aProcessID, FileImpl* aBlobImpl); + IDTableEntry(const nsID& aID, intptr_t aProcessID, BlobImpl* aBlobImpl); ~IDTableEntry(); static already_AddRefed<IDTableEntry> GetOrCreateInternal(const nsID& aID, intptr_t aProcessID, - FileImpl* aBlobImpl, + BlobImpl* aBlobImpl, bool aMayCreate, bool aMayGet, bool aIgnoreProcessID); }; /******************************************************************************* * BlobParent::OpenStreamRunnable Declaration ******************************************************************************/ @@ -1827,26 +1827,26 @@ private: NS_IMPL_ISUPPORTS_INHERITED0(BlobParent::OpenStreamRunnable, nsRunnable) /******************************************************************************* * BlobChild::RemoteBlobImpl Declaration ******************************************************************************/ class BlobChild::RemoteBlobImpl - : public FileImplBase + : public BlobImplBase , public nsIRemoteBlob { protected: class CreateStreamHelper; BlobChild* mActor; nsCOMPtr<nsIEventTarget> mActorTarget; - nsRefPtr<FileImpl> mSameProcessFileImpl; + nsRefPtr<BlobImpl> mSameProcessBlobImpl; const bool mIsSlice; public: // For File. RemoteBlobImpl(BlobChild* aActor, const nsAString& aName, const nsAString& aContentType, @@ -1855,25 +1855,25 @@ public: // For Blob. RemoteBlobImpl(BlobChild* aActor, const nsAString& aContentType, uint64_t aLength); // For same-process blobs. RemoteBlobImpl(BlobChild* aActor, - FileImpl* aSameProcessBlobImpl, + BlobImpl* aSameProcessBlobImpl, const nsAString& aName, const nsAString& aContentType, uint64_t aLength, int64_t aModDate); // For same-process blobs. RemoteBlobImpl(BlobChild* aActor, - FileImpl* aSameProcessBlobImpl, + BlobImpl* aSameProcessBlobImpl, const nsAString& aContentType, uint64_t aLength); // For mystery blobs. explicit RemoteBlobImpl(BlobChild* aActor); void @@ -1911,17 +1911,17 @@ public: RemoteBlobImpl* BaseRemoteBlobImpl() const; NS_DECL_ISUPPORTS_INHERITED virtual void GetMozFullPathInternal(nsAString& aFileName, ErrorResult& aRv) override; - virtual already_AddRefed<FileImpl> + virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) override; virtual nsresult GetInternalStream(nsIInputStream** aStream) override; @@ -2041,25 +2041,25 @@ private: EnsureActorWasCreatedInternal(); }; /******************************************************************************* * BlobParent::RemoteBlobImpl Declaration ******************************************************************************/ class BlobParent::RemoteBlobImpl final - : public FileImpl + : public BlobImpl , public nsIRemoteBlob { BlobParent* mActor; nsCOMPtr<nsIEventTarget> mActorTarget; - nsRefPtr<FileImpl> mBlobImpl; + nsRefPtr<BlobImpl> mBlobImpl; public: - RemoteBlobImpl(BlobParent* aActor, FileImpl* aBlobImpl); + RemoteBlobImpl(BlobParent* aActor, BlobImpl* aBlobImpl); void NoteDyingActor(); NS_DECL_ISUPPORTS_INHERITED virtual void GetName(nsAString& aName) override; @@ -2080,23 +2080,23 @@ public: GetMozFullPathInternal(nsAString& aFileName, ErrorResult& aRv) override; virtual uint64_t GetSize(ErrorResult& aRv) override; virtual void GetType(nsAString& aType) override; - virtual already_AddRefed<FileImpl> + virtual already_AddRefed<BlobImpl> CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) override; - virtual const nsTArray<nsRefPtr<FileImpl>>* + virtual const nsTArray<nsRefPtr<BlobImpl>>* GetSubBlobImpls() const override; virtual nsresult GetInternalStream(nsIInputStream** aStream) override; virtual int64_t GetFileId() override; @@ -2161,75 +2161,75 @@ private: ******************************************************************************/ BlobChild:: RemoteBlobImpl::RemoteBlobImpl(BlobChild* aActor, const nsAString& aName, const nsAString& aContentType, uint64_t aLength, int64_t aModDate) - : FileImplBase(aName, aContentType, aLength, aModDate) + : BlobImplBase(aName, aContentType, aLength, aModDate) , mIsSlice(false) { CommonInit(aActor); } BlobChild:: RemoteBlobImpl::RemoteBlobImpl(BlobChild* aActor, const nsAString& aContentType, uint64_t aLength) - : FileImplBase(aContentType, aLength) + : BlobImplBase(aContentType, aLength) , mIsSlice(false) { CommonInit(aActor); } BlobChild:: RemoteBlobImpl::RemoteBlobImpl(BlobChild* aActor, - FileImpl* aSameProcessBlobImpl, + BlobImpl* aSameProcessBlobImpl, const nsAString& aName, const nsAString& aContentType, uint64_t aLength, int64_t aModDate) - : FileImplBase(aName, aContentType, aLength, aModDate) - , mSameProcessFileImpl(aSameProcessBlobImpl) + : BlobImplBase(aName, aContentType, aLength, aModDate) + , mSameProcessBlobImpl(aSameProcessBlobImpl) , mIsSlice(false) { MOZ_ASSERT(aSameProcessBlobImpl); MOZ_ASSERT(gProcessType == GeckoProcessType_Default); CommonInit(aActor); } BlobChild:: RemoteBlobImpl::RemoteBlobImpl(BlobChild* aActor, - FileImpl* aSameProcessBlobImpl, + BlobImpl* aSameProcessBlobImpl, const nsAString& aContentType, uint64_t aLength) - : FileImplBase(aContentType, aLength) - , mSameProcessFileImpl(aSameProcessBlobImpl) + : BlobImplBase(aContentType, aLength) + , mSameProcessBlobImpl(aSameProcessBlobImpl) , mIsSlice(false) { MOZ_ASSERT(aSameProcessBlobImpl); MOZ_ASSERT(gProcessType == GeckoProcessType_Default); CommonInit(aActor); } BlobChild:: RemoteBlobImpl::RemoteBlobImpl(BlobChild* aActor) - : FileImplBase(EmptyString(), EmptyString(), UINT64_MAX, INT64_MAX) + : BlobImplBase(EmptyString(), EmptyString(), UINT64_MAX, INT64_MAX) , mIsSlice(false) { CommonInit(aActor); } BlobChild:: RemoteBlobImpl::RemoteBlobImpl(const nsAString& aContentType, uint64_t aLength) - : FileImplBase(aContentType, aLength) + : BlobImplBase(aContentType, aLength) , mActor(nullptr) , mIsSlice(true) { mImmutable = true; } void BlobChild:: @@ -2301,32 +2301,32 @@ RemoteBlobImpl::Destroy() } else { MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(destroyRunnable))); } } NS_IMPL_ADDREF(BlobChild::RemoteBlobImpl) NS_IMPL_RELEASE_WITH_DESTROY(BlobChild::RemoteBlobImpl, Destroy()) NS_IMPL_QUERY_INTERFACE_INHERITED(BlobChild::RemoteBlobImpl, - FileImpl, + BlobImpl, nsIRemoteBlob) void BlobChild:: RemoteBlobImpl::GetMozFullPathInternal(nsAString& aFilePath, ErrorResult& aRv) { if (!EventTargetIsOnCurrentThread(mActorTarget)) { MOZ_CRASH("Not implemented!"); } - if (mSameProcessFileImpl) { + if (mSameProcessBlobImpl) { MOZ_ASSERT(gProcessType == GeckoProcessType_Default); - mSameProcessFileImpl->GetMozFullPathInternal(aFilePath, aRv); + mSameProcessBlobImpl->GetMozFullPathInternal(aFilePath, aRv); return; } if (!mActor) { aRv.Throw(NS_ERROR_UNEXPECTED); return; } @@ -2334,75 +2334,75 @@ RemoteBlobImpl::GetMozFullPathInternal(n if (!mActor->SendGetFilePath(&filePath)) { aRv.Throw(NS_ERROR_FAILURE); return; } aFilePath = filePath; } -already_AddRefed<FileImpl> +already_AddRefed<BlobImpl> BlobChild:: RemoteBlobImpl::CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) { // May be called on any thread. - if (mSameProcessFileImpl) { + if (mSameProcessBlobImpl) { MOZ_ASSERT(gProcessType == GeckoProcessType_Default); - return mSameProcessFileImpl->CreateSlice(aStart, + return mSameProcessBlobImpl->CreateSlice(aStart, aLength, aContentType, aRv); } nsRefPtr<RemoteBlobSliceImpl> slice = new RemoteBlobSliceImpl(this, aStart, aLength, aContentType); return slice.forget(); } nsresult BlobChild:: RemoteBlobImpl::GetInternalStream(nsIInputStream** aStream) { // May be called on any thread. - if (mSameProcessFileImpl) { + if (mSameProcessBlobImpl) { MOZ_ASSERT(gProcessType == GeckoProcessType_Default); nsCOMPtr<nsIInputStream> realStream; nsresult rv = - mSameProcessFileImpl->GetInternalStream(getter_AddRefs(realStream)); + mSameProcessBlobImpl->GetInternalStream(getter_AddRefs(realStream)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } nsRefPtr<BlobInputStreamTether> tether = - new BlobInputStreamTether(realStream, mSameProcessFileImpl); + new BlobInputStreamTether(realStream, mSameProcessBlobImpl); tether.forget(aStream); return NS_OK; } nsRefPtr<CreateStreamHelper> helper = new CreateStreamHelper(this); return helper->GetStream(aStream); } int64_t BlobChild:: RemoteBlobImpl::GetFileId() { if (!EventTargetIsOnCurrentThread(mActorTarget)) { MOZ_CRASH("Not implemented!"); } - if (mSameProcessFileImpl) { + if (mSameProcessBlobImpl) { MOZ_ASSERT(gProcessType == GeckoProcessType_Default); - return mSameProcessFileImpl->GetFileId(); + return mSameProcessBlobImpl->GetFileId(); } int64_t fileId; if (mActor && mActor->SendGetFileId(&fileId)) { return fileId; } return -1; @@ -2431,17 +2431,17 @@ BlobChild:: RemoteBlobImpl::SetMutable(bool aMutable) { if (!aMutable && IsSlice()) { // Make sure that slices are backed by a real actor now while we are still // on the correct thread. AsSlice()->EnsureActorWasCreated(); } - nsresult rv = FileImplBase::SetMutable(aMutable); + nsresult rv = BlobImplBase::SetMutable(aMutable); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } MOZ_ASSERT_IF(!aMutable, mImmutable); return NS_OK; } @@ -2672,17 +2672,17 @@ RemoteBlobSliceImpl::GetBlobChild() return RemoteBlobImpl::GetBlobChild(); } /******************************************************************************* * BlobParent::RemoteBlobImpl ******************************************************************************/ BlobParent:: -RemoteBlobImpl::RemoteBlobImpl(BlobParent* aActor, FileImpl* aBlobImpl) +RemoteBlobImpl::RemoteBlobImpl(BlobParent* aActor, BlobImpl* aBlobImpl) : mActor(aActor) , mActorTarget(aActor->EventTarget()) , mBlobImpl(aBlobImpl) { MOZ_ASSERT(aActor); aActor->AssertIsOnOwningThread(); MOZ_ASSERT(aBlobImpl); @@ -2727,17 +2727,17 @@ RemoteBlobImpl::Destroy() } else { MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(destroyRunnable))); } } NS_IMPL_ADDREF(BlobParent::RemoteBlobImpl) NS_IMPL_RELEASE_WITH_DESTROY(BlobParent::RemoteBlobImpl, Destroy()) NS_IMPL_QUERY_INTERFACE_INHERITED(BlobParent::RemoteBlobImpl, - FileImpl, + BlobImpl, nsIRemoteBlob) void BlobParent:: RemoteBlobImpl::GetName(nsAString& aName) { mBlobImpl->GetName(aName); } @@ -2786,27 +2786,27 @@ RemoteBlobImpl::GetSize(ErrorResult& aRv void BlobParent:: RemoteBlobImpl::GetType(nsAString& aType) { mBlobImpl->GetType(aType); } -already_AddRefed<FileImpl> +already_AddRefed<BlobImpl> BlobParent:: RemoteBlobImpl::CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType, ErrorResult& aRv) { return mBlobImpl->CreateSlice(aStart, aLength, aContentType, aRv); } -const nsTArray<nsRefPtr<FileImpl>>* +const nsTArray<nsRefPtr<BlobImpl>>* BlobParent:: RemoteBlobImpl::GetSubBlobImpls() const { return mBlobImpl->GetSubBlobImpls(); } nsresult BlobParent:: @@ -2921,27 +2921,27 @@ RemoteBlobImpl::GetBlobParent() { return mActor; } /******************************************************************************* * BlobChild ******************************************************************************/ -BlobChild::BlobChild(nsIContentChild* aManager, FileImpl* aBlobImpl) +BlobChild::BlobChild(nsIContentChild* aManager, BlobImpl* aBlobImpl) : mBackgroundManager(nullptr) , mContentManager(aManager) { AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aManager); CommonInit(aBlobImpl); } -BlobChild::BlobChild(PBackgroundChild* aManager, FileImpl* aBlobImpl) +BlobChild::BlobChild(PBackgroundChild* aManager, BlobImpl* aBlobImpl) : mBackgroundManager(aManager) , mContentManager(nullptr) { AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aManager); if (!NS_IsMainThread()) { mEventTarget = do_GetCurrentThread(); @@ -2958,17 +2958,17 @@ BlobChild::BlobChild(nsIContentChild* aM AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aManager); CommonInit(aOther, /* aBlobImpl */ nullptr); } BlobChild::BlobChild(PBackgroundChild* aManager, BlobChild* aOther, - FileImpl* aBlobImpl) + BlobImpl* aBlobImpl) : mBackgroundManager(aManager) , mContentManager(nullptr) { AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aManager); MOZ_ASSERT(aBlobImpl); if (!NS_IsMainThread()) { @@ -3038,42 +3038,42 @@ BlobChild::BlobChild(PBackgroundChild* a BlobChild::~BlobChild() { AssertIsOnOwningThread(); MOZ_COUNT_DTOR(BlobChild); } void -BlobChild::CommonInit(FileImpl* aBlobImpl) +BlobChild::CommonInit(BlobImpl* aBlobImpl) { AssertIsOnOwningThread(); MOZ_ASSERT(aBlobImpl); MOZ_COUNT_CTOR(BlobChild); mBlobImpl = aBlobImpl; mRemoteBlobImpl = nullptr; mBlobImpl->AddRef(); mOwnsBlobImpl = true; memset(&mParentID, 0, sizeof(mParentID)); } void -BlobChild::CommonInit(BlobChild* aOther, FileImpl* aBlobImpl) +BlobChild::CommonInit(BlobChild* aOther, BlobImpl* aBlobImpl) { AssertIsOnOwningThread(); MOZ_ASSERT(aOther); MOZ_ASSERT_IF(mContentManager, aOther->GetBackgroundManager()); MOZ_ASSERT_IF(mContentManager, !aBlobImpl); MOZ_ASSERT_IF(mBackgroundManager, aBlobImpl); - nsRefPtr<FileImpl> otherImpl; + nsRefPtr<BlobImpl> otherImpl; if (mBackgroundManager && aOther->GetBackgroundManager()) { otherImpl = aBlobImpl; } else { otherImpl = aOther->GetBlobImpl(); } MOZ_ASSERT(otherImpl); nsString contentType; @@ -3137,20 +3137,20 @@ BlobChild::CommonInit(const ChildBlobCon break; } case AnyBlobConstructorParams::TSameProcessBlobConstructorParams: { MOZ_ASSERT(gProcessType == GeckoProcessType_Default); const SameProcessBlobConstructorParams& params = blobParams.get_SameProcessBlobConstructorParams(); - MOZ_ASSERT(params.addRefedFileImpl()); - - nsRefPtr<FileImpl> blobImpl = - dont_AddRef(reinterpret_cast<FileImpl*>(params.addRefedFileImpl())); + MOZ_ASSERT(params.addRefedBlobImpl()); + + nsRefPtr<BlobImpl> blobImpl = + dont_AddRef(reinterpret_cast<BlobImpl*>(params.addRefedBlobImpl())); ErrorResult rv; uint64_t size = blobImpl->GetSize(rv); MOZ_ASSERT(!rv.Failed()); nsString contentType; blobImpl->GetType(contentType); @@ -3236,27 +3236,27 @@ BlobChild::Startup(const FriendKey& /* a { MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default); CommonStartup(); } // static BlobChild* -BlobChild::GetOrCreate(nsIContentChild* aManager, FileImpl* aBlobImpl) +BlobChild::GetOrCreate(nsIContentChild* aManager, BlobImpl* aBlobImpl) { AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aManager); return GetOrCreateFromImpl(aManager, aBlobImpl); } // static BlobChild* -BlobChild::GetOrCreate(PBackgroundChild* aManager, FileImpl* aBlobImpl) +BlobChild::GetOrCreate(PBackgroundChild* aManager, BlobImpl* aBlobImpl) { AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aManager); return GetOrCreateFromImpl(aManager, aBlobImpl); } // static @@ -3280,17 +3280,17 @@ BlobChild::Create(PBackgroundChild* aMan return CreateFromParams(aManager, aParams); } // static template <class ChildManagerType> BlobChild* BlobChild::GetOrCreateFromImpl(ChildManagerType* aManager, - FileImpl* aBlobImpl) + BlobImpl* aBlobImpl) { AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aManager); MOZ_ASSERT(aBlobImpl); // If the blob represents a remote blob then we can simply pass its actor back // here. if (nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(aBlobImpl)) { @@ -3309,29 +3309,29 @@ BlobChild::GetOrCreateFromImpl(ChildMana MOZ_ASSERT(!aBlobImpl->IsSizeUnknown()); MOZ_ASSERT(!aBlobImpl->IsDateUnknown()); AnyBlobConstructorParams blobParams; nsCOMPtr<nsIInputStream> snapshotInputStream; if (gProcessType == GeckoProcessType_Default) { - nsCOMPtr<PIFileImplSnapshot> snapshot = do_QueryInterface(aBlobImpl); + nsCOMPtr<PIBlobImplSnapshot> snapshot = do_QueryInterface(aBlobImpl); if (snapshot) { MOZ_ALWAYS_TRUE(NS_SUCCEEDED( aBlobImpl->GetInternalStream(getter_AddRefs(snapshotInputStream)))); } } if (gProcessType == GeckoProcessType_Default && !snapshotInputStream) { - nsRefPtr<FileImpl> sameProcessImpl = aBlobImpl; - auto addRefedFileImpl = + nsRefPtr<BlobImpl> sameProcessImpl = aBlobImpl; + auto addRefedBlobImpl = reinterpret_cast<intptr_t>(sameProcessImpl.forget().take()); - blobParams = SameProcessBlobConstructorParams(addRefedFileImpl); + blobParams = SameProcessBlobConstructorParams(addRefedBlobImpl); } else { BlobData blobData; if (snapshotInputStream) { blobData = reinterpret_cast<intptr_t>(snapshotInputStream.forget().take()); } else { BlobDataFromBlobImpl(aBlobImpl, blobData); } @@ -3428,17 +3428,17 @@ BlobChild::SendSliceConstructor(ChildMan return nullptr; } // static BlobChild* BlobChild::MaybeGetActorFromRemoteBlob(nsIRemoteBlob* aRemoteBlob, nsIContentChild* aManager, - FileImpl* aBlobImpl) + BlobImpl* aBlobImpl) { AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aRemoteBlob); MOZ_ASSERT(aManager); MOZ_ASSERT(aBlobImpl); if (BlobChild* actor = aRemoteBlob->GetBlobChild()) { if (actor->GetContentManager() == aManager) { @@ -3459,17 +3459,17 @@ BlobChild::MaybeGetActorFromRemoteBlob(n return nullptr; } // static BlobChild* BlobChild::MaybeGetActorFromRemoteBlob(nsIRemoteBlob* aRemoteBlob, PBackgroundChild* aManager, - FileImpl* aBlobImpl) + BlobImpl* aBlobImpl) { AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aRemoteBlob); MOZ_ASSERT(aManager); MOZ_ASSERT(aBlobImpl); if (BlobChild* actor = aRemoteBlob->GetBlobChild()) { if (actor->GetBackgroundManager() == aManager) { @@ -3492,23 +3492,23 @@ BlobChild::MaybeGetActorFromRemoteBlob(n const nsID& BlobChild::ParentID() const { MOZ_ASSERT(mRemoteBlobImpl); return mParentID; } -already_AddRefed<FileImpl> +already_AddRefed<BlobImpl> BlobChild::GetBlobImpl() { AssertIsOnOwningThread(); MOZ_ASSERT(mBlobImpl); - nsRefPtr<FileImpl> blobImpl; + nsRefPtr<BlobImpl> blobImpl; // Remote blobs are held alive until the first call to GetBlobImpl. Thereafter // we only hold a weak reference. Normal blobs are held alive until the actor // is destroyed. if (mRemoteBlobImpl && mOwnsBlobImpl) { blobImpl = dont_AddRef(mBlobImpl); mOwnsBlobImpl = false; } else { @@ -3661,29 +3661,29 @@ BlobParent::BlobParent(PBackgroundParent AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aManager); MOZ_ASSERT(mEventTarget); CommonInit(aIDTableEntry); } BlobParent::BlobParent(nsIContentParent* aManager, - FileImpl* aBlobImpl, + BlobImpl* aBlobImpl, IDTableEntry* aIDTableEntry) : mBackgroundManager(nullptr) , mContentManager(aManager) { AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aManager); CommonInit(aBlobImpl, aIDTableEntry); } BlobParent::BlobParent(PBackgroundParent* aManager, - FileImpl* aBlobImpl, + BlobImpl* aBlobImpl, IDTableEntry* aIDTableEntry) : mBackgroundManager(aManager) , mContentManager(nullptr) , mEventTarget(do_GetCurrentThread()) { AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aManager); MOZ_ASSERT(mEventTarget); @@ -3698,31 +3698,31 @@ BlobParent::~BlobParent() MOZ_COUNT_DTOR(BlobParent); } void BlobParent::CommonInit(IDTableEntry* aIDTableEntry) { AssertIsOnOwningThread(); MOZ_ASSERT(aIDTableEntry); - MOZ_ASSERT(aIDTableEntry->BlobImpl()); + MOZ_ASSERT(aIDTableEntry->GetBlobImpl()); MOZ_COUNT_CTOR(BlobParent); - mBlobImpl = aIDTableEntry->BlobImpl(); + mBlobImpl = aIDTableEntry->GetBlobImpl(); mRemoteBlobImpl = nullptr; mBlobImpl->AddRef(); mOwnsBlobImpl = true; mIDTableEntry = aIDTableEntry; } void -BlobParent::CommonInit(FileImpl* aBlobImpl, IDTableEntry* aIDTableEntry) +BlobParent::CommonInit(BlobImpl* aBlobImpl, IDTableEntry* aIDTableEntry) { AssertIsOnOwningThread(); MOZ_ASSERT(aBlobImpl); MOZ_ASSERT(aIDTableEntry); MOZ_COUNT_CTOR(BlobParent); DebugOnly<bool> isMutable; @@ -3763,27 +3763,27 @@ BlobParent::Startup(const FriendKey& /* ClearOnShutdown(&sIDTable); sIDTableMutex = new Mutex("BlobParent::sIDTableMutex"); ClearOnShutdown(&sIDTableMutex); } // static BlobParent* -BlobParent::GetOrCreate(nsIContentParent* aManager, FileImpl* aBlobImpl) +BlobParent::GetOrCreate(nsIContentParent* aManager, BlobImpl* aBlobImpl) { AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aManager); return GetOrCreateFromImpl(aManager, aBlobImpl); } // static BlobParent* -BlobParent::GetOrCreate(PBackgroundParent* aManager, FileImpl* aBlobImpl) +BlobParent::GetOrCreate(PBackgroundParent* aManager, BlobImpl* aBlobImpl) { AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aManager); return GetOrCreateFromImpl(aManager, aBlobImpl); } // static @@ -3804,40 +3804,40 @@ BlobParent::Create(PBackgroundParent* aM { AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aManager); return CreateFromParams(aManager, aParams); } // static -already_AddRefed<FileImpl> +already_AddRefed<BlobImpl> BlobParent::GetBlobImplForID(const nsID& aID) { if (NS_WARN_IF(gProcessType != GeckoProcessType_Default)) { ASSERT_UNLESS_FUZZING(); return nullptr; } nsRefPtr<IDTableEntry> idTableEntry = IDTableEntry::Get(aID); if (NS_WARN_IF(!idTableEntry)) { return nullptr; } - nsRefPtr<FileImpl> blobImpl = idTableEntry->BlobImpl(); + nsRefPtr<BlobImpl> blobImpl = idTableEntry->GetBlobImpl(); MOZ_ASSERT(blobImpl); return blobImpl.forget(); } // static template <class ParentManagerType> BlobParent* BlobParent::GetOrCreateFromImpl(ParentManagerType* aManager, - FileImpl* aBlobImpl) + BlobImpl* aBlobImpl) { AssertCorrectThreadForManager(aManager); MOZ_ASSERT(aManager); MOZ_ASSERT(aBlobImpl); // If the blob represents a remote blob for this manager then we can simply // pass its actor back here. if (nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(aBlobImpl)) { @@ -3854,28 +3854,28 @@ BlobParent::GetOrCreateFromImpl(ParentMa const bool isSameProcessActor = ActorManagerIsSameProcess(aManager); AnyBlobConstructorParams blobParams; bool isSnapshot; if (isSameProcessActor) { - nsCOMPtr<PIFileImplSnapshot> snapshot = do_QueryInterface(aBlobImpl); + nsCOMPtr<PIBlobImplSnapshot> snapshot = do_QueryInterface(aBlobImpl); isSnapshot = !!snapshot; } else { isSnapshot = false; } if (isSameProcessActor && !isSnapshot) { - nsRefPtr<FileImpl> sameProcessImpl = aBlobImpl; - auto addRefedFileImpl = + nsRefPtr<BlobImpl> sameProcessImpl = aBlobImpl; + auto addRefedBlobImpl = reinterpret_cast<intptr_t>(sameProcessImpl.forget().take()); - blobParams = SameProcessBlobConstructorParams(addRefedFileImpl); + blobParams = SameProcessBlobConstructorParams(addRefedBlobImpl); } else { if (aBlobImpl->IsSizeUnknown() || aBlobImpl->IsDateUnknown()) { // We don't want to call GetSize or GetLastModifiedDate yet since that may // stat a file on the this thread. Instead we'll learn the size lazily // from the other side. blobParams = MysteryBlobConstructorParams(); } else { nsString contentType; @@ -3942,17 +3942,17 @@ BlobParent::CreateFromParams(ParentManag blobParams.get_NormalBlobConstructorParams().optionalBlobData() : blobParams.get_FileBlobConstructorParams().optionalBlobData(); if (NS_WARN_IF(optionalBlobData.type() != OptionalBlobData::TBlobData)) { ASSERT_UNLESS_FUZZING(); return nullptr; } - nsRefPtr<FileImpl> blobImpl = + nsRefPtr<BlobImpl> blobImpl = CreateBlobImpl(aParams, optionalBlobData.get_BlobData(), ActorManagerIsSameProcess(aManager)); if (NS_WARN_IF(!blobImpl)) { ASSERT_UNLESS_FUZZING(); return nullptr; } @@ -3978,21 +3978,21 @@ BlobParent::CreateFromParams(ParentManag return nullptr; } auto* actor = const_cast<BlobParent*>( static_cast<const BlobParent*>(params.sourceParent())); MOZ_ASSERT(actor); - nsRefPtr<FileImpl> source = actor->GetBlobImpl(); + nsRefPtr<BlobImpl> source = actor->GetBlobImpl(); MOZ_ASSERT(source); ErrorResult rv; - nsRefPtr<FileImpl> slice = + nsRefPtr<BlobImpl> slice = source->CreateSlice(params.begin(), params.end() - params.begin(), params.contentType(), rv); if (NS_WARN_IF(rv.Failed())) { ASSERT_UNLESS_FUZZING(); return nullptr; } @@ -4029,18 +4029,18 @@ BlobParent::CreateFromParams(ParentManag if (NS_WARN_IF(!ActorManagerIsSameProcess(aManager))) { ASSERT_UNLESS_FUZZING(); return nullptr; } const SameProcessBlobConstructorParams& params = blobParams.get_SameProcessBlobConstructorParams(); - nsRefPtr<FileImpl> blobImpl = - dont_AddRef(reinterpret_cast<FileImpl*>(params.addRefedFileImpl())); + nsRefPtr<BlobImpl> blobImpl = + dont_AddRef(reinterpret_cast<BlobImpl*>(params.addRefedBlobImpl())); MOZ_ASSERT(blobImpl); nsID id; MOZ_ALWAYS_TRUE(NS_SUCCEEDED(gUUIDGenerator->GenerateUUIDInPlace(&id))); nsRefPtr<IDTableEntry> idTableEntry = IDTableEntry::Create(id, ActorManagerProcessID(aManager), blobImpl); MOZ_ASSERT(idTableEntry); @@ -4105,23 +4105,23 @@ BlobParent::MaybeGetActorFromRemoteBlob( BlobParent* actor = aRemoteBlob->GetBlobParent(); if (actor && actor->GetBackgroundManager() == aManager) { return actor; } return nullptr; } -already_AddRefed<FileImpl> +already_AddRefed<BlobImpl> BlobParent::GetBlobImpl() { AssertIsOnOwningThread(); MOZ_ASSERT(mBlobImpl); - nsRefPtr<FileImpl> blobImpl; + nsRefPtr<BlobImpl> blobImpl; // Remote blobs are held alive until the first call to GetBlobImpl. Thereafter // we only hold a weak reference. Normal blobs are held alive until the actor // is destroyed. if (mRemoteBlobImpl && mOwnsBlobImpl) { blobImpl = dont_AddRef(mBlobImpl); mOwnsBlobImpl = false; } else { @@ -4253,17 +4253,17 @@ BlobParent::RecvPBlobStreamConstructor(P uint64_t blobLength = mBlobImpl->GetSize(errorResult); MOZ_ASSERT(!errorResult.Failed()); if (NS_WARN_IF(aStart + aLength > blobLength)) { ASSERT_UNLESS_FUZZING(); return false; } - nsRefPtr<FileImpl> blobImpl; + nsRefPtr<BlobImpl> blobImpl; if (!aStart && aLength == blobLength) { blobImpl = mBlobImpl; } else { nsString type; mBlobImpl->GetType(type); blobImpl = mBlobImpl->CreateSlice(aStart, aLength, type, errorResult); @@ -4520,17 +4520,17 @@ BlobParent::RecvGetFilePath(nsString* aF /******************************************************************************* * BlobParent::IDTableEntry ******************************************************************************/ BlobParent:: IDTableEntry::IDTableEntry(const nsID& aID, intptr_t aProcessID, - FileImpl* aBlobImpl) + BlobImpl* aBlobImpl) : mID(aID) , mProcessID(aProcessID) , mBlobImpl(aBlobImpl) { MOZ_ASSERT(aBlobImpl); } BlobParent:: @@ -4552,17 +4552,17 @@ IDTableEntry::~IDTableEntry() } } // static already_AddRefed<BlobParent::IDTableEntry> BlobParent:: IDTableEntry::GetOrCreateInternal(const nsID& aID, intptr_t aProcessID, - FileImpl* aBlobImpl, + BlobImpl* aBlobImpl, bool aMayCreate, bool aMayGet, bool aIgnoreProcessID) { MOZ_ASSERT(gProcessType == GeckoProcessType_Default); MOZ_ASSERT(sIDTableMutex); sIDTableMutex->AssertNotCurrentThreadOwns(); @@ -4577,17 +4577,17 @@ IDTableEntry::GetOrCreateInternal(const } sIDTable = new IDTable(); } entry = sIDTable->Get(aID); if (entry) { - MOZ_ASSERT_IF(aBlobImpl, entry->BlobImpl() == aBlobImpl); + MOZ_ASSERT_IF(aBlobImpl, entry->GetBlobImpl() == aBlobImpl); if (NS_WARN_IF(!aMayGet)) { return nullptr; } if (!aIgnoreProcessID && NS_WARN_IF(entry->mProcessID != aProcessID)) { return nullptr; }
--- a/dom/ipc/BlobChild.h +++ b/dom/ipc/BlobChild.h @@ -20,33 +20,33 @@ namespace mozilla { namespace ipc { class PBackgroundChild; } // namespace ipc namespace dom { +class BlobImpl; class ContentChild; -class FileImpl; class nsIContentChild; class PBlobStreamChild; class BlobChild final : public PBlobChild { typedef mozilla::ipc::PBackgroundChild PBackgroundChild; class RemoteBlobImpl; friend class RemoteBlobImpl; class RemoteBlobSliceImpl; friend class RemoteBlobSliceImpl; - FileImpl* mBlobImpl; + BlobImpl* mBlobImpl; RemoteBlobImpl* mRemoteBlobImpl; // One of these will be null and the other non-null. PBackgroundChild* mBackgroundManager; nsCOMPtr<nsIContentChild> mContentManager; nsCOMPtr<nsIEventTarget> mEventTarget; @@ -57,20 +57,20 @@ class BlobChild final public: class FriendKey; static void Startup(const FriendKey& aKey); // These create functions are called on the sending side. static BlobChild* - GetOrCreate(nsIContentChild* aManager, FileImpl* aBlobImpl); + GetOrCreate(nsIContentChild* aManager, BlobImpl* aBlobImpl); static BlobChild* - GetOrCreate(PBackgroundChild* aManager, FileImpl* aBlobImpl); + GetOrCreate(PBackgroundChild* aManager, BlobImpl* aBlobImpl); // These create functions are called on the receiving side. static BlobChild* Create(nsIContentChild* aManager, const ChildBlobConstructorParams& aParams); static BlobChild* Create(PBackgroundChild* aManager, const ChildBlobConstructorParams& aParams); @@ -97,21 +97,21 @@ public: GetContentManager() const { return mContentManager; } const nsID& ParentID() const; - // Get the FileImpl associated with this actor. This may always be called + // Get the BlobImpl associated with this actor. This may always be called // on the sending side. It may also be called on the receiving side unless // this is a "mystery" blob that has not yet received a SetMysteryBlobInfo() // call. - already_AddRefed<FileImpl> + already_AddRefed<BlobImpl> GetBlobImpl(); // Use this for files. bool SetMysteryBlobInfo(const nsString& aName, const nsString& aContentType, uint64_t aLength, int64_t aLastModifiedDate); @@ -125,23 +125,23 @@ public: #ifdef DEBUG ; #else { } #endif private: // These constructors are called on the sending side. - BlobChild(nsIContentChild* aManager, FileImpl* aBlobImpl); + BlobChild(nsIContentChild* aManager, BlobImpl* aBlobImpl); - BlobChild(PBackgroundChild* aManager, FileImpl* aBlobImpl); + BlobChild(PBackgroundChild* aManager, BlobImpl* aBlobImpl); BlobChild(nsIContentChild* aManager, BlobChild* aOther); - BlobChild(PBackgroundChild* aManager, BlobChild* aOther, FileImpl* aBlobImpl); + BlobChild(PBackgroundChild* aManager, BlobChild* aOther, BlobImpl* aBlobImpl); // These constructors are called on the receiving side. BlobChild(nsIContentChild* aManager, const ChildBlobConstructorParams& aParams); BlobChild(PBackgroundChild* aManager, const ChildBlobConstructorParams& aParams); @@ -153,51 +153,51 @@ private: BlobChild(PBackgroundChild* aManager, const nsID& aParentID, RemoteBlobSliceImpl* aRemoteBlobSliceImpl); // Only called by Destroy(). ~BlobChild(); void - CommonInit(FileImpl* aBlobImpl); + CommonInit(BlobImpl* aBlobImpl); void - CommonInit(BlobChild* aOther, FileImpl* aBlobImpl); + CommonInit(BlobChild* aOther, BlobImpl* aBlobImpl); void CommonInit(const ChildBlobConstructorParams& aParams); void CommonInit(const nsID& aParentID, RemoteBlobImpl* aRemoteBlobImpl); template <class ChildManagerType> static BlobChild* - GetOrCreateFromImpl(ChildManagerType* aManager, FileImpl* aBlobImpl); + GetOrCreateFromImpl(ChildManagerType* aManager, BlobImpl* aBlobImpl); template <class ChildManagerType> static BlobChild* CreateFromParams(ChildManagerType* aManager, const ChildBlobConstructorParams& aParams); template <class ChildManagerType> static BlobChild* SendSliceConstructor(ChildManagerType* aManager, RemoteBlobSliceImpl* aRemoteBlobSliceImpl, const ParentBlobConstructorParams& aParams); static BlobChild* MaybeGetActorFromRemoteBlob(nsIRemoteBlob* aRemoteBlob, nsIContentChild* aManager, - FileImpl* aBlobImpl); + BlobImpl* aBlobImpl); static BlobChild* MaybeGetActorFromRemoteBlob(nsIRemoteBlob* aRemoteBlob, PBackgroundChild* aManager, - FileImpl* aBlobImpl); + BlobImpl* aBlobImpl); void NoteDyingRemoteBlobImpl(); nsIEventTarget* EventTarget() const { return mEventTarget;
--- a/dom/ipc/BlobParent.h +++ b/dom/ipc/BlobParent.h @@ -29,17 +29,17 @@ namespace ipc { class PBackgroundParent; } // namespace ipc namespace dom { class ContentParent; -class FileImpl; +class BlobImpl; class nsIContentParent; class PBlobStreamParent; class BlobParent final : public PBlobParent { typedef mozilla::ipc::PBackgroundParent PBackgroundParent; @@ -51,17 +51,17 @@ class BlobParent final class RemoteBlobImpl; struct CreateBlobImplMetadata; static StaticAutoPtr<IDTable> sIDTable; static StaticAutoPtr<Mutex> sIDTableMutex; - FileImpl* mBlobImpl; + BlobImpl* mBlobImpl; RemoteBlobImpl* mRemoteBlobImpl; // One of these will be null and the other non-null. PBackgroundParent* mBackgroundManager; nsCOMPtr<nsIContentParent> mContentManager; nsCOMPtr<nsIEventTarget> mEventTarget; @@ -81,37 +81,37 @@ class BlobParent final public: class FriendKey; static void Startup(const FriendKey& aKey); // These create functions are called on the sending side. static BlobParent* - GetOrCreate(nsIContentParent* aManager, FileImpl* aBlobImpl); + GetOrCreate(nsIContentParent* aManager, BlobImpl* aBlobImpl); static BlobParent* - GetOrCreate(PBackgroundParent* aManager, FileImpl* aBlobImpl); + GetOrCreate(PBackgroundParent* aManager, BlobImpl* aBlobImpl); // These create functions are called on the receiving side. static BlobParent* Create(nsIContentParent* aManager, const ParentBlobConstructorParams& aParams); static BlobParent* Create(PBackgroundParent* aManager, const ParentBlobConstructorParams& aParams); static void Destroy(PBlobParent* aActor) { delete static_cast<BlobParent*>(aActor); } - static already_AddRefed<FileImpl> + static already_AddRefed<BlobImpl> GetBlobImplForID(const nsID& aID); bool HasManager() const { return mBackgroundManager || mContentManager; } @@ -122,18 +122,18 @@ public: } nsIContentParent* GetContentManager() const { return mContentManager; } - // Get the FileImpl associated with this actor. - already_AddRefed<FileImpl> + // Get the BlobImpl associated with this actor. + already_AddRefed<BlobImpl> GetBlobImpl(); void AssertIsOnOwningThread() const #ifdef DEBUG ; #else { } @@ -142,36 +142,36 @@ public: private: // These constructors are called on the sending side. BlobParent(nsIContentParent* aManager, IDTableEntry* aIDTableEntry); BlobParent(PBackgroundParent* aManager, IDTableEntry* aIDTableEntry); // These constructors are called on the receiving side. BlobParent(nsIContentParent* aManager, - FileImpl* aBlobImpl, + BlobImpl* aBlobImpl, IDTableEntry* aIDTableEntry); BlobParent(PBackgroundParent* aManager, - FileImpl* aBlobImpl, + BlobImpl* aBlobImpl, IDTableEntry* aIDTableEntry); // Only destroyed by BackgroundParentImpl and ContentParent. ~BlobParent(); void CommonInit(IDTableEntry* aIDTableEntry); void - CommonInit(FileImpl* aBlobImpl, IDTableEntry* aIDTableEntry); + CommonInit(BlobImpl* aBlobImpl, IDTableEntry* aIDTableEntry); template <class ParentManagerType> static BlobParent* GetOrCreateFromImpl(ParentManagerType* aManager, - FileImpl* aBlobImpl); + BlobImpl* aBlobImpl); template <class ParentManagerType> static BlobParent* CreateFromParams(ParentManagerType* aManager, const ParentBlobConstructorParams& aParams); template <class ParentManagerType> static BlobParent*
--- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -2912,22 +2912,22 @@ ContentChild::RecvInvokeDragSession(nsTA nsCOMPtr<nsIWritableVariant> variant = do_CreateInstance(NS_VARIANT_CONTRACTID); NS_ENSURE_TRUE(variant, false); if (item.data().type() == IPCDataTransferData::TnsString) { const nsString& data = item.data().get_nsString(); variant->SetAsAString(data); } else if (item.data().type() == IPCDataTransferData::TPBlobChild) { BlobChild* blob = static_cast<BlobChild*>(item.data().get_PBlobChild()); - nsRefPtr<FileImpl> fileImpl = blob->GetBlobImpl(); + nsRefPtr<BlobImpl> blobImpl = blob->GetBlobImpl(); nsString path; ErrorResult result; - fileImpl->GetMozFullPathInternal(path, result); + blobImpl->GetMozFullPathInternal(path, result); if (result.Failed()) { - variant->SetAsISupports(fileImpl); + variant->SetAsISupports(blobImpl); } else { nsCOMPtr<nsIFile> file; NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(path), true, getter_AddRefs(file)); variant->SetAsISupports(file); } } else { continue; }
--- a/dom/ipc/DOMTypes.ipdlh +++ b/dom/ipc/DOMTypes.ipdlh @@ -90,19 +90,19 @@ struct MysteryBlobConstructorParams struct KnownBlobConstructorParams { nsID id; }; // This may only be used for same-process inter-thread communication! struct SameProcessBlobConstructorParams { - // This member should be reinterpret_cast'd to mozilla::dom::FileImpl. It + // This member should be reinterpret_cast'd to mozilla::dom::BlobImpl. It // carries a reference. - intptr_t addRefedFileImpl; + intptr_t addRefedBlobImpl; }; union AnyBlobConstructorParams { // These types may be sent to/from parent and child. NormalBlobConstructorParams; FileBlobConstructorParams; SameProcessBlobConstructorParams;
--- a/dom/ipc/FilePickerParent.cpp +++ b/dom/ipc/FilePickerParent.cpp @@ -50,20 +50,20 @@ FilePickerParent::~FilePickerParent() // process. This runnable stat()s the file off the main thread. // // We run code in three places: // 1. The main thread calls Dispatch() to start the runnable. // 2. The stream transport thread stat()s the file in Run() and then dispatches // the same runnable on the main thread. // 3. The main thread sends the results over IPC. FilePickerParent::FileSizeAndDateRunnable::FileSizeAndDateRunnable(FilePickerParent *aFPParent, - nsTArray<nsRefPtr<FileImpl>>& aFiles) + nsTArray<nsRefPtr<BlobImpl>>& aBlobs) : mFilePickerParent(aFPParent) { - mFiles.SwapElements(aFiles); + mBlobs.SwapElements(aBlobs); } bool FilePickerParent::FileSizeAndDateRunnable::Dispatch() { MOZ_ASSERT(NS_IsMainThread()); mEventTarget = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID); @@ -77,26 +77,26 @@ FilePickerParent::FileSizeAndDateRunnabl NS_IMETHODIMP FilePickerParent::FileSizeAndDateRunnable::Run() { // If we're on the main thread, then that means we're done. Just send the // results. if (NS_IsMainThread()) { if (mFilePickerParent) { - mFilePickerParent->SendFiles(mFiles); + mFilePickerParent->SendFiles(mBlobs); } return NS_OK; } // We're not on the main thread, so do the stat(). - for (unsigned i = 0; i < mFiles.Length(); i++) { + for (unsigned i = 0; i < mBlobs.Length(); i++) { ErrorResult rv; - mFiles[i]->GetSize(rv); - mFiles[i]->GetLastModified(rv); + mBlobs[i]->GetSize(rv); + mBlobs[i]->GetLastModified(rv); } // Dispatch ourselves back on the main thread. if (NS_FAILED(NS_DispatchToMainThread(this))) { // It's hard to see how we can recover gracefully in this case. The child // process is waiting for an IPC, but that can only happen on the main // thread. MOZ_CRASH(); @@ -106,70 +106,70 @@ FilePickerParent::FileSizeAndDateRunnabl void FilePickerParent::FileSizeAndDateRunnable::Destroy() { mFilePickerParent = nullptr; } void -FilePickerParent::SendFiles(const nsTArray<nsRefPtr<FileImpl>>& aFiles) +FilePickerParent::SendFiles(const nsTArray<nsRefPtr<BlobImpl>>& aBlobs) { nsIContentParent* parent = TabParent::GetFrom(Manager())->Manager(); - InfallibleTArray<PBlobParent*> files; + InfallibleTArray<PBlobParent*> blobs; - for (unsigned i = 0; i < aFiles.Length(); i++) { - BlobParent* blobParent = parent->GetOrCreateActorForFileImpl(aFiles[i]); + for (unsigned i = 0; i < aBlobs.Length(); i++) { + BlobParent* blobParent = parent->GetOrCreateActorForBlobImpl(aBlobs[i]); if (blobParent) { - files.AppendElement(blobParent); + blobs.AppendElement(blobParent); } } - InputFiles infiles; - infiles.filesParent().SwapElements(files); - unused << Send__delete__(this, infiles, mResult); + InputFiles inblobs; + inblobs.blobsParent().SwapElements(blobs); + unused << Send__delete__(this, inblobs, mResult); } void FilePickerParent::Done(int16_t aResult) { mResult = aResult; if (mResult != nsIFilePicker::returnOK) { unused << Send__delete__(this, void_t(), mResult); return; } - nsTArray<nsRefPtr<FileImpl>> files; + nsTArray<nsRefPtr<BlobImpl>> blobs; if (mMode == nsIFilePicker::modeOpenMultiple) { nsCOMPtr<nsISimpleEnumerator> iter; NS_ENSURE_SUCCESS_VOID(mFilePicker->GetFiles(getter_AddRefs(iter))); nsCOMPtr<nsISupports> supports; bool loop = true; while (NS_SUCCEEDED(iter->HasMoreElements(&loop)) && loop) { iter->GetNext(getter_AddRefs(supports)); if (supports) { nsCOMPtr<nsIFile> file = do_QueryInterface(supports); - nsRefPtr<FileImpl> fileimpl = new FileImplFile(file); - files.AppendElement(fileimpl); + nsRefPtr<BlobImpl> blobimpl = new BlobImplFile(file); + blobs.AppendElement(blobimpl); } } } else { nsCOMPtr<nsIFile> file; mFilePicker->GetFile(getter_AddRefs(file)); if (file) { - nsRefPtr<FileImpl> fileimpl = new FileImplFile(file); - files.AppendElement(fileimpl); + nsRefPtr<BlobImpl> blobimpl = new BlobImplFile(file); + blobs.AppendElement(blobimpl); } } MOZ_ASSERT(!mRunnable); - mRunnable = new FileSizeAndDateRunnable(this, files); + mRunnable = new FileSizeAndDateRunnable(this, blobs); if (!mRunnable->Dispatch()) { unused << Send__delete__(this, void_t(), nsIFilePicker::returnCancel); } } bool FilePickerParent::CreateFilePicker() {
--- a/dom/ipc/FilePickerParent.h +++ b/dom/ipc/FilePickerParent.h @@ -25,17 +25,17 @@ class FilePickerParent : public PFilePic const int16_t& aMode) : mTitle(aTitle) , mMode(aMode) {} virtual ~FilePickerParent(); void Done(int16_t aResult); - void SendFiles(const nsTArray<nsRefPtr<FileImpl>>& aDomfiles); + void SendFiles(const nsTArray<nsRefPtr<BlobImpl>>& aDomBlobs); virtual bool RecvOpen(const int16_t& aSelectedType, const bool& aAddToRecentDocs, const nsString& aDefaultFile, const nsString& aDefaultExtension, InfallibleTArray<nsString>&& aFilters, InfallibleTArray<nsString>&& aFilterNames, const nsString& aDisplayDirectory) override; @@ -60,21 +60,21 @@ class FilePickerParent : public PFilePic }; private: bool CreateFilePicker(); class FileSizeAndDateRunnable : public nsRunnable { FilePickerParent* mFilePickerParent; - nsTArray<nsRefPtr<FileImpl>> mFiles; + nsTArray<nsRefPtr<BlobImpl>> mBlobs; nsCOMPtr<nsIEventTarget> mEventTarget; public: - FileSizeAndDateRunnable(FilePickerParent *aFPParent, nsTArray<nsRefPtr<FileImpl>>& aFiles); + FileSizeAndDateRunnable(FilePickerParent *aFPParent, nsTArray<nsRefPtr<BlobImpl>>& aBlobs); bool Dispatch(); NS_IMETHOD Run(); void Destroy(); }; nsRefPtr<FileSizeAndDateRunnable> mRunnable; nsRefPtr<FilePickerShownCallback> mCallback; nsCOMPtr<nsIFilePicker> mFilePicker;
--- a/dom/ipc/PFilePicker.ipdl +++ b/dom/ipc/PFilePicker.ipdl @@ -9,17 +9,17 @@ include protocol PBrowser; using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; namespace mozilla { namespace dom { struct InputFiles { - PBlob[] files; + PBlob[] blobs; }; union MaybeInputFiles { InputFiles; void_t; };
--- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -182,17 +182,17 @@ private: // It's probably safer to take the main thread IO hit here rather // than leak a file descriptor. CloseFile(); } } // Helper method to avoid gnarly control flow for failures. - void OpenFileImpl() + void OpenBlobImpl() { MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!mFD); nsCOMPtr<nsIFile> file; nsresult rv = NS_NewLocalFile(mPath, false, getter_AddRefs(file)); NS_ENSURE_SUCCESS_VOID(rv); @@ -202,17 +202,17 @@ private: mFD = fd; } void OpenFile() { MOZ_ASSERT(!NS_IsMainThread()); - OpenFileImpl(); + OpenBlobImpl(); if (NS_FAILED(NS_DispatchToMainThread(this))) { NS_WARNING("Failed to dispatch to main thread!"); // Intentionally leak the runnable (but not the fd) rather // than crash when trying to release a main thread object // off the main thread. mTabParent.forget();
--- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -519,17 +519,17 @@ private: bool mSendOfflineStatus; uint32_t mChromeFlags; struct DataTransferItem { nsCString mFlavor; nsString mStringData; - nsRefPtr<mozilla::dom::FileImpl> mBlobData; + nsRefPtr<mozilla::dom::BlobImpl> mBlobData; enum DataType { eString, eBlob }; DataType mType; }; nsTArray<nsTArray<DataTransferItem>> mInitialDataTransferItems;
--- a/dom/ipc/nsIContentChild.cpp +++ b/dom/ipc/nsIContentChild.cpp @@ -93,24 +93,24 @@ nsIContentChild::DeallocPBlobChild(PBlob } BlobChild* nsIContentChild::GetOrCreateActorForBlob(Blob* aBlob) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aBlob); - nsRefPtr<FileImpl> blobImpl = aBlob->Impl(); + nsRefPtr<BlobImpl> blobImpl = aBlob->Impl(); MOZ_ASSERT(blobImpl); - return GetOrCreateActorForFileImpl(blobImpl); + return GetOrCreateActorForBlobImpl(blobImpl); } BlobChild* -nsIContentChild::GetOrCreateActorForFileImpl(FileImpl* aImpl) +nsIContentChild::GetOrCreateActorForBlobImpl(BlobImpl* aImpl) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aImpl); BlobChild* actor = BlobChild::GetOrCreate(this, aImpl); NS_ENSURE_TRUE(actor, nullptr); return actor;
--- a/dom/ipc/nsIContentChild.h +++ b/dom/ipc/nsIContentChild.h @@ -29,31 +29,31 @@ namespace jsipc { class PJavaScriptChild; class CpowEntry; } // jsipc namespace dom { class Blob; class BlobChild; +class BlobImpl; class BlobConstructorParams; class ClonedMessageData; -class FileImpl; class IPCTabContext; class PBlobChild; class PBrowserChild; class nsIContentChild : public nsISupports , public CPOWManagerGetter { public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTCHILD_IID) BlobChild* GetOrCreateActorForBlob(Blob* aBlob); - BlobChild* GetOrCreateActorForFileImpl(FileImpl* aImpl); + BlobChild* GetOrCreateActorForBlobImpl(BlobImpl* aImpl); virtual PBlobChild* SendPBlobConstructor( PBlobChild* aActor, const BlobConstructorParams& aParams) = 0; virtual bool SendPBrowserConstructor(PBrowserChild* aActor, const TabId& aTabId,
--- a/dom/ipc/nsIContentParent.cpp +++ b/dom/ipc/nsIContentParent.cpp @@ -159,24 +159,24 @@ nsIContentParent::DeallocPBlobParent(PBl } BlobParent* nsIContentParent::GetOrCreateActorForBlob(Blob* aBlob) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aBlob); - nsRefPtr<FileImpl> blobImpl = aBlob->Impl(); + nsRefPtr<BlobImpl> blobImpl = aBlob->Impl(); MOZ_ASSERT(blobImpl); - return GetOrCreateActorForFileImpl(blobImpl); + return GetOrCreateActorForBlobImpl(blobImpl); } BlobParent* -nsIContentParent::GetOrCreateActorForFileImpl(FileImpl* aImpl) +nsIContentParent::GetOrCreateActorForBlobImpl(BlobImpl* aImpl) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aImpl); BlobParent* actor = BlobParent::GetOrCreate(this, aImpl); NS_ENSURE_TRUE(actor, nullptr); return actor;
--- a/dom/ipc/nsIContentParent.h +++ b/dom/ipc/nsIContentParent.h @@ -30,34 +30,34 @@ namespace jsipc { class PJavaScriptParent; class CpowEntry; } // namespace jsipc namespace dom { class Blob; class BlobConstructorParams; +class BlobImpl; class BlobParent; class ContentParent; -class FileImpl; class IPCTabContext; class PBlobParent; class PBrowserParent; class nsIContentParent : public nsISupports , public mozilla::dom::ipc::MessageManagerCallback , public CPOWManagerGetter { public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTPARENT_IID) nsIContentParent(); BlobParent* GetOrCreateActorForBlob(Blob* aBlob); - BlobParent* GetOrCreateActorForFileImpl(FileImpl* aImpl); + BlobParent* GetOrCreateActorForBlobImpl(BlobImpl* aImpl); virtual ContentParentId ChildID() = 0; virtual bool IsForApp() = 0; virtual bool IsForBrowser() = 0; MOZ_WARN_UNUSED_RESULT virtual PBlobParent* SendPBlobConstructor( PBlobParent* aActor,
--- a/dom/mobilemessage/MmsMessage.cpp +++ b/dom/mobilemessage/MmsMessage.cpp @@ -88,20 +88,20 @@ MmsMessage::MmsMessage(const mobilemessa MmsAttachment att; const MmsAttachmentData &element = aData.attachments()[i]; att.mId = element.id(); att.mLocation = element.location(); // mContent is not going to be exposed to JS directly so we can use // nullptr as parent. if (element.contentParent()) { - nsRefPtr<FileImpl> impl = static_cast<BlobParent*>(element.contentParent())->GetBlobImpl(); + nsRefPtr<BlobImpl> impl = static_cast<BlobParent*>(element.contentParent())->GetBlobImpl(); att.mContent = Blob::Create(nullptr, impl); } else if (element.contentChild()) { - nsRefPtr<FileImpl> impl = static_cast<BlobChild*>(element.contentChild())->GetBlobImpl(); + nsRefPtr<BlobImpl> impl = static_cast<BlobChild*>(element.contentChild())->GetBlobImpl(); att.mContent = Blob::Create(nullptr, impl); } else { NS_WARNING("MmsMessage: Unable to get attachment content."); } mAttachments.AppendElement(att); } len = aData.deliveryInfo().Length(); @@ -385,17 +385,17 @@ MmsMessage::GetData(ContentParent* aPare const Attachment &element = mAttachments[i]; mma.id().Assign(element.id); mma.location().Assign(element.location); // This is a workaround. Sometimes the blob we get from the database // doesn't have a valid last modified date, making the ContentParent // send a "Mystery Blob" to the ContentChild. Attempting to get the // last modified date of blob can force that value to be initialized. - nsRefPtr<FileImpl> impl = element.content->Impl(); + nsRefPtr<BlobImpl> impl = element.content->Impl(); if (impl && impl->IsDateUnknown()) { ErrorResult rv; impl->GetLastModified(rv); if (rv.Failed()) { NS_WARNING("Failed to get last modified date!"); rv.SuppressException(); } }
--- a/dom/mobilemessage/ipc/SmsParent.cpp +++ b/dom/mobilemessage/ipc/SmsParent.cpp @@ -48,17 +48,17 @@ MmsAttachmentDataToJSObject(JSContext* a JS::Rooted<JSString*> locStr(aContext, JS_NewUCStringCopyN(aContext, aAttachment.location().get(), aAttachment.location().Length())); NS_ENSURE_TRUE(locStr, nullptr); if (!JS_DefineProperty(aContext, obj, "location", locStr, 0)) { return nullptr; } - nsRefPtr<FileImpl> blobImpl = static_cast<BlobParent*>(aAttachment.contentParent())->GetBlobImpl(); + nsRefPtr<BlobImpl> blobImpl = static_cast<BlobParent*>(aAttachment.contentParent())->GetBlobImpl(); // nsRefPtr<File> needs to go out of scope before toObjectOrNull() is // called because the static analysis thinks dereferencing XPCOM objects // can GC (because in some cases it can!), and a return statement with a // JSObject* type means that JSObject* is on the stack as a raw pointer // while destructors are running. JS::Rooted<JS::Value> content(aContext); {
--- a/dom/workers/URL.cpp +++ b/dom/workers/URL.cpp @@ -64,21 +64,21 @@ private: nsRefPtr<mozilla::dom::URL> mURL; }; // This class creates an URL from a DOM Blob on the main thread. class CreateURLRunnable : public WorkerMainThreadRunnable { private: - FileImpl* mBlobImpl; + BlobImpl* mBlobImpl; nsAString& mURL; public: - CreateURLRunnable(WorkerPrivate* aWorkerPrivate, FileImpl* aBlobImpl, + CreateURLRunnable(WorkerPrivate* aWorkerPrivate, BlobImpl* aBlobImpl, const mozilla::dom::objectURLOptions& aOptions, nsAString& aURL) : WorkerMainThreadRunnable(aWorkerPrivate) , mBlobImpl(aBlobImpl) , mURL(aURL) { MOZ_ASSERT(aBlobImpl); @@ -89,17 +89,17 @@ public: bool MainThreadRun() { using namespace mozilla::ipc; AssertIsOnMainThread(); - nsRefPtr<FileImpl> newBlobImplHolder; + nsRefPtr<BlobImpl> newBlobImplHolder; if (nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(mBlobImpl)) { if (BlobChild* blobChild = remoteBlob->GetBlobChild()) { if (PBackgroundChild* blobManager = blobChild->GetBackgroundManager()) { PBackgroundChild* backgroundManager = BackgroundChild::GetForCurrentThread(); MOZ_ASSERT(backgroundManager); @@ -882,17 +882,17 @@ URL::SetHash(const nsAString& aHash, Err void URL::CreateObjectURL(const GlobalObject& aGlobal, Blob& aBlob, const mozilla::dom::objectURLOptions& aOptions, nsAString& aResult, mozilla::ErrorResult& aRv) { JSContext* cx = aGlobal.Context(); WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx); - nsRefPtr<FileImpl> blobImpl = aBlob.Impl(); + nsRefPtr<BlobImpl> blobImpl = aBlob.Impl(); MOZ_ASSERT(blobImpl); aRv = blobImpl->SetMutable(false); if (NS_WARN_IF(aRv.Failed())) { return; } nsRefPtr<CreateURLRunnable> runnable =
--- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -64,17 +64,17 @@ #include "mozilla/dom/WorkerGlobalScopeBinding.h" #include "mozilla/dom/indexedDB/IDBFactory.h" #include "mozilla/dom/ipc/BlobChild.h" #include "mozilla/dom/ipc/nsIRemoteBlob.h" #include "mozilla/ipc/BackgroundChild.h" #include "mozilla/ipc/BackgroundUtils.h" #include "mozilla/ipc/PBackgroundSharedTypes.h" #include "mozilla/Preferences.h" -#include "MultipartFileImpl.h" +#include "MultipartBlobImpl.h" #include "nsAlgorithm.h" #include "nsContentUtils.h" #include "nsCycleCollector.h" #include "nsError.h" #include "nsDOMJSUtils.h" #include "nsFormData.h" #include "nsHostObjectProtocolHandler.h" #include "nsJSEnvironment.h" @@ -315,30 +315,30 @@ LogErrorToConsole(const nsAString& aMess filename.get(), aLineNumber); #endif fprintf(stderr, kErrorString, msg.get(), filename.get(), aLineNumber); fflush(stderr); } // Recursive! -already_AddRefed<FileImpl> -EnsureBlobForBackgroundManager(FileImpl* aBlobImpl, +already_AddRefed<BlobImpl> +EnsureBlobForBackgroundManager(BlobImpl* aBlobImpl, PBackgroundChild* aManager = nullptr) { MOZ_ASSERT(aBlobImpl); if (!aManager) { aManager = BackgroundChild::GetForCurrentThread(); MOZ_ASSERT(aManager); } - nsRefPtr<FileImpl> blobImpl = aBlobImpl; - - const nsTArray<nsRefPtr<FileImpl>>* subBlobImpls = + nsRefPtr<BlobImpl> blobImpl = aBlobImpl; + + const nsTArray<nsRefPtr<BlobImpl>>* subBlobImpls = aBlobImpl->GetSubBlobImpls(); if (!subBlobImpls) { if (nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryObject(blobImpl)) { // Always make sure we have a blob from an actor we can use on this // thread. BlobChild* blobChild = BlobChild::GetOrCreate(aManager, blobImpl); MOZ_ASSERT(blobChild); @@ -354,26 +354,26 @@ EnsureBlobForBackgroundManager(FileImpl* } return blobImpl.forget(); } const uint32_t subBlobCount = subBlobImpls->Length(); MOZ_ASSERT(subBlobCount); - nsTArray<nsRefPtr<FileImpl>> newSubBlobImpls; + nsTArray<nsRefPtr<BlobImpl>> newSubBlobImpls; newSubBlobImpls.SetLength(subBlobCount); bool newBlobImplNeeded = false; for (uint32_t index = 0; index < subBlobCount; index++) { - const nsRefPtr<FileImpl>& subBlobImpl = subBlobImpls->ElementAt(index); + const nsRefPtr<BlobImpl>& subBlobImpl = subBlobImpls->ElementAt(index); MOZ_ASSERT(subBlobImpl); - nsRefPtr<FileImpl>& newSubBlobImpl = newSubBlobImpls[index]; + nsRefPtr<BlobImpl>& newSubBlobImpl = newSubBlobImpls[index]; newSubBlobImpl = EnsureBlobForBackgroundManager(subBlobImpl, aManager); MOZ_ASSERT(newSubBlobImpl); if (subBlobImpl != newSubBlobImpl) { newBlobImplNeeded = true; } } @@ -381,38 +381,38 @@ EnsureBlobForBackgroundManager(FileImpl* if (newBlobImplNeeded) { nsString contentType; blobImpl->GetType(contentType); if (blobImpl->IsFile()) { nsString name; blobImpl->GetName(name); - blobImpl = new MultipartFileImpl(newSubBlobImpls, name, contentType); + blobImpl = new MultipartBlobImpl(newSubBlobImpls, name, contentType); } else { - blobImpl = new MultipartFileImpl(newSubBlobImpls, contentType); + blobImpl = new MultipartBlobImpl(newSubBlobImpls, contentType); } MOZ_ALWAYS_TRUE(NS_SUCCEEDED(blobImpl->SetMutable(false))); } return blobImpl.forget(); } already_AddRefed<Blob> ReadBlobOrFileNoWrap(JSContext* aCx, JSStructuredCloneReader* aReader, bool aIsMainThread) { MOZ_ASSERT(aCx); MOZ_ASSERT(aReader); - nsRefPtr<FileImpl> blobImpl; + nsRefPtr<BlobImpl> blobImpl; { - FileImpl* rawBlobImpl; + BlobImpl* rawBlobImpl; MOZ_ALWAYS_TRUE(JS_ReadBytes(aReader, &rawBlobImpl, sizeof(rawBlobImpl))); MOZ_ASSERT(rawBlobImpl); blobImpl = rawBlobImpl; } blobImpl = EnsureBlobForBackgroundManager(blobImpl); @@ -506,36 +506,36 @@ ReadFormData(JSContext* aCx, } aFormData.set(formData->WrapObject(aCx, JS::NullPtr())); } bool WriteBlobOrFile(JSContext* aCx, JSStructuredCloneWriter* aWriter, - FileImpl* aBlobOrFileImpl, + BlobImpl* aBlobOrBlobImpl, nsTArray<nsCOMPtr<nsISupports>>& aClonedObjects) { MOZ_ASSERT(aCx); MOZ_ASSERT(aWriter); - MOZ_ASSERT(aBlobOrFileImpl); - - nsRefPtr<FileImpl> blobImpl = EnsureBlobForBackgroundManager(aBlobOrFileImpl); + MOZ_ASSERT(aBlobOrBlobImpl); + + nsRefPtr<BlobImpl> blobImpl = EnsureBlobForBackgroundManager(aBlobOrBlobImpl); MOZ_ASSERT(blobImpl); - aBlobOrFileImpl = blobImpl; + aBlobOrBlobImpl = blobImpl; if (NS_WARN_IF(!JS_WriteUint32Pair(aWriter, DOMWORKER_SCTAG_BLOB, 0)) || NS_WARN_IF(!JS_WriteBytes(aWriter, - &aBlobOrFileImpl, - sizeof(aBlobOrFileImpl)))) { + &aBlobOrBlobImpl, + sizeof(aBlobOrBlobImpl)))) { return false; } - aClonedObjects.AppendElement(aBlobOrFileImpl); + aClonedObjects.AppendElement(aBlobOrBlobImpl); return true; } // A FormData is serialized as: // - A pair of ints (tag identifying it as a FormData, number of elements in // the FormData) // - for each (key, value) pair: // - pair of ints (is value a file?, 0). If not a file, value is a string. @@ -643,17 +643,17 @@ struct WorkerStructuredCloneCallbacks // We'll stash any nsISupports pointers that need to be AddRef'd here. auto* clonedObjects = static_cast<nsTArray<nsCOMPtr<nsISupports>>*>(aClosure); // See if this is a Blob/File object. { nsRefPtr<Blob> blob; if (NS_SUCCEEDED(UNWRAP_OBJECT(Blob, aObj, blob))) { - FileImpl* blobImpl = blob->Impl(); + BlobImpl* blobImpl = blob->Impl(); MOZ_ASSERT(blobImpl); if (WriteBlobOrFile(aCx, aWriter, blobImpl, *clonedObjects)) { return true; } } } @@ -735,17 +735,17 @@ struct MainThreadWorkerStructuredCloneCa // We'll stash any nsISupports pointers that need to be AddRef'd here. auto* clonedObjects = static_cast<nsTArray<nsCOMPtr<nsISupports>>*>(aClosure); // See if this is a Blob/File object. { nsRefPtr<Blob> blob; if (NS_SUCCEEDED(UNWRAP_OBJECT(Blob, aObj, blob))) { - FileImpl* blobImpl = blob->Impl(); + BlobImpl* blobImpl = blob->Impl(); MOZ_ASSERT(blobImpl); if (!blobImpl->MayBeClonedToOtherThreads()) { NS_WARNING("Not all the blob implementations can be sent between threads."); } else if (WriteBlobOrFile(aCx, aWriter, blobImpl, *clonedObjects)) { return true; } }
--- a/dom/workers/XMLHttpRequest.cpp +++ b/dom/workers/XMLHttpRequest.cpp @@ -2172,17 +2172,17 @@ XMLHttpRequest::Send(Blob& aBody, ErrorR } JS::Rooted<JS::Value> value(cx); if (!GetOrCreateDOMReflector(cx, &aBody, &value)) { aRv.Throw(NS_ERROR_FAILURE); return; } - nsRefPtr<FileImpl> blobImpl = aBody.Impl(); + nsRefPtr<BlobImpl> blobImpl = aBody.Impl(); MOZ_ASSERT(blobImpl); aRv = blobImpl->SetMutable(false); if (NS_WARN_IF(aRv.Failed())) { return; } const JSStructuredCloneCallbacks* callbacks =
--- a/ipc/glue/BackgroundImpl.cpp +++ b/ipc/glue/BackgroundImpl.cpp @@ -840,17 +840,17 @@ BackgroundParent::GetContentParent(PBack { return ParentImpl::GetContentParent(aBackgroundActor); } // static PBlobParent* BackgroundParent::GetOrCreateActorForBlobImpl( PBackgroundParent* aBackgroundActor, - FileImpl* aBlobImpl) + BlobImpl* aBlobImpl) { AssertIsOnBackgroundThread(); MOZ_ASSERT(aBackgroundActor); MOZ_ASSERT(aBlobImpl); BlobParent* actor = BlobParent::GetOrCreate(aBackgroundActor, aBlobImpl); if (NS_WARN_IF(!actor)) { return nullptr; @@ -916,17 +916,17 @@ BackgroundChild::GetOrCreateActorForBlob { MOZ_ASSERT(aBackgroundActor); MOZ_ASSERT(aBlob); MOZ_ASSERT(GetForCurrentThread(), "BackgroundChild not created on this thread yet!"); MOZ_ASSERT(aBackgroundActor == GetForCurrentThread(), "BackgroundChild is bound to a different thread!"); - nsRefPtr<FileImpl> blobImpl = static_cast<Blob*>(aBlob)->Impl(); + nsRefPtr<BlobImpl> blobImpl = static_cast<Blob*>(aBlob)->Impl(); MOZ_ASSERT(blobImpl); BlobChild* actor = BlobChild::GetOrCreate(aBackgroundActor, blobImpl); if (NS_WARN_IF(!actor)) { return nullptr; } return actor;
--- a/ipc/glue/BackgroundParent.h +++ b/ipc/glue/BackgroundParent.h @@ -9,35 +9,35 @@ #include "mozilla/Attributes.h" #include "mozilla/ipc/Transport.h" template <class> struct already_AddRefed; namespace mozilla { namespace dom { +class BlobImpl; class ContentParent; -class FileImpl; class PBlobParent; } // namespace dom namespace ipc { class PBackgroundParent; // This class is not designed for public consumption beyond the few static // member functions. class BackgroundParent final { friend class mozilla::dom::ContentParent; typedef base::ProcessId ProcessId; + typedef mozilla::dom::BlobImpl BlobImpl; typedef mozilla::dom::ContentParent ContentParent; - typedef mozilla::dom::FileImpl FileImpl; typedef mozilla::ipc::Transport Transport; public: // This function allows the caller to determine if the given parent actor // corresponds to a child actor from another process or a child actor from a // different thread in the same process. // This function may only be called on the background thread. static bool @@ -51,17 +51,17 @@ public: // ContentParent is not threadsafe and the returned pointer may not be used on // any thread other than the main thread. Callers must take care to use (and // release) the returned pointer appropriately. static already_AddRefed<ContentParent> GetContentParent(PBackgroundParent* aBackgroundActor); static mozilla::dom::PBlobParent* GetOrCreateActorForBlobImpl(PBackgroundParent* aBackgroundActor, - FileImpl* aBlobImpl); + BlobImpl* aBlobImpl); // Get a value that represents the ContentParent associated with the parent // actor for comparison. The value is not guaranteed to uniquely identify the // ContentParent after the ContentParent has died. This function may only be // called on the background thread. static intptr_t GetRawContentParentForComparison(PBackgroundParent* aBackgroundActor);
--- a/ipc/glue/InputStreamUtils.cpp +++ b/ipc/glue/InputStreamUtils.cpp @@ -107,17 +107,17 @@ DeserializeInputStream(const InputStream // is retrieve the original instead of sending any data over the wire. case InputStreamParams::TRemoteInputStreamParams: { if (NS_WARN_IF(XRE_GetProcessType() != GeckoProcessType_Default)) { return nullptr; } const nsID& id = aParams.get_RemoteInputStreamParams().id(); - nsRefPtr<FileImpl> blobImpl = BlobParent::GetBlobImplForID(id); + nsRefPtr<BlobImpl> blobImpl = BlobParent::GetBlobImplForID(id); MOZ_ASSERT(blobImpl, "Invalid blob contents"); // If fetching the internal stream fails, we ignore it and return a // null stream. nsCOMPtr<nsIInputStream> stream; nsresult rv = blobImpl->GetInternalStream(getter_AddRefs(stream)); if (NS_FAILED(rv) || !stream) {
--- a/js/xpconnect/src/ExportHelpers.cpp +++ b/js/xpconnect/src/ExportHelpers.cpp @@ -51,17 +51,17 @@ public: : mOptions(aOptions) , mReflectors(aCx) , mFunctions(aCx) {} StackScopedCloneOptions* mOptions; AutoObjectVector mReflectors; AutoObjectVector mFunctions; - nsTArray<nsRefPtr<FileImpl>> mBlobImpls; + nsTArray<nsRefPtr<BlobImpl>> mBlobImpls; }; static JSObject* StackScopedCloneRead(JSContext* cx, JSStructuredCloneReader* reader, uint32_t tag, uint32_t data, void* closure) { MOZ_ASSERT(closure, "Null pointer!"); StackScopedCloneData* cloneData = static_cast<StackScopedCloneData*>(closure); @@ -175,17 +175,17 @@ StackScopedCloneWrite(JSContext* cx, JSS Handle<JSObject*> obj, void* closure) { MOZ_ASSERT(closure, "Null pointer!"); StackScopedCloneData* cloneData = static_cast<StackScopedCloneData*>(closure); { Blob* blob = nullptr; if (NS_SUCCEEDED(UNWRAP_OBJECT(Blob, obj, blob))) { - FileImpl* blobImpl = blob->Impl(); + BlobImpl* blobImpl = blob->Impl(); MOZ_ASSERT(blobImpl); if (!cloneData->mBlobImpls.AppendElement(blobImpl)) return false; size_t idx = cloneData->mBlobImpls.Length() - 1; return JS_WriteUint32Pair(writer, SCTAG_BLOB, 0) && JS_WriteBytes(writer, &idx, sizeof(size_t));
--- a/widget/nsFilePickerProxy.cpp +++ b/widget/nsFilePickerProxy.cpp @@ -147,20 +147,20 @@ nsFilePickerProxy::Open(nsIFilePickerSho return NS_OK; } bool nsFilePickerProxy::Recv__delete__(const MaybeInputFiles& aFiles, const int16_t& aResult) { if (aFiles.type() == MaybeInputFiles::TInputFiles) { - const InfallibleTArray<PBlobChild*>& files = aFiles.get_InputFiles().filesChild(); - for (uint32_t i = 0; i < files.Length(); ++i) { - BlobChild* actor = static_cast<BlobChild*>(files[i]); - nsRefPtr<FileImpl> blobImpl = actor->GetBlobImpl(); + const InfallibleTArray<PBlobChild*>& blobs = aFiles.get_InputFiles().blobsChild(); + for (uint32_t i = 0; i < blobs.Length(); ++i) { + BlobChild* actor = static_cast<BlobChild*>(blobs[i]); + nsRefPtr<BlobImpl> blobImpl = actor->GetBlobImpl(); NS_ENSURE_TRUE(blobImpl, true); if (!blobImpl->IsFile()) { return true; } nsRefPtr<File> file = File::Create(mParent, blobImpl); MOZ_ASSERT(file);