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/change_list_processor.h" | 5 #include "chrome/browser/chromeos/drive/change_list_processor.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.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_util.h" | 9 #include "chrome/browser/chromeos/drive/file_system_util.h" |
10 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" | 10 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 for (size_t i = 0; i < entries.size(); ++i) { | 156 for (size_t i = 0; i < entries.size(); ++i) { |
157 ResourceEntryMap::iterator it = entries[i]; | 157 ResourceEntryMap::iterator it = entries[i]; |
158 ApplyEntry(it->second); | 158 ApplyEntry(it->second); |
159 entry_map_.erase(it); | 159 entry_map_.erase(it); |
160 } | 160 } |
161 } | 161 } |
162 } | 162 } |
163 | 163 |
164 void ChangeListProcessor::ApplyEntry(const ResourceEntry& entry) { | 164 void ChangeListProcessor::ApplyEntry(const ResourceEntry& entry) { |
165 // Lookup the entry. | 165 // Lookup the entry. |
166 FileError error = | 166 ResourceEntry existing_entry; |
167 resource_metadata_->GetResourceEntryById(entry.resource_id(), NULL, NULL); | 167 FileError error = resource_metadata_->GetResourceEntryById( |
| 168 entry.resource_id(), &existing_entry); |
168 | 169 |
169 if (error == FILE_ERROR_OK) { | 170 if (error == FILE_ERROR_OK) { |
170 if (entry.deleted()) { | 171 if (entry.deleted()) { |
171 // Deleted file/directory. | 172 // Deleted file/directory. |
172 RemoveEntry(entry); | 173 RemoveEntry(entry); |
173 } else { | 174 } else { |
174 // Entry exists and needs to be refreshed. | 175 // Entry exists and needs to be refreshed. |
175 RefreshEntry(entry); | 176 RefreshEntry(entry); |
176 } | 177 } |
177 } else if (error == FILE_ERROR_NOT_FOUND && !entry.deleted()) { | 178 } else if (error == FILE_ERROR_NOT_FOUND && !entry.deleted()) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 // The changestamp should always be updated. | 299 // The changestamp should always be updated. |
299 root.mutable_directory_specific_info()->set_changestamp(largest_changestamp); | 300 root.mutable_directory_specific_info()->set_changestamp(largest_changestamp); |
300 | 301 |
301 error = resource_metadata_->RefreshEntry(root, NULL, NULL); | 302 error = resource_metadata_->RefreshEntry(root, NULL, NULL); |
302 | 303 |
303 LOG_IF(WARNING, error != FILE_ERROR_OK) << "Failed to refresh root directory"; | 304 LOG_IF(WARNING, error != FILE_ERROR_OK) << "Failed to refresh root directory"; |
304 } | 305 } |
305 | 306 |
306 } // namespace internal | 307 } // namespace internal |
307 } // namespace drive | 308 } // namespace drive |
OLD | NEW |