| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" | 5 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" |
| 6 | 6 |
| 7 #include "base/sequenced_task_runner.h" | 7 #include "base/sequenced_task_runner.h" |
| 8 #include "chrome/browser/chromeos/drive/drive.pb.h" | 8 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 9 #include "chrome/browser/chromeos/drive/file_cache.h" | 9 #include "chrome/browser/chromeos/drive/file_cache.h" |
| 10 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" | 10 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 79 } |
| 80 | 80 |
| 81 void RemoveOperation::Remove(const base::FilePath& path, | 81 void RemoveOperation::Remove(const base::FilePath& path, |
| 82 bool is_recursive, | 82 bool is_recursive, |
| 83 const FileOperationCallback& callback) { | 83 const FileOperationCallback& callback) { |
| 84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 85 DCHECK(!callback.is_null()); | 85 DCHECK(!callback.is_null()); |
| 86 | 86 |
| 87 ResourceEntry* entry = new ResourceEntry; | 87 ResourceEntry* entry = new ResourceEntry; |
| 88 base::PostTaskAndReplyWithResult( | 88 base::PostTaskAndReplyWithResult( |
| 89 blocking_task_runner_, | 89 blocking_task_runner_.get(), |
| 90 FROM_HERE, | 90 FROM_HERE, |
| 91 base::Bind(&CheckLocalState, | 91 base::Bind(&CheckLocalState, metadata_, path, is_recursive, entry), |
| 92 metadata_, | |
| 93 path, | |
| 94 is_recursive, | |
| 95 entry), | |
| 96 base::Bind(&RemoveOperation::RemoveAfterCheckLocalState, | 92 base::Bind(&RemoveOperation::RemoveAfterCheckLocalState, |
| 97 weak_ptr_factory_.GetWeakPtr(), | 93 weak_ptr_factory_.GetWeakPtr(), |
| 98 callback, | 94 callback, |
| 99 base::Owned(entry))); | 95 base::Owned(entry))); |
| 100 } | 96 } |
| 101 | 97 |
| 102 void RemoveOperation::RemoveAfterCheckLocalState( | 98 void RemoveOperation::RemoveAfterCheckLocalState( |
| 103 const FileOperationCallback& callback, | 99 const FileOperationCallback& callback, |
| 104 const ResourceEntry* entry, | 100 const ResourceEntry* entry, |
| 105 FileError error) { | 101 FileError error) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 127 DCHECK(!callback.is_null()); | 123 DCHECK(!callback.is_null()); |
| 128 | 124 |
| 129 FileError error = util::GDataToFileError(status); | 125 FileError error = util::GDataToFileError(status); |
| 130 if (error != FILE_ERROR_OK) { | 126 if (error != FILE_ERROR_OK) { |
| 131 callback.Run(error); | 127 callback.Run(error); |
| 132 return; | 128 return; |
| 133 } | 129 } |
| 134 | 130 |
| 135 base::FilePath* changed_directory_path = new base::FilePath; | 131 base::FilePath* changed_directory_path = new base::FilePath; |
| 136 base::PostTaskAndReplyWithResult( | 132 base::PostTaskAndReplyWithResult( |
| 137 blocking_task_runner_, | 133 blocking_task_runner_.get(), |
| 138 FROM_HERE, | 134 FROM_HERE, |
| 139 base::Bind(&UpdateLocalState, | 135 base::Bind(&UpdateLocalState, |
| 140 metadata_, | 136 metadata_, |
| 141 cache_, | 137 cache_, |
| 142 resource_id, | 138 resource_id, |
| 143 changed_directory_path), | 139 changed_directory_path), |
| 144 base::Bind(&RemoveOperation::RemoveAfterUpdateLocalState, | 140 base::Bind(&RemoveOperation::RemoveAfterUpdateLocalState, |
| 145 weak_ptr_factory_.GetWeakPtr(), | 141 weak_ptr_factory_.GetWeakPtr(), |
| 146 callback, | 142 callback, |
| 147 base::Owned(changed_directory_path))); | 143 base::Owned(changed_directory_path))); |
| 148 } | 144 } |
| 149 | 145 |
| 150 void RemoveOperation::RemoveAfterUpdateLocalState( | 146 void RemoveOperation::RemoveAfterUpdateLocalState( |
| 151 const FileOperationCallback& callback, | 147 const FileOperationCallback& callback, |
| 152 const base::FilePath* changed_directory_path, | 148 const base::FilePath* changed_directory_path, |
| 153 FileError error) { | 149 FileError error) { |
| 154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 155 DCHECK(!callback.is_null()); | 151 DCHECK(!callback.is_null()); |
| 156 | 152 |
| 157 if (error == FILE_ERROR_OK) | 153 if (error == FILE_ERROR_OK) |
| 158 observer_->OnDirectoryChangedByOperation(*changed_directory_path); | 154 observer_->OnDirectoryChangedByOperation(*changed_directory_path); |
| 159 | 155 |
| 160 callback.Run(error); | 156 callback.Run(error); |
| 161 } | 157 } |
| 162 | 158 |
| 163 } // namespace file_system | 159 } // namespace file_system |
| 164 } // namespace drive | 160 } // namespace drive |
| OLD | NEW |