1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/file/ArchiveZipFile.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_file_domarchivefile_h__ 1.11 +#define mozilla_dom_file_domarchivefile_h__ 1.12 + 1.13 +#include "mozilla/Attributes.h" 1.14 +#include "nsDOMFile.h" 1.15 + 1.16 +#include "ArchiveReader.h" 1.17 + 1.18 +#include "FileCommon.h" 1.19 +#include "zipstruct.h" 1.20 + 1.21 +BEGIN_FILE_NAMESPACE 1.22 + 1.23 +/** 1.24 + * ZipFile to DOMFileCC 1.25 + */ 1.26 +class ArchiveZipFile : public nsDOMFileCC 1.27 +{ 1.28 +public: 1.29 + ArchiveZipFile(const nsAString& aName, 1.30 + const nsAString& aContentType, 1.31 + uint64_t aLength, 1.32 + ZipCentral& aCentral, 1.33 + ArchiveReader* aReader) 1.34 + : nsDOMFileCC(aName, aContentType, aLength), 1.35 + mCentral(aCentral), 1.36 + mArchiveReader(aReader), 1.37 + mFilename(aName) 1.38 + { 1.39 + NS_ASSERTION(mArchiveReader, "must have a reader"); 1.40 + MOZ_COUNT_CTOR(ArchiveZipFile); 1.41 + } 1.42 + 1.43 + ArchiveZipFile(const nsAString& aName, 1.44 + const nsAString& aContentType, 1.45 + uint64_t aStart, 1.46 + uint64_t aLength, 1.47 + ZipCentral& aCentral, 1.48 + ArchiveReader* aReader) 1.49 + : nsDOMFileCC(aContentType, aStart, aLength), 1.50 + mCentral(aCentral), 1.51 + mArchiveReader(aReader), 1.52 + mFilename(aName) 1.53 + { 1.54 + NS_ASSERTION(mArchiveReader, "must have a reader"); 1.55 + MOZ_COUNT_CTOR(ArchiveZipFile); 1.56 + } 1.57 + 1.58 + virtual ~ArchiveZipFile() 1.59 + { 1.60 + MOZ_COUNT_DTOR(ArchiveZipFile); 1.61 + } 1.62 + 1.63 + // Overrides: 1.64 + NS_IMETHOD GetInternalStream(nsIInputStream**) MOZ_OVERRIDE; 1.65 + 1.66 + NS_DECL_ISUPPORTS_INHERITED 1.67 + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ArchiveZipFile, nsDOMFileCC) 1.68 + 1.69 +protected: 1.70 + virtual already_AddRefed<nsIDOMBlob> CreateSlice(uint64_t aStart, 1.71 + uint64_t aLength, 1.72 + const nsAString& aContentType) MOZ_OVERRIDE; 1.73 + 1.74 +private: // Data 1.75 + ZipCentral mCentral; 1.76 + nsRefPtr<ArchiveReader> mArchiveReader; 1.77 + 1.78 + nsString mFilename; 1.79 +}; 1.80 + 1.81 +END_FILE_NAMESPACE 1.82 + 1.83 +#endif // mozilla_dom_file_domarchivefile_h__