OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/sync/entry_revert_performer.h" | 5 #include "chrome/browser/chromeos/drive/sync/entry_revert_performer.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/drive/change_list_processor.h" | 7 #include "chrome/browser/chromeos/drive/change_list_processor.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_system/operation_observer.h" | 9 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" |
10 #include "chrome/browser/chromeos/drive/job_scheduler.h" | 10 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 break; | 33 break; |
34 | 34 |
35 case FILE_ERROR_NOT_FOUND: | 35 case FILE_ERROR_NOT_FOUND: |
36 entry.set_deleted(true); | 36 entry.set_deleted(true); |
37 break; | 37 break; |
38 | 38 |
39 default: | 39 default: |
40 return error; | 40 return error; |
41 } | 41 } |
42 | 42 |
43 const base::FilePath original_path = metadata->GetFilePath(local_id); | 43 base::FilePath original_path; |
| 44 error = metadata->GetFilePath(local_id, &original_path); |
| 45 if (error != FILE_ERROR_OK) |
| 46 return error; |
44 | 47 |
45 if (entry.deleted()) { | 48 if (entry.deleted()) { |
46 error = metadata->RemoveEntry(local_id); | 49 error = metadata->RemoveEntry(local_id); |
47 if (error != FILE_ERROR_OK) | 50 if (error != FILE_ERROR_OK) |
48 return error; | 51 return error; |
49 | 52 |
50 changed_directories->insert(original_path.DirName()); | 53 changed_directories->insert(original_path.DirName()); |
51 } else { | 54 } else { |
52 error = ChangeListProcessor::SetParentLocalIdOfEntry(metadata, &entry, | 55 error = ChangeListProcessor::SetParentLocalIdOfEntry(metadata, &entry, |
53 parent_resource_id); | 56 parent_resource_id); |
54 if (error != FILE_ERROR_OK) | 57 if (error != FILE_ERROR_OK) |
55 return error; | 58 return error; |
56 | 59 |
57 entry.set_local_id(local_id); | 60 entry.set_local_id(local_id); |
58 error = metadata->RefreshEntry(entry); | 61 error = metadata->RefreshEntry(entry); |
59 if (error != FILE_ERROR_OK) | 62 if (error != FILE_ERROR_OK) |
60 return error; | 63 return error; |
61 | 64 |
62 changed_directories->insert(metadata->GetFilePath(entry.parent_local_id())); | 65 base::FilePath new_parent_path; |
| 66 error = metadata->GetFilePath(entry.parent_local_id(), &new_parent_path); |
| 67 if (error != FILE_ERROR_OK) |
| 68 return error; |
| 69 changed_directories->insert(new_parent_path); |
63 changed_directories->insert(original_path.DirName()); | 70 changed_directories->insert(original_path.DirName()); |
64 } | 71 } |
65 return FILE_ERROR_OK; | 72 return FILE_ERROR_OK; |
66 } | 73 } |
67 | 74 |
68 } // namespace | 75 } // namespace |
69 | 76 |
70 EntryRevertPerformer::EntryRevertPerformer( | 77 EntryRevertPerformer::EntryRevertPerformer( |
71 base::SequencedTaskRunner* blocking_task_runner, | 78 base::SequencedTaskRunner* blocking_task_runner, |
72 file_system::OperationObserver* observer, | 79 file_system::OperationObserver* observer, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 160 |
154 for (std::set<base::FilePath>::const_iterator it = | 161 for (std::set<base::FilePath>::const_iterator it = |
155 changed_directories->begin(); it != changed_directories->end(); ++it) | 162 changed_directories->begin(); it != changed_directories->end(); ++it) |
156 observer_->OnDirectoryChangedByOperation(*it); | 163 observer_->OnDirectoryChangedByOperation(*it); |
157 | 164 |
158 callback.Run(error); | 165 callback.Run(error); |
159 } | 166 } |
160 | 167 |
161 } // namespace internal | 168 } // namespace internal |
162 } // namespace drive | 169 } // namespace drive |
OLD | NEW |