| 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 "sync/engine/process_updates_command.h" | 5 #include "sync/engine/process_updates_command.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // We need to run the Verify checks again; the world could have changed | 113 // We need to run the Verify checks again; the world could have changed |
| 114 // since VerifyUpdatesCommand. | 114 // since VerifyUpdatesCommand. |
| 115 if (!ReverifyEntry(trans, update, &target_entry)) { | 115 if (!ReverifyEntry(trans, update, &target_entry)) { |
| 116 return SUCCESS_PROCESSED; // The entry has become irrelevant. | 116 return SUCCESS_PROCESSED; // The entry has become irrelevant. |
| 117 } | 117 } |
| 118 | 118 |
| 119 // If we're repurposing an existing local entry with a new server ID, | 119 // If we're repurposing an existing local entry with a new server ID, |
| 120 // change the ID now, after we're sure that the update can succeed. | 120 // change the ID now, after we're sure that the update can succeed. |
| 121 if (local_id != server_id) { | 121 if (local_id != server_id) { |
| 122 DCHECK(!update.deleted()); | 122 DCHECK(!update.deleted()); |
| 123 SyncerUtil::ChangeEntryIDAndUpdateChildren(trans, &target_entry, | 123 ChangeEntryIDAndUpdateChildren(trans, &target_entry, server_id); |
| 124 server_id); | |
| 125 // When IDs change, versions become irrelevant. Forcing BASE_VERSION | 124 // When IDs change, versions become irrelevant. Forcing BASE_VERSION |
| 126 // to zero would ensure that this update gets applied, but would indicate | 125 // to zero would ensure that this update gets applied, but would indicate |
| 127 // creation or undeletion if it were committed that way. Instead, prefer | 126 // creation or undeletion if it were committed that way. Instead, prefer |
| 128 // forcing BASE_VERSION to entry.version() while also forcing | 127 // forcing BASE_VERSION to entry.version() while also forcing |
| 129 // IS_UNAPPLIED_UPDATE to true. If the item is UNSYNCED, it's committable | 128 // IS_UNAPPLIED_UPDATE to true. If the item is UNSYNCED, it's committable |
| 130 // from the new state; it may commit before the conflict resolver gets | 129 // from the new state; it may commit before the conflict resolver gets |
| 131 // a crack at it. | 130 // a crack at it. |
| 132 if (target_entry.Get(syncable::IS_UNSYNCED) || | 131 if (target_entry.Get(syncable::IS_UNSYNCED) || |
| 133 target_entry.Get(syncable::BASE_VERSION) > 0) { | 132 target_entry.Get(syncable::BASE_VERSION) > 0) { |
| 134 // If either of these conditions are met, then we can expect valid client | 133 // If either of these conditions are met, then we can expect valid client |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 target_entry.Put(syncable::BASE_SERVER_SPECIFICS, | 173 target_entry.Put(syncable::BASE_SERVER_SPECIFICS, |
| 175 sync_pb::EntitySpecifics()); | 174 sync_pb::EntitySpecifics()); |
| 176 } | 175 } |
| 177 | 176 |
| 178 SyncerUtil::UpdateServerFieldsFromUpdate(&target_entry, update, name); | 177 SyncerUtil::UpdateServerFieldsFromUpdate(&target_entry, update, name); |
| 179 | 178 |
| 180 return SUCCESS_PROCESSED; | 179 return SUCCESS_PROCESSED; |
| 181 } | 180 } |
| 182 | 181 |
| 183 } // namespace browser_sync | 182 } // namespace browser_sync |
| OLD | NEW |