summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-17 08:10:47 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-17 08:10:47 +0000
commitc74bac708bbf5ca54f4a26345229c581e29cad97 (patch)
tree04c5946d4d948e7a69ee12a75353108e2c72a805 /sync
parentab4d990db6b31722f604fb4f25e8debb7bac5f95 (diff)
downloadchromium_src-c74bac708bbf5ca54f4a26345229c581e29cad97.zip
chromium_src-c74bac708bbf5ca54f4a26345229c581e29cad97.tar.gz
chromium_src-c74bac708bbf5ca54f4a26345229c581e29cad97.tar.bz2
sync: Process conflicts out of order
Since the UniquePosition patch landed, it's no longer necessary to process conflcits in order to properly detect position changes. Rather than convert this to the new iteration API, we can simply ignore ordering altogether and iterate iterate in whatever order happens to be convenient. We can reliably detect position changes by comparing UniquePosition values. BUG=178275 Review URL: https://chromiumcodereview.appspot.com/14793023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200751 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r--sync/engine/conflict_resolver.cc45
1 files changed, 6 insertions, 39 deletions
diff --git a/sync/engine/conflict_resolver.cc b/sync/engine/conflict_resolver.cc
index 074eb37..fafd237 100644
--- a/sync/engine/conflict_resolver.cc
+++ b/sync/engine/conflict_resolver.cc
@@ -222,52 +222,19 @@ void ConflictResolver::ResolveConflicts(
const std::set<syncable::Id>& simple_conflict_ids,
sessions::StatusController* status) {
// Iterate over simple conflict items.
- set<Id>::const_iterator conflicting_item_it;
- set<Id> processed_items;
- for (conflicting_item_it = simple_conflict_ids.begin();
- conflicting_item_it != simple_conflict_ids.end();
- ++conflicting_item_it) {
- Id id = *conflicting_item_it;
- if (processed_items.count(id) > 0)
- continue;
-
+ set<Id>::const_iterator it;
+ for (it = simple_conflict_ids.begin();
+ it != simple_conflict_ids.end();
+ ++it) {
// We don't resolve conflicts for control types here.
- Entry conflicting_node(trans, syncable::GET_BY_ID, id);
+ Entry conflicting_node(trans, syncable::GET_BY_ID, *it);
CHECK(conflicting_node.good());
if (IsControlType(
GetModelTypeFromSpecifics(conflicting_node.Get(syncable::SPECIFICS)))) {
continue;
}
- // We have a simple conflict. In order check if positions have changed,
- // we need to process conflicting predecessors before successors. Traverse
- // backwards through all continuous conflicting predecessors, building a
- // stack of items to resolve in predecessor->successor order, then process
- // each item individually.
- list<Id> predecessors;
- Id prev_id = id;
- do {
- predecessors.push_back(prev_id);
- Entry entry(trans, syncable::GET_BY_ID, prev_id);
- // Any entry in conflict must be valid.
- CHECK(entry.good());
-
- // We can't traverse over a delete item.
- if (entry.Get(syncable::IS_DEL))
- break;
-
- Id new_prev_id = entry.GetPredecessorId();
- if (new_prev_id == prev_id)
- break;
- prev_id = new_prev_id;
- } while (processed_items.count(prev_id) == 0 &&
- simple_conflict_ids.count(prev_id) > 0); // Excludes root.
- while (!predecessors.empty()) {
- id = predecessors.back();
- predecessors.pop_back();
- ProcessSimpleConflict(trans, id, cryptographer, status);
- processed_items.insert(id);
- }
+ ProcessSimpleConflict(trans, *it, cryptographer, status);
}
return;
}