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

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

Issue 553015: Support for multiple sync ModelSafeWorkers.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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
« no previous file with comments | « chrome/browser/sync/engine/model_safe_worker.h ('k') | chrome/browser/sync/engine/syncapi.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/process_updates_command.h" 5 #include "chrome/browser/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 "chrome/browser/sync/engine/syncer.h" 10 #include "chrome/browser/sync/engine/syncer.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 116
117 namespace { 117 namespace {
118 // Returns true if the entry is still ok to process. 118 // Returns true if the entry is still ok to process.
119 bool ReverifyEntry(syncable::WriteTransaction* trans, const SyncEntity& entry, 119 bool ReverifyEntry(syncable::WriteTransaction* trans, const SyncEntity& entry,
120 syncable::MutableEntry* same_id) { 120 syncable::MutableEntry* same_id) {
121 121
122 const bool deleted = entry.has_deleted() && entry.deleted(); 122 const bool deleted = entry.has_deleted() && entry.deleted();
123 const bool is_directory = entry.IsFolder(); 123 const bool is_directory = entry.IsFolder();
124 const bool is_bookmark = 124 const bool is_bookmark =
125 SyncerUtil::GetSyncDataType(entry) == SYNC_TYPE_BOOKMARK; 125 SyncerUtil::GetModelType(entry) == syncable::BOOKMARKS;
126 126
127 return VERIFY_SUCCESS == SyncerUtil::VerifyUpdateConsistency(trans, 127 return VERIFY_SUCCESS == SyncerUtil::VerifyUpdateConsistency(trans,
128 entry, 128 entry,
129 same_id, 129 same_id,
130 deleted, 130 deleted,
131 is_directory, 131 is_directory,
132 is_bookmark); 132 is_bookmark);
133 } 133 }
134 } // namespace 134 } // namespace
135 135
136 // TODO(sync): Refactor this code. 136 // TODO(sync): Refactor this code.
137 // Process a single update. Will avoid touching global state. 137 // Process a single update. Will avoid touching global state.
138 ServerUpdateProcessingResult ProcessUpdatesCommand::ProcessUpdate( 138 ServerUpdateProcessingResult ProcessUpdatesCommand::ProcessUpdate(
139 const syncable::ScopedDirLookup& dir, const sync_pb::SyncEntity& pb_entry) { 139 const syncable::ScopedDirLookup& dir, const sync_pb::SyncEntity& pb_entry) {
140 140
141 const SyncEntity& entry = *static_cast<const SyncEntity*>(&pb_entry); 141 const SyncEntity& entry = *static_cast<const SyncEntity*>(&pb_entry);
142 using namespace syncable; 142 using namespace syncable;
143 syncable::Id id = entry.id(); 143 syncable::Id id = entry.id();
144 const std::string name = 144 const std::string name = SyncerProtoUtil::NameFromSyncEntity(entry);
145 SyncerProtoUtil::NameFromSyncEntity(entry);
146 145
147 WriteTransaction trans(dir, SYNCER, __FILE__, __LINE__); 146 WriteTransaction trans(dir, SYNCER, __FILE__, __LINE__);
148 147
149 SyncerUtil::CreateNewEntry(&trans, id); 148 SyncerUtil::CreateNewEntry(&trans, id);
150 149
151 // We take a two step approach. First we store the entries data in the 150 // We take a two step approach. First we store the entries data in the
152 // server fields of a local entry and then move the data to the local fields 151 // server fields of a local entry and then move the data to the local fields
153 MutableEntry update_entry(&trans, GET_BY_ID, id); 152 MutableEntry update_entry(&trans, GET_BY_ID, id);
154 // TODO(sync): do we need to run ALL these checks, or is a mere version check 153 // TODO(sync): do we need to run ALL these checks, or is a mere version check
155 // good enough? 154 // good enough?
156 if (!ReverifyEntry(&trans, entry, &update_entry)) { 155 if (!ReverifyEntry(&trans, entry, &update_entry)) {
157 return SUCCESS_PROCESSED; // the entry has become irrelevant 156 return SUCCESS_PROCESSED; // the entry has become irrelevant
158 } 157 }
159 158
160 SyncerUtil::UpdateServerFieldsFromUpdate(&update_entry, entry, name); 159 SyncerUtil::UpdateServerFieldsFromUpdate(&update_entry, entry, name);
161 160
162 if (update_entry.Get(SERVER_VERSION) == update_entry.Get(BASE_VERSION) && 161 if (update_entry.Get(SERVER_VERSION) == update_entry.Get(BASE_VERSION) &&
163 !update_entry.Get(IS_UNSYNCED)) { 162 !update_entry.Get(IS_UNSYNCED)) {
164 // It's largely OK if data doesn't match exactly since a future update 163 // It's largely OK if data doesn't match exactly since a future update
165 // will just clobber the data. Conflict resolution will overwrite and 164 // will just clobber the data. Conflict resolution will overwrite and
166 // take one side as the winner and does not try to merge, so strict 165 // take one side as the winner and does not try to merge, so strict
167 // equality isn't necessary. 166 // equality isn't necessary.
168 LOG_IF(ERROR, !SyncerUtil::ServerAndLocalEntriesMatch(&update_entry)) 167 LOG_IF(ERROR, !SyncerUtil::ServerAndLocalEntriesMatch(&update_entry))
169 << update_entry; 168 << update_entry;
170 } 169 }
171 return SUCCESS_PROCESSED; 170 return SUCCESS_PROCESSED;
172 } 171 }
173 172
174 } // namespace browser_sync 173 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/model_safe_worker.h ('k') | chrome/browser/sync/engine/syncapi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698