dom/file/File.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/file/File.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,97 @@
     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_file_h__
    1.11 +#define mozilla_dom_file_file_h__
    1.12 +
    1.13 +#include "mozilla/Attributes.h"
    1.14 +#include "FileCommon.h"
    1.15 +
    1.16 +#include "nsDOMFile.h"
    1.17 +
    1.18 +#include "LockedFile.h"
    1.19 +
    1.20 +BEGIN_FILE_NAMESPACE
    1.21 +
    1.22 +class File : public nsDOMFileCC
    1.23 +{
    1.24 +public:
    1.25 +  NS_DECL_ISUPPORTS_INHERITED
    1.26 +
    1.27 +  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(File, nsDOMFileCC)
    1.28 +
    1.29 +  // Create as a file
    1.30 +  File(const nsAString& aName, const nsAString& aContentType,
    1.31 +       uint64_t aLength, nsIFile* aFile, LockedFile* aLockedFile)
    1.32 +  : nsDOMFileCC(aName, aContentType, aLength),
    1.33 +    mFile(aFile), mLockedFile(aLockedFile),
    1.34 +    mWholeFile(true), mStoredFile(false)
    1.35 +  {
    1.36 +    NS_ASSERTION(mFile, "Null file!");
    1.37 +    NS_ASSERTION(mLockedFile, "Null locked file!");
    1.38 +  }
    1.39 +
    1.40 +  // Create as a stored file
    1.41 +  File(const nsAString& aName, const nsAString& aContentType,
    1.42 +       uint64_t aLength, nsIFile* aFile, LockedFile* aLockedFile,
    1.43 +       FileInfo* aFileInfo)
    1.44 +  : nsDOMFileCC(aName, aContentType, aLength),
    1.45 +    mFile(aFile), mLockedFile(aLockedFile),
    1.46 +    mWholeFile(true), mStoredFile(true)
    1.47 +  {
    1.48 +    NS_ASSERTION(mFile, "Null file!");
    1.49 +    NS_ASSERTION(mLockedFile, "Null locked file!");
    1.50 +    mFileInfos.AppendElement(aFileInfo);
    1.51 +  }
    1.52 +
    1.53 +  // Overrides
    1.54 +  NS_IMETHOD
    1.55 +  GetMozFullPathInternal(nsAString& aFullPath) MOZ_OVERRIDE;
    1.56 +
    1.57 +  NS_IMETHOD
    1.58 +  GetInternalStream(nsIInputStream** aStream) MOZ_OVERRIDE;
    1.59 +
    1.60 +protected:
    1.61 +  // Create slice
    1.62 +  File(const File* aOther, uint64_t aStart, uint64_t aLength,
    1.63 +       const nsAString& aContentType);
    1.64 +
    1.65 +  virtual ~File()
    1.66 +  { }
    1.67 +
    1.68 +  virtual already_AddRefed<nsIDOMBlob>
    1.69 +  CreateSlice(uint64_t aStart, uint64_t aLength,
    1.70 +              const nsAString& aContentType) MOZ_OVERRIDE;
    1.71 +
    1.72 +  virtual bool
    1.73 +  IsStoredFile() const MOZ_OVERRIDE
    1.74 +  {
    1.75 +    return mStoredFile;
    1.76 +  }
    1.77 +
    1.78 +  virtual bool
    1.79 +  IsWholeFile() const MOZ_OVERRIDE
    1.80 +  {
    1.81 +    return mWholeFile;
    1.82 +  }
    1.83 +
    1.84 +  virtual bool
    1.85 +  IsSnapshot() const MOZ_OVERRIDE
    1.86 +  {
    1.87 +    return true;
    1.88 +  }
    1.89 +
    1.90 +private:
    1.91 +  nsCOMPtr<nsIFile> mFile;
    1.92 +  nsRefPtr<LockedFile> mLockedFile;
    1.93 +
    1.94 +  bool mWholeFile;
    1.95 +  bool mStoredFile;
    1.96 +};
    1.97 +
    1.98 +END_FILE_NAMESPACE
    1.99 +
   1.100 +#endif // mozilla_dom_file_file_h__

mercurial