Chromium Code Reviews| Index: chrome/browser/chromeos/drive/file_system/remove_operation.cc |
| diff --git a/chrome/browser/chromeos/drive/file_system/remove_operation.cc b/chrome/browser/chromeos/drive/file_system/remove_operation.cc |
| index d11efb823b379400a54749602142d35c6af21b26..7e72bc4a149833926939a333b1c28f4fadb4cf25 100644 |
| --- a/chrome/browser/chromeos/drive/file_system/remove_operation.cc |
| +++ b/chrome/browser/chromeos/drive/file_system/remove_operation.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/sequenced_task_runner.h" |
| #include "chrome/browser/chromeos/drive/drive.pb.h" |
| #include "chrome/browser/chromeos/drive/file_cache.h" |
| +#include "chrome/browser/chromeos/drive/file_change.h" |
| #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" |
| #include "chrome/browser/chromeos/drive/file_system_util.h" |
| #include "chrome/browser/chromeos/drive/resource_metadata.h" |
| @@ -25,7 +26,7 @@ FileError UpdateLocalState(internal::ResourceMetadata* metadata, |
| const base::FilePath& path, |
| bool is_recursive, |
| std::string* local_id, |
| - base::FilePath* changed_directory_path) { |
| + base::FilePath* changed_path) { |
| FileError error = metadata->GetIdByPath(path, local_id); |
| if (error != FILE_ERROR_OK) |
| return error; |
| @@ -49,7 +50,7 @@ FileError UpdateLocalState(internal::ResourceMetadata* metadata, |
| if (error != FILE_ERROR_OK) |
| return error; |
| - *changed_directory_path = path.DirName(); |
| + *changed_path = path; |
| // Move to the trash. |
| entry.set_parent_local_id(util::kDriveTrashDirLocalId); |
| @@ -82,7 +83,7 @@ void RemoveOperation::Remove(const base::FilePath& path, |
| DCHECK(!callback.is_null()); |
| std::string* local_id = new std::string; |
| - base::FilePath* changed_directory_path = new base::FilePath; |
| + base::FilePath* changed_path = new base::FilePath; |
| base::PostTaskAndReplyWithResult( |
| blocking_task_runner_.get(), |
| FROM_HERE, |
| @@ -92,25 +93,33 @@ void RemoveOperation::Remove(const base::FilePath& path, |
| path, |
| is_recursive, |
| local_id, |
| - changed_directory_path), |
| + changed_path), |
| base::Bind(&RemoveOperation::RemoveAfterUpdateLocalState, |
| weak_ptr_factory_.GetWeakPtr(), |
| callback, |
| base::Owned(local_id), |
| - base::Owned(changed_directory_path))); |
| + base::Owned(changed_path))); |
| } |
| void RemoveOperation::RemoveAfterUpdateLocalState( |
| const FileOperationCallback& callback, |
| const std::string* local_id, |
| - const base::FilePath* changed_directory_path, |
| + const base::FilePath* changed_path, |
| FileError error) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| DCHECK(!callback.is_null()); |
| - if (error == FILE_ERROR_OK) { |
| - observer_->OnDirectoryChangedByOperation(*changed_directory_path); |
| - observer_->OnEntryUpdatedByOperation(*local_id); |
| + ResourceEntry entry; |
| + FileError error2 = metadata_->GetResourceEntryById(*local_id, &entry); |
|
kinaba
2014/06/23 05:37:43
this is violating thread restriction (metadata mus
yoshiki
2014/06/24 02:02:22
Done.
|
| + DCHECK(error2 == FILE_ERROR_OK); |
| + |
| + if (!changed_path->empty()) { |
| + FileChange changed_file; |
| + changed_file.Update(*changed_path, entry, FileChange::DELETE); |
| + if (error == FILE_ERROR_OK) { |
| + observer_->OnDirectoryChangedByOperation(changed_file); |
| + observer_->OnEntryUpdatedByOperation(*local_id); |
| + } |
| } |
| callback.Run(error); |