Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/sync/engine_impl/worker_entity_tracker.h" | 5 #include "components/sync/engine_impl/worker_entity_tracker.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "components/sync/base/model_type.h" | 10 #include "components/sync/base/model_type.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 ack->sequence_number = sequence_number_; | 118 ack->sequence_number = sequence_number_; |
| 119 ack->specifics_hash = pending_commit_specifics_hash_; | 119 ack->specifics_hash = pending_commit_specifics_hash_; |
| 120 | 120 |
| 121 // Because an in-progress commit blocks the sync thread, we can assume that | 121 // Because an in-progress commit blocks the sync thread, we can assume that |
| 122 // the item we just committed successfully is exactly the one we have now. | 122 // the item we just committed successfully is exactly the one we have now. |
| 123 // Nothing changed it while the commit was happening. Since we're now in | 123 // Nothing changed it while the commit was happening. Since we're now in |
| 124 // sync with the server, we can clear the pending commit. | 124 // sync with the server, we can clear the pending commit. |
| 125 ClearPendingCommit(); | 125 ClearPendingCommit(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void WorkerEntityTracker::ReceiveUpdate(int64_t version) { | 128 void WorkerEntityTracker::ReceiveUpdate(const UpdateResponseData& update) { |
| 129 if (version <= highest_gu_response_version_) | 129 if (update.response_version <= highest_gu_response_version_) |
| 130 return; | 130 return; |
| 131 | 131 |
| 132 highest_gu_response_version_ = version; | 132 highest_gu_response_version_ = update.response_version; |
| 133 id_ = update.entity->id; | |
|
pavely
2016/09/16 16:11:08
Could you adjust comment for entities_ in model_ty
maxbogue
2016/09/16 17:39:43
Done and done.
| |
| 133 | 134 |
| 134 // Got an applicable update newer than any pending updates. It must be safe | 135 // Got an applicable update newer than any pending updates. It must be safe |
| 135 // to discard the old encrypted update, if there was one. | 136 // to discard the old encrypted update, if there was one. |
| 136 ClearEncryptedUpdate(); | 137 ClearEncryptedUpdate(); |
| 137 | 138 |
| 138 if (IsInConflict()) { | 139 if (IsInConflict()) { |
| 139 // Incoming update clobbers the pending commit on the sync thread. | 140 // Incoming update clobbers the pending commit on the sync thread. |
| 140 // The model thread can re-request this commit later if it wants to. | 141 // The model thread can re-request this commit later if it wants to. |
| 141 ClearPendingCommit(); | 142 ClearPendingCommit(); |
| 142 } | 143 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 bool WorkerEntityTracker::IsServerKnown() const { | 192 bool WorkerEntityTracker::IsServerKnown() const { |
| 192 return base_version_ != kUncommittedVersion; | 193 return base_version_ != kUncommittedVersion; |
| 193 } | 194 } |
| 194 | 195 |
| 195 void WorkerEntityTracker::ClearPendingCommit() { | 196 void WorkerEntityTracker::ClearPendingCommit() { |
| 196 pending_commit_.reset(); | 197 pending_commit_.reset(); |
| 197 pending_commit_specifics_hash_.clear(); | 198 pending_commit_specifics_hash_.clear(); |
| 198 } | 199 } |
| 199 | 200 |
| 200 } // namespace syncer_v2 | 201 } // namespace syncer_v2 |
| OLD | NEW |