Simplifies RemoveOperationDelegate implementation.
RecursiveOperationDelegate supports PostProcessDirectory(), so
RemoveOperationDelegate implementation can be simplified with the moethd.
BUG=282107
TEST=Ran content_unittests and unit_tests
Review URL: https://chromiumcodereview.appspot.com/23844007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224168 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/webkit/browser/fileapi/remove_operation_delegate.cc b/webkit/browser/fileapi/remove_operation_delegate.cc
index 5988733..b053960 100644
--- a/webkit/browser/fileapi/remove_operation_delegate.cc
+++ b/webkit/browser/fileapi/remove_operation_delegate.cc
@@ -28,39 +28,30 @@
}
void RemoveOperationDelegate::RunRecursively() {
- StartRecursiveOperation(
- url_,
- base::Bind(&RemoveOperationDelegate::RemoveNextDirectory,
- weak_factory_.GetWeakPtr()));
+ StartRecursiveOperation(url_, callback_);
}
void RemoveOperationDelegate::ProcessFile(const FileSystemURL& url,
const StatusCallback& callback) {
- if (to_remove_directories_.size() == 1u &&
- to_remove_directories_.top() == url) {
- // We seem to have been re-directed from ProcessDirectory.
- to_remove_directories_.pop();
- }
- operation_runner()->RemoveFile(url, base::Bind(
- &RemoveOperationDelegate::DidRemoveFile,
- weak_factory_.GetWeakPtr(), callback));
+ operation_runner()->RemoveFile(
+ url,
+ base::Bind(&RemoveOperationDelegate::DidRemoveFile,
+ weak_factory_.GetWeakPtr(), callback));
}
void RemoveOperationDelegate::ProcessDirectory(const FileSystemURL& url,
const StatusCallback& callback) {
- to_remove_directories_.push(url);
callback.Run(base::PLATFORM_FILE_OK);
}
void RemoveOperationDelegate::PostProcessDirectory(
const FileSystemURL& url, const StatusCallback& callback) {
- callback.Run(base::PLATFORM_FILE_OK);
+ operation_runner()->RemoveDirectory(url, callback);
}
void RemoveOperationDelegate::DidTryRemoveFile(
base::PlatformFileError error) {
- if (error == base::PLATFORM_FILE_OK ||
- error != base::PLATFORM_FILE_ERROR_NOT_A_FILE) {
+ if (error != base::PLATFORM_FILE_ERROR_NOT_A_FILE) {
callback_.Run(error);
return;
}
@@ -76,18 +67,4 @@
callback.Run(error);
}
-void RemoveOperationDelegate::RemoveNextDirectory(
- base::PlatformFileError error) {
- if (error != base::PLATFORM_FILE_OK ||
- to_remove_directories_.empty()) {
- callback_.Run(error);
- return;
- }
- FileSystemURL url = to_remove_directories_.top();
- to_remove_directories_.pop();
- operation_runner()->RemoveDirectory(url, base::Bind(
- &RemoveOperationDelegate::RemoveNextDirectory,
- weak_factory_.GetWeakPtr()));
-}
-
} // namespace fileapi
diff --git a/webkit/browser/fileapi/remove_operation_delegate.h b/webkit/browser/fileapi/remove_operation_delegate.h
index 0271e53c..bee24466 100644
--- a/webkit/browser/fileapi/remove_operation_delegate.h
+++ b/webkit/browser/fileapi/remove_operation_delegate.h
@@ -11,8 +11,7 @@
namespace fileapi {
-class RemoveOperationDelegate
- : public RecursiveOperationDelegate {
+class RemoveOperationDelegate : public RecursiveOperationDelegate {
public:
RemoveOperationDelegate(FileSystemContext* file_system_context,
const FileSystemURL& url,
@@ -33,15 +32,10 @@
void DidTryRemoveFile(base::PlatformFileError error);
void DidRemoveFile(const StatusCallback& callback,
base::PlatformFileError error);
- void RemoveNextDirectory(base::PlatformFileError error);
FileSystemURL url_;
StatusCallback callback_;
-
- std::stack<FileSystemURL> to_remove_directories_;
-
base::WeakPtrFactory<RemoveOperationDelegate> weak_factory_;
-
DISALLOW_COPY_AND_ASSIGN(RemoveOperationDelegate);
};