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 <algorithm> |
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" |
11 #include "components/sync/base/time.h" | 11 #include "components/sync/base/time.h" |
12 #include "components/sync/syncable/syncable_util.h" | 12 #include "components/sync/syncable/syncable_util.h" |
13 | 13 |
14 namespace syncer_v2 { | 14 namespace syncer_v2 { |
15 | 15 |
16 WorkerEntityTracker::WorkerEntityTracker(const std::string& client_tag_hash) | 16 WorkerEntityTracker::WorkerEntityTracker(const std::string& client_tag_hash) |
17 : client_tag_hash_(client_tag_hash) { | 17 : client_tag_hash_(client_tag_hash) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 // There's no need to inform the model thread of the conflict. The | 89 // There's no need to inform the model thread of the conflict. The |
90 // conflicting update has already been posted to its task runner; it will | 90 // conflicting update has already been posted to its task runner; it will |
91 // figure it out as soon as it runs that task. | 91 // figure it out as soon as it runs that task. |
92 // | 92 // |
93 // Note that this check must be after pending_commit_ is set. | 93 // Note that this check must be after pending_commit_ is set. |
94 if (IsInConflict()) { | 94 if (IsInConflict()) { |
95 ClearPendingCommit(); | 95 ClearPendingCommit(); |
96 return; | 96 return; |
97 } | 97 } |
98 | 98 |
99 // Now that we know we're not in a conflict state, increase if there have been | |
maxbogue
2016/09/21 00:57:14
"There's no conflict; increase base_version_ if th
skym
2016/09/22 18:58:51
Done.
| |
100 // successful commits between the creation of this commit data and now. | |
101 base_version_ = std::max(base_version_, highest_commit_response_version_); | |
102 | |
99 // Otherwise, keep the data associated with this pending commit | 103 // Otherwise, keep the data associated with this pending commit |
100 // so it can be committed at the next possible opportunity. | 104 // so it can be committed at the next possible opportunity. |
101 } | 105 } |
102 | 106 |
103 void WorkerEntityTracker::ReceiveCommitResponse(CommitResponseData* ack) { | 107 void WorkerEntityTracker::ReceiveCommitResponse(CommitResponseData* ack) { |
104 DCHECK_GT(ack->response_version, highest_commit_response_version_) | 108 DCHECK_GT(ack->response_version, highest_commit_response_version_) |
105 << "Had expected higher response version." | 109 << "Had expected higher response version." |
106 << " id: " << id_; | 110 << " id: " << id_; |
107 | 111 |
108 // Commit responses, especially after the first commit, can update our ID. | 112 // Commit responses, especially after the first commit, can update our ID. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 bool WorkerEntityTracker::IsServerKnown() const { | 193 bool WorkerEntityTracker::IsServerKnown() const { |
190 return base_version_ != kUncommittedVersion; | 194 return base_version_ != kUncommittedVersion; |
191 } | 195 } |
192 | 196 |
193 void WorkerEntityTracker::ClearPendingCommit() { | 197 void WorkerEntityTracker::ClearPendingCommit() { |
194 pending_commit_.reset(); | 198 pending_commit_.reset(); |
195 pending_commit_specifics_hash_.clear(); | 199 pending_commit_specifics_hash_.clear(); |
196 } | 200 } |
197 | 201 |
198 } // namespace syncer_v2 | 202 } // namespace syncer_v2 |
OLD | NEW |