2015-07-10 20:54:53 +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: */
|
|
|
|
/* 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_OSFileSystem_h
|
|
|
|
#define mozilla_dom_OSFileSystem_h
|
|
|
|
|
|
|
|
#include "mozilla/dom/FileSystemBase.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-12-30 11:53:38 +03:00
|
|
|
class OSFileSystem final : public FileSystemBase
|
2015-07-10 20:54:53 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit OSFileSystem(const nsAString& aRootDir);
|
|
|
|
|
|
|
|
void
|
2016-03-20 13:56:10 +03:00
|
|
|
Init(nsISupports* aParent);
|
2015-07-10 20:54:53 +03:00
|
|
|
|
|
|
|
// Overrides FileSystemBase
|
|
|
|
|
2016-03-20 13:58:01 +03:00
|
|
|
virtual already_AddRefed<FileSystemBase>
|
|
|
|
Clone() override;
|
|
|
|
|
2016-04-18 10:32:59 +03:00
|
|
|
virtual bool
|
|
|
|
ShouldCreateDirectory() override
|
|
|
|
{
|
|
|
|
MOZ_CRASH("This should not be called.");
|
|
|
|
// Because OSFileSystem should not be used when the creation of directories
|
|
|
|
// is needed. For that we have OSFileSystemParent.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-03-20 13:56:10 +03:00
|
|
|
virtual nsISupports*
|
|
|
|
GetParentObject() const override;
|
2015-07-10 20:54:53 +03:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
IsSafeFile(nsIFile* aFile) const override;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
IsSafeDirectory(Directory* aDir) const override;
|
|
|
|
|
2016-03-20 13:56:10 +03:00
|
|
|
virtual void
|
|
|
|
SerializeDOMPath(nsAString& aOutput) const override;
|
|
|
|
|
2015-12-30 11:53:38 +03:00
|
|
|
// CC methods
|
|
|
|
virtual void Unlink() override;
|
|
|
|
virtual void Traverse(nsCycleCollectionTraversalCallback &cb) override;
|
|
|
|
|
2015-07-10 20:54:53 +03:00
|
|
|
private:
|
|
|
|
virtual ~OSFileSystem() {}
|
|
|
|
|
2016-04-09 21:17:02 +03:00
|
|
|
nsCOMPtr<nsISupports> mParent;
|
|
|
|
};
|
|
|
|
|
|
|
|
class OSFileSystemParent final : public FileSystemBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit OSFileSystemParent(const nsAString& aRootDir);
|
|
|
|
|
|
|
|
// Overrides FileSystemBase
|
|
|
|
|
|
|
|
virtual already_AddRefed<FileSystemBase>
|
|
|
|
Clone() override
|
|
|
|
{
|
|
|
|
MOZ_CRASH("This should not be called on the PBackground thread.");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-04-18 10:32:59 +03:00
|
|
|
virtual bool
|
|
|
|
ShouldCreateDirectory() override { return false; }
|
|
|
|
|
2016-04-09 21:17:02 +03:00
|
|
|
virtual nsISupports*
|
|
|
|
GetParentObject() const override
|
|
|
|
{
|
|
|
|
MOZ_CRASH("This should not be called on the PBackground thread.");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void
|
2016-04-18 10:32:30 +03:00
|
|
|
GetDirectoryName(nsIFile* aFile, nsAString& aRetval,
|
|
|
|
ErrorResult& aRv) const override
|
2016-04-09 21:17:02 +03:00
|
|
|
{
|
|
|
|
MOZ_CRASH("This should not be called on the PBackground thread.");
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
IsSafeFile(nsIFile* aFile) const override
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
IsSafeDirectory(Directory* aDir) const override
|
|
|
|
{
|
|
|
|
MOZ_CRASH("This should not be called on the PBackground thread.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
SerializeDOMPath(nsAString& aOutput) const override
|
|
|
|
{
|
|
|
|
MOZ_CRASH("This should not be called on the PBackground thread.");
|
|
|
|
}
|
|
|
|
|
|
|
|
// CC methods
|
|
|
|
virtual void
|
|
|
|
Unlink() override
|
|
|
|
{
|
|
|
|
MOZ_CRASH("This should not be called on the PBackground thread.");
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
Traverse(nsCycleCollectionTraversalCallback &cb) override
|
|
|
|
{
|
|
|
|
MOZ_CRASH("This should not be called on the PBackground thread.");
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~OSFileSystemParent() {}
|
2015-07-10 20:54:53 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_OSFileSystem_h
|