OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/sync/engine/syncer_util.h" | 5 #include "chrome/browser/sync/engine/syncer_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 syncable::Id old_id = entry->Get(ID); | 83 syncable::Id old_id = entry->Get(ID); |
84 if (!entry->Put(ID, new_id)) { | 84 if (!entry->Put(ID, new_id)) { |
85 Entry old_entry(trans, GET_BY_ID, new_id); | 85 Entry old_entry(trans, GET_BY_ID, new_id); |
86 CHECK(old_entry.good()); | 86 CHECK(old_entry.good()); |
87 LOG(FATAL) << "Attempt to change ID to " << new_id | 87 LOG(FATAL) << "Attempt to change ID to " << new_id |
88 << " conflicts with existing entry.\n\n" | 88 << " conflicts with existing entry.\n\n" |
89 << *entry << "\n\n" << old_entry; | 89 << *entry << "\n\n" << old_entry; |
90 } | 90 } |
91 if (entry->Get(IS_DIR)) { | 91 if (entry->Get(IS_DIR)) { |
92 // Get all child entries of the old id. | 92 // Get all child entries of the old id. |
93 trans->directory()->GetChildHandles(trans, old_id, children); | 93 trans->directory()->GetChildHandlesById(trans, old_id, children); |
94 Directory::ChildHandles::iterator i = children->begin(); | 94 Directory::ChildHandles::iterator i = children->begin(); |
95 while (i != children->end()) { | 95 while (i != children->end()) { |
96 MutableEntry child_entry(trans, GET_BY_HANDLE, *i++); | 96 MutableEntry child_entry(trans, GET_BY_HANDLE, *i++); |
97 CHECK(child_entry.good()); | 97 CHECK(child_entry.good()); |
98 // Use the unchecked setter here to avoid touching the child's NEXT_ID | 98 // Use the unchecked setter here to avoid touching the child's NEXT_ID |
99 // and PREV_ID fields (which Put(PARENT_ID) would normally do to | 99 // and PREV_ID fields (which Put(PARENT_ID) would normally do to |
100 // maintain linked-list invariants). In this case, NEXT_ID and PREV_ID | 100 // maintain linked-list invariants). In this case, NEXT_ID and PREV_ID |
101 // among the children will be valid after the loop, since we update all | 101 // among the children will be valid after the loop, since we update all |
102 // the children at once. | 102 // the children at once. |
103 child_entry.PutParentIdPropertyOnly(new_id); | 103 child_entry.PutParentIdPropertyOnly(new_id); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 } | 272 } |
273 if (entry->Get(PARENT_ID) != new_parent) { | 273 if (entry->Get(PARENT_ID) != new_parent) { |
274 if (!entry->Get(IS_DEL) && !IsLegalNewParent(trans, id, new_parent)) { | 274 if (!entry->Get(IS_DEL) && !IsLegalNewParent(trans, id, new_parent)) { |
275 VLOG(1) << "Not updating item " << id | 275 VLOG(1) << "Not updating item " << id |
276 << ", illegal new parent (would cause loop)."; | 276 << ", illegal new parent (would cause loop)."; |
277 return CONFLICT; | 277 return CONFLICT; |
278 } | 278 } |
279 } | 279 } |
280 } else if (entry->Get(IS_DIR)) { | 280 } else if (entry->Get(IS_DIR)) { |
281 Directory::ChildHandles handles; | 281 Directory::ChildHandles handles; |
282 trans->directory()->GetChildHandles(trans, id, &handles); | 282 trans->directory()->GetChildHandlesById(trans, id, &handles); |
283 if (!handles.empty()) { | 283 if (!handles.empty()) { |
284 // If we have still-existing children, then we need to deal with | 284 // If we have still-existing children, then we need to deal with |
285 // them before we can process this change. | 285 // them before we can process this change. |
286 VLOG(1) << "Not deleting directory; it's not empty " << *entry; | 286 VLOG(1) << "Not deleting directory; it's not empty " << *entry; |
287 return CONFLICT; | 287 return CONFLICT; |
288 } | 288 } |
289 } | 289 } |
290 | 290 |
291 // We intercept updates to the Nigori node, update the Cryptographer and | 291 // We intercept updates to the Nigori node, update the Cryptographer and |
292 // encrypt any unsynced changes here because there is no Nigori | 292 // encrypt any unsynced changes here because there is no Nigori |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 if (update.version() < target->Get(SERVER_VERSION)) { | 826 if (update.version() < target->Get(SERVER_VERSION)) { |
827 LOG(WARNING) << "Update older than current server version for " | 827 LOG(WARNING) << "Update older than current server version for " |
828 << *target << " Update:" | 828 << *target << " Update:" |
829 << SyncerProtoUtil::SyncEntityDebugString(update); | 829 << SyncerProtoUtil::SyncEntityDebugString(update); |
830 return VERIFY_SUCCESS; // Expected in new sync protocol. | 830 return VERIFY_SUCCESS; // Expected in new sync protocol. |
831 } | 831 } |
832 return VERIFY_UNDECIDED; | 832 return VERIFY_UNDECIDED; |
833 } | 833 } |
834 | 834 |
835 } // namespace browser_sync | 835 } // namespace browser_sync |
OLD | NEW |