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

Unified Diff: sync/engine/entity_tracker.cc

Issue 442053002: sync: Add non-blocking type encryption (retry) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/engine/entity_tracker.h ('k') | sync/engine/model_type_entity.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/entity_tracker.cc
diff --git a/sync/engine/entity_tracker.cc b/sync/engine/entity_tracker.cc
index 0f10906ab15c67fc253b0e24c2115d650c0ef4b0..bad76f9932575f43300e7ea74cea38e9e3d4b6df 100644
--- a/sync/engine/entity_tracker.cc
+++ b/sync/engine/entity_tracker.cc
@@ -193,8 +193,14 @@ 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_)
+ return;
+
+ highest_gu_response_version_ = version;
+
+ // Got an applicable update newer than any pending updates. It must be safe
+ // to discard the old pending update, if there was one.
+ ClearPendingUpdate();
if (IsInConflict()) {
// Incoming update clobbers the pending commit on the sync thread.
@@ -203,10 +209,35 @@ void EntityTracker::ReceiveUpdate(int64 version) {
}
}
+bool EntityTracker::ReceivePendingUpdate(const UpdateResponseData& data) {
+ if (data.response_version < highest_gu_response_version_)
+ return false;
+
+ highest_gu_response_version_ = data.response_version;
+ pending_update_.reset(new UpdateResponseData(data));
+ ClearPendingCommit();
+ return true;
+}
+
+bool EntityTracker::HasPendingUpdate() const {
+ return !!pending_update_;
+}
+
+UpdateResponseData EntityTracker::GetPendingUpdate() const {
+ return *pending_update_;
+}
+
+void EntityTracker::ClearPendingUpdate() {
+ pending_update_.reset();
+}
+
bool EntityTracker::IsInConflict() const {
if (!is_commit_pending_)
return false;
+ if (HasPendingUpdate())
+ 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.
« no previous file with comments | « sync/engine/entity_tracker.h ('k') | sync/engine/model_type_entity.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698