Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: sync/engine/process_updates_command.cc

Issue 10696087: [Sync] Move ModelType and related classes to 'syncer' namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort headers, update copyrights Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return SYNCER_OK; 70 return SYNCER_OK;
71 } 71 }
72 72
73 namespace { 73 namespace {
74 // Returns true if the entry is still ok to process. 74 // Returns true if the entry is still ok to process.
75 bool ReverifyEntry(syncable::WriteTransaction* trans, const SyncEntity& entry, 75 bool ReverifyEntry(syncable::WriteTransaction* trans, const SyncEntity& entry,
76 syncable::MutableEntry* same_id) { 76 syncable::MutableEntry* same_id) {
77 77
78 const bool deleted = entry.has_deleted() && entry.deleted(); 78 const bool deleted = entry.has_deleted() && entry.deleted();
79 const bool is_directory = entry.IsFolder(); 79 const bool is_directory = entry.IsFolder();
80 const syncable::ModelType model_type = entry.GetModelType(); 80 const syncer::ModelType model_type = entry.GetModelType();
81 81
82 return VERIFY_SUCCESS == VerifyUpdateConsistency(trans, 82 return VERIFY_SUCCESS == VerifyUpdateConsistency(trans,
83 entry, 83 entry,
84 same_id, 84 same_id,
85 deleted, 85 deleted,
86 is_directory, 86 is_directory,
87 model_type); 87 model_type);
88 } 88 }
89 } // namespace 89 } // namespace
90 90
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 (update.parent_id() == target_entry.Get(syncable::SERVER_PARENT_ID)) && 153 (update.parent_id() == target_entry.Get(syncable::SERVER_PARENT_ID)) &&
154 (update.position_in_parent() == 154 (update.position_in_parent() ==
155 target_entry.Get(syncable::SERVER_POSITION_IN_PARENT)) && 155 target_entry.Get(syncable::SERVER_POSITION_IN_PARENT)) &&
156 update.has_specifics() && update.specifics().has_encrypted() && 156 update.has_specifics() && update.specifics().has_encrypted() &&
157 !cryptographer->CanDecrypt(update.specifics().encrypted())) { 157 !cryptographer->CanDecrypt(update.specifics().encrypted())) {
158 sync_pb::EntitySpecifics prev_specifics = 158 sync_pb::EntitySpecifics prev_specifics =
159 target_entry.Get(syncable::SERVER_SPECIFICS); 159 target_entry.Get(syncable::SERVER_SPECIFICS);
160 // We only store the old specifics if they were decryptable and applied and 160 // We only store the old specifics if they were decryptable and applied and
161 // there is no BASE_SERVER_SPECIFICS already. Else do nothing. 161 // there is no BASE_SERVER_SPECIFICS already. Else do nothing.
162 if (!target_entry.Get(syncable::IS_UNAPPLIED_UPDATE) && 162 if (!target_entry.Get(syncable::IS_UNAPPLIED_UPDATE) &&
163 !syncable::IsRealDataType(syncable::GetModelTypeFromSpecifics( 163 !syncer::IsRealDataType(syncer::GetModelTypeFromSpecifics(
164 target_entry.Get(syncable::BASE_SERVER_SPECIFICS))) && 164 target_entry.Get(syncable::BASE_SERVER_SPECIFICS))) &&
165 (!prev_specifics.has_encrypted() || 165 (!prev_specifics.has_encrypted() ||
166 cryptographer->CanDecrypt(prev_specifics.encrypted()))) { 166 cryptographer->CanDecrypt(prev_specifics.encrypted()))) {
167 DVLOG(2) << "Storing previous server specifcs: " 167 DVLOG(2) << "Storing previous server specifcs: "
168 << prev_specifics.SerializeAsString(); 168 << prev_specifics.SerializeAsString();
169 target_entry.Put(syncable::BASE_SERVER_SPECIFICS, prev_specifics); 169 target_entry.Put(syncable::BASE_SERVER_SPECIFICS, prev_specifics);
170 } 170 }
171 } else if (syncable::IsRealDataType(syncable::GetModelTypeFromSpecifics( 171 } else if (syncer::IsRealDataType(syncer::GetModelTypeFromSpecifics(
172 target_entry.Get(syncable::BASE_SERVER_SPECIFICS)))) { 172 target_entry.Get(syncable::BASE_SERVER_SPECIFICS)))) {
173 // We have a BASE_SERVER_SPECIFICS, but a subsequent non-specifics-only 173 // We have a BASE_SERVER_SPECIFICS, but a subsequent non-specifics-only
174 // change arrived. As a result, we can't use the specifics alone to detect 174 // change arrived. As a result, we can't use the specifics alone to detect
175 // changes, so we clear BASE_SERVER_SPECIFICS. 175 // changes, so we clear BASE_SERVER_SPECIFICS.
176 target_entry.Put(syncable::BASE_SERVER_SPECIFICS, 176 target_entry.Put(syncable::BASE_SERVER_SPECIFICS,
177 sync_pb::EntitySpecifics()); 177 sync_pb::EntitySpecifics());
178 } 178 }
179 179
180 UpdateServerFieldsFromUpdate(&target_entry, update, name); 180 UpdateServerFieldsFromUpdate(&target_entry, update, name);
181 181
182 return SUCCESS_PROCESSED; 182 return SUCCESS_PROCESSED;
183 } 183 }
184 184
185 } // namespace syncer 185 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/process_commit_response_command_unittest.cc ('k') | sync/engine/process_updates_command_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698