Bug 1113062 - patch 2 - ArchiveReaderZipFile non-CCed, r=smaug

This commit is contained in:
Andrea Marchesini 2015-01-11 21:34:57 +00:00
Родитель 3b2aab48cb
Коммит 972e5e33ac
5 изменённых файлов: 30 добавлений и 44 удалений

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

@ -48,7 +48,7 @@ ArchiveReader::Constructor(const GlobalObject& aGlobal,
ArchiveReader::ArchiveReader(File& aBlob, nsPIDOMWindow* aWindow,
const nsACString& aEncoding)
: mBlob(&aBlob)
: mFileImpl(aBlob.Impl())
, mWindow(aWindow)
, mStatus(NOT_STARTED)
, mEncoding(aEncoding)
@ -95,7 +95,7 @@ nsresult
ArchiveReader::GetInputStream(nsIInputStream** aInputStream)
{
// Getting the input stream
mBlob->GetInternalStream(aInputStream);
mFileImpl->GetInternalStream(aInputStream);
NS_ENSURE_TRUE(*aInputStream, NS_ERROR_UNEXPECTED);
return NS_OK;
}
@ -103,9 +103,9 @@ ArchiveReader::GetInputStream(nsIInputStream** aInputStream)
nsresult
ArchiveReader::GetSize(uint64_t* aSize)
{
nsresult rv = mBlob->GetSize(aSize);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
ErrorResult rv;
*aSize = mFileImpl->GetSize(rv);
return rv.ErrorCode();
}
// Here we open the archive:
@ -199,7 +199,7 @@ ArchiveReader::GenerateArchiveRequest()
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ArchiveReader,
mBlob,
mFileImpl,
mWindow,
mData.fileList,
mRequests)

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

@ -20,6 +20,7 @@ namespace mozilla {
namespace dom {
struct ArchiveReaderOptions;
class File;
class FileImpl;
class GlobalObject;
} // namespace dom
} // namespace mozilla
@ -49,6 +50,7 @@ public:
{
return mWindow;
}
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
already_AddRefed<ArchiveRequest> GetFilenames();
@ -62,6 +64,11 @@ public: // for the ArchiveRequest:
nsresult RegisterRequest(ArchiveRequest* aRequest);
public: // For events:
FileImpl* GetFileImpl() const
{
return mFileImpl;
}
void Ready(nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList,
nsresult aStatus);
@ -76,7 +83,7 @@ private:
protected:
// The archive blob/file
nsRefPtr<File> mBlob;
nsRefPtr<FileImpl> mFileImpl;
// The window is needed by the requests
nsCOMPtr<nsPIDOMWindow> mWindow;

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

@ -88,7 +88,7 @@ ArchiveZipItem::File(ArchiveReader* aArchiveReader)
new ArchiveZipFileImpl(filename,
NS_ConvertUTF8toUTF16(GetType()),
StrToInt32(mCentralStruct.orglen),
mCentralStruct, aArchiveReader));
mCentralStruct, aArchiveReader->GetFileImpl()));
}
uint32_t

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

@ -362,13 +362,15 @@ ArchiveZipFileImpl::GetInternalStream(nsIInputStream** aStream)
return NS_ERROR_FAILURE;
}
uint64_t size;
nsresult rv = mArchiveReader->GetSize(&size);
NS_ENSURE_SUCCESS(rv, rv);
ErrorResult rv;
uint64_t size = mFileImpl->GetSize(rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.ErrorCode();
}
nsCOMPtr<nsIInputStream> inputStream;
rv = mArchiveReader->GetInputStream(getter_AddRefs(inputStream));
if (NS_FAILED(rv) || !inputStream) {
rv = mFileImpl->GetInternalStream(getter_AddRefs(inputStream));
if (NS_WARN_IF(rv.Failed()) || !inputStream) {
return NS_ERROR_UNEXPECTED;
}
@ -383,20 +385,6 @@ ArchiveZipFileImpl::GetInternalStream(nsIInputStream** aStream)
return NS_OK;
}
void
ArchiveZipFileImpl::Unlink()
{
ArchiveZipFileImpl* tmp = this;
NS_IMPL_CYCLE_COLLECTION_UNLINK(mArchiveReader);
}
void
ArchiveZipFileImpl::Traverse(nsCycleCollectionTraversalCallback &cb)
{
ArchiveZipFileImpl* tmp = this;
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mArchiveReader);
}
already_AddRefed<mozilla::dom::FileImpl>
ArchiveZipFileImpl::CreateSlice(uint64_t aStart,
uint64_t aLength,
@ -405,7 +393,7 @@ ArchiveZipFileImpl::CreateSlice(uint64_t aStart,
{
nsRefPtr<FileImpl> impl =
new ArchiveZipFileImpl(mFilename, mContentType, aStart, mLength, mCentral,
mArchiveReader);
mFileImpl);
return impl.forget();
}

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

@ -30,13 +30,13 @@ public:
const nsAString& aContentType,
uint64_t aLength,
ZipCentral& aCentral,
ArchiveReader* aReader)
FileImpl* aFileImpl)
: FileImplBase(aName, aContentType, aLength),
mCentral(aCentral),
mArchiveReader(aReader),
mFileImpl(aFileImpl),
mFilename(aName)
{
NS_ASSERTION(mArchiveReader, "must have a reader");
MOZ_ASSERT(mFileImpl);
MOZ_COUNT_CTOR(ArchiveZipFileImpl);
}
@ -45,27 +45,18 @@ public:
uint64_t aStart,
uint64_t aLength,
ZipCentral& aCentral,
ArchiveReader* aReader)
FileImpl* aFileImpl)
: FileImplBase(aContentType, aStart, aLength),
mCentral(aCentral),
mArchiveReader(aReader),
mFileImpl(aFileImpl),
mFilename(aName)
{
NS_ASSERTION(mArchiveReader, "must have a reader");
MOZ_ASSERT(mFileImpl);
MOZ_COUNT_CTOR(ArchiveZipFileImpl);
}
// Overrides:
virtual nsresult GetInternalStream(nsIInputStream**) MOZ_OVERRIDE;
virtual void Unlink() MOZ_OVERRIDE;
virtual void Traverse(nsCycleCollectionTraversalCallback &aCb) MOZ_OVERRIDE;
virtual bool IsCCed() const MOZ_OVERRIDE
{
return true;
}
protected:
virtual ~ArchiveZipFileImpl()
{
@ -78,7 +69,7 @@ protected:
private: // Data
ZipCentral mCentral;
nsRefPtr<ArchiveReader> mArchiveReader;
nsRefPtr<FileImpl> mFileImpl;
nsString mFilename;
};