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" |
11 #include "sync/engine/syncer.h" | 11 #include "sync/engine/syncer.h" |
12 #include "sync/engine/syncer_proto_util.h" | 12 #include "sync/engine/syncer_proto_util.h" |
13 #include "sync/engine/syncer_util.h" | 13 #include "sync/engine/syncer_util.h" |
14 #include "sync/sessions/sync_session.h" | 14 #include "sync/sessions/sync_session.h" |
15 #include "sync/syncable/directory.h" | 15 #include "sync/syncable/directory.h" |
16 #include "sync/syncable/mutable_entry.h" | 16 #include "sync/syncable/mutable_entry.h" |
17 #include "sync/syncable/syncable_proto_util.h" | 17 #include "sync/syncable/syncable_proto_util.h" |
18 #include "sync/syncable/syncable_util.h" | 18 #include "sync/syncable/syncable_util.h" |
19 #include "sync/syncable/write_transaction.h" | 19 #include "sync/syncable/write_transaction.h" |
20 #include "sync/util/cryptographer.h" | 20 #include "sync/util/cryptographer.h" |
21 | 21 |
| 22 // TODO(vishwath): Remove this include after node positions have |
| 23 // shifted to completely using Ordinals. |
| 24 // See http://crbug.com/145412 . |
| 25 #include "sync/internal_api/public/base/node_ordinal.h" |
| 26 |
22 using std::vector; | 27 using std::vector; |
23 | 28 |
24 namespace syncer { | 29 namespace syncer { |
25 | 30 |
26 using sessions::SyncSession; | 31 using sessions::SyncSession; |
27 using sessions::StatusController; | 32 using sessions::StatusController; |
28 using sessions::UpdateProgress; | 33 using sessions::UpdateProgress; |
29 | 34 |
30 ProcessUpdatesCommand::ProcessUpdatesCommand() {} | 35 ProcessUpdatesCommand::ProcessUpdatesCommand() {} |
31 ProcessUpdatesCommand::~ProcessUpdatesCommand() {} | 36 ProcessUpdatesCommand::~ProcessUpdatesCommand() {} |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 150 |
146 // If this is a newly received undecryptable update, and the only thing that | 151 // If this is a newly received undecryptable update, and the only thing that |
147 // has changed are the specifics, store the original decryptable specifics, | 152 // has changed are the specifics, store the original decryptable specifics, |
148 // (on which any current or future local changes are based) before we | 153 // (on which any current or future local changes are based) before we |
149 // overwrite SERVER_SPECIFICS. | 154 // overwrite SERVER_SPECIFICS. |
150 // MTIME, CTIME, and NON_UNIQUE_NAME are not enforced. | 155 // MTIME, CTIME, and NON_UNIQUE_NAME are not enforced. |
151 if (!update.deleted() && !target_entry.Get(syncable::SERVER_IS_DEL) && | 156 if (!update.deleted() && !target_entry.Get(syncable::SERVER_IS_DEL) && |
152 (SyncableIdFromProto(update.parent_id_string()) == | 157 (SyncableIdFromProto(update.parent_id_string()) == |
153 target_entry.Get(syncable::SERVER_PARENT_ID)) && | 158 target_entry.Get(syncable::SERVER_PARENT_ID)) && |
154 (update.position_in_parent() == | 159 (update.position_in_parent() == |
155 target_entry.Get(syncable::SERVER_POSITION_IN_PARENT)) && | 160 NodeOrdinalToInt64( |
| 161 target_entry.Get(syncable::SERVER_ORDINAL_IN_PARENT))) && |
156 update.has_specifics() && update.specifics().has_encrypted() && | 162 update.has_specifics() && update.specifics().has_encrypted() && |
157 !cryptographer->CanDecrypt(update.specifics().encrypted())) { | 163 !cryptographer->CanDecrypt(update.specifics().encrypted())) { |
158 sync_pb::EntitySpecifics prev_specifics = | 164 sync_pb::EntitySpecifics prev_specifics = |
159 target_entry.Get(syncable::SERVER_SPECIFICS); | 165 target_entry.Get(syncable::SERVER_SPECIFICS); |
160 // We only store the old specifics if they were decryptable and applied and | 166 // We only store the old specifics if they were decryptable and applied and |
161 // there is no BASE_SERVER_SPECIFICS already. Else do nothing. | 167 // there is no BASE_SERVER_SPECIFICS already. Else do nothing. |
162 if (!target_entry.Get(syncable::IS_UNAPPLIED_UPDATE) && | 168 if (!target_entry.Get(syncable::IS_UNAPPLIED_UPDATE) && |
163 !IsRealDataType(GetModelTypeFromSpecifics( | 169 !IsRealDataType(GetModelTypeFromSpecifics( |
164 target_entry.Get(syncable::BASE_SERVER_SPECIFICS))) && | 170 target_entry.Get(syncable::BASE_SERVER_SPECIFICS))) && |
165 (!prev_specifics.has_encrypted() || | 171 (!prev_specifics.has_encrypted() || |
(...skipping 10 matching lines...) Expand all Loading... |
176 target_entry.Put(syncable::BASE_SERVER_SPECIFICS, | 182 target_entry.Put(syncable::BASE_SERVER_SPECIFICS, |
177 sync_pb::EntitySpecifics()); | 183 sync_pb::EntitySpecifics()); |
178 } | 184 } |
179 | 185 |
180 UpdateServerFieldsFromUpdate(&target_entry, update, name); | 186 UpdateServerFieldsFromUpdate(&target_entry, update, name); |
181 | 187 |
182 return SUCCESS_PROCESSED; | 188 return SUCCESS_PROCESSED; |
183 } | 189 } |
184 | 190 |
185 } // namespace syncer | 191 } // namespace syncer |
OLD | NEW |