dom/file/File.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

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_file_h__
michael@0 8 #define mozilla_dom_file_file_h__
michael@0 9
michael@0 10 #include "mozilla/Attributes.h"
michael@0 11 #include "FileCommon.h"
michael@0 12
michael@0 13 #include "nsDOMFile.h"
michael@0 14
michael@0 15 #include "LockedFile.h"
michael@0 16
michael@0 17 BEGIN_FILE_NAMESPACE
michael@0 18
michael@0 19 class File : public nsDOMFileCC
michael@0 20 {
michael@0 21 public:
michael@0 22 NS_DECL_ISUPPORTS_INHERITED
michael@0 23
michael@0 24 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(File, nsDOMFileCC)
michael@0 25
michael@0 26 // Create as a file
michael@0 27 File(const nsAString& aName, const nsAString& aContentType,
michael@0 28 uint64_t aLength, nsIFile* aFile, LockedFile* aLockedFile)
michael@0 29 : nsDOMFileCC(aName, aContentType, aLength),
michael@0 30 mFile(aFile), mLockedFile(aLockedFile),
michael@0 31 mWholeFile(true), mStoredFile(false)
michael@0 32 {
michael@0 33 NS_ASSERTION(mFile, "Null file!");
michael@0 34 NS_ASSERTION(mLockedFile, "Null locked file!");
michael@0 35 }
michael@0 36
michael@0 37 // Create as a stored file
michael@0 38 File(const nsAString& aName, const nsAString& aContentType,
michael@0 39 uint64_t aLength, nsIFile* aFile, LockedFile* aLockedFile,
michael@0 40 FileInfo* aFileInfo)
michael@0 41 : nsDOMFileCC(aName, aContentType, aLength),
michael@0 42 mFile(aFile), mLockedFile(aLockedFile),
michael@0 43 mWholeFile(true), mStoredFile(true)
michael@0 44 {
michael@0 45 NS_ASSERTION(mFile, "Null file!");
michael@0 46 NS_ASSERTION(mLockedFile, "Null locked file!");
michael@0 47 mFileInfos.AppendElement(aFileInfo);
michael@0 48 }
michael@0 49
michael@0 50 // Overrides
michael@0 51 NS_IMETHOD
michael@0 52 GetMozFullPathInternal(nsAString& aFullPath) MOZ_OVERRIDE;
michael@0 53
michael@0 54 NS_IMETHOD
michael@0 55 GetInternalStream(nsIInputStream** aStream) MOZ_OVERRIDE;
michael@0 56
michael@0 57 protected:
michael@0 58 // Create slice
michael@0 59 File(const File* aOther, uint64_t aStart, uint64_t aLength,
michael@0 60 const nsAString& aContentType);
michael@0 61
michael@0 62 virtual ~File()
michael@0 63 { }
michael@0 64
michael@0 65 virtual already_AddRefed<nsIDOMBlob>
michael@0 66 CreateSlice(uint64_t aStart, uint64_t aLength,
michael@0 67 const nsAString& aContentType) MOZ_OVERRIDE;
michael@0 68
michael@0 69 virtual bool
michael@0 70 IsStoredFile() const MOZ_OVERRIDE
michael@0 71 {
michael@0 72 return mStoredFile;
michael@0 73 }
michael@0 74
michael@0 75 virtual bool
michael@0 76 IsWholeFile() const MOZ_OVERRIDE
michael@0 77 {
michael@0 78 return mWholeFile;
michael@0 79 }
michael@0 80
michael@0 81 virtual bool
michael@0 82 IsSnapshot() const MOZ_OVERRIDE
michael@0 83 {
michael@0 84 return true;
michael@0 85 }
michael@0 86
michael@0 87 private:
michael@0 88 nsCOMPtr<nsIFile> mFile;
michael@0 89 nsRefPtr<LockedFile> mLockedFile;
michael@0 90
michael@0 91 bool mWholeFile;
michael@0 92 bool mStoredFile;
michael@0 93 };
michael@0 94
michael@0 95 END_FILE_NAMESPACE
michael@0 96
michael@0 97 #endif // mozilla_dom_file_file_h__

mercurial