Chromium Code Reviews| Index: sync/engine/entity_tracker.cc |
| diff --git a/sync/engine/entity_tracker.cc b/sync/engine/entity_tracker.cc |
| index 0f10906ab15c67fc253b0e24c2115d650c0ef4b0..5340dfcf95ed113455fa83ae1c02b4bd98e25e84 100644 |
| --- a/sync/engine/entity_tracker.cc |
| +++ b/sync/engine/entity_tracker.cc |
| @@ -193,8 +193,13 @@ void EntityTracker::ReceiveCommitResponse(const std::string& response_id, |
| } |
| void EntityTracker::ReceiveUpdate(int64 version) { |
| - highest_gu_response_version_ = |
| - std::max(highest_gu_response_version_, version); |
| + if (version > highest_gu_response_version_) { |
|
Nicolas Zea
2014/07/30 00:34:15
It seems like it might be better to do:
if (versio
rlarocque
2014/07/30 21:56:00
Done.
|
| + highest_gu_response_version_ = version; |
| + |
| + // Got an applicable update newer than any inapplicable updates. It must |
| + // be safe to discard the old inapplicable update, if there was one. |
| + ClearInapplicableUpdate(); |
| + } |
| if (IsInConflict()) { |
| // Incoming update clobbers the pending commit on the sync thread. |
| @@ -203,10 +208,35 @@ void EntityTracker::ReceiveUpdate(int64 version) { |
| } |
| } |
| +bool EntityTracker::ReceiveInapplicableUpdate(const UpdateResponseData& data) { |
| + if (data.response_version >= highest_gu_response_version_) { |
|
Nicolas Zea
2014/07/30 00:34:15
nit: I find it cleaner to just return early here t
rlarocque
2014/07/30 21:56:00
Done.
|
| + highest_gu_response_version_ = data.response_version; |
| + inapplicable_update_.reset(new UpdateResponseData(data)); |
| + ClearPendingCommit(); |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| +bool EntityTracker::HasInapplicableUpdate() const { |
| + return !!inapplicable_update_; |
| +} |
| + |
| +UpdateResponseData EntityTracker::GetInapplicableUpdate() const { |
| + return *inapplicable_update_; |
| +} |
| + |
| +void EntityTracker::ClearInapplicableUpdate() { |
| + inapplicable_update_.reset(); |
| +} |
| + |
| bool EntityTracker::IsInConflict() const { |
| if (!is_commit_pending_) |
| return false; |
| + if (HasInapplicableUpdate()) |
| + return true; |
| + |
| if (highest_gu_response_version_ <= highest_commit_response_version_) { |
| // The most recent server state was created in a commit made by this |
| // client. We're fully up to date, and therefore not in conflict. |