LCOV - code coverage report
Current view: top level - dom/filesystem/compat - FileSystemRootDirectoryReader.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 34 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 file,
       5             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "FileSystemRootDirectoryReader.h"
       8             : #include "CallbackRunnables.h"
       9             : #include "nsIGlobalObject.h"
      10             : #include "mozilla/dom/FileSystemUtils.h"
      11             : 
      12             : namespace mozilla {
      13             : namespace dom {
      14             : 
      15             : namespace {
      16             : 
      17           0 : class EntriesCallbackRunnable final : public Runnable
      18             : {
      19             : public:
      20           0 :   EntriesCallbackRunnable(FileSystemEntriesCallback* aCallback,
      21             :                           const Sequence<RefPtr<FileSystemEntry>>& aEntries)
      22           0 :     : Runnable("EntriesCallbackRunnable")
      23             :     , mCallback(aCallback)
      24           0 :     , mEntries(aEntries)
      25             :   {
      26           0 :     MOZ_ASSERT(aCallback);
      27           0 :   }
      28             : 
      29             :   NS_IMETHOD
      30           0 :   Run() override
      31             :   {
      32           0 :     Sequence<OwningNonNull<FileSystemEntry>> entries;
      33           0 :     for (uint32_t i = 0; i < mEntries.Length(); ++i) {
      34           0 :       if (!entries.AppendElement(mEntries[i].forget(), fallible)) {
      35           0 :         return NS_ERROR_OUT_OF_MEMORY;
      36             :       }
      37             :     }
      38             : 
      39           0 :     mCallback->HandleEvent(entries);
      40           0 :     return NS_OK;
      41             :   }
      42             : 
      43             : private:
      44             :   RefPtr<FileSystemEntriesCallback> mCallback;
      45             :   Sequence<RefPtr<FileSystemEntry>> mEntries;
      46             : };
      47             : 
      48             : } // anonymous namespace
      49             : 
      50           0 : NS_IMPL_CYCLE_COLLECTION_INHERITED(FileSystemRootDirectoryReader,
      51             :                                    FileSystemDirectoryReader, mEntries)
      52             : 
      53           0 : NS_IMPL_ADDREF_INHERITED(FileSystemRootDirectoryReader,
      54             :                          FileSystemDirectoryReader)
      55           0 : NS_IMPL_RELEASE_INHERITED(FileSystemRootDirectoryReader,
      56             :                           FileSystemDirectoryReader)
      57             : 
      58           0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FileSystemRootDirectoryReader)
      59           0 : NS_INTERFACE_MAP_END_INHERITING(FileSystemDirectoryReader)
      60             : 
      61           0 : FileSystemRootDirectoryReader::FileSystemRootDirectoryReader(FileSystemDirectoryEntry* aParentEntry,
      62             :                                                              FileSystem* aFileSystem,
      63           0 :                                                              const Sequence<RefPtr<FileSystemEntry>>& aEntries)
      64             :   : FileSystemDirectoryReader(aParentEntry, aFileSystem, nullptr)
      65             :   , mEntries(aEntries)
      66           0 :   , mAlreadyRead(false)
      67             : {
      68           0 :   MOZ_ASSERT(aParentEntry);
      69           0 :   MOZ_ASSERT(aFileSystem);
      70           0 : }
      71             : 
      72           0 : FileSystemRootDirectoryReader::~FileSystemRootDirectoryReader()
      73           0 : {}
      74             : 
      75             : void
      76           0 : FileSystemRootDirectoryReader::ReadEntries(FileSystemEntriesCallback& aSuccessCallback,
      77             :                                            const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
      78             :                                            ErrorResult& aRv)
      79             : {
      80           0 :   if (mAlreadyRead) {
      81             :     RefPtr<EmptyEntriesCallbackRunnable> runnable =
      82           0 :       new EmptyEntriesCallbackRunnable(&aSuccessCallback);
      83             : 
      84           0 :     aRv = FileSystemUtils::DispatchRunnable(GetParentObject(), runnable.forget());
      85           0 :     return;
      86             :   }
      87             : 
      88             :   // This object can be used only once.
      89           0 :   mAlreadyRead = true;
      90             : 
      91             :   RefPtr<EntriesCallbackRunnable> runnable =
      92           0 :     new EntriesCallbackRunnable(&aSuccessCallback, mEntries);
      93             : 
      94           0 :   aRv = FileSystemUtils::DispatchRunnable(GetParentObject(), runnable.forget());
      95             : }
      96             : 
      97             : } // dom namespace
      98             : } // mozilla namespace

Generated by: LCOV version 1.13