LCOV - code coverage report
Current view: top level - dom/file - BaseBlobImpl.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 47 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 16 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_dom_BaseBlobImpl_h
       8             : #define mozilla_dom_BaseBlobImpl_h
       9             : 
      10             : #include "mozilla/dom/BlobImpl.h"
      11             : 
      12             : namespace mozilla {
      13             : namespace dom {
      14             : 
      15             : class BaseBlobImpl : public BlobImpl
      16             : {
      17             : public:
      18           0 :   BaseBlobImpl(const nsAString& aName, const nsAString& aContentType,
      19             :                uint64_t aLength, int64_t aLastModifiedDate)
      20           0 :     : mIsFile(true)
      21             :     , mImmutable(false)
      22             :     , mContentType(aContentType)
      23             :     , mName(aName)
      24             :     , mStart(0)
      25             :     , mLength(aLength)
      26             :     , mLastModificationDate(aLastModifiedDate)
      27           0 :     , mSerialNumber(NextSerialNumber())
      28             :   {
      29             :     // Ensure non-null mContentType by default
      30           0 :     mContentType.SetIsVoid(false);
      31           0 :   }
      32             : 
      33           0 :   BaseBlobImpl(const nsAString& aName, const nsAString& aContentType,
      34             :                uint64_t aLength)
      35           0 :     : mIsFile(true)
      36             :     , mImmutable(false)
      37             :     , mContentType(aContentType)
      38             :     , mName(aName)
      39             :     , mStart(0)
      40             :     , mLength(aLength)
      41             :     , mLastModificationDate(INT64_MAX)
      42           0 :     , mSerialNumber(NextSerialNumber())
      43             :   {
      44             :     // Ensure non-null mContentType by default
      45           0 :     mContentType.SetIsVoid(false);
      46           0 :   }
      47             : 
      48           0 :   BaseBlobImpl(const nsAString& aContentType, uint64_t aLength)
      49           0 :     : mIsFile(false)
      50             :     , mImmutable(false)
      51             :     , mContentType(aContentType)
      52             :     , mStart(0)
      53             :     , mLength(aLength)
      54             :     , mLastModificationDate(INT64_MAX)
      55           0 :     , mSerialNumber(NextSerialNumber())
      56             :   {
      57             :     // Ensure non-null mContentType by default
      58           0 :     mContentType.SetIsVoid(false);
      59           0 :   }
      60             : 
      61           0 :   BaseBlobImpl(const nsAString& aContentType, uint64_t aStart,
      62             :                uint64_t aLength)
      63           0 :     : mIsFile(false)
      64             :     , mImmutable(false)
      65             :     , mContentType(aContentType)
      66             :     , mStart(aStart)
      67             :     , mLength(aLength)
      68             :     , mLastModificationDate(INT64_MAX)
      69           0 :     , mSerialNumber(NextSerialNumber())
      70             :   {
      71           0 :     MOZ_ASSERT(aLength != UINT64_MAX, "Must know length when creating slice");
      72             :     // Ensure non-null mContentType by default
      73           0 :     mContentType.SetIsVoid(false);
      74           0 :   }
      75             : 
      76             :   virtual void GetName(nsAString& aName) const override;
      77             : 
      78             :   virtual void GetDOMPath(nsAString& aName) const override;
      79             : 
      80             :   virtual void SetDOMPath(const nsAString& aName) override;
      81             : 
      82             :   virtual int64_t GetLastModified(ErrorResult& aRv) override;
      83             : 
      84             :   virtual void SetLastModified(int64_t aLastModified) override;
      85             : 
      86             :   virtual void GetMozFullPath(nsAString& aName,
      87             :                               SystemCallerGuarantee /* unused */,
      88             :                               ErrorResult& aRv) const override;
      89             : 
      90             :   virtual void GetMozFullPathInternal(nsAString& aFileName,
      91             :                                       ErrorResult& aRv) const override;
      92             : 
      93           0 :   virtual uint64_t GetSize(ErrorResult& aRv) override
      94             :   {
      95           0 :     return mLength;
      96             :   }
      97             : 
      98             :   virtual void GetType(nsAString& aType) override;
      99             : 
     100           0 :   virtual uint64_t GetSerialNumber() const override { return mSerialNumber; }
     101             : 
     102             :   virtual already_AddRefed<BlobImpl>
     103           0 :   CreateSlice(uint64_t aStart, uint64_t aLength,
     104             :               const nsAString& aContentType, ErrorResult& aRv) override
     105             :   {
     106           0 :     return nullptr;
     107             :   }
     108             : 
     109             :   virtual const nsTArray<RefPtr<BlobImpl>>*
     110           0 :   GetSubBlobImpls() const override
     111             :   {
     112           0 :     return nullptr;
     113             :   }
     114             : 
     115           0 :   virtual void GetInternalStream(nsIInputStream** aStream,
     116             :                                  ErrorResult& aRv) override
     117             :   {
     118           0 :     aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
     119           0 :   }
     120             : 
     121             :   virtual int64_t GetFileId() override;
     122             : 
     123             :   virtual nsresult GetSendInfo(nsIInputStream** aBody,
     124             :                                uint64_t* aContentLength,
     125             :                                nsACString& aContentType,
     126             :                                nsACString& aCharset) override;
     127             : 
     128             :   virtual nsresult GetMutable(bool* aMutable) const override;
     129             : 
     130             :   virtual nsresult SetMutable(bool aMutable) override;
     131             : 
     132             :   virtual void
     133           0 :   SetLazyData(const nsAString& aName, const nsAString& aContentType,
     134             :               uint64_t aLength, int64_t aLastModifiedDate) override
     135             :   {
     136           0 :     mName = aName;
     137           0 :     mContentType = aContentType;
     138           0 :     mLength = aLength;
     139           0 :     mLastModificationDate = aLastModifiedDate;
     140           0 :     mIsFile = !aName.IsVoid();
     141           0 :   }
     142             : 
     143           0 :   virtual bool IsMemoryFile() const override
     144             :   {
     145           0 :     return false;
     146             :   }
     147             : 
     148           0 :   virtual bool IsDateUnknown() const override
     149             :   {
     150           0 :     return mIsFile && mLastModificationDate == INT64_MAX;
     151             :   }
     152             : 
     153           0 :   virtual bool IsFile() const override
     154             :   {
     155           0 :     return mIsFile;
     156             :   }
     157             : 
     158           0 :   virtual bool IsSizeUnknown() const override
     159             :   {
     160           0 :     return mLength == UINT64_MAX;
     161             :   }
     162             : 
     163             : protected:
     164           0 :   virtual ~BaseBlobImpl() {}
     165             : 
     166             :   /**
     167             :    * Returns a new, effectively-unique serial number. This should be used
     168             :    * by implementations to obtain a serial number for GetSerialNumber().
     169             :    * The implementation is thread safe.
     170             :    */
     171             :   static uint64_t NextSerialNumber();
     172             : 
     173             :   bool mIsFile;
     174             :   bool mImmutable;
     175             : 
     176             :   nsString mContentType;
     177             :   nsString mName;
     178             :   nsString mPath; // The path relative to a directory chosen by the user
     179             : 
     180             :   uint64_t mStart;
     181             :   uint64_t mLength;
     182             : 
     183             :   int64_t mLastModificationDate;
     184             : 
     185             :   const uint64_t mSerialNumber;
     186             : };
     187             : 
     188             : } // namespace dom
     189             : } // namespace mozilla
     190             : 
     191             : #endif // mozilla_dom_BaseBlobImpl_h

Generated by: LCOV version 1.13