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