michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_file_file_h__ michael@0: #define mozilla_dom_file_file_h__ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "FileCommon.h" michael@0: michael@0: #include "nsDOMFile.h" michael@0: michael@0: #include "LockedFile.h" michael@0: michael@0: BEGIN_FILE_NAMESPACE michael@0: michael@0: class File : public nsDOMFileCC michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(File, nsDOMFileCC) michael@0: michael@0: // Create as a file michael@0: File(const nsAString& aName, const nsAString& aContentType, michael@0: uint64_t aLength, nsIFile* aFile, LockedFile* aLockedFile) michael@0: : nsDOMFileCC(aName, aContentType, aLength), michael@0: mFile(aFile), mLockedFile(aLockedFile), michael@0: mWholeFile(true), mStoredFile(false) michael@0: { michael@0: NS_ASSERTION(mFile, "Null file!"); michael@0: NS_ASSERTION(mLockedFile, "Null locked file!"); michael@0: } michael@0: michael@0: // Create as a stored file michael@0: File(const nsAString& aName, const nsAString& aContentType, michael@0: uint64_t aLength, nsIFile* aFile, LockedFile* aLockedFile, michael@0: FileInfo* aFileInfo) michael@0: : nsDOMFileCC(aName, aContentType, aLength), michael@0: mFile(aFile), mLockedFile(aLockedFile), michael@0: mWholeFile(true), mStoredFile(true) michael@0: { michael@0: NS_ASSERTION(mFile, "Null file!"); michael@0: NS_ASSERTION(mLockedFile, "Null locked file!"); michael@0: mFileInfos.AppendElement(aFileInfo); michael@0: } michael@0: michael@0: // Overrides michael@0: NS_IMETHOD michael@0: GetMozFullPathInternal(nsAString& aFullPath) MOZ_OVERRIDE; michael@0: michael@0: NS_IMETHOD michael@0: GetInternalStream(nsIInputStream** aStream) MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: // Create slice michael@0: File(const File* aOther, uint64_t aStart, uint64_t aLength, michael@0: const nsAString& aContentType); michael@0: michael@0: virtual ~File() michael@0: { } michael@0: michael@0: virtual already_AddRefed michael@0: CreateSlice(uint64_t aStart, uint64_t aLength, michael@0: const nsAString& aContentType) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: IsStoredFile() const MOZ_OVERRIDE michael@0: { michael@0: return mStoredFile; michael@0: } michael@0: michael@0: virtual bool michael@0: IsWholeFile() const MOZ_OVERRIDE michael@0: { michael@0: return mWholeFile; michael@0: } michael@0: michael@0: virtual bool michael@0: IsSnapshot() const MOZ_OVERRIDE michael@0: { michael@0: return true; michael@0: } michael@0: michael@0: private: michael@0: nsCOMPtr mFile; michael@0: nsRefPtr mLockedFile; michael@0: michael@0: bool mWholeFile; michael@0: bool mStoredFile; michael@0: }; michael@0: michael@0: END_FILE_NAMESPACE michael@0: michael@0: #endif // mozilla_dom_file_file_h__