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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_OSFileSystem_h
8 #define mozilla_dom_OSFileSystem_h
10 #include "mozilla/dom/FileSystemBase.h"
15 class OSFileSystem final
: public FileSystemBase
{
17 explicit OSFileSystem(const nsAString
& aRootDir
);
19 void Init(nsISupports
* aParent
);
21 // Overrides FileSystemBase
23 virtual already_AddRefed
<FileSystemBase
> Clone() override
;
25 virtual bool ShouldCreateDirectory() override
{
26 MOZ_CRASH("This should not be called.");
27 // Because OSFileSystem should not be used when the creation of directories
28 // is needed. For that we have OSFileSystemParent.
32 virtual nsISupports
* GetParentObject() const override
;
34 virtual bool IsSafeFile(nsIFile
* aFile
) const override
;
36 virtual bool IsSafeDirectory(Directory
* aDir
) const override
;
38 virtual void SerializeDOMPath(nsAString
& aOutput
) const override
;
41 virtual void Unlink() override
;
42 virtual void Traverse(nsCycleCollectionTraversalCallback
& cb
) override
;
45 virtual ~OSFileSystem() {}
47 nsCOMPtr
<nsISupports
> mParent
;
50 class OSFileSystemParent final
: public FileSystemBase
{
52 explicit OSFileSystemParent(const nsAString
& aRootDir
);
54 // Overrides FileSystemBase
56 virtual already_AddRefed
<FileSystemBase
> Clone() override
{
57 MOZ_CRASH("This should not be called on the PBackground thread.");
61 virtual bool ShouldCreateDirectory() override
{ return false; }
63 virtual nsISupports
* GetParentObject() const override
{
64 MOZ_CRASH("This should not be called on the PBackground thread.");
68 virtual void GetDirectoryName(nsIFile
* aFile
, nsAString
& aRetval
,
69 ErrorResult
& aRv
) const override
{
70 MOZ_CRASH("This should not be called on the PBackground thread.");
73 virtual bool IsSafeFile(nsIFile
* aFile
) const override
{ return true; }
75 virtual bool IsSafeDirectory(Directory
* aDir
) const override
{
76 MOZ_CRASH("This should not be called on the PBackground thread.");
80 virtual void SerializeDOMPath(nsAString
& aOutput
) const override
{
81 MOZ_CRASH("This should not be called on the PBackground thread.");
85 virtual void Unlink() override
{
86 MOZ_CRASH("This should not be called on the PBackground thread.");
89 virtual void Traverse(nsCycleCollectionTraversalCallback
& cb
) override
{
90 MOZ_CRASH("This should not be called on the PBackground thread.");
94 virtual ~OSFileSystemParent() {}
98 } // namespace mozilla
100 #endif // mozilla_dom_OSFileSystem_h