2012-06-03 09:33:52 -07: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 07:32:12 -07:00
|
|
|
#ifndef mozilla_dom_File_h
|
|
|
|
#define mozilla_dom_File_h
|
2012-06-03 09:33:52 -07:00
|
|
|
|
2013-06-05 09:15:48 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-05-07 07:32:12 -07:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2012-06-03 09:33:52 -07:00
|
|
|
#include "nsDOMFile.h"
|
|
|
|
|
2014-05-07 07:32:12 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2012-06-03 09:33:52 -07:00
|
|
|
|
2014-05-07 07:32:12 -07:00
|
|
|
class LockedFile;
|
2012-06-03 09:33:52 -07:00
|
|
|
|
|
|
|
class File : public nsDOMFileCC
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(File, nsDOMFileCC)
|
|
|
|
|
|
|
|
// Create as a file
|
|
|
|
File(const nsAString& aName, const nsAString& aContentType,
|
2014-05-07 07:32:12 -07:00
|
|
|
uint64_t aLength, nsIFile* aFile, LockedFile* aLockedFile);
|
2012-06-03 09:33:52 -07:00
|
|
|
|
|
|
|
// Create as a stored file
|
|
|
|
File(const nsAString& aName, const nsAString& aContentType,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t aLength, nsIFile* aFile, LockedFile* aLockedFile,
|
2014-05-07 07:32:12 -07:00
|
|
|
FileInfo* aFileInfo);
|
2012-06-03 09:33:52 -07:00
|
|
|
|
|
|
|
// Overrides
|
|
|
|
NS_IMETHOD
|
2013-06-05 09:15:48 -07:00
|
|
|
GetMozFullPathInternal(nsAString& aFullPath) MOZ_OVERRIDE;
|
2012-06-03 09:33:52 -07:00
|
|
|
|
|
|
|
NS_IMETHOD
|
2013-06-05 09:15:48 -07:00
|
|
|
GetInternalStream(nsIInputStream** aStream) MOZ_OVERRIDE;
|
2012-06-03 09:33:52 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// Create slice
|
2012-08-22 08:56:38 -07:00
|
|
|
File(const File* aOther, uint64_t aStart, uint64_t aLength,
|
2012-06-03 09:33:52 -07:00
|
|
|
const nsAString& aContentType);
|
|
|
|
|
2014-05-07 07:32:12 -07:00
|
|
|
virtual ~File();
|
2012-06-03 09:33:52 -07:00
|
|
|
|
|
|
|
virtual already_AddRefed<nsIDOMBlob>
|
2012-08-22 08:56:38 -07:00
|
|
|
CreateSlice(uint64_t aStart, uint64_t aLength,
|
2013-06-05 09:15:48 -07:00
|
|
|
const nsAString& aContentType) MOZ_OVERRIDE;
|
2012-06-03 09:33:52 -07:00
|
|
|
|
|
|
|
virtual bool
|
2013-06-05 09:15:48 -07:00
|
|
|
IsStoredFile() const MOZ_OVERRIDE
|
2012-06-03 09:33:52 -07:00
|
|
|
{
|
|
|
|
return mStoredFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool
|
2013-06-05 09:15:48 -07:00
|
|
|
IsWholeFile() const MOZ_OVERRIDE
|
2012-06-03 09:33:52 -07:00
|
|
|
{
|
|
|
|
return mWholeFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool
|
2013-06-05 09:15:48 -07:00
|
|
|
IsSnapshot() const MOZ_OVERRIDE
|
2012-06-03 09:33:52 -07:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIFile> mFile;
|
|
|
|
nsRefPtr<LockedFile> mLockedFile;
|
|
|
|
|
|
|
|
bool mWholeFile;
|
|
|
|
bool mStoredFile;
|
|
|
|
};
|
|
|
|
|
2014-05-07 07:32:12 -07:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2012-06-03 09:33:52 -07:00
|
|
|
|
2014-05-07 07:32:12 -07:00
|
|
|
#endif // mozilla_dom_File_h
|