author B2G Bumper Bot <>
Fri, 27 Jun 2014 17:00:29 -0700
changeset 208544 135686e1d4f41d1df1b172238bc8a4f9d534d5d9
parent 188475 edf18d2929c328c10b62b8779d63431b84aca6c3
child 212223 1679e9d569c36fa32df9977f13464f4325c9303a
permissions -rw-r--r--
Bumping manifests a=b2g-bump

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 * vim: set sw=4 ts=8 et tw=80 :
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */

#ifndef mozilla_dom_FilePickerParent_h
#define mozilla_dom_FilePickerParent_h

#include "nsIDOMFile.h"
#include "nsIEventTarget.h"
#include "nsIFilePicker.h"
#include "nsCOMArray.h"
#include "nsThreadUtils.h"
#include "mozilla/dom/PFilePickerParent.h"

namespace mozilla {
namespace dom {

class FilePickerParent : public PFilePickerParent
  FilePickerParent(const nsString& aTitle,
                   const int16_t& aMode)
  : mTitle(aTitle)
  , mMode(aMode)

  virtual ~FilePickerParent();

  void Done(int16_t aResult);
  void SendFiles(const nsCOMArray<nsIDOMFile>& aDomfiles);

  virtual bool RecvOpen(const int16_t& aSelectedType,
                        const bool& aAddToRecentDocs,
                        const nsString& aDefaultFile,
                        const nsString& aDefaultExtension,
                        const InfallibleTArray<nsString>& aFilters,
                        const InfallibleTArray<nsString>& aFilterNames) MOZ_OVERRIDE;

  virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;

  class FilePickerShownCallback : public nsIFilePickerShownCallback
    FilePickerShownCallback(FilePickerParent* aFilePickerParent)
      : mFilePickerParent(aFilePickerParent)
    { }
    virtual ~FilePickerShownCallback() {}


    void Destroy();

    FilePickerParent* mFilePickerParent;

  bool CreateFilePicker();

  class FileSizeAndDateRunnable : public nsRunnable
    FilePickerParent* mFilePickerParent;
    nsCOMArray<nsIDOMFile> mDomfiles;
    nsCOMPtr<nsIEventTarget> mEventTarget;

    FileSizeAndDateRunnable(FilePickerParent *aFPParent, nsCOMArray<nsIDOMFile>& aDomfiles);
    bool Dispatch();
    NS_IMETHOD Run();
    void Destroy();

  nsRefPtr<FileSizeAndDateRunnable> mRunnable;
  nsRefPtr<FilePickerShownCallback> mCallback;
  nsCOMPtr<nsIFilePicker> mFilePicker;

  nsString mTitle;
  int16_t mMode;
  int16_t mResult;

} // namespace dom
} // namespace mozilla