Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Unified Diff: Source/core/inspector/InspectorFileSystemAgent.cpp

Issue 23537011: FileAPI: Add WebFileSystem::resolveURL (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/inspector/InspectorFileSystemAgent.cpp
diff --git a/Source/core/inspector/InspectorFileSystemAgent.cpp b/Source/core/inspector/InspectorFileSystemAgent.cpp
index b16d96614cae465724c64855fa7cf0cbf520d623..8efed934542c11e7b54d1fce9dce0aab9bf5d332 100644
--- a/Source/core/inspector/InspectorFileSystemAgent.cpp
+++ b/Source/core/inspector/InspectorFileSystemAgent.cpp
@@ -150,20 +150,22 @@ void FileSystemRootRequest::start(ScriptExecutionContext* scriptExecutionContext
ASSERT(scriptExecutionContext);
RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &FileSystemRootRequest::didHitError);
+
FileSystemType type;
- if (m_type == DOMFileSystemBase::persistentPathPrefix)
- type = FileSystemTypePersistent;
- else if (m_type == DOMFileSystemBase::temporaryPathPrefix)
- type = FileSystemTypeTemporary;
- else {
+ if (!DOMFileSystemBase::pathPrefixToFileSystemType(m_type, type)) {
errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get());
return;
}
- RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &FileSystemRootRequest::didGetEntry);
- OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, "/");
+ KURL rootURL = DOMFileSystemBase::createFileSystemRootURL(scriptExecutionContext->securityOrigin()->toString(), type);
+ if (!rootURL.isValid()) {
+ errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get());
+ return;
+ }
- LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
+ RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &FileSystemRootRequest::didGetEntry);
+ OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext);
+ LocalFileSystem::from(scriptExecutionContext)->resolveURL(scriptExecutionContext, rootURL, fileSystemCallbacks.release());
}
bool FileSystemRootRequest::didGetEntry(Entry* entry)
@@ -223,17 +225,11 @@ void DirectoryContentRequest::start(ScriptExecutionContext* scriptExecutionConte
ASSERT(scriptExecutionContext);
RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &DirectoryContentRequest::didHitError);
- FileSystemType type;
- String path;
- if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, path)) {
- errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get());
- return;
- }
-
RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &DirectoryContentRequest::didGetEntry);
- OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, path);
- LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
+ OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext);
+
+ LocalFileSystem::from(scriptExecutionContext)->resolveURL(scriptExecutionContext, m_url, fileSystemCallbacks.release());
}
bool DirectoryContentRequest::didGetEntry(Entry* entry)
@@ -339,7 +335,6 @@ private:
RefPtr<RequestMetadataCallback> m_requestCallback;
KURL m_url;
- String m_path;
bool m_isDirectory;
};
@@ -348,16 +343,9 @@ void MetadataRequest::start(ScriptExecutionContext* scriptExecutionContext)
ASSERT(scriptExecutionContext);
RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &MetadataRequest::didHitError);
-
- FileSystemType type;
- if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, m_path)) {
- errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get());
- return;
- }
-
RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &MetadataRequest::didGetEntry);
- OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, m_path);
- LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
+ OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext);
+ LocalFileSystem::from(scriptExecutionContext)->resolveURL(scriptExecutionContext, m_url, fileSystemCallbacks.release());
}
bool MetadataRequest::didGetEntry(Entry* entry)
@@ -453,18 +441,10 @@ void FileContentRequest::start(ScriptExecutionContext* scriptExecutionContext)
ASSERT(scriptExecutionContext);
RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &FileContentRequest::didHitError);
-
- FileSystemType type;
- String path;
- if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, path)) {
- errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get());
- return;
- }
-
RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &FileContentRequest::didGetEntry);
- OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, path);
- LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
+ OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext);
+ LocalFileSystem::from(scriptExecutionContext)->resolveURL(scriptExecutionContext, m_url, fileSystemCallbacks.release());
}
bool FileContentRequest::didGetEntry(Entry* entry)
@@ -576,8 +556,8 @@ void DeleteEntryRequest::start(ScriptExecutionContext* scriptExecutionContext)
LocalFileSystem::from(scriptExecutionContext)->deleteFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
} else {
RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &DeleteEntryRequest::didGetEntry);
- OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, path);
- LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
+ OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext);
+ LocalFileSystem::from(scriptExecutionContext)->resolveURL(scriptExecutionContext, m_url, fileSystemCallbacks.release());
}
}

Powered by Google App Engine
This is Rietveld 408576698