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
|
|
|
|
|
|
|
|
#include "mozilla/dom/FileSystemTaskBase.h"
|
|
|
|
#include "nsAutoPtr.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;
|
2014-06-27 07:46:34 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class GetFileOrDirectoryTask final
|
2014-03-05 07:25:40 +04:00
|
|
|
: public FileSystemTaskBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// If aDirectoryOnly is set, we should ensure that the target is a directory.
|
|
|
|
GetFileOrDirectoryTask(FileSystemBase* aFileSystem,
|
|
|
|
const nsAString& aTargetPath,
|
2014-07-19 05:31:11 +04:00
|
|
|
bool aDirectoryOnly,
|
|
|
|
ErrorResult& aRv);
|
2014-03-05 07:25:40 +04:00
|
|
|
GetFileOrDirectoryTask(FileSystemBase* aFileSystem,
|
|
|
|
const FileSystemGetFileOrDirectoryParams& aParam,
|
|
|
|
FileSystemRequestParent* aParent);
|
|
|
|
|
|
|
|
virtual
|
|
|
|
~GetFileOrDirectoryTask();
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
|
|
|
GetPromise();
|
|
|
|
|
2014-03-05 07:24:19 +04:00
|
|
|
virtual void
|
2015-03-21 19:28:04 +03:00
|
|
|
GetPermissionAccessType(nsCString& aAccess) const override;
|
2014-03-05 07:25:40 +04:00
|
|
|
protected:
|
|
|
|
virtual FileSystemParams
|
2015-03-21 19:28:04 +03:00
|
|
|
GetRequestParams(const nsString& aFileSystem) const override;
|
2014-03-05 07:25:40 +04:00
|
|
|
|
|
|
|
virtual FileSystemResponseValue
|
2015-03-21 19:28:04 +03:00
|
|
|
GetSuccessRequestResult() const override;
|
2014-03-05 07:25:40 +04:00
|
|
|
|
|
|
|
virtual void
|
2015-03-21 19:28:04 +03:00
|
|
|
SetSuccessRequestResult(const FileSystemResponseValue& aValue) override;
|
2014-03-05 07:25:40 +04:00
|
|
|
|
|
|
|
virtual nsresult
|
2015-03-21 19:28:04 +03:00
|
|
|
Work() 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:
|
|
|
|
nsRefPtr<Promise> mPromise;
|
|
|
|
nsString mTargetRealPath;
|
|
|
|
// Whether we get a directory.
|
|
|
|
bool mIsDirectory;
|
2014-06-27 07:46:34 +04:00
|
|
|
|
2014-10-08 20:15:23 +04:00
|
|
|
// This cannot be a File bacause this object is created on a different
|
2015-05-12 15:11:03 +03:00
|
|
|
// thread and File is not thread-safe. Let's use the BlobImpl instead.
|
|
|
|
nsRefPtr<BlobImpl> mTargetBlobImpl;
|
2014-03-05 07:25:40 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_GetFileOrDirectory_h
|