LCOV - code coverage report
Current view: top level - dom/ipc - FilePickerParent.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 10 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 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_FilePickerParent_h
       8             : #define mozilla_dom_FilePickerParent_h
       9             : 
      10             : #include "nsIEventTarget.h"
      11             : #include "nsIFilePicker.h"
      12             : #include "nsCOMArray.h"
      13             : #include "nsThreadUtils.h"
      14             : #include "mozilla/dom/File.h"
      15             : #include "mozilla/dom/PFilePickerParent.h"
      16             : 
      17             : class nsIFile;
      18             : 
      19             : namespace mozilla {
      20             : namespace dom {
      21             : 
      22             : class FilePickerParent : public PFilePickerParent
      23             : {
      24             :  public:
      25           0 :   FilePickerParent(const nsString& aTitle,
      26             :                    const int16_t& aMode)
      27           0 :   : mTitle(aTitle)
      28           0 :   , mMode(aMode)
      29           0 :   {}
      30             : 
      31             :   virtual ~FilePickerParent();
      32             : 
      33             :   void Done(int16_t aResult);
      34             : 
      35           0 :   struct BlobImplOrString
      36             :   {
      37             :     RefPtr<BlobImpl> mBlobImpl;
      38             :     nsString mDirectoryPath;
      39             : 
      40             :     enum {
      41             :       eBlobImpl,
      42             :       eDirectoryPath
      43             :     } mType;
      44             :   };
      45             : 
      46             :   void SendFilesOrDirectories(const nsTArray<BlobImplOrString>& aData);
      47             : 
      48             :   virtual mozilla::ipc::IPCResult RecvOpen(const int16_t& aSelectedType,
      49             :                                            const bool& aAddToRecentDocs,
      50             :                                            const nsString& aDefaultFile,
      51             :                                            const nsString& aDefaultExtension,
      52             :                                            InfallibleTArray<nsString>&& aFilters,
      53             :                                            InfallibleTArray<nsString>&& aFilterNames,
      54             :                                            const nsString& aDisplayDirectory,
      55             :                                            const nsString& aDisplaySpecialDirectory,
      56             :                                            const nsString& aOkButtonLabel) override;
      57             : 
      58             :   virtual void ActorDestroy(ActorDestroyReason aWhy) override;
      59             : 
      60             :   class FilePickerShownCallback : public nsIFilePickerShownCallback
      61             :   {
      62             :   public:
      63           0 :     explicit FilePickerShownCallback(FilePickerParent* aFilePickerParent)
      64           0 :       : mFilePickerParent(aFilePickerParent)
      65           0 :     { }
      66             : 
      67             :     NS_DECL_ISUPPORTS
      68             :     NS_DECL_NSIFILEPICKERSHOWNCALLBACK
      69             : 
      70             :     void Destroy();
      71             : 
      72             :   private:
      73           0 :     virtual ~FilePickerShownCallback() {}
      74             :     FilePickerParent* mFilePickerParent;
      75             :   };
      76             : 
      77             :  private:
      78             :   bool CreateFilePicker();
      79             : 
      80             :   // This runnable is used to do some I/O operation on a separate thread.
      81           0 :   class IORunnable : public Runnable
      82             :   {
      83             :     FilePickerParent* mFilePickerParent;
      84             :     nsTArray<nsCOMPtr<nsIFile>> mFiles;
      85             :     nsTArray<BlobImplOrString> mResults;
      86             :     nsCOMPtr<nsIEventTarget> mEventTarget;
      87             :     bool mIsDirectory;
      88             : 
      89             :   public:
      90             :     IORunnable(FilePickerParent *aFPParent,
      91             :                nsTArray<nsCOMPtr<nsIFile>>& aFiles,
      92             :                bool aIsDirectory);
      93             : 
      94             :     bool Dispatch();
      95             :     NS_IMETHOD Run();
      96             :     void Destroy();
      97             :   };
      98             : 
      99             :   RefPtr<IORunnable> mRunnable;
     100             :   RefPtr<FilePickerShownCallback> mCallback;
     101             :   nsCOMPtr<nsIFilePicker> mFilePicker;
     102             : 
     103             :   nsString mTitle;
     104             :   int16_t mMode;
     105             :   int16_t mResult;
     106             : };
     107             : 
     108             : } // namespace dom
     109             : } // namespace mozilla
     110             : 
     111             : #endif // mozilla_dom_FilePickerParent_h

Generated by: LCOV version 1.13