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

Unified Diff: base/file_util_proxy.cc

Issue 8508001: Retry: Bind: Merge FileUtilProxy and FileSystemFileUtilProxy: Delete/Touch/Truncate/Copy/Move (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « base/file_util_proxy.h ('k') | webkit/fileapi/file_system_file_util_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_proxy.cc
diff --git a/base/file_util_proxy.cc b/base/file_util_proxy.cc
index 4c79465c4ed850a0d7919726c4ef056ab4463eb8..9b51d34b9a88acef7b663ff59dd8f0c1070125b0 100644
--- a/base/file_util_proxy.cc
+++ b/base/file_util_proxy.cc
@@ -176,19 +176,6 @@ class CreateTemporaryHelper {
DISALLOW_COPY_AND_ASSIGN(CreateTemporaryHelper);
};
-PlatformFileError DeleteHelper(const FilePath& file_path, bool recursive) {
- if (!file_util::PathExists(file_path)) {
- return PLATFORM_FILE_ERROR_NOT_FOUND;
- }
- if (!file_util::Delete(file_path, recursive)) {
- if (!recursive && !file_util::IsDirectoryEmpty(file_path)) {
- return PLATFORM_FILE_ERROR_NOT_EMPTY;
- }
- return PLATFORM_FILE_ERROR_FAILED;
- }
- return PLATFORM_FILE_OK;
-}
-
class GetFileInfoHelper {
public:
GetFileInfoHelper()
@@ -297,6 +284,19 @@ PlatformFileError CloseAdapter(PlatformFile file_handle) {
return PLATFORM_FILE_OK;
}
+PlatformFileError DeleteAdapter(const FilePath& file_path, bool recursive) {
+ if (!file_util::PathExists(file_path)) {
+ return PLATFORM_FILE_ERROR_NOT_FOUND;
+ }
+ if (!file_util::Delete(file_path, recursive)) {
+ if (!recursive && !file_util::IsDirectoryEmpty(file_path)) {
+ return PLATFORM_FILE_ERROR_NOT_EMPTY;
+ }
+ return PLATFORM_FILE_ERROR_FAILED;
+ }
+ return PLATFORM_FILE_OK;
+}
+
} // namespace
// static
@@ -367,10 +367,10 @@ bool FileUtilProxy::Delete(scoped_refptr<MessageLoopProxy> message_loop_proxy,
const FilePath& file_path,
bool recursive,
const StatusCallback& callback) {
- return PostTaskAndReplyWithStatus<PlatformFileError>(
+ return RelayFileTask(
message_loop_proxy, FROM_HERE,
- Bind(&DeleteHelper, file_path, recursive), callback,
- new PlatformFileError);
+ Bind(&DeleteAdapter, file_path, recursive),
+ callback);
}
// static
@@ -378,10 +378,10 @@ bool FileUtilProxy::RecursiveDelete(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
const FilePath& file_path,
const StatusCallback& callback) {
- return PostTaskAndReplyWithStatus<PlatformFileError>(
+ return RelayFileTask(
message_loop_proxy, FROM_HERE,
- Bind(&DeleteHelper, file_path, true /* recursive */), callback,
- new PlatformFileError);
+ Bind(&DeleteAdapter, file_path, true /* recursive */),
+ callback);
}
// static
@@ -472,6 +472,19 @@ bool FileUtilProxy::Flush(
}
// static
+bool FileUtilProxy::RelayFileTask(
+ scoped_refptr<MessageLoopProxy> message_loop_proxy,
+ const tracked_objects::Location& from_here,
+ const FileTask& file_task,
+ const StatusCallback& callback) {
+ PlatformFileError* result = new PlatformFileError;
+ return message_loop_proxy->PostTaskAndReply(
+ from_here,
+ ReturnAsParam(file_task, result),
+ ReplyHelper(callback, Owned(result)));
+}
+
+// static
bool FileUtilProxy::RelayCreateOrOpen(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
const CreateOrOpenTask& open_task,
« no previous file with comments | « base/file_util_proxy.h ('k') | webkit/fileapi/file_system_file_util_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698