Files
tubestation/dom/filesystem/FileSystemBase.h
Phil Ringnalda 9e96cfb31d Backed out 8 changesets (bug 1173320) for adding dom/filesystem/tests/test_basic.html without making it work on Android
Backed out changeset 7e3a105b9160 (bug 1173320)
Backed out changeset 094819fbb07f (bug 1173320)
Backed out changeset 23b0e55ff1db (bug 1173320)
Backed out changeset 8bf8e2fcedad (bug 1173320)
Backed out changeset 3de390c6f47f (bug 1173320)
Backed out changeset fb298010e12e (bug 1173320)
Backed out changeset f1a965c2f796 (bug 1173320)
Backed out changeset 176128ba757f (bug 1173320)
2016-03-19 19:44:22 -07:00

133 lines
2.9 KiB
C++

/* -*- 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_FileSystemBase_h
#define mozilla_dom_FileSystemBase_h
#include "nsAutoPtr.h"
#include "nsString.h"
class nsPIDOMWindowInner;
namespace mozilla {
namespace dom {
class BlobImpl;
class Directory;
class FileSystemBase
{
NS_INLINE_DECL_REFCOUNTING(FileSystemBase)
public:
// Create file system object from its string representation.
static already_AddRefed<FileSystemBase>
FromString(const nsAString& aString);
FileSystemBase();
virtual void
Shutdown();
// Get the string representation of the file system.
const nsString&
ToString() const
{
return mString;
}
virtual nsPIDOMWindowInner*
GetWindow() const;
/**
* Create nsIFile object from the given real path (absolute DOM path).
*/
already_AddRefed<nsIFile>
GetLocalFile(const nsAString& aRealPath) const;
/*
* Get the virtual name of the root directory. This name will be exposed to
* the content page.
*/
virtual void
GetRootName(nsAString& aRetval) const = 0;
const nsAString&
GetLocalRootPath() const
{
return mLocalRootPath;
}
bool
IsShutdown() const
{
return mShutdown;
}
virtual bool
IsSafeFile(nsIFile* aFile) const;
virtual bool
IsSafeDirectory(Directory* aDir) const;
/*
* Get the real path (absolute DOM path) of the DOM file in the file system.
* If succeeded, returns true. Otherwise, returns false and set aRealPath to
* empty string.
*/
bool
GetRealPath(BlobImpl* aFile, nsAString& aRealPath) const;
/*
* Get the permission name required to access this file system.
*/
const nsCString&
GetPermission() const
{
return mPermission;
}
bool
RequiresPermissionChecks() const
{
return mRequiresPermissionChecks;
}
// CC methods
virtual void Unlink() {}
virtual void Traverse(nsCycleCollectionTraversalCallback &cb) {}
protected:
virtual ~FileSystemBase();
bool
LocalPathToRealPath(const nsAString& aLocalPath, nsAString& aRealPath) const;
// The local path of the root (i.e. the OS path, with OS path separators, of
// the OS directory that acts as the root of this OSFileSystem).
// Only available in the parent process.
// In the child process, we don't use it and its value should be empty.
nsString mLocalRootPath;
// The same, but with path separators normalized to "/".
nsString mNormalizedLocalRootPath;
// The string representation of the file system.
nsString mString;
bool mShutdown;
// The permission name required to access the file system.
nsCString mPermission;
bool mRequiresPermissionChecks;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_FileSystemBase_h