| Index: third_party/WebKit/Source/modules/filesystem/FileSystemBase.cpp
|
| diff --git a/third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.cpp b/third_party/WebKit/Source/modules/filesystem/FileSystemBase.cpp
|
| similarity index 69%
|
| rename from third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.cpp
|
| rename to third_party/WebKit/Source/modules/filesystem/FileSystemBase.cpp
|
| index e15477ee836df46b71113bf623817db077c163f6..81d81bf576c6e1b2a1219580aebe84de330a7266 100644
|
| --- a/third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.cpp
|
| +++ b/third_party/WebKit/Source/modules/filesystem/FileSystemBase.cpp
|
| @@ -28,21 +28,21 @@
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
|
|
| -#include "modules/filesystem/DOMFileSystemBase.h"
|
| +#include "modules/filesystem/FileSystemBase.h"
|
|
|
| #include "core/dom/ExecutionContext.h"
|
| #include "core/fileapi/File.h"
|
| #include "core/fileapi/FileError.h"
|
| #include "core/html/VoidCallback.h"
|
| #include "modules/filesystem/DOMFilePath.h"
|
| -#include "modules/filesystem/DirectoryEntry.h"
|
| -#include "modules/filesystem/DirectoryReaderBase.h"
|
| -#include "modules/filesystem/EntriesCallback.h"
|
| -#include "modules/filesystem/Entry.h"
|
| -#include "modules/filesystem/EntryBase.h"
|
| -#include "modules/filesystem/EntryCallback.h"
|
| #include "modules/filesystem/FileSystemCallbacks.h"
|
| -#include "modules/filesystem/MetadataCallback.h"
|
| +#include "modules/filesystem/FileSystemDirectoryEntry.h"
|
| +#include "modules/filesystem/FileSystemDirectoryReaderBase.h"
|
| +#include "modules/filesystem/FileSystemEntriesCallback.h"
|
| +#include "modules/filesystem/FileSystemEntry.h"
|
| +#include "modules/filesystem/FileSystemEntryBase.h"
|
| +#include "modules/filesystem/FileSystemEntryCallback.h"
|
| +#include "modules/filesystem/FileSystemMetadataCallback.h"
|
| #include "platform/weborigin/SecurityOrigin.h"
|
| #include "public/platform/Platform.h"
|
| #include "public/platform/WebFileSystem.h"
|
| @@ -53,45 +53,45 @@
|
|
|
| namespace blink {
|
|
|
| -const char DOMFileSystemBase::persistentPathPrefix[] = "persistent";
|
| -const char DOMFileSystemBase::temporaryPathPrefix[] = "temporary";
|
| -const char DOMFileSystemBase::isolatedPathPrefix[] = "isolated";
|
| -const char DOMFileSystemBase::externalPathPrefix[] = "external";
|
| +const char FileSystemBase::persistentPathPrefix[] = "persistent";
|
| +const char FileSystemBase::temporaryPathPrefix[] = "temporary";
|
| +const char FileSystemBase::isolatedPathPrefix[] = "isolated";
|
| +const char FileSystemBase::externalPathPrefix[] = "external";
|
|
|
| -DOMFileSystemBase::DOMFileSystemBase(ExecutionContext* context,
|
| - const String& name,
|
| - FileSystemType type,
|
| - const KURL& rootURL)
|
| +FileSystemBase::FileSystemBase(ExecutionContext* context,
|
| + const String& name,
|
| + FileSystemType type,
|
| + const KURL& rootURL)
|
| : m_context(context),
|
| m_name(name),
|
| m_type(type),
|
| m_filesystemRootURL(rootURL),
|
| m_clonable(false) {}
|
|
|
| -DOMFileSystemBase::~DOMFileSystemBase() {}
|
| +FileSystemBase::~FileSystemBase() {}
|
|
|
| -DEFINE_TRACE(DOMFileSystemBase) {
|
| +DEFINE_TRACE(FileSystemBase) {
|
| visitor->trace(m_context);
|
| }
|
|
|
| -WebFileSystem* DOMFileSystemBase::fileSystem() const {
|
| +WebFileSystem* FileSystemBase::fileSystem() const {
|
| Platform* platform = Platform::current();
|
| if (!platform)
|
| return nullptr;
|
| return platform->fileSystem();
|
| }
|
|
|
| -SecurityOrigin* DOMFileSystemBase::getSecurityOrigin() const {
|
| +SecurityOrigin* FileSystemBase::getSecurityOrigin() const {
|
| return m_context->getSecurityOrigin();
|
| }
|
|
|
| -bool DOMFileSystemBase::isValidType(FileSystemType type) {
|
| +bool FileSystemBase::isValidType(FileSystemType type) {
|
| return type == FileSystemTypeTemporary || type == FileSystemTypePersistent ||
|
| type == FileSystemTypeIsolated || type == FileSystemTypeExternal;
|
| }
|
|
|
| -KURL DOMFileSystemBase::createFileSystemRootURL(const String& origin,
|
| - FileSystemType type) {
|
| +KURL FileSystemBase::createFileSystemRootURL(const String& origin,
|
| + FileSystemType type) {
|
| String typeString;
|
| if (type == FileSystemTypeTemporary)
|
| typeString = temporaryPathPrefix;
|
| @@ -106,17 +106,18 @@ KURL DOMFileSystemBase::createFileSystemRootURL(const String& origin,
|
| return KURL(ParsedURLString, result);
|
| }
|
|
|
| -bool DOMFileSystemBase::supportsToURL() const {
|
| - ASSERT(isValidType(m_type));
|
| +bool FileSystemBase::supportsToURL() const {
|
| + DCHECK(isValidType(m_type));
|
| return m_type != FileSystemTypeIsolated;
|
| }
|
|
|
| -KURL DOMFileSystemBase::createFileSystemURL(const EntryBase* entry) const {
|
| +KURL FileSystemBase::createFileSystemURL(
|
| + const FileSystemEntryBase* entry) const {
|
| return createFileSystemURL(entry->fullPath());
|
| }
|
|
|
| -KURL DOMFileSystemBase::createFileSystemURL(const String& fullPath) const {
|
| - ASSERT(DOMFilePath::isAbsolute(fullPath));
|
| +KURL FileSystemBase::createFileSystemURL(const String& fullPath) const {
|
| + DCHECK(DOMFilePath::isAbsolute(fullPath));
|
|
|
| if (type() == FileSystemTypeExternal) {
|
| // For external filesystem originString could be different from what we have
|
| @@ -135,18 +136,18 @@ KURL DOMFileSystemBase::createFileSystemURL(const String& fullPath) const {
|
| // For regular types we can just append the entry's fullPath to the
|
| // m_filesystemRootURL that should look like
|
| // 'filesystem:<origin>/<typePrefix>'.
|
| - ASSERT(!m_filesystemRootURL.isEmpty());
|
| + DCHECK(!m_filesystemRootURL.isEmpty());
|
| KURL url = m_filesystemRootURL;
|
| // Remove the extra leading slash.
|
| url.setPath(url.path() + encodeWithURLEscapeSequences(fullPath.substring(1)));
|
| return url;
|
| }
|
|
|
| -bool DOMFileSystemBase::pathToAbsolutePath(FileSystemType type,
|
| - const EntryBase* base,
|
| - String path,
|
| - String& absolutePath) {
|
| - ASSERT(base);
|
| +bool FileSystemBase::pathToAbsolutePath(FileSystemType type,
|
| + const FileSystemEntryBase* base,
|
| + String path,
|
| + String& absolutePath) {
|
| + DCHECK(base);
|
|
|
| if (!DOMFilePath::isAbsolute(path))
|
| path = DOMFilePath::append(base->fullPath(), path);
|
| @@ -157,8 +158,8 @@ bool DOMFileSystemBase::pathToAbsolutePath(FileSystemType type,
|
| DOMFilePath::isValidPath(absolutePath);
|
| }
|
|
|
| -bool DOMFileSystemBase::pathPrefixToFileSystemType(const String& pathPrefix,
|
| - FileSystemType& type) {
|
| +bool FileSystemBase::pathPrefixToFileSystemType(const String& pathPrefix,
|
| + FileSystemType& type) {
|
| if (pathPrefix == temporaryPathPrefix) {
|
| type = FileSystemTypeTemporary;
|
| return true;
|
| @@ -177,10 +178,10 @@ bool DOMFileSystemBase::pathPrefixToFileSystemType(const String& pathPrefix,
|
| return false;
|
| }
|
|
|
| -File* DOMFileSystemBase::createFile(const FileMetadata& metadata,
|
| - const KURL& fileSystemURL,
|
| - FileSystemType type,
|
| - const String name) {
|
| +File* FileSystemBase::createFile(const FileMetadata& metadata,
|
| + const KURL& fileSystemURL,
|
| + FileSystemType type,
|
| + const String name) {
|
| // For regular filesystem types (temporary or persistent), we should not cache
|
| // file metadata as it could change File semantics. For other filesystem
|
| // types (which could be platform-specific ones), there's a chance that the
|
| @@ -199,17 +200,16 @@ File* DOMFileSystemBase::createFile(const FileMetadata& metadata,
|
| // If the platformPath in the returned metadata is given, we create a File
|
| // object for the snapshot path.
|
| return File::createForFileSystemFile(name, metadata, userVisibility);
|
| - } else {
|
| - // Otherwise we create a File object for the fileSystemURL.
|
| - return File::createForFileSystemFile(fileSystemURL, metadata,
|
| - userVisibility);
|
| }
|
| +
|
| + // Otherwise we create a File object for the fileSystemURL.
|
| + return File::createForFileSystemFile(fileSystemURL, metadata, userVisibility);
|
| }
|
|
|
| -void DOMFileSystemBase::getMetadata(const EntryBase* entry,
|
| - MetadataCallback* successCallback,
|
| - ErrorCallbackBase* errorCallback,
|
| - SynchronousType synchronousType) {
|
| +void FileSystemBase::getMetadata(const FileSystemEntryBase* entry,
|
| + FileSystemMetadataCallback* successCallback,
|
| + ErrorCallbackBase* errorCallback,
|
| + SynchronousType synchronousType) {
|
| if (!fileSystem()) {
|
| reportError(errorCallback, FileError::kAbortErr);
|
| return;
|
| @@ -221,11 +221,12 @@ void DOMFileSystemBase::getMetadata(const EntryBase* entry,
|
| fileSystem()->readMetadata(createFileSystemURL(entry), std::move(callbacks));
|
| }
|
|
|
| -static bool verifyAndGetDestinationPathForCopyOrMove(const EntryBase* source,
|
| - EntryBase* parent,
|
| - const String& newName,
|
| - String& destinationPath) {
|
| - ASSERT(source);
|
| +static bool verifyAndGetDestinationPathForCopyOrMove(
|
| + const FileSystemEntryBase* source,
|
| + FileSystemEntryBase* parent,
|
| + const String& newName,
|
| + String& destinationPath) {
|
| + DCHECK(source);
|
|
|
| if (!parent || !parent->isDirectory())
|
| return false;
|
| @@ -257,12 +258,12 @@ static bool verifyAndGetDestinationPathForCopyOrMove(const EntryBase* source,
|
| return true;
|
| }
|
|
|
| -void DOMFileSystemBase::move(const EntryBase* source,
|
| - EntryBase* parent,
|
| - const String& newName,
|
| - EntryCallback* successCallback,
|
| - ErrorCallbackBase* errorCallback,
|
| - SynchronousType synchronousType) {
|
| +void FileSystemBase::move(const FileSystemEntryBase* source,
|
| + FileSystemEntryBase* parent,
|
| + const String& newName,
|
| + FileSystemEntryCallback* successCallback,
|
| + ErrorCallbackBase* errorCallback,
|
| + SynchronousType synchronousType) {
|
| if (!fileSystem()) {
|
| reportError(errorCallback, FileError::kAbortErr);
|
| return;
|
| @@ -285,12 +286,12 @@ void DOMFileSystemBase::move(const EntryBase* source,
|
| std::move(callbacks));
|
| }
|
|
|
| -void DOMFileSystemBase::copy(const EntryBase* source,
|
| - EntryBase* parent,
|
| - const String& newName,
|
| - EntryCallback* successCallback,
|
| - ErrorCallbackBase* errorCallback,
|
| - SynchronousType synchronousType) {
|
| +void FileSystemBase::copy(const FileSystemEntryBase* source,
|
| + FileSystemEntryBase* parent,
|
| + const String& newName,
|
| + FileSystemEntryCallback* successCallback,
|
| + ErrorCallbackBase* errorCallback,
|
| + SynchronousType synchronousType) {
|
| if (!fileSystem()) {
|
| reportError(errorCallback, FileError::kAbortErr);
|
| return;
|
| @@ -313,16 +314,16 @@ void DOMFileSystemBase::copy(const EntryBase* source,
|
| std::move(callbacks));
|
| }
|
|
|
| -void DOMFileSystemBase::remove(const EntryBase* entry,
|
| - VoidCallback* successCallback,
|
| - ErrorCallbackBase* errorCallback,
|
| - SynchronousType synchronousType) {
|
| +void FileSystemBase::remove(const FileSystemEntryBase* entry,
|
| + VoidCallback* successCallback,
|
| + ErrorCallbackBase* errorCallback,
|
| + SynchronousType synchronousType) {
|
| if (!fileSystem()) {
|
| reportError(errorCallback, FileError::kAbortErr);
|
| return;
|
| }
|
|
|
| - ASSERT(entry);
|
| + DCHECK(entry);
|
| // We don't allow calling remove() on the root directory.
|
| if (entry->fullPath() == String(DOMFilePath::root)) {
|
| reportError(errorCallback, FileError::kInvalidModificationErr);
|
| @@ -336,16 +337,16 @@ void DOMFileSystemBase::remove(const EntryBase* entry,
|
| fileSystem()->remove(createFileSystemURL(entry), std::move(callbacks));
|
| }
|
|
|
| -void DOMFileSystemBase::removeRecursively(const EntryBase* entry,
|
| - VoidCallback* successCallback,
|
| - ErrorCallbackBase* errorCallback,
|
| - SynchronousType synchronousType) {
|
| +void FileSystemBase::removeRecursively(const FileSystemEntryBase* entry,
|
| + VoidCallback* successCallback,
|
| + ErrorCallbackBase* errorCallback,
|
| + SynchronousType synchronousType) {
|
| if (!fileSystem()) {
|
| reportError(errorCallback, FileError::kAbortErr);
|
| return;
|
| }
|
|
|
| - ASSERT(entry && entry->isDirectory());
|
| + DCHECK(entry && entry->isDirectory());
|
| // We don't allow calling remove() on the root directory.
|
| if (entry->fullPath() == String(DOMFilePath::root)) {
|
| reportError(errorCallback, FileError::kInvalidModificationErr);
|
| @@ -360,15 +361,15 @@ void DOMFileSystemBase::removeRecursively(const EntryBase* entry,
|
| std::move(callbacks));
|
| }
|
|
|
| -void DOMFileSystemBase::getParent(const EntryBase* entry,
|
| - EntryCallback* successCallback,
|
| - ErrorCallbackBase* errorCallback) {
|
| +void FileSystemBase::getParent(const FileSystemEntryBase* entry,
|
| + FileSystemEntryCallback* successCallback,
|
| + ErrorCallbackBase* errorCallback) {
|
| if (!fileSystem()) {
|
| reportError(errorCallback, FileError::kAbortErr);
|
| return;
|
| }
|
|
|
| - ASSERT(entry);
|
| + DCHECK(entry);
|
| String path = DOMFilePath::getDirectory(entry->fullPath());
|
|
|
| fileSystem()->directoryExists(
|
| @@ -377,12 +378,12 @@ void DOMFileSystemBase::getParent(const EntryBase* entry,
|
| path, true));
|
| }
|
|
|
| -void DOMFileSystemBase::getFile(const EntryBase* entry,
|
| - const String& path,
|
| - const FileSystemFlags& flags,
|
| - EntryCallback* successCallback,
|
| - ErrorCallbackBase* errorCallback,
|
| - SynchronousType synchronousType) {
|
| +void FileSystemBase::getFile(const FileSystemEntryBase* entry,
|
| + const String& path,
|
| + const FileSystemFlags& flags,
|
| + FileSystemEntryCallback* successCallback,
|
| + ErrorCallbackBase* errorCallback,
|
| + SynchronousType synchronousType) {
|
| if (!fileSystem()) {
|
| reportError(errorCallback, FileError::kAbortErr);
|
| return;
|
| @@ -398,20 +399,21 @@ void DOMFileSystemBase::getFile(const EntryBase* entry,
|
| successCallback, errorCallback, m_context, this, absolutePath, false));
|
| callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);
|
|
|
| - if (flags.createFlag())
|
| + if (flags.createFlag()) {
|
| fileSystem()->createFile(createFileSystemURL(absolutePath),
|
| flags.exclusive(), std::move(callbacks));
|
| - else
|
| + } else {
|
| fileSystem()->fileExists(createFileSystemURL(absolutePath),
|
| std::move(callbacks));
|
| + }
|
| }
|
|
|
| -void DOMFileSystemBase::getDirectory(const EntryBase* entry,
|
| - const String& path,
|
| - const FileSystemFlags& flags,
|
| - EntryCallback* successCallback,
|
| - ErrorCallbackBase* errorCallback,
|
| - SynchronousType synchronousType) {
|
| +void FileSystemBase::getDirectory(const FileSystemEntryBase* entry,
|
| + const String& path,
|
| + const FileSystemFlags& flags,
|
| + FileSystemEntryCallback* successCallback,
|
| + ErrorCallbackBase* errorCallback,
|
| + SynchronousType synchronousType) {
|
| if (!fileSystem()) {
|
| reportError(errorCallback, FileError::kAbortErr);
|
| return;
|
| @@ -427,25 +429,26 @@ void DOMFileSystemBase::getDirectory(const EntryBase* entry,
|
| successCallback, errorCallback, m_context, this, absolutePath, true));
|
| callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);
|
|
|
| - if (flags.createFlag())
|
| + if (flags.createFlag()) {
|
| fileSystem()->createDirectory(createFileSystemURL(absolutePath),
|
| flags.exclusive(), std::move(callbacks));
|
| - else
|
| + } else {
|
| fileSystem()->directoryExists(createFileSystemURL(absolutePath),
|
| std::move(callbacks));
|
| + }
|
| }
|
|
|
| -int DOMFileSystemBase::readDirectory(DirectoryReaderBase* reader,
|
| - const String& path,
|
| - EntriesCallback* successCallback,
|
| - ErrorCallbackBase* errorCallback,
|
| - SynchronousType synchronousType) {
|
| +int FileSystemBase::readDirectory(FileSystemDirectoryReaderBase* reader,
|
| + const String& path,
|
| + FileSystemEntriesCallback* successCallback,
|
| + ErrorCallbackBase* errorCallback,
|
| + SynchronousType synchronousType) {
|
| if (!fileSystem()) {
|
| reportError(errorCallback, FileError::kAbortErr);
|
| return 0;
|
| }
|
|
|
| - ASSERT(DOMFilePath::isAbsolute(path));
|
| + DCHECK(DOMFilePath::isAbsolute(path));
|
|
|
| std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntriesCallbacks::create(
|
| successCallback, errorCallback, m_context, reader, path));
|
| @@ -455,7 +458,7 @@ int DOMFileSystemBase::readDirectory(DirectoryReaderBase* reader,
|
| std::move(callbacks));
|
| }
|
|
|
| -bool DOMFileSystemBase::waitForAdditionalResult(int callbacksId) {
|
| +bool FileSystemBase::waitForAdditionalResult(int callbacksId) {
|
| if (!fileSystem())
|
| return false;
|
| return fileSystem()->waitForAdditionalResult(callbacksId);
|
|
|