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

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

Issue 351026: Remove context-based dependencies on SyncerSession from ApplyUpdatesCommand.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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) 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/build_and_process_conflict_sets_command.h" 5 #include "chrome/browser/sync/engine/build_and_process_conflict_sets_command.h"
6 6
7 #include <string> 7 #include <string>
8 #include <sstream> 8 #include <sstream>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // 4. Use the preparer to move things to an initial starting state where no 211 // 4. Use the preparer to move things to an initial starting state where no
212 // names collide, and nothing in the set is a child of anything else. If 212 // names collide, and nothing in the set is a child of anything else. If
213 // we've correctly calculated the set, the server tree is valid and no 213 // we've correctly calculated the set, the server tree is valid and no
214 // changes have occurred locally we should be able to apply updates from this 214 // changes have occurred locally we should be able to apply updates from this
215 // state. 215 // state.
216 TransactionalUpdateEntryPreparer preparer; 216 TransactionalUpdateEntryPreparer preparer;
217 preparer.PrepareEntries(trans, update_set); 217 preparer.PrepareEntries(trans, update_set);
218 218
219 // 5. Use the usual apply updates from the special start state we've just 219 // 5. Use the usual apply updates from the special start state we've just
220 // prepared. 220 // prepared.
221 UpdateApplicator applicator(session, handles.begin(), handles.end()); 221 UpdateApplicator applicator(session->resolver(), handles.begin(),
222 handles.end());
222 while (applicator.AttemptOneApplication(trans)) { 223 while (applicator.AttemptOneApplication(trans)) {
223 // Keep going till all updates are applied. 224 // Keep going till all updates are applied.
224 } 225 }
225 if (!applicator.AllUpdatesApplied()) { 226 if (!applicator.AllUpdatesApplied()) {
226 LOG(ERROR) << "Transactional Apply Failed, Rolling back."; 227 LOG(ERROR) << "Transactional Apply Failed, Rolling back.";
227 // We have to move entries into the temp dir again. e.g. if a swap was in a 228 // We have to move entries into the temp dir again. e.g. if a swap was in a
228 // set with other failing updates, the swap may have gone through, meaning 229 // set with other failing updates, the swap may have gone through, meaning
229 // the roll back needs to be transactional. But as we're going to a known 230 // the roll back needs to be transactional. But as we're going to a known
230 // good state we should always succeed. 231 // good state we should always succeed.
231 preparer.PrepareEntries(trans, update_set); 232 preparer.PrepareEntries(trans, update_set);
232 233
233 // Rollback all entries. 234 // Rollback all entries.
234 for (size_t i = 0; i < rollback_data.size(); ++i) { 235 for (size_t i = 0; i < rollback_data.size(); ++i) {
235 CHECK(RollbackEntry(trans, &rollback_data[i])); 236 CHECK(RollbackEntry(trans, &rollback_data[i]));
236 } 237 }
237 return false; // Don't save progress -- we just undid it. 238 return false; // Don't save progress -- we just undid it.
238 } 239 }
239 applicator.SaveProgressIntoSessionState(); 240 applicator.SaveProgressIntoSessionState(session);
240 return true; 241 return true;
241 } 242 }
242 243
243 void BuildAndProcessConflictSetsCommand::BuildConflictSets( 244 void BuildAndProcessConflictSetsCommand::BuildConflictSets(
244 syncable::BaseTransaction* trans, 245 syncable::BaseTransaction* trans,
245 ConflictResolutionView* view) { 246 ConflictResolutionView* view) {
246 view->CleanupSets(); 247 view->CleanupSets();
247 set<syncable::Id>::iterator i = view->CommitConflictsBegin(); 248 set<syncable::Id>::iterator i = view->CommitConflictsBegin();
248 while (i != view->CommitConflictsEnd()) { 249 while (i != view->CommitConflictsEnd()) {
249 syncable::Entry entry(trans, syncable::GET_BY_ID, *i); 250 syncable::Entry entry(trans, syncable::GET_BY_ID, *i);
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 return; 433 return;
433 LocallyDeletedPathChecker checker; 434 LocallyDeletedPathChecker checker;
434 if (!checker.CausingConflict(parent, *entry)) 435 if (!checker.CausingConflict(parent, *entry))
435 return; 436 return;
436 view->MergeSets(entry->Get(syncable::ID), parent.Get(syncable::ID)); 437 view->MergeSets(entry->Get(syncable::ID), parent.Get(syncable::ID));
437 CrawlDeletedTreeMergingSets(trans, parent, view, checker); 438 CrawlDeletedTreeMergingSets(trans, parent, view, checker);
438 } 439 }
439 } 440 }
440 441
441 } // namespace browser_sync 442 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/apply_updates_command.cc ('k') | chrome/browser/sync/engine/conflict_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698