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

Unified Diff: chrome/browser/chromeos/file_system_provider/fileapi/provider_async_file_util.cc

Issue 375543002: [fsp] Add support for deleting entries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased + cleaned up. Created 6 years, 5 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: chrome/browser/chromeos/file_system_provider/fileapi/provider_async_file_util.cc
diff --git a/chrome/browser/chromeos/file_system_provider/fileapi/provider_async_file_util.cc b/chrome/browser/chromeos/file_system_provider/fileapi/provider_async_file_util.cc
index a3f0ce62af96ede7dc541876898814c9c71baf67..c88414ce729fcc90d3ddcb4ce6531915b10bd9c6 100644
--- a/chrome/browser/chromeos/file_system_provider/fileapi/provider_async_file_util.cc
+++ b/chrome/browser/chromeos/file_system_provider/fileapi/provider_async_file_util.cc
@@ -107,6 +107,28 @@ void OnCreateDirectory(const fileapi::AsyncFileUtil::StatusCallback& callback,
BrowserThread::IO, FROM_HERE, base::Bind(callback, result));
}
+// Executes DeleteEntry on the UI thread.
+void DeleteEntryOnUIThread(
+ scoped_ptr<fileapi::FileSystemOperationContext> context,
+ const fileapi::FileSystemURL& url,
+ bool recursive,
+ const fileapi::AsyncFileUtil::StatusCallback& callback) {
+ util::FileSystemURLParser parser(url);
+ if (!parser.Parse()) {
+ callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
+ return;
+ }
+
+ parser.file_system()->DeleteEntry(parser.file_path(), recursive, callback);
+}
+
+// Routes the response of DeleteEntry back to the IO thread.
+void OnDeleteEntry(const fileapi::AsyncFileUtil::StatusCallback& callback,
+ base::File::Error result) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE, base::Bind(callback, result));
+}
+
} // namespace
ProviderAsyncFileUtil::ProviderAsyncFileUtil() {}
@@ -238,7 +260,13 @@ void ProviderAsyncFileUtil::DeleteFile(
const fileapi::FileSystemURL& url,
const StatusCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- callback.Run(base::File::FILE_ERROR_ACCESS_DENIED);
+ BrowserThread::PostTask(BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&DeleteEntryOnUIThread,
+ base::Passed(&context),
+ url,
+ false, // recursive
+ base::Bind(&OnDeleteEntry, callback)));
}
void ProviderAsyncFileUtil::DeleteDirectory(
@@ -246,7 +274,13 @@ void ProviderAsyncFileUtil::DeleteDirectory(
const fileapi::FileSystemURL& url,
const StatusCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- callback.Run(base::File::FILE_ERROR_ACCESS_DENIED);
+ BrowserThread::PostTask(BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&DeleteEntryOnUIThread,
+ base::Passed(&context),
+ url,
+ false, // recursive
+ base::Bind(&OnDeleteEntry, callback)));
}
void ProviderAsyncFileUtil::DeleteRecursively(
@@ -254,7 +288,13 @@ void ProviderAsyncFileUtil::DeleteRecursively(
const fileapi::FileSystemURL& url,
const StatusCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- callback.Run(base::File::FILE_ERROR_ACCESS_DENIED);
+ BrowserThread::PostTask(BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&DeleteEntryOnUIThread,
+ base::Passed(&context),
+ url,
+ true, // recursive
+ base::Bind(&OnDeleteEntry, callback)));
}
void ProviderAsyncFileUtil::CreateSnapshotFile(

Powered by Google App Engine
This is Rietveld 408576698