2012-07-28 00:21:34 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=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/. */
|
|
|
|
|
2014-05-07 14:32:12 +00:00
|
|
|
#ifndef mozilla_dom_archivereader_domarchivefile_h__
|
|
|
|
#define mozilla_dom_archivereader_domarchivefile_h__
|
2012-07-28 00:21:34 +00:00
|
|
|
|
2013-06-05 16:15:48 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-07-28 00:21:34 +00:00
|
|
|
#include "nsDOMFile.h"
|
|
|
|
|
|
|
|
#include "ArchiveReader.h"
|
|
|
|
|
2014-05-07 14:32:12 +00:00
|
|
|
#include "ArchiveReaderCommon.h"
|
2012-07-28 00:21:34 +00:00
|
|
|
#include "zipstruct.h"
|
|
|
|
|
2014-05-07 14:32:12 +00:00
|
|
|
BEGIN_ARCHIVEREADER_NAMESPACE
|
2012-07-28 00:21:34 +00:00
|
|
|
|
2012-11-06 23:23:13 +00:00
|
|
|
/**
|
2014-06-26 16:47:44 +00:00
|
|
|
* ArchiveZipFileImpl to DOMFileImpl
|
2012-11-06 23:23:13 +00:00
|
|
|
*/
|
2014-06-26 16:47:44 +00:00
|
|
|
class ArchiveZipFileImpl : public DOMFileImplBase
|
2012-07-28 00:21:34 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-06-27 03:46:34 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2014-06-26 16:47:44 +00:00
|
|
|
ArchiveZipFileImpl(const nsAString& aName,
|
|
|
|
const nsAString& aContentType,
|
|
|
|
uint64_t aLength,
|
|
|
|
ZipCentral& aCentral,
|
|
|
|
ArchiveReader* aReader)
|
|
|
|
: DOMFileImplBase(aName, aContentType, aLength),
|
2012-07-28 00:21:34 +00:00
|
|
|
mCentral(aCentral),
|
|
|
|
mArchiveReader(aReader),
|
|
|
|
mFilename(aName)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mArchiveReader, "must have a reader");
|
2014-06-26 16:47:44 +00:00
|
|
|
MOZ_COUNT_CTOR(ArchiveZipFileImpl);
|
2012-07-28 00:21:34 +00:00
|
|
|
}
|
|
|
|
|
2014-06-26 16:47:44 +00:00
|
|
|
ArchiveZipFileImpl(const nsAString& aName,
|
|
|
|
const nsAString& aContentType,
|
|
|
|
uint64_t aStart,
|
|
|
|
uint64_t aLength,
|
|
|
|
ZipCentral& aCentral,
|
|
|
|
ArchiveReader* aReader)
|
|
|
|
: DOMFileImplBase(aContentType, aStart, aLength),
|
2012-07-28 00:21:34 +00:00
|
|
|
mCentral(aCentral),
|
|
|
|
mArchiveReader(aReader),
|
|
|
|
mFilename(aName)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mArchiveReader, "must have a reader");
|
2014-06-26 16:47:44 +00:00
|
|
|
MOZ_COUNT_CTOR(ArchiveZipFileImpl);
|
2012-08-08 18:11:15 +00:00
|
|
|
}
|
|
|
|
|
2012-07-28 00:21:34 +00:00
|
|
|
// Overrides:
|
2014-06-26 16:47:44 +00:00
|
|
|
virtual nsresult GetInternalStream(nsIInputStream**) MOZ_OVERRIDE;
|
2012-07-28 00:21:34 +00:00
|
|
|
|
2014-06-26 16:47:44 +00:00
|
|
|
virtual void Unlink() MOZ_OVERRIDE;
|
|
|
|
virtual void Traverse(nsCycleCollectionTraversalCallback &aCb) MOZ_OVERRIDE;
|
2012-07-28 00:21:34 +00:00
|
|
|
|
2014-06-27 03:46:34 +00:00
|
|
|
virtual bool IsCCed() const MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-28 00:21:34 +00:00
|
|
|
protected:
|
2014-07-08 21:23:17 +00:00
|
|
|
virtual ~ArchiveZipFileImpl()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(ArchiveZipFileImpl);
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual already_AddRefed<nsIDOMBlob> CreateSlice(uint64_t aStart,
|
|
|
|
uint64_t aLength,
|
2013-06-05 16:15:48 +00:00
|
|
|
const nsAString& aContentType) MOZ_OVERRIDE;
|
2012-07-28 00:21:34 +00:00
|
|
|
|
|
|
|
private: // Data
|
|
|
|
ZipCentral mCentral;
|
|
|
|
nsRefPtr<ArchiveReader> mArchiveReader;
|
|
|
|
|
|
|
|
nsString mFilename;
|
|
|
|
};
|
|
|
|
|
2014-05-07 14:32:12 +00:00
|
|
|
END_ARCHIVEREADER_NAMESPACE
|
2012-07-28 00:21:34 +00:00
|
|
|
|
2014-05-07 14:32:12 +00:00
|
|
|
#endif // mozilla_dom_archivereader_domarchivefile_h__
|