Index: sync/engine/verify_updates_command.cc |
diff --git a/sync/engine/verify_updates_command.cc b/sync/engine/verify_updates_command.cc |
index ab555a2138193b16a64c34817408c42fde8a5533..69683f47f838daf4a17b610a4ac3c9e4bc577beb 100644 |
--- a/sync/engine/verify_updates_command.cc |
+++ b/sync/engine/verify_updates_command.cc |
@@ -22,6 +22,36 @@ using syncable::WriteTransaction; |
using syncable::GET_BY_ID; |
using syncable::SYNCER; |
+namespace { |
+ |
+// Returns true if the update's version is greather than the version of the |
tim (not reviewing)
2012/03/20 20:43:53
nit - greater
rlarocque
2012/03/21 17:42:34
Done.
|
+// existing matching entry. Will return true if there is no matching entry. |
+bool UpdateContainsNewVersion(syncable::BaseTransaction *trans, |
+ const SyncEntity &update) { |
+ int64 existing_version = -1; // The server always sends positive versions. |
+ syncable::Entry existing_entry(trans, GET_BY_ID, update.id()); |
tim (not reviewing)
2012/03/20 20:43:53
When we create an item (version 0), we expect to s
rlarocque
2012/03/21 17:42:34
Interesting. I hadn't fully considered the new ID
tim (not reviewing)
2012/03/21 18:23:57
Makes sense.
|
+ if (existing_entry.good()) { |
tim (not reviewing)
2012/03/20 20:43:53
nit - no braces around single line ifs in this fil
rlarocque
2012/03/21 17:42:34
Done.
|
+ existing_version = existing_entry.Get(syncable::BASE_VERSION); |
+ } |
+ |
+ return existing_version < update.version(); |
tim (not reviewing)
2012/03/20 20:43:53
Does this catch redeliveries in general, or only o
rlarocque
2012/03/21 17:42:34
I assumed that we're looking for redeliveries in g
|
+} |
+ |
+// In the event that IDs match, but tags differ AttemptReuniteClient tag |
+// will have refused to unify the update. |
+// We should not attempt to apply it at all since it violates consistency |
+// rules. |
+VerifyResult VerifyTagConsistency(const SyncEntity& entry, |
+ const syncable::MutableEntry& same_id) { |
+ if (entry.has_client_defined_unique_tag() && |
+ entry.client_defined_unique_tag() != |
+ same_id.Get(syncable::UNIQUE_CLIENT_TAG)) { |
+ return VERIFY_FAIL; |
+ } |
+ return VERIFY_UNDECIDED; |
+} |
+} // namespace |
+ |
VerifyUpdatesCommand::VerifyUpdatesCommand() {} |
VerifyUpdatesCommand::~VerifyUpdatesCommand() {} |
@@ -62,6 +92,8 @@ SyncerError VerifyUpdatesCommand::ModelChangingExecuteImpl( |
session->routing_info()); |
status->mutable_update_progress()->AddVerifyResult(result.value, update); |
status->increment_num_updates_downloaded_by(1); |
+ if (!UpdateContainsNewVersion(&trans, update)) |
+ status->increment_num_echo_updates_downloaded_by(1); |
if (update.deleted()) |
status->increment_num_tombstone_updates_downloaded_by(1); |
} |
@@ -69,22 +101,6 @@ SyncerError VerifyUpdatesCommand::ModelChangingExecuteImpl( |
return SYNCER_OK; |
} |
-namespace { |
-// In the event that IDs match, but tags differ AttemptReuniteClient tag |
-// will have refused to unify the update. |
-// We should not attempt to apply it at all since it violates consistency |
-// rules. |
-VerifyResult VerifyTagConsistency(const SyncEntity& entry, |
- const syncable::MutableEntry& same_id) { |
- if (entry.has_client_defined_unique_tag() && |
- entry.client_defined_unique_tag() != |
- same_id.Get(syncable::UNIQUE_CLIENT_TAG)) { |
- return VERIFY_FAIL; |
- } |
- return VERIFY_UNDECIDED; |
-} |
-} // namespace |
- |
VerifyUpdatesCommand::VerifyUpdateResult VerifyUpdatesCommand::VerifyUpdate( |
syncable::WriteTransaction* trans, const SyncEntity& entry, |
const ModelSafeRoutingInfo& routes) { |