2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-03-05 07:25:40 +04:00
|
|
|
/* 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 http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_GetFileOrDirectory_h
|
|
|
|
#define mozilla_dom_GetFileOrDirectory_h
|
|
|
|
|
2016-03-20 13:56:10 +03:00
|
|
|
#include "mozilla/dom/Directory.h"
|
2014-03-05 07:25:40 +04:00
|
|
|
#include "mozilla/dom/FileSystemTaskBase.h"
|
2014-07-19 05:31:11 +04:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2014-03-05 07:25:40 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-05-12 15:11:03 +03:00
|
|
|
class BlobImpl;
|
2017-03-08 22:15:44 +03:00
|
|
|
class FileSystemGetFileOrDirectoryParams;
|
2014-06-27 07:46:34 +04:00
|
|
|
|
2016-04-09 21:17:28 +03:00
|
|
|
class GetFileOrDirectoryTaskChild final : public FileSystemTaskChildBase
|
2014-03-05 07:25:40 +04:00
|
|
|
{
|
|
|
|
public:
|
2016-04-09 21:17:28 +03:00
|
|
|
static already_AddRefed<GetFileOrDirectoryTaskChild>
|
2016-03-20 13:56:10 +03:00
|
|
|
Create(FileSystemBase* aFileSystem,
|
|
|
|
nsIFile* aTargetPath,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2014-03-05 07:25:40 +04:00
|
|
|
virtual
|
2016-04-09 21:17:28 +03:00
|
|
|
~GetFileOrDirectoryTaskChild();
|
2014-03-05 07:25:40 +04:00
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
|
|
|
GetPromise();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual FileSystemParams
|
2016-03-20 13:56:10 +03:00
|
|
|
GetRequestParams(const nsString& aSerializedDOMPath,
|
|
|
|
ErrorResult& aRv) const override;
|
2014-03-05 07:25:40 +04:00
|
|
|
|
|
|
|
virtual void
|
2016-03-20 13:56:10 +03:00
|
|
|
SetSuccessRequestResult(const FileSystemResponseValue& aValue,
|
|
|
|
ErrorResult& aRv) override;
|
2014-03-05 07:25:40 +04:00
|
|
|
virtual void
|
2015-03-21 19:28:04 +03:00
|
|
|
HandlerCallback() override;
|
2014-03-05 07:25:40 +04:00
|
|
|
|
|
|
|
private:
|
2016-04-09 21:17:28 +03:00
|
|
|
GetFileOrDirectoryTaskChild(FileSystemBase* aFileSystem,
|
2017-03-08 22:15:45 +03:00
|
|
|
nsIFile* aTargetPath);
|
2016-03-20 13:56:10 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Promise> mPromise;
|
2016-03-20 13:56:10 +03:00
|
|
|
nsCOMPtr<nsIFile> mTargetPath;
|
|
|
|
|
2017-02-01 09:33:18 +03:00
|
|
|
RefPtr<File> mResultFile;
|
|
|
|
RefPtr<Directory> mResultDirectory;
|
2014-03-05 07:25:40 +04:00
|
|
|
};
|
|
|
|
|
2016-04-09 21:17:02 +03:00
|
|
|
class GetFileOrDirectoryTaskParent final : public FileSystemTaskParentBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static already_AddRefed<GetFileOrDirectoryTaskParent>
|
|
|
|
Create(FileSystemBase* aFileSystem,
|
|
|
|
const FileSystemGetFileOrDirectoryParams& aParam,
|
|
|
|
FileSystemRequestParent* aParent,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual FileSystemResponseValue
|
|
|
|
GetSuccessRequestResult(ErrorResult& aRv) const override;
|
|
|
|
|
|
|
|
virtual nsresult
|
|
|
|
IOWork() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
GetFileOrDirectoryTaskParent(FileSystemBase* aFileSystem,
|
|
|
|
const FileSystemGetFileOrDirectoryParams& aParam,
|
|
|
|
FileSystemRequestParent* aParent);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFile> mTargetPath;
|
|
|
|
|
|
|
|
// Whether we get a directory.
|
|
|
|
bool mIsDirectory;
|
|
|
|
};
|
|
|
|
|
2014-03-05 07:25:40 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_GetFileOrDirectory_h
|