diff options
author | hidehiko@chromium.org <hidehiko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-19 18:14:01 +0000 |
---|---|---|
committer | hidehiko@chromium.org <hidehiko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-19 18:14:01 +0000 |
commit | dc231f603273f4f5e77e3d7921ebaf55921fd25f (patch) | |
tree | 4de1c7f0dee1aa0868a866f583ccb451e5d3d6fc /webkit | |
parent | 23eecbd0a328c257455ed188523cde6113493fde (diff) | |
download | chromium_src-dc231f603273f4f5e77e3d7921ebaf55921fd25f.zip chromium_src-dc231f603273f4f5e77e3d7921ebaf55921fd25f.tar.gz chromium_src-dc231f603273f4f5e77e3d7921ebaf55921fd25f.tar.bz2 |
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
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/browser/fileapi/remove_operation_delegate.cc | 37 | ||||
-rw-r--r-- | webkit/browser/fileapi/remove_operation_delegate.h | 8 |
2 files changed, 8 insertions, 37 deletions
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::Run() { } 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 @@ void RemoveOperationDelegate::DidRemoveFile(const StatusCallback& callback, 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 0271e53..bee2446 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 @@ class RemoveOperationDelegate 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); }; |