#ifndef DOMFileSystemBase_h
#define DOMFileSystemBase_h
#include "heap/Handle.h"
#include "modules/filesystem/FileSystemFlags.h"
#include "platform/FileSystemType.h"
#include "platform/weborigin/KURL.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/text/WTFString.h"
namespace blink {
class WebFileSystem;
}
namespace WebCore {
class DirectoryEntry;
class DirectoryReaderBase;
class EntriesCallback;
class EntryBase;
class EntryCallback;
class ErrorCallback;
class FileError;
class MetadataCallback;
class ExecutionContext;
class SecurityOrigin;
class VoidCallback;
class DOMFileSystemBase : public RefCountedWillBeRefCountedGarbageCollected<DOMFileSystemBase> {
public:
enum SynchronousType {
Synchronous,
Asynchronous,
};
static const char persistentPathPrefix[];
static const char temporaryPathPrefix[];
static const char isolatedPathPrefix[];
static const char externalPathPrefix[];
virtual ~DOMFileSystemBase();
virtual void addPendingCallbacks() { }
virtual void removePendingCallbacks() { }
virtual void reportError(PassOwnPtr<ErrorCallback>, PassRefPtrWillBeRawPtr<FileError>) = 0;
const String& name() const { return m_name; }
FileSystemType type() const { return m_type; }
KURL rootURL() const { return m_filesystemRootURL; }
blink::WebFileSystem* fileSystem() const;
SecurityOrigin* securityOrigin() const;
void makeClonable() { m_clonable = true; }
bool clonable() const { return m_clonable; }
static bool isValidType(FileSystemType);
static bool crackFileSystemURL(const KURL&, FileSystemType&, String& filePath);
static KURL createFileSystemRootURL(const String& origin, FileSystemType);
bool supportsToURL() const;
KURL createFileSystemURL(const EntryBase*) const;
KURL createFileSystemURL(const String& fullPath) const;
static bool pathToAbsolutePath(FileSystemType, const EntryBase*, String path, String& absolutePath);
static bool pathPrefixToFileSystemType(const String& pathPrefix, FileSystemType&);
void getMetadata(const EntryBase*, PassOwnPtr<MetadataCallback>, PassOwnPtr<ErrorCallback>, SynchronousType = Asynchronous);
void move(const EntryBase* source, EntryBase* parent, const String& name, PassOwnPtr<EntryCallback>, PassOwnPtr<ErrorCallback>, SynchronousType = Asynchronous);
void copy(const EntryBase* source, EntryBase* parent, const String& name, PassOwnPtr<EntryCallback>, PassOwnPtr<ErrorCallback>, SynchronousType = Asynchronous);
void remove(const EntryBase*, PassOwnPtr<VoidCallback>, PassOwnPtr<ErrorCallback>, SynchronousType = Asynchronous);
void removeRecursively(const EntryBase*, PassOwnPtr<VoidCallback>, PassOwnPtr<ErrorCallback>, SynchronousType = Asynchronous);
void getParent(const EntryBase*, PassOwnPtr<EntryCallback>, PassOwnPtr<ErrorCallback>);
void getFile(const EntryBase*, const String& path, const FileSystemFlags&, PassOwnPtr<EntryCallback>, PassOwnPtr<ErrorCallback>, SynchronousType = Asynchronous);
void getDirectory(const EntryBase*, const String& path, const FileSystemFlags&, PassOwnPtr<EntryCallback>, PassOwnPtr<ErrorCallback>, SynchronousType = Asynchronous);
int readDirectory(PassRefPtrWillBeRawPtr<DirectoryReaderBase>, const String& path, PassOwnPtr<EntriesCallback>, PassOwnPtr<ErrorCallback>, SynchronousType = Asynchronous);
bool waitForAdditionalResult(int callbacksId);
virtual void trace(Visitor*) { }
protected:
DOMFileSystemBase(ExecutionContext*, const String& name, FileSystemType, const KURL& rootURL);
friend class DOMFileSystemSync;
ExecutionContext* m_context;
String m_name;
FileSystemType m_type;
KURL m_filesystemRootURL;
bool m_clonable;
};
inline bool operator==(const DOMFileSystemBase& a, const DOMFileSystemBase& b) { return a.name() == b.name() && a.type() == b.type() && a.rootURL() == b.rootURL(); }
}
#endif