LCOV - code coverage report
Current view: top level - dom/filesystem/compat - FileSystemFileEntry.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 42 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 file,
       5             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "FileSystemFileEntry.h"
       8             : #include "CallbackRunnables.h"
       9             : #include "mozilla/dom/File.h"
      10             : #include "mozilla/dom/FileSystemUtils.h"
      11             : #include "mozilla/dom/MultipartBlobImpl.h"
      12             : #include "mozilla/dom/FileSystemFileEntryBinding.h"
      13             : 
      14             : namespace mozilla {
      15             : namespace dom {
      16             : 
      17             : namespace {
      18             : 
      19           0 : class FileCallbackRunnable final : public Runnable
      20             : {
      21             : public:
      22           0 :   FileCallbackRunnable(FileCallback* aCallback, File* aFile)
      23           0 :     : Runnable("FileCallbackRunnable")
      24             :     , mCallback(aCallback)
      25           0 :     , mFile(aFile)
      26             :   {
      27           0 :     MOZ_ASSERT(aCallback);
      28           0 :     MOZ_ASSERT(aFile);
      29           0 :   }
      30             : 
      31             :   NS_IMETHOD
      32           0 :   Run() override
      33             :   {
      34             :     // Here we clone the File object.
      35             : 
      36           0 :     RefPtr<File> file = File::Create(mFile->GetParentObject(), mFile->Impl());
      37           0 :     MOZ_ASSERT(file);
      38             : 
      39           0 :     mCallback->HandleEvent(*file);
      40           0 :     return NS_OK;
      41             :   }
      42             : 
      43             : private:
      44             :   RefPtr<FileCallback> mCallback;
      45             :   RefPtr<File> mFile;
      46             : };
      47             : 
      48             : } // anonymous namespace
      49             : 
      50           0 : NS_IMPL_CYCLE_COLLECTION_INHERITED(FileSystemFileEntry, FileSystemEntry, mFile)
      51             : 
      52           0 : NS_IMPL_ADDREF_INHERITED(FileSystemFileEntry, FileSystemEntry)
      53           0 : NS_IMPL_RELEASE_INHERITED(FileSystemFileEntry, FileSystemEntry)
      54             : 
      55           0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FileSystemFileEntry)
      56           0 : NS_INTERFACE_MAP_END_INHERITING(FileSystemEntry)
      57             : 
      58           0 : FileSystemFileEntry::FileSystemFileEntry(nsIGlobalObject* aGlobal,
      59             :                                          File* aFile,
      60             :                                          FileSystemDirectoryEntry* aParentEntry,
      61           0 :                                          FileSystem* aFileSystem)
      62             :   : FileSystemEntry(aGlobal, aParentEntry, aFileSystem)
      63           0 :   , mFile(aFile)
      64             : {
      65           0 :   MOZ_ASSERT(aGlobal);
      66           0 :   MOZ_ASSERT(mFile);
      67           0 : }
      68             : 
      69           0 : FileSystemFileEntry::~FileSystemFileEntry()
      70           0 : {}
      71             : 
      72             : JSObject*
      73           0 : FileSystemFileEntry::WrapObject(JSContext* aCx,
      74             :                                 JS::Handle<JSObject*> aGivenProto)
      75             : {
      76           0 :   return FileSystemFileEntryBinding::Wrap(aCx, this, aGivenProto);
      77             : }
      78             : 
      79             : void
      80           0 : FileSystemFileEntry::GetName(nsAString& aName, ErrorResult& aRv) const
      81             : {
      82           0 :   mFile->GetName(aName);
      83           0 : }
      84             : 
      85             : void
      86           0 : FileSystemFileEntry::GetFullPath(nsAString& aPath, ErrorResult& aRv) const
      87             : {
      88           0 :   mFile->Impl()->GetDOMPath(aPath);
      89           0 :   if (aPath.IsEmpty()) {
      90             :     // We're under the root directory. webkitRelativePath
      91             :     // (implemented as GetPath) is for cases when file is selected because its
      92             :     // ancestor directory is selected. But that is not the case here, so need to
      93             :     // manually prepend '/'.
      94           0 :     nsAutoString name;
      95           0 :     mFile->GetName(name);
      96           0 :     aPath.AssignLiteral(FILESYSTEM_DOM_PATH_SEPARATOR_LITERAL);
      97           0 :     aPath.Append(name);
      98             :   }
      99           0 : }
     100             : 
     101             : void
     102           0 : FileSystemFileEntry::GetFile(FileCallback& aSuccessCallback,
     103             :                              const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback) const
     104             : {
     105             :   RefPtr<FileCallbackRunnable> runnable =
     106           0 :     new FileCallbackRunnable(&aSuccessCallback, mFile);
     107             : 
     108           0 :   FileSystemUtils::DispatchRunnable(GetParentObject(), runnable.forget());
     109           0 : }
     110             : 
     111             : } // dom namespace
     112             : } // mozilla namespace

Generated by: LCOV version 1.13