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

Side by Side Diff: components/sync/engine_impl/worker_entity_tracker.cc

Issue 2339403004: [Sync] Add two more USS integration tests. (Closed)
Patch Set: Address comments. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
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 16 matching lines...) Expand all
27 27
28 WorkerEntityTracker::~WorkerEntityTracker() {} 28 WorkerEntityTracker::~WorkerEntityTracker() {}
29 29
30 bool WorkerEntityTracker::HasPendingCommit() const { 30 bool WorkerEntityTracker::HasPendingCommit() const {
31 return !!pending_commit_; 31 return !!pending_commit_;
32 } 32 }
33 33
34 void WorkerEntityTracker::PopulateCommitProto( 34 void WorkerEntityTracker::PopulateCommitProto(
35 sync_pb::SyncEntity* commit_entity) const { 35 sync_pb::SyncEntity* commit_entity) const {
36 DCHECK(HasPendingCommit()); 36 DCHECK(HasPendingCommit());
37 DCHECK(!client_tag_hash_.empty());
38 37
39 if (!id_.empty()) { 38 if (!id_.empty()) {
40 commit_entity->set_id_string(id_); 39 commit_entity->set_id_string(id_);
41 } 40 }
42 41
43 const EntityData& entity = pending_commit_->entity.value(); 42 const EntityData& entity = pending_commit_->entity.value();
44 DCHECK_EQ(client_tag_hash_, entity.client_tag_hash); 43 DCHECK_EQ(client_tag_hash_, entity.client_tag_hash);
45 44
46 commit_entity->set_client_defined_unique_tag(client_tag_hash_); 45 commit_entity->set_client_defined_unique_tag(client_tag_hash_);
47 commit_entity->set_version(base_version_); 46 commit_entity->set_version(base_version_);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 ack->sequence_number = sequence_number_; 117 ack->sequence_number = sequence_number_;
119 ack->specifics_hash = pending_commit_specifics_hash_; 118 ack->specifics_hash = pending_commit_specifics_hash_;
120 119
121 // Because an in-progress commit blocks the sync thread, we can assume that 120 // 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. 121 // 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 122 // Nothing changed it while the commit was happening. Since we're now in
124 // sync with the server, we can clear the pending commit. 123 // sync with the server, we can clear the pending commit.
125 ClearPendingCommit(); 124 ClearPendingCommit();
126 } 125 }
127 126
128 void WorkerEntityTracker::ReceiveUpdate(int64_t version) { 127 void WorkerEntityTracker::ReceiveUpdate(const UpdateResponseData& update) {
129 if (version <= highest_gu_response_version_) 128 if (update.response_version <= highest_gu_response_version_)
130 return; 129 return;
131 130
132 highest_gu_response_version_ = version; 131 highest_gu_response_version_ = update.response_version;
132 id_ = update.entity->id;
133 133
134 // Got an applicable update newer than any pending updates. It must be safe 134 // Got an applicable update newer than any pending updates. It must be safe
135 // to discard the old encrypted update, if there was one. 135 // to discard the old encrypted update, if there was one.
136 ClearEncryptedUpdate(); 136 ClearEncryptedUpdate();
137 137
138 if (IsInConflict()) { 138 if (IsInConflict()) {
139 // Incoming update clobbers the pending commit on the sync thread. 139 // Incoming update clobbers the pending commit on the sync thread.
140 // The model thread can re-request this commit later if it wants to. 140 // The model thread can re-request this commit later if it wants to.
141 ClearPendingCommit(); 141 ClearPendingCommit();
142 } 142 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 bool WorkerEntityTracker::IsServerKnown() const { 191 bool WorkerEntityTracker::IsServerKnown() const {
192 return base_version_ != kUncommittedVersion; 192 return base_version_ != kUncommittedVersion;
193 } 193 }
194 194
195 void WorkerEntityTracker::ClearPendingCommit() { 195 void WorkerEntityTracker::ClearPendingCommit() {
196 pending_commit_.reset(); 196 pending_commit_.reset();
197 pending_commit_specifics_hash_.clear(); 197 pending_commit_specifics_hash_.clear();
198 } 198 }
199 199
200 } // namespace syncer_v2 200 } // namespace syncer_v2
OLDNEW
« no previous file with comments | « components/sync/engine_impl/worker_entity_tracker.h ('k') | components/sync/engine_impl/worker_entity_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698