LCOV - code coverage report
Current view: top level - dom/file - BaseBlobImpl.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 69 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 13 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             : #include "mozilla/dom/BaseBlobImpl.h"
       8             : #include "nsRFPService.h"
       9             : #include "prtime.h"
      10             : 
      11             : namespace mozilla {
      12             : namespace dom {
      13             : 
      14             : void
      15           0 : BaseBlobImpl::GetName(nsAString& aName) const
      16             : {
      17           0 :   MOZ_ASSERT(mIsFile, "Should only be called on files");
      18           0 :   aName = mName;
      19           0 : }
      20             : 
      21             : void
      22           0 : BaseBlobImpl::GetDOMPath(nsAString& aPath) const
      23             : {
      24           0 :   MOZ_ASSERT(mIsFile, "Should only be called on files");
      25           0 :   aPath = mPath;
      26           0 : }
      27             : 
      28             : void
      29           0 : BaseBlobImpl::SetDOMPath(const nsAString& aPath)
      30             : {
      31           0 :   MOZ_ASSERT(mIsFile, "Should only be called on files");
      32           0 :   mPath = aPath;
      33           0 : }
      34             : 
      35             : void
      36           0 : BaseBlobImpl::GetMozFullPath(nsAString& aFileName,
      37             :                              SystemCallerGuarantee /* unused */,
      38             :                              ErrorResult& aRv) const
      39             : {
      40           0 :   MOZ_ASSERT(mIsFile, "Should only be called on files");
      41             : 
      42           0 :   GetMozFullPathInternal(aFileName, aRv);
      43           0 : }
      44             : 
      45             : void
      46           0 : BaseBlobImpl::GetMozFullPathInternal(nsAString& aFileName, ErrorResult& aRv) const
      47             : {
      48           0 :   if (!mIsFile) {
      49           0 :     aRv.Throw(NS_ERROR_FAILURE);
      50           0 :     return;
      51             :   }
      52             : 
      53           0 :   aFileName.Truncate();
      54             : }
      55             : 
      56             : void
      57           0 : BaseBlobImpl::GetType(nsAString& aType)
      58             : {
      59           0 :   aType = mContentType;
      60           0 : }
      61             : 
      62             : int64_t
      63           0 : BaseBlobImpl::GetLastModified(ErrorResult& aRv)
      64             : {
      65           0 :   MOZ_ASSERT(mIsFile, "Should only be called on files");
      66           0 :   if (IsDateUnknown()) {
      67           0 :     mLastModificationDate = nsRFPService::ReduceTimePrecisionAsUSecs(PR_Now());
      68             :   }
      69             : 
      70           0 :   return mLastModificationDate / PR_USEC_PER_MSEC;
      71             : }
      72             : 
      73             : void
      74           0 : BaseBlobImpl::SetLastModified(int64_t aLastModified)
      75             : {
      76           0 :   mLastModificationDate = aLastModified * PR_USEC_PER_MSEC;
      77           0 : }
      78             : 
      79             : int64_t
      80           0 : BaseBlobImpl::GetFileId()
      81             : {
      82           0 :   return -1;
      83             : }
      84             : 
      85             : nsresult
      86           0 : BaseBlobImpl::GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
      87             :                           nsACString& aContentType, nsACString& aCharset)
      88             : {
      89           0 :   MOZ_ASSERT(aContentLength);
      90             : 
      91           0 :   ErrorResult rv;
      92             : 
      93           0 :   nsCOMPtr<nsIInputStream> stream;
      94           0 :   GetInternalStream(getter_AddRefs(stream), rv);
      95           0 :   if (NS_WARN_IF(rv.Failed())) {
      96           0 :     return rv.StealNSResult();
      97             :   }
      98             : 
      99           0 :   *aContentLength = GetSize(rv);
     100           0 :   if (NS_WARN_IF(rv.Failed())) {
     101           0 :     return rv.StealNSResult();
     102             :   }
     103             : 
     104           0 :   nsAutoString contentType;
     105           0 :   GetType(contentType);
     106             : 
     107           0 :   if (contentType.IsEmpty()) {
     108           0 :     aContentType.SetIsVoid(true);
     109             :   } else {
     110           0 :     CopyUTF16toUTF8(contentType, aContentType);
     111             :   }
     112             : 
     113           0 :   aCharset.Truncate();
     114             : 
     115           0 :   stream.forget(aBody);
     116           0 :   return NS_OK;
     117             : }
     118             : 
     119             : nsresult
     120           0 : BaseBlobImpl::GetMutable(bool* aMutable) const
     121             : {
     122           0 :   *aMutable = !mImmutable;
     123           0 :   return NS_OK;
     124             : }
     125             : 
     126             : nsresult
     127           0 : BaseBlobImpl::SetMutable(bool aMutable)
     128             : {
     129           0 :   nsresult rv = NS_OK;
     130             : 
     131           0 :   NS_ENSURE_ARG(!mImmutable || !aMutable);
     132             : 
     133           0 :   if (!mImmutable && !aMutable) {
     134             :     // Force the content type and size to be cached
     135           0 :     nsAutoString dummyString;
     136           0 :     GetType(dummyString);
     137             : 
     138           0 :     ErrorResult error;
     139           0 :     GetSize(error);
     140           0 :     if (NS_WARN_IF(error.Failed())) {
     141           0 :       return error.StealNSResult();
     142             :     }
     143             :   }
     144             : 
     145           0 :   mImmutable = !aMutable;
     146           0 :   return rv;
     147             : }
     148             : 
     149             : /* static */ uint64_t
     150           0 : BaseBlobImpl::NextSerialNumber()
     151             : {
     152             :   static Atomic<uint64_t> nextSerialNumber;
     153           0 :   return nextSerialNumber++;
     154             : }
     155             : 
     156             : } // namespace dom
     157             : } // namespace mozilla

Generated by: LCOV version 1.13