Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_dom_file_domarchivefile_h__ |
michael@0 | 8 | #define mozilla_dom_file_domarchivefile_h__ |
michael@0 | 9 | |
michael@0 | 10 | #include "mozilla/Attributes.h" |
michael@0 | 11 | #include "nsDOMFile.h" |
michael@0 | 12 | |
michael@0 | 13 | #include "ArchiveReader.h" |
michael@0 | 14 | |
michael@0 | 15 | #include "FileCommon.h" |
michael@0 | 16 | #include "zipstruct.h" |
michael@0 | 17 | |
michael@0 | 18 | BEGIN_FILE_NAMESPACE |
michael@0 | 19 | |
michael@0 | 20 | /** |
michael@0 | 21 | * ZipFile to DOMFileCC |
michael@0 | 22 | */ |
michael@0 | 23 | class ArchiveZipFile : public nsDOMFileCC |
michael@0 | 24 | { |
michael@0 | 25 | public: |
michael@0 | 26 | ArchiveZipFile(const nsAString& aName, |
michael@0 | 27 | const nsAString& aContentType, |
michael@0 | 28 | uint64_t aLength, |
michael@0 | 29 | ZipCentral& aCentral, |
michael@0 | 30 | ArchiveReader* aReader) |
michael@0 | 31 | : nsDOMFileCC(aName, aContentType, aLength), |
michael@0 | 32 | mCentral(aCentral), |
michael@0 | 33 | mArchiveReader(aReader), |
michael@0 | 34 | mFilename(aName) |
michael@0 | 35 | { |
michael@0 | 36 | NS_ASSERTION(mArchiveReader, "must have a reader"); |
michael@0 | 37 | MOZ_COUNT_CTOR(ArchiveZipFile); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | ArchiveZipFile(const nsAString& aName, |
michael@0 | 41 | const nsAString& aContentType, |
michael@0 | 42 | uint64_t aStart, |
michael@0 | 43 | uint64_t aLength, |
michael@0 | 44 | ZipCentral& aCentral, |
michael@0 | 45 | ArchiveReader* aReader) |
michael@0 | 46 | : nsDOMFileCC(aContentType, aStart, aLength), |
michael@0 | 47 | mCentral(aCentral), |
michael@0 | 48 | mArchiveReader(aReader), |
michael@0 | 49 | mFilename(aName) |
michael@0 | 50 | { |
michael@0 | 51 | NS_ASSERTION(mArchiveReader, "must have a reader"); |
michael@0 | 52 | MOZ_COUNT_CTOR(ArchiveZipFile); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | virtual ~ArchiveZipFile() |
michael@0 | 56 | { |
michael@0 | 57 | MOZ_COUNT_DTOR(ArchiveZipFile); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | // Overrides: |
michael@0 | 61 | NS_IMETHOD GetInternalStream(nsIInputStream**) MOZ_OVERRIDE; |
michael@0 | 62 | |
michael@0 | 63 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 64 | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ArchiveZipFile, nsDOMFileCC) |
michael@0 | 65 | |
michael@0 | 66 | protected: |
michael@0 | 67 | virtual already_AddRefed<nsIDOMBlob> CreateSlice(uint64_t aStart, |
michael@0 | 68 | uint64_t aLength, |
michael@0 | 69 | const nsAString& aContentType) MOZ_OVERRIDE; |
michael@0 | 70 | |
michael@0 | 71 | private: // Data |
michael@0 | 72 | ZipCentral mCentral; |
michael@0 | 73 | nsRefPtr<ArchiveReader> mArchiveReader; |
michael@0 | 74 | |
michael@0 | 75 | nsString mFilename; |
michael@0 | 76 | }; |
michael@0 | 77 | |
michael@0 | 78 | END_FILE_NAMESPACE |
michael@0 | 79 | |
michael@0 | 80 | #endif // mozilla_dom_file_domarchivefile_h__ |