| 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_change.h" | 10 #include "chrome/browser/chromeos/drive/file_change.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 RemoveOperation::RemoveOperation( | 63 RemoveOperation::RemoveOperation( |
| 64 base::SequencedTaskRunner* blocking_task_runner, | 64 base::SequencedTaskRunner* blocking_task_runner, |
| 65 OperationDelegate* delegate, | 65 OperationDelegate* delegate, |
| 66 internal::ResourceMetadata* metadata, | 66 internal::ResourceMetadata* metadata, |
| 67 internal::FileCache* cache) | 67 internal::FileCache* cache) |
| 68 : blocking_task_runner_(blocking_task_runner), | 68 : blocking_task_runner_(blocking_task_runner), |
| 69 delegate_(delegate), | 69 delegate_(delegate), |
| 70 metadata_(metadata), | 70 metadata_(metadata), |
| 71 cache_(cache), | 71 cache_(cache), |
| 72 weak_ptr_factory_(this) { | 72 weak_ptr_factory_(this) { |
| 73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 73 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 74 } | 74 } |
| 75 | 75 |
| 76 RemoveOperation::~RemoveOperation() { | 76 RemoveOperation::~RemoveOperation() { |
| 77 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 77 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void RemoveOperation::Remove(const base::FilePath& path, | 80 void RemoveOperation::Remove(const base::FilePath& path, |
| 81 bool is_recursive, | 81 bool is_recursive, |
| 82 const FileOperationCallback& callback) { | 82 const FileOperationCallback& callback) { |
| 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 83 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 84 DCHECK(!callback.is_null()); | 84 DCHECK(!callback.is_null()); |
| 85 | 85 |
| 86 std::string* local_id = new std::string; | 86 std::string* local_id = new std::string; |
| 87 base::FilePath* changed_path = new base::FilePath; | 87 base::FilePath* changed_path = new base::FilePath; |
| 88 ResourceEntry* entry = new ResourceEntry; | 88 ResourceEntry* entry = new ResourceEntry; |
| 89 base::PostTaskAndReplyWithResult( | 89 base::PostTaskAndReplyWithResult( |
| 90 blocking_task_runner_.get(), | 90 blocking_task_runner_.get(), |
| 91 FROM_HERE, | 91 FROM_HERE, |
| 92 base::Bind(&UpdateLocalState, | 92 base::Bind(&UpdateLocalState, |
| 93 metadata_, | 93 metadata_, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 104 base::Owned(entry), | 104 base::Owned(entry), |
| 105 base::Owned(changed_path))); | 105 base::Owned(changed_path))); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void RemoveOperation::RemoveAfterUpdateLocalState( | 108 void RemoveOperation::RemoveAfterUpdateLocalState( |
| 109 const FileOperationCallback& callback, | 109 const FileOperationCallback& callback, |
| 110 const std::string* local_id, | 110 const std::string* local_id, |
| 111 const ResourceEntry* entry, | 111 const ResourceEntry* entry, |
| 112 const base::FilePath* changed_path, | 112 const base::FilePath* changed_path, |
| 113 FileError error) { | 113 FileError error) { |
| 114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 114 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 115 DCHECK(!callback.is_null()); | 115 DCHECK(!callback.is_null()); |
| 116 | 116 |
| 117 if (!changed_path->empty()) { | 117 if (!changed_path->empty()) { |
| 118 FileChange changed_file; | 118 FileChange changed_file; |
| 119 changed_file.Update(*changed_path, *entry, FileChange::DELETE); | 119 changed_file.Update(*changed_path, *entry, FileChange::DELETE); |
| 120 if (error == FILE_ERROR_OK) { | 120 if (error == FILE_ERROR_OK) { |
| 121 delegate_->OnFileChangedByOperation(changed_file); | 121 delegate_->OnFileChangedByOperation(changed_file); |
| 122 delegate_->OnEntryUpdatedByOperation(ClientContext(USER_INITIATED), | 122 delegate_->OnEntryUpdatedByOperation(ClientContext(USER_INITIATED), |
| 123 *local_id); | 123 *local_id); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 callback.Run(error); | 127 callback.Run(error); |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace file_system | 130 } // namespace file_system |
| 131 } // namespace drive | 131 } // namespace drive |
| OLD | NEW |