| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "components/sync/base/model_type.h" | 11 #include "components/sync/base/model_type.h" |
| 12 #include "components/sync/base/time.h" | 12 #include "components/sync/base/time.h" |
| 13 #include "components/sync/syncable/syncable_util.h" | 13 #include "components/sync/syncable/syncable_util.h" |
| 14 | 14 |
| 15 namespace syncer { | 15 namespace syncer { |
| 16 | 16 |
| 17 WorkerEntityTracker::WorkerEntityTracker(const std::string& client_tag_hash) | 17 WorkerEntityTracker::WorkerEntityTracker(const std::string& client_tag_hash) |
| 18 : client_tag_hash_(client_tag_hash) { | 18 : client_tag_hash_(client_tag_hash) { |
| 19 DCHECK(!client_tag_hash_.empty()); | 19 DCHECK(!client_tag_hash_.empty()); |
| 20 } | 20 } |
| 21 | 21 |
| 22 WorkerEntityTracker::~WorkerEntityTracker() {} | 22 WorkerEntityTracker::~WorkerEntityTracker() {} |
| 23 | 23 |
| 24 bool WorkerEntityTracker::HasPendingCommit() const { | 24 bool WorkerEntityTracker::HasPendingCommit() const { |
| 25 return !!pending_commit_; | 25 return !!pending_commit_; |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool WorkerEntityTracker::PendingCommitIsDeletion() const { |
| 29 DCHECK(pending_commit_); |
| 30 return pending_commit_->entity.value().is_deleted(); |
| 31 } |
| 32 |
| 28 void WorkerEntityTracker::PopulateCommitProto( | 33 void WorkerEntityTracker::PopulateCommitProto( |
| 29 sync_pb::SyncEntity* commit_entity) const { | 34 sync_pb::SyncEntity* commit_entity) const { |
| 30 DCHECK(HasPendingCommit()); | 35 DCHECK(HasPendingCommit()); |
| 31 | 36 |
| 32 const EntityData& entity = pending_commit_->entity.value(); | 37 const EntityData& entity = pending_commit_->entity.value(); |
| 33 DCHECK_EQ(client_tag_hash_, entity.client_tag_hash); | 38 DCHECK_EQ(client_tag_hash_, entity.client_tag_hash); |
| 34 | 39 |
| 35 commit_entity->set_id_string(id_); | 40 commit_entity->set_id_string(id_); |
| 36 commit_entity->set_client_defined_unique_tag(client_tag_hash_); | 41 commit_entity->set_client_defined_unique_tag(client_tag_hash_); |
| 37 commit_entity->set_version(base_version_); | 42 commit_entity->set_version(base_version_); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 bool WorkerEntityTracker::IsServerKnown() const { | 203 bool WorkerEntityTracker::IsServerKnown() const { |
| 199 return base_version_ != kUncommittedVersion; | 204 return base_version_ != kUncommittedVersion; |
| 200 } | 205 } |
| 201 | 206 |
| 202 void WorkerEntityTracker::ClearPendingCommit() { | 207 void WorkerEntityTracker::ClearPendingCommit() { |
| 203 pending_commit_.reset(); | 208 pending_commit_.reset(); |
| 204 pending_commit_specifics_hash_.clear(); | 209 pending_commit_specifics_hash_.clear(); |
| 205 } | 210 } |
| 206 | 211 |
| 207 } // namespace syncer | 212 } // namespace syncer |
| OLD | NEW |