summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
Diffstat (limited to 'sync')
-rw-r--r--sync/BUILD.gn12
-rw-r--r--sync/engine/model_type_worker.cc22
-rw-r--r--sync/engine/model_type_worker.h8
-rw-r--r--sync/engine/worker_entity_tracker.cc (renamed from sync/engine/entity_tracker.cc)53
-rw-r--r--sync/engine/worker_entity_tracker.h (renamed from sync/engine/entity_tracker.h)24
-rw-r--r--sync/engine/worker_entity_tracker_unittest.cc (renamed from sync/engine/entity_tracker_unittest.cc)45
-rw-r--r--sync/internal_api/processor_entity_tracker.cc (renamed from sync/internal_api/model_type_entity.cc)57
-rw-r--r--sync/internal_api/processor_entity_tracker_unittest.cc (renamed from sync/internal_api/model_type_entity_unittest.cc)73
-rw-r--r--sync/internal_api/public/processor_entity_tracker.h (renamed from sync/internal_api/public/model_type_entity.h)31
-rw-r--r--sync/internal_api/public/shared_model_type_processor.h13
-rw-r--r--sync/internal_api/public/util/proto_value_ptr.h4
-rw-r--r--sync/internal_api/shared_model_type_processor.cc32
-rw-r--r--sync/internal_api/shared_model_type_processor_unittest.cc10
-rw-r--r--sync/sync.gyp8
-rw-r--r--sync/sync_tests.gypi4
15 files changed, 203 insertions, 193 deletions
diff --git a/sync/BUILD.gn b/sync/BUILD.gn
index f28fee8..413f11c 100644
--- a/sync/BUILD.gn
+++ b/sync/BUILD.gn
@@ -87,8 +87,6 @@ source_set("sync_core") {
"engine/directory_commit_contributor.h",
"engine/directory_update_handler.cc",
"engine/directory_update_handler.h",
- "engine/entity_tracker.cc",
- "engine/entity_tracker.h",
"engine/get_commit_ids.cc",
"engine/get_commit_ids.h",
"engine/get_updates_delegate.cc",
@@ -130,6 +128,8 @@ source_set("sync_core") {
"engine/update_applicator.h",
"engine/update_handler.cc",
"engine/update_handler.h",
+ "engine/worker_entity_tracker.cc",
+ "engine/worker_entity_tracker.h",
"internal_api/activation_context.cc",
"internal_api/attachments/attachment_downloader.cc",
"internal_api/attachments/attachment_downloader_impl.cc",
@@ -172,9 +172,9 @@ source_set("sync_core") {
"internal_api/js_sync_encryption_handler_observer.h",
"internal_api/js_sync_manager_observer.cc",
"internal_api/js_sync_manager_observer.h",
- "internal_api/model_type_entity.cc",
"internal_api/model_type_store_backend.cc",
"internal_api/model_type_store_impl.cc",
+ "internal_api/processor_entity_tracker.cc",
"internal_api/protocol_event_buffer.cc",
"internal_api/protocol_event_buffer.h",
"internal_api/public/activation_context.h",
@@ -244,7 +244,6 @@ source_set("sync_core") {
"internal_api/public/http_post_provider_interface.h",
"internal_api/public/internal_components_factory.h",
"internal_api/public/internal_components_factory_impl.h",
- "internal_api/public/model_type_entity.h",
"internal_api/public/model_type_processor.cc",
"internal_api/public/model_type_processor.h",
"internal_api/public/model_type_store_backend.h",
@@ -252,6 +251,7 @@ source_set("sync_core") {
"internal_api/public/network_resources.h",
"internal_api/public/non_blocking_sync_common.cc",
"internal_api/public/non_blocking_sync_common.h",
+ "internal_api/public/processor_entity_tracker.h",
"internal_api/public/read_node.h",
"internal_api/public/read_transaction.h",
"internal_api/public/sessions/commit_counters.cc",
@@ -617,13 +617,13 @@ test("sync_unit_tests") {
"engine/backoff_delay_provider_unittest.cc",
"engine/directory_commit_contribution_unittest.cc",
"engine/directory_update_handler_unittest.cc",
- "engine/entity_tracker_unittest.cc",
"engine/get_updates_processor_unittest.cc",
"engine/model_type_worker_unittest.cc",
"engine/sync_scheduler_unittest.cc",
"engine/syncer_proto_util_unittest.cc",
"engine/syncer_unittest.cc",
"engine/syncer_util_unittest.cc",
+ "engine/worker_entity_tracker_unittest.cc",
"internal_api/attachments/attachment_downloader_impl_unittest.cc",
"internal_api/attachments/attachment_service_impl_unittest.cc",
"internal_api/attachments/attachment_service_proxy_unittest.cc",
@@ -640,9 +640,9 @@ test("sync_unit_tests") {
"internal_api/js_mutation_event_observer_unittest.cc",
"internal_api/js_sync_encryption_handler_observer_unittest.cc",
"internal_api/js_sync_manager_observer_unittest.cc",
- "internal_api/model_type_entity_unittest.cc",
"internal_api/model_type_store_backend_unittest.cc",
"internal_api/model_type_store_impl_unittest.cc",
+ "internal_api/processor_entity_tracker_unittest.cc",
"internal_api/protocol_event_buffer_unittest.cc",
"internal_api/public/base/attachment_id_proto_unittest.cc",
"internal_api/public/base/cancelation_signal_unittest.cc",
diff --git a/sync/engine/model_type_worker.cc b/sync/engine/model_type_worker.cc
index 8f58de2..1d55066 100644
--- a/sync/engine/model_type_worker.cc
+++ b/sync/engine/model_type_worker.cc
@@ -16,8 +16,8 @@
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "sync/engine/commit_contribution.h"
-#include "sync/engine/entity_tracker.h"
#include "sync/engine/non_blocking_type_commit_contribution.h"
+#include "sync/engine/worker_entity_tracker.h"
#include "sync/internal_api/public/model_type_processor.h"
#include "sync/syncable/syncable_util.h"
#include "sync/util/cryptographer.h"
@@ -134,11 +134,11 @@ SyncerError ModelTypeWorker::ProcessGetUpdatesResponse(
UpdateResponseData response_data;
response_data.response_version = update_entity->version();
- EntityTracker* entity_tracker = nullptr;
+ WorkerEntityTracker* entity_tracker = nullptr;
EntityMap::const_iterator map_it = entities_.find(client_tag_hash);
if (map_it == entities_.end()) {
- scoped_ptr<EntityTracker> scoped_entity_tracker =
- EntityTracker::FromUpdateResponse(response_data);
+ scoped_ptr<WorkerEntityTracker> scoped_entity_tracker =
+ WorkerEntityTracker::FromUpdateResponse(response_data);
entity_tracker = scoped_entity_tracker.get();
entities_.insert(
std::make_pair(client_tag_hash, std::move(scoped_entity_tracker)));
@@ -199,8 +199,8 @@ void ModelTypeWorker::ApplyUpdates(syncer::sessions::StatusController* status) {
data_type_state_.set_initial_sync_done(true);
- model_type_processor_->OnUpdateReceived(
- data_type_state_, UpdateResponseDataList());
+ model_type_processor_->OnUpdateReceived(data_type_state_,
+ UpdateResponseDataList());
}
}
@@ -242,7 +242,7 @@ scoped_ptr<CommitContribution> ModelTypeWorker::GetContribution(
// TODO(rlarocque): Avoid iterating here.
for (EntityMap::const_iterator it = entities_.begin();
it != entities_.end() && space_remaining > 0; ++it) {
- EntityTracker* entity = it->second.get();
+ WorkerEntityTracker* entity = it->second.get();
if (entity->HasPendingCommit()) {
sync_pb::SyncEntity* commit_entity = commit_entities.Add();
int64_t sequence_number = -1;
@@ -269,11 +269,11 @@ void ModelTypeWorker::StorePendingCommit(const CommitRequestData& request) {
DCHECK_EQ(type_, syncer::GetModelTypeFromSpecifics(data.specifics));
}
- EntityTracker* entity;
+ WorkerEntityTracker* entity;
EntityMap::const_iterator map_it = entities_.find(data.client_tag_hash);
if (map_it == entities_.end()) {
- scoped_ptr<EntityTracker> scoped_entity =
- EntityTracker::FromCommitRequest(request);
+ scoped_ptr<WorkerEntityTracker> scoped_entity =
+ WorkerEntityTracker::FromCommitRequest(request);
entity = scoped_entity.get();
entities_.insert(
std::make_pair(data.client_tag_hash, std::move(scoped_entity)));
@@ -299,7 +299,7 @@ void ModelTypeWorker::OnCommitResponse(
continue;
}
- EntityTracker* entity = map_it->second.get();
+ WorkerEntityTracker* entity = map_it->second.get();
entity->ReceiveCommitResponse(response_it->id,
response_it->response_version,
response_it->sequence_number);
diff --git a/sync/engine/model_type_worker.h b/sync/engine/model_type_worker.h
index 61e4b6e..34fc38f 100644
--- a/sync/engine/model_type_worker.h
+++ b/sync/engine/model_type_worker.h
@@ -32,7 +32,7 @@ class SingleThreadTaskRunner;
namespace syncer_v2 {
class ModelTypeProcessor;
-class EntityTracker;
+class WorkerEntityTracker;
// A smart cache for sync types that use message passing (rather than
// transactions and the syncable::Directory) to communicate with the sync
@@ -96,7 +96,7 @@ class SYNC_EXPORT ModelTypeWorker : public syncer::UpdateHandler,
base::WeakPtr<ModelTypeWorker> AsWeakPtr();
private:
- using EntityMap = std::map<std::string, scoped_ptr<EntityTracker>>;
+ using EntityMap = std::map<std::string, scoped_ptr<WorkerEntityTracker>>;
// Stores a single commit request in this object's internal state.
void StorePendingCommit(const CommitRequestData& request);
@@ -112,13 +112,13 @@ class SYNC_EXPORT ModelTypeWorker : public syncer::UpdateHandler,
bool CanCommitItems() const;
// Initializes the parts of a commit entity that are the responsibility of
- // this class, and not the EntityTracker. Some fields, like the
+ // this class, and not the WorkerEntityTracker. Some fields, like the
// client-assigned ID, can only be set by an entity with knowledge of the
// entire data type's state.
void HelpInitializeCommitEntity(sync_pb::SyncEntity* commit_entity);
// Attempts to decrypt pending updates stored in the EntityMap. If
- // successful, will remove the update from the its EntityTracker and forward
+ // successful, will remove the update from the its tracker and forward
// it to the proxy thread for application. Will forward any new encryption
// keys to the proxy to trigger re-encryption if necessary.
void OnCryptographerUpdated();
diff --git a/sync/engine/entity_tracker.cc b/sync/engine/worker_entity_tracker.cc
index a209c09..33ab384 100644
--- a/sync/engine/entity_tracker.cc
+++ b/sync/engine/worker_entity_tracker.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "sync/engine/entity_tracker.h"
+#include "sync/engine/worker_entity_tracker.h"
#include <stdint.h>
@@ -14,22 +14,23 @@
namespace syncer_v2 {
-scoped_ptr<EntityTracker> EntityTracker::FromUpdateResponse(
+scoped_ptr<WorkerEntityTracker> WorkerEntityTracker::FromUpdateResponse(
const UpdateResponseData& data) {
- return make_scoped_ptr(new EntityTracker(
+ return make_scoped_ptr(new WorkerEntityTracker(
data.entity->id, data.entity->client_tag_hash, 0, data.response_version));
}
-scoped_ptr<EntityTracker> EntityTracker::FromCommitRequest(
+scoped_ptr<WorkerEntityTracker> WorkerEntityTracker::FromCommitRequest(
const CommitRequestData& data) {
- return make_scoped_ptr(
- new EntityTracker(data.entity->id, data.entity->client_tag_hash, 0, 0));
+ return make_scoped_ptr(new WorkerEntityTracker(
+ data.entity->id, data.entity->client_tag_hash, 0, 0));
}
-EntityTracker::EntityTracker(const std::string& id,
- const std::string& client_tag_hash,
- int64_t highest_commit_response_version,
- int64_t highest_gu_response_version)
+WorkerEntityTracker::WorkerEntityTracker(
+ const std::string& id,
+ const std::string& client_tag_hash,
+ int64_t highest_commit_response_version,
+ int64_t highest_gu_response_version)
: id_(id),
client_tag_hash_(client_tag_hash),
highest_commit_response_version_(highest_commit_response_version),
@@ -37,14 +38,14 @@ EntityTracker::EntityTracker(const std::string& id,
sequence_number_(0),
base_version_(kUncommittedVersion) {}
-EntityTracker::~EntityTracker() {}
+WorkerEntityTracker::~WorkerEntityTracker() {}
-bool EntityTracker::HasPendingCommit() const {
+bool WorkerEntityTracker::HasPendingCommit() const {
return !!pending_commit_;
}
-void EntityTracker::PrepareCommitProto(sync_pb::SyncEntity* commit_entity,
- int64_t* sequence_number) const {
+void WorkerEntityTracker::PrepareCommitProto(sync_pb::SyncEntity* commit_entity,
+ int64_t* sequence_number) const {
DCHECK(HasPendingCommit());
DCHECK(!client_tag_hash_.empty());
@@ -73,7 +74,7 @@ void EntityTracker::PrepareCommitProto(sync_pb::SyncEntity* commit_entity,
*sequence_number = sequence_number_;
}
-void EntityTracker::RequestCommit(const CommitRequestData& data) {
+void WorkerEntityTracker::RequestCommit(const CommitRequestData& data) {
DCHECK_GE(data.base_version, base_version_)
<< "Base version should never decrease";
@@ -116,9 +117,9 @@ void EntityTracker::RequestCommit(const CommitRequestData& data) {
// so it can be committed at the next possible opportunity.
}
-void EntityTracker::ReceiveCommitResponse(const std::string& response_id,
- int64_t response_version,
- int64_t sequence_number) {
+void WorkerEntityTracker::ReceiveCommitResponse(const std::string& response_id,
+ int64_t response_version,
+ int64_t sequence_number) {
// Commit responses, especially after the first commit, can update our ID.
id_ = response_id;
@@ -141,7 +142,7 @@ void EntityTracker::ReceiveCommitResponse(const std::string& response_id,
ClearPendingCommit();
}
-void EntityTracker::ReceiveUpdate(int64_t version) {
+void WorkerEntityTracker::ReceiveUpdate(int64_t version) {
if (version <= highest_gu_response_version_)
return;
@@ -158,7 +159,7 @@ void EntityTracker::ReceiveUpdate(int64_t version) {
}
}
-bool EntityTracker::ReceivePendingUpdate(const UpdateResponseData& data) {
+bool WorkerEntityTracker::ReceivePendingUpdate(const UpdateResponseData& data) {
if (data.response_version < highest_gu_response_version_)
return false;
@@ -168,19 +169,19 @@ bool EntityTracker::ReceivePendingUpdate(const UpdateResponseData& data) {
return true;
}
-bool EntityTracker::HasPendingUpdate() const {
+bool WorkerEntityTracker::HasPendingUpdate() const {
return !!pending_update_;
}
-UpdateResponseData EntityTracker::GetPendingUpdate() const {
+UpdateResponseData WorkerEntityTracker::GetPendingUpdate() const {
return *pending_update_;
}
-void EntityTracker::ClearPendingUpdate() {
+void WorkerEntityTracker::ClearPendingUpdate() {
pending_update_.reset();
}
-bool EntityTracker::IsInConflict() const {
+bool WorkerEntityTracker::IsInConflict() const {
if (!HasPendingCommit())
return false;
@@ -203,11 +204,11 @@ bool EntityTracker::IsInConflict() const {
}
}
-bool EntityTracker::IsServerKnown() const {
+bool WorkerEntityTracker::IsServerKnown() const {
return base_version_ != kUncommittedVersion;
}
-void EntityTracker::ClearPendingCommit() {
+void WorkerEntityTracker::ClearPendingCommit() {
pending_commit_.reset();
}
diff --git a/sync/engine/entity_tracker.h b/sync/engine/worker_entity_tracker.h
index e0e66f6..5f413e0 100644
--- a/sync/engine/entity_tracker.h
+++ b/sync/engine/worker_entity_tracker.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef SYNC_ENGINE_ENTITY_TRACKER_H_
-#define SYNC_ENGINE_ENTITY_TRACKER_H_
+#ifndef SYNC_ENGINE_WORKER_ENTITY_TRACKER_H_
+#define SYNC_ENGINE_WORKER_ENTITY_TRACKER_H_
#include <stdint.h>
@@ -31,16 +31,16 @@ struct UpdateResponseData;
//
// This object may contain state associated with a pending commit, pending
// update, or both.
-class SYNC_EXPORT EntityTracker {
+class SYNC_EXPORT WorkerEntityTracker {
public:
- ~EntityTracker();
+ ~WorkerEntityTracker();
// Initialize a new entity based on an update response.
- static scoped_ptr<EntityTracker> FromUpdateResponse(
+ static scoped_ptr<WorkerEntityTracker> FromUpdateResponse(
const UpdateResponseData& data);
// Initialize a new entity based on a commit request.
- static scoped_ptr<EntityTracker> FromCommitRequest(
+ static scoped_ptr<WorkerEntityTracker> FromCommitRequest(
const CommitRequestData& data);
// Returns true if this entity should be commited to the server.
@@ -85,10 +85,10 @@ class SYNC_EXPORT EntityTracker {
private:
// Initializes the entity tracker's main fields. Does not initialize state
// related to a pending commit.
- EntityTracker(const std::string& id,
- const std::string& client_tag_hash,
- int64_t highest_commit_response_version,
- int64_t highest_gu_response_version);
+ WorkerEntityTracker(const std::string& id,
+ const std::string& client_tag_hash,
+ int64_t highest_commit_response_version,
+ int64_t highest_gu_response_version);
// Checks if the current state indicates a conflict.
//
@@ -130,9 +130,9 @@ class SYNC_EXPORT EntityTracker {
// source of pending updates is updates that can't currently be decrypted.
scoped_ptr<UpdateResponseData> pending_update_;
- DISALLOW_COPY_AND_ASSIGN(EntityTracker);
+ DISALLOW_COPY_AND_ASSIGN(WorkerEntityTracker);
};
} // namespace syncer_v2
-#endif // SYNC_ENGINE_ENTITY_TRACKER_H_
+#endif // SYNC_ENGINE_WORKER_ENTITY_TRACKER_H_
diff --git a/sync/engine/entity_tracker_unittest.cc b/sync/engine/worker_entity_tracker_unittest.cc
index 6ba3222..8a30b6a 100644
--- a/sync/engine/entity_tracker_unittest.cc
+++ b/sync/engine/worker_entity_tracker_unittest.cc
@@ -3,7 +3,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "sync/engine/entity_tracker.h"
+#include "sync/engine/worker_entity_tracker.h"
#include <stdint.h>
@@ -17,17 +17,17 @@
namespace syncer_v2 {
-// Some simple tests for the EntityTracker.
+// Some simple tests for the WorkerEntityTracker.
//
-// The EntityTracker is an implementation detail of the ModelTypeWorker.
+// The WorkerEntityTracker is an implementation detail of the ModelTypeWorker.
// As such, it doesn't make much sense to test it exhaustively, since it
// already gets a lot of test coverage from the ModelTypeWorker unit tests.
//
// These tests are intended as a basic sanity check. Anything more complicated
// would be redundant.
-class EntityTrackerTest : public ::testing::Test {
+class WorkerEntityTrackerTest : public ::testing::Test {
public:
- EntityTrackerTest()
+ WorkerEntityTrackerTest()
: kServerId("ServerID"),
kClientTag("some.sample.tag"),
kClientTagHash(
@@ -39,7 +39,7 @@ class EntityTrackerTest : public ::testing::Test {
specifics.mutable_preference()->set_value("pref.value");
}
- ~EntityTrackerTest() override {}
+ ~WorkerEntityTrackerTest() override {}
CommitRequestData MakeCommitRequestData(int64_t sequence_number,
int64_t base_version) {
@@ -78,9 +78,9 @@ class EntityTrackerTest : public ::testing::Test {
};
// Construct a new entity from a server update. Then receive another update.
-TEST_F(EntityTrackerTest, FromUpdateResponse) {
- scoped_ptr<EntityTracker> entity(
- EntityTracker::FromUpdateResponse(MakeUpdateResponseData(10)));
+TEST_F(WorkerEntityTrackerTest, FromUpdateResponse) {
+ scoped_ptr<WorkerEntityTracker> entity(
+ WorkerEntityTracker::FromUpdateResponse(MakeUpdateResponseData(10)));
EXPECT_FALSE(entity->HasPendingCommit());
entity->ReceiveUpdate(20);
@@ -88,11 +88,12 @@ TEST_F(EntityTrackerTest, FromUpdateResponse) {
}
// Construct a new entity from a commit request. Then serialize it.
-TEST_F(EntityTrackerTest, FromCommitRequest) {
+TEST_F(WorkerEntityTrackerTest, FromCommitRequest) {
const int64_t kSequenceNumber = 22;
const int64_t kBaseVersion = 33;
CommitRequestData data = MakeCommitRequestData(kSequenceNumber, kBaseVersion);
- scoped_ptr<EntityTracker> entity(EntityTracker::FromCommitRequest(data));
+ scoped_ptr<WorkerEntityTracker> entity(
+ WorkerEntityTracker::FromCommitRequest(data));
entity->RequestCommit(data);
ASSERT_TRUE(entity->HasPendingCommit());
@@ -113,9 +114,9 @@ TEST_F(EntityTrackerTest, FromCommitRequest) {
}
// Start with a server initiated entity. Commit over top of it.
-TEST_F(EntityTrackerTest, RequestCommit) {
- scoped_ptr<EntityTracker> entity(
- EntityTracker::FromUpdateResponse(MakeUpdateResponseData(10)));
+TEST_F(WorkerEntityTrackerTest, RequestCommit) {
+ scoped_ptr<WorkerEntityTracker> entity(
+ WorkerEntityTracker::FromUpdateResponse(MakeUpdateResponseData(10)));
entity->RequestCommit(MakeCommitRequestData(1, 10));
@@ -124,9 +125,9 @@ TEST_F(EntityTrackerTest, RequestCommit) {
// Start with a server initiated entity. Fail to request a commit because of
// an out of date base version.
-TEST_F(EntityTrackerTest, RequestCommitFailure) {
- scoped_ptr<EntityTracker> entity(
- EntityTracker::FromUpdateResponse(MakeUpdateResponseData(10)));
+TEST_F(WorkerEntityTrackerTest, RequestCommitFailure) {
+ scoped_ptr<WorkerEntityTracker> entity(
+ WorkerEntityTracker::FromUpdateResponse(MakeUpdateResponseData(10)));
EXPECT_FALSE(entity->HasPendingCommit());
entity->RequestCommit(MakeCommitRequestData(23, 5 /* base_version 5 < 10 */));
@@ -134,9 +135,10 @@ TEST_F(EntityTrackerTest, RequestCommitFailure) {
}
// Start with a pending commit. Clobber it with an incoming update.
-TEST_F(EntityTrackerTest, UpdateClobbersCommit) {
+TEST_F(WorkerEntityTrackerTest, UpdateClobbersCommit) {
CommitRequestData data = MakeCommitRequestData(22, 33);
- scoped_ptr<EntityTracker> entity(EntityTracker::FromCommitRequest(data));
+ scoped_ptr<WorkerEntityTracker> entity(
+ WorkerEntityTracker::FromCommitRequest(data));
entity->RequestCommit(data);
EXPECT_TRUE(entity->HasPendingCommit());
@@ -147,9 +149,10 @@ TEST_F(EntityTrackerTest, UpdateClobbersCommit) {
// Start with a pending commit. Send it a reflected update that
// will not override the in-progress commit.
-TEST_F(EntityTrackerTest, ReflectedUpdateDoesntClobberCommit) {
+TEST_F(WorkerEntityTrackerTest, ReflectedUpdateDoesntClobberCommit) {
CommitRequestData data = MakeCommitRequestData(22, 33);
- scoped_ptr<EntityTracker> entity(EntityTracker::FromCommitRequest(data));
+ scoped_ptr<WorkerEntityTracker> entity(
+ WorkerEntityTracker::FromCommitRequest(data));
entity->RequestCommit(data);
EXPECT_TRUE(entity->HasPendingCommit());
diff --git a/sync/internal_api/model_type_entity.cc b/sync/internal_api/processor_entity_tracker.cc
index d73a8f6..87c400c 100644
--- a/sync/internal_api/model_type_entity.cc
+++ b/sync/internal_api/processor_entity_tracker.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "sync/internal_api/public/model_type_entity.h"
+#include "sync/internal_api/public/processor_entity_tracker.h"
#include <stdint.h>
@@ -15,7 +15,7 @@
namespace syncer_v2 {
-scoped_ptr<ModelTypeEntity> ModelTypeEntity::CreateNew(
+scoped_ptr<ProcessorEntityTracker> ProcessorEntityTracker::CreateNew(
const std::string& client_tag,
const std::string& client_tag_hash,
const std::string& id,
@@ -30,18 +30,20 @@ scoped_ptr<ModelTypeEntity> ModelTypeEntity::CreateNew(
metadata.set_server_version(kUncommittedVersion);
metadata.set_creation_time(syncer::TimeToProtoTime(creation_time));
- return scoped_ptr<ModelTypeEntity>(
- new ModelTypeEntity(client_tag, &metadata));
+ return scoped_ptr<ProcessorEntityTracker>(
+ new ProcessorEntityTracker(client_tag, &metadata));
}
-scoped_ptr<ModelTypeEntity> ModelTypeEntity::CreateFromMetadata(
+scoped_ptr<ProcessorEntityTracker> ProcessorEntityTracker::CreateFromMetadata(
const std::string& client_tag,
sync_pb::EntityMetadata* metadata) {
- return scoped_ptr<ModelTypeEntity>(new ModelTypeEntity(client_tag, metadata));
+ return scoped_ptr<ProcessorEntityTracker>(
+ new ProcessorEntityTracker(client_tag, metadata));
}
-ModelTypeEntity::ModelTypeEntity(const std::string& client_tag,
- sync_pb::EntityMetadata* metadata)
+ProcessorEntityTracker::ProcessorEntityTracker(
+ const std::string& client_tag,
+ sync_pb::EntityMetadata* metadata)
: client_tag_(client_tag),
commit_requested_sequence_number_(metadata->acked_sequence_number()) {
DCHECK(metadata->has_client_tag_hash());
@@ -49,9 +51,9 @@ ModelTypeEntity::ModelTypeEntity(const std::string& client_tag,
metadata_.Swap(metadata);
}
-ModelTypeEntity::~ModelTypeEntity() {}
+ProcessorEntityTracker::~ProcessorEntityTracker() {}
-void ModelTypeEntity::CacheCommitData(EntityData* data) {
+void ProcessorEntityTracker::CacheCommitData(EntityData* data) {
DCHECK(RequiresCommitRequest());
if (data->client_tag_hash.empty()) {
data->client_tag_hash = metadata_.client_tag_hash();
@@ -60,31 +62,31 @@ void ModelTypeEntity::CacheCommitData(EntityData* data) {
DCHECK(HasCommitData());
}
-bool ModelTypeEntity::HasCommitData() const {
+bool ProcessorEntityTracker::HasCommitData() const {
return !commit_data_->client_tag_hash.empty();
}
-bool ModelTypeEntity::IsUnsynced() const {
+bool ProcessorEntityTracker::IsUnsynced() const {
return metadata_.sequence_number() > metadata_.acked_sequence_number();
}
-bool ModelTypeEntity::RequiresCommitRequest() const {
+bool ProcessorEntityTracker::RequiresCommitRequest() const {
return metadata_.sequence_number() > commit_requested_sequence_number_;
}
-bool ModelTypeEntity::RequiresCommitData() const {
+bool ProcessorEntityTracker::RequiresCommitData() const {
return RequiresCommitRequest() && !HasCommitData() && !metadata_.is_deleted();
}
-bool ModelTypeEntity::UpdateIsReflection(int64_t update_version) const {
+bool ProcessorEntityTracker::UpdateIsReflection(int64_t update_version) const {
return metadata_.server_version() >= update_version;
}
-bool ModelTypeEntity::UpdateIsInConflict(int64_t update_version) const {
+bool ProcessorEntityTracker::UpdateIsInConflict(int64_t update_version) const {
return IsUnsynced() && !UpdateIsReflection(update_version);
}
-void ModelTypeEntity::ApplyUpdateFromServer(
+void ProcessorEntityTracker::ApplyUpdateFromServer(
const UpdateResponseData& response_data) {
DCHECK(metadata_.has_client_tag_hash());
DCHECK(!metadata_.client_tag_hash().empty());
@@ -109,7 +111,7 @@ void ModelTypeEntity::ApplyUpdateFromServer(
encryption_key_name_ = response_data.encryption_key_name;
}
-void ModelTypeEntity::MakeLocalChange(scoped_ptr<EntityData> data) {
+void ProcessorEntityTracker::MakeLocalChange(scoped_ptr<EntityData> data) {
DCHECK(!metadata_.client_tag_hash().empty());
DCHECK_EQ(metadata_.client_tag_hash(), data->client_tag_hash);
DCHECK(!data->modification_time.is_null());
@@ -125,7 +127,8 @@ void ModelTypeEntity::MakeLocalChange(scoped_ptr<EntityData> data) {
CacheCommitData(data.get());
}
-void ModelTypeEntity::UpdateDesiredEncryptionKey(const std::string& name) {
+void ProcessorEntityTracker::UpdateDesiredEncryptionKey(
+ const std::string& name) {
if (encryption_key_name_ == name)
return;
@@ -138,15 +141,17 @@ void ModelTypeEntity::UpdateDesiredEncryptionKey(const std::string& name) {
IncrementSequenceNumber();
}
-void ModelTypeEntity::Delete() {
+void ProcessorEntityTracker::Delete() {
IncrementSequenceNumber();
metadata_.set_is_deleted(true);
metadata_.clear_specifics_hash();
// Clear any cached pending commit data.
- if (HasCommitData()) commit_data_.reset();
+ if (HasCommitData())
+ commit_data_.reset();
}
-void ModelTypeEntity::InitializeCommitRequestData(CommitRequestData* request) {
+void ProcessorEntityTracker::InitializeCommitRequestData(
+ CommitRequestData* request) {
if (!metadata_.is_deleted()) {
DCHECK(HasCommitData());
DCHECK_EQ(commit_data_->client_tag_hash, metadata_.client_tag_hash());
@@ -166,7 +171,7 @@ void ModelTypeEntity::InitializeCommitRequestData(CommitRequestData* request) {
commit_requested_sequence_number_ = metadata_.sequence_number();
}
-void ModelTypeEntity::ReceiveCommitResponse(
+void ProcessorEntityTracker::ReceiveCommitResponse(
const std::string& id,
int64_t sequence_number,
int64_t response_version,
@@ -178,19 +183,19 @@ void ModelTypeEntity::ReceiveCommitResponse(
encryption_key_name_ = encryption_key_name;
}
-void ModelTypeEntity::ClearTransientSyncState() {
+void ProcessorEntityTracker::ClearTransientSyncState() {
// If we have any unacknowledged commit requests outstanding, they've been
// dropped and we should forget about them.
commit_requested_sequence_number_ = metadata_.acked_sequence_number();
}
-void ModelTypeEntity::IncrementSequenceNumber() {
+void ProcessorEntityTracker::IncrementSequenceNumber() {
DCHECK(metadata_.has_sequence_number());
metadata_.set_sequence_number(metadata_.sequence_number() + 1);
}
// Update hash string for EntitySpecifics.
-void ModelTypeEntity::UpdateSpecificsHash(
+void ProcessorEntityTracker::UpdateSpecificsHash(
const sync_pb::EntitySpecifics& specifics) {
if (specifics.ByteSize() > 0) {
std::string hash_input;
diff --git a/sync/internal_api/model_type_entity_unittest.cc b/sync/internal_api/processor_entity_tracker_unittest.cc
index 6f2856c..0ccbea6 100644
--- a/sync/internal_api/model_type_entity_unittest.cc
+++ b/sync/internal_api/processor_entity_tracker_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "sync/internal_api/public/model_type_entity.h"
+#include "sync/internal_api/public/processor_entity_tracker.h"
#include <stdint.h>
#include <utility>
@@ -17,18 +17,18 @@
namespace syncer_v2 {
-// Some simple sanity tests for the ModelTypeEntity.
+// Some simple sanity tests for the ProcessorEntityTracker.
//
// A lot of the more complicated sync logic is implemented in the
-// SharedModelTypeProcessor that owns the ModelTypeEntity. We can't unit test
-// it here.
+// SharedModelTypeProcessor that owns the ProcessorEntityTracker. We can't unit
+// test it here.
//
// Instead, we focus on simple tests to make sure that variables are getting
// properly intialized and flags properly set. Anything more complicated would
// be a redundant and incomplete version of the SharedModelTypeProcessor tests.
-class ModelTypeEntityTest : public ::testing::Test {
+class ProcessorEntityTrackerTest : public ::testing::Test {
public:
- ModelTypeEntityTest()
+ ProcessorEntityTrackerTest()
: kServerId("ServerID"),
kClientTag("sample.pref.name"),
kClientTagHash(GetSyncableHash(kClientTag)),
@@ -44,20 +44,20 @@ class ModelTypeEntityTest : public ::testing::Test {
return syncer::syncable::GenerateSyncableHash(syncer::PREFERENCES, tag);
}
- scoped_ptr<ModelTypeEntity> NewLocalItem(const std::string& tag) {
- return scoped_ptr<ModelTypeEntity>(
- ModelTypeEntity::CreateNew(tag, GetSyncableHash(tag), "", kCtime));
+ scoped_ptr<ProcessorEntityTracker> NewLocalItem(const std::string& tag) {
+ return scoped_ptr<ProcessorEntityTracker>(ProcessorEntityTracker::CreateNew(
+ tag, GetSyncableHash(tag), "", kCtime));
}
- scoped_ptr<ModelTypeEntity> NewLocalItem(
+ scoped_ptr<ProcessorEntityTracker> NewLocalItem(
const std::string& tag,
const sync_pb::EntitySpecifics& specifics) {
- scoped_ptr<ModelTypeEntity> entity(NewLocalItem(tag));
+ scoped_ptr<ProcessorEntityTracker> entity(NewLocalItem(tag));
MakeLocalChange(entity.get(), specifics);
return entity;
}
- void MakeLocalChange(ModelTypeEntity* entity,
+ void MakeLocalChange(ProcessorEntityTracker* entity,
const sync_pb::EntitySpecifics& specifics) {
scoped_ptr<EntityData> entity_data = make_scoped_ptr(new EntityData());
entity_data->client_tag_hash = entity->metadata().client_tag_hash();
@@ -67,26 +67,26 @@ class ModelTypeEntityTest : public ::testing::Test {
entity->MakeLocalChange(std::move(entity_data));
}
- scoped_ptr<ModelTypeEntity> NewServerItem() {
- return scoped_ptr<ModelTypeEntity>(ModelTypeEntity::CreateNew(
+ scoped_ptr<ProcessorEntityTracker> NewServerItem() {
+ return scoped_ptr<ProcessorEntityTracker>(ProcessorEntityTracker::CreateNew(
kClientTag, kClientTagHash, kServerId, kCtime));
}
- scoped_ptr<ModelTypeEntity> NewServerItem(
+ scoped_ptr<ProcessorEntityTracker> NewServerItem(
int64_t version,
const sync_pb::EntitySpecifics& specifics) {
- scoped_ptr<ModelTypeEntity> entity(NewServerItem());
+ scoped_ptr<ProcessorEntityTracker> entity(NewServerItem());
ApplyUpdateFromServer(entity.get(), version, specifics);
return entity;
}
- void ApplyUpdateFromServer(ModelTypeEntity* entity,
+ void ApplyUpdateFromServer(ProcessorEntityTracker* entity,
int64_t version,
const sync_pb::EntitySpecifics& specifics) {
ApplyUpdateFromServer(entity, version, specifics, kMtime);
}
- void ApplyUpdateFromServer(ModelTypeEntity* entity,
+ void ApplyUpdateFromServer(ProcessorEntityTracker* entity,
int64_t version,
const sync_pb::EntitySpecifics& specifics,
base::Time mtime) {
@@ -103,7 +103,8 @@ class ModelTypeEntityTest : public ::testing::Test {
entity->ApplyUpdateFromServer(response_data);
}
- bool HasSpecificsHash(const scoped_ptr<ModelTypeEntity>& entity) const {
+ bool HasSpecificsHash(
+ const scoped_ptr<ProcessorEntityTracker>& entity) const {
return !entity->metadata().specifics_hash().empty();
}
@@ -115,8 +116,8 @@ class ModelTypeEntityTest : public ::testing::Test {
sync_pb::EntitySpecifics specifics;
};
-TEST_F(ModelTypeEntityTest, NewItem) {
- scoped_ptr<ModelTypeEntity> entity(NewLocalItem("asdf"));
+TEST_F(ProcessorEntityTrackerTest, NewItem) {
+ scoped_ptr<ProcessorEntityTracker> entity(NewLocalItem("asdf"));
EXPECT_EQ(entity->client_tag(), "asdf");
EXPECT_EQ(entity->metadata().client_tag_hash(), GetSyncableHash("asdf"));
@@ -129,8 +130,8 @@ TEST_F(ModelTypeEntityTest, NewItem) {
EXPECT_FALSE(entity->UpdateIsInConflict(1));
}
-TEST_F(ModelTypeEntityTest, NewLocalItem) {
- scoped_ptr<ModelTypeEntity> entity(NewLocalItem("asdf", specifics));
+TEST_F(ProcessorEntityTrackerTest, NewLocalItem) {
+ scoped_ptr<ProcessorEntityTracker> entity(NewLocalItem("asdf", specifics));
EXPECT_TRUE(entity->HasCommitData());
EXPECT_TRUE(HasSpecificsHash(entity));
@@ -139,8 +140,8 @@ TEST_F(ModelTypeEntityTest, NewLocalItem) {
EXPECT_TRUE(entity->UpdateIsInConflict(1));
}
-TEST_F(ModelTypeEntityTest, FromServerUpdate) {
- scoped_ptr<ModelTypeEntity> entity(NewServerItem());
+TEST_F(ProcessorEntityTrackerTest, FromServerUpdate) {
+ scoped_ptr<ProcessorEntityTracker> entity(NewServerItem());
EXPECT_EQ(entity->client_tag(), kClientTag);
EXPECT_EQ(entity->metadata().client_tag_hash(), kClientTagHash);
@@ -163,9 +164,9 @@ TEST_F(ModelTypeEntityTest, FromServerUpdate) {
// thing about them is that they don't have specifics, so it can be hard to
// detect their type. Fortunately, this class doesn't care about types in
// received updates.
-TEST_F(ModelTypeEntityTest, TombstoneUpdate) {
+TEST_F(ProcessorEntityTrackerTest, TombstoneUpdate) {
// Empty EntitySpecifics indicates tombstone update.
- scoped_ptr<ModelTypeEntity> entity(
+ scoped_ptr<ProcessorEntityTracker> entity(
NewServerItem(10, sync_pb::EntitySpecifics()));
EXPECT_EQ(kClientTagHash, entity->metadata().client_tag_hash());
@@ -180,9 +181,9 @@ TEST_F(ModelTypeEntityTest, TombstoneUpdate) {
}
// Apply a deletion update.
-TEST_F(ModelTypeEntityTest, ApplyUpdate) {
+TEST_F(ProcessorEntityTrackerTest, ApplyUpdate) {
// Start with a non-deleted state with version 10.
- scoped_ptr<ModelTypeEntity> entity(NewServerItem(10, specifics));
+ scoped_ptr<ProcessorEntityTracker> entity(NewServerItem(10, specifics));
EXPECT_TRUE(HasSpecificsHash(entity));
@@ -197,9 +198,9 @@ TEST_F(ModelTypeEntityTest, ApplyUpdate) {
EXPECT_FALSE(entity->UpdateIsReflection(12));
}
-TEST_F(ModelTypeEntityTest, LocalChange) {
+TEST_F(ProcessorEntityTrackerTest, LocalChange) {
// Start with a non-deleted state with version 10.
- scoped_ptr<ModelTypeEntity> entity(NewServerItem(10, specifics));
+ scoped_ptr<ProcessorEntityTracker> entity(NewServerItem(10, specifics));
std::string specifics_hash = entity->metadata().specifics_hash();
@@ -221,9 +222,9 @@ TEST_F(ModelTypeEntityTest, LocalChange) {
EXPECT_TRUE(entity->UpdateIsInConflict(11));
}
-TEST_F(ModelTypeEntityTest, LocalDeletion) {
+TEST_F(ProcessorEntityTrackerTest, LocalDeletion) {
// Start with a non-deleted state with version 10.
- scoped_ptr<ModelTypeEntity> entity(NewServerItem(10, specifics));
+ scoped_ptr<ProcessorEntityTracker> entity(NewServerItem(10, specifics));
EXPECT_TRUE(HasSpecificsHash(entity));
// Make a local delete.
@@ -241,10 +242,10 @@ TEST_F(ModelTypeEntityTest, LocalDeletion) {
EXPECT_TRUE(entity->UpdateIsInConflict(11));
}
-// Verify generation of CommitRequestData from ModelTypeEntity.
+// Verify generation of CommitRequestData from ProcessorEntityTracker.
// Verify that the sequence number increments on local changes.
-TEST_F(ModelTypeEntityTest, InitializeCommitRequestData) {
- scoped_ptr<ModelTypeEntity> entity(NewLocalItem(kClientTag));
+TEST_F(ProcessorEntityTrackerTest, InitializeCommitRequestData) {
+ scoped_ptr<ProcessorEntityTracker> entity(NewLocalItem(kClientTag));
MakeLocalChange(entity.get(), specifics);
CommitRequestData commit_request;
diff --git a/sync/internal_api/public/model_type_entity.h b/sync/internal_api/public/processor_entity_tracker.h
index 733a148..a3c1d00 100644
--- a/sync/internal_api/public/model_type_entity.h
+++ b/sync/internal_api/public/processor_entity_tracker.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef SYNC_INTERNAL_API_PUBLIC_MODEL_TYPE_ENTITY_H_
-#define SYNC_INTERNAL_API_PUBLIC_MODEL_TYPE_ENTITY_H_
+#ifndef SYNC_INTERNAL_API_PUBLIC_PROCESSOR_ENTITY_TRACKER_H_
+#define SYNC_INTERNAL_API_PUBLIC_PROCESSOR_ENTITY_TRACKER_H_
#include <stdint.h>
@@ -19,17 +19,14 @@ namespace syncer_v2 {
struct CommitRequestData;
struct UpdateResponseData;
-// This is the model thread's representation of a sync entity which is used
-// to cache entity data and metadata in SharedModelTypeProcessor.
-//
-// The metadata part of ModelTypeEntity is loaded on Sync startup and is always
-// present. The data part of ModelTypeEntity is cached temporarily, only for
-// in-flight entities that are being committed to the server.
-//
-class SYNC_EXPORT ModelTypeEntity {
+// This class is used by the SharedModelTypeProcessor to track the state of each
+// entity with its type. It can be considered a helper class internal to the
+// processor. It manages the metadata for its entity and caches entity data
+// upon a local change until commit confirmation is received.
+class SYNC_EXPORT ProcessorEntityTracker {
public:
// Construct an instance representing a new locally-created item.
- static scoped_ptr<ModelTypeEntity> CreateNew(
+ static scoped_ptr<ProcessorEntityTracker> CreateNew(
const std::string& client_tag,
const std::string& client_tag_hash,
const std::string& id,
@@ -37,11 +34,11 @@ class SYNC_EXPORT ModelTypeEntity {
// Construct an instance representing an item loaded from storage on init.
// This method swaps out the contents of |metadata|.
- static scoped_ptr<ModelTypeEntity> CreateFromMetadata(
+ static scoped_ptr<ProcessorEntityTracker> CreateFromMetadata(
const std::string& client_tag,
sync_pb::EntityMetadata* metadata);
- ~ModelTypeEntity();
+ ~ProcessorEntityTracker();
// Returns entity's client tag.
const std::string& client_tag() const { return client_tag_; }
@@ -115,11 +112,11 @@ class SYNC_EXPORT ModelTypeEntity {
bool HasCommitData() const;
private:
- friend class ModelTypeEntityTest;
+ friend class ProcessorEntityTrackerTest;
// The constructor swaps the data from the passed metadata.
- ModelTypeEntity(const std::string& client_tag,
- sync_pb::EntityMetadata* metadata);
+ ProcessorEntityTracker(const std::string& client_tag,
+ sync_pb::EntityMetadata* metadata);
// Increment sequence number in the metadata.
void IncrementSequenceNumber();
@@ -148,4 +145,4 @@ class SYNC_EXPORT ModelTypeEntity {
} // namespace syncer_v2
-#endif // SYNC_INTERNAL_API_PUBLIC_MODEL_TYPE_ENTITY_H_
+#endif // SYNC_INTERNAL_API_PUBLIC_PROCESSOR_ENTITY_TRACKER_H_
diff --git a/sync/internal_api/public/shared_model_type_processor.h b/sync/internal_api/public/shared_model_type_processor.h
index 7ca4572..db20870 100644
--- a/sync/internal_api/public/shared_model_type_processor.h
+++ b/sync/internal_api/public/shared_model_type_processor.h
@@ -27,7 +27,7 @@
namespace syncer_v2 {
struct ActivationContext;
class CommitQueue;
-class ModelTypeEntity;
+class ProcessorEntityTracker;
// A sync component embedded on the synced type's thread that helps to handle
// communication between sync and model type threads.
@@ -87,7 +87,7 @@ class SYNC_EXPORT SharedModelTypeProcessor : public ModelTypeProcessor,
private:
friend class SharedModelTypeProcessorTest;
- using EntityMap = std::map<std::string, scoped_ptr<ModelTypeEntity>>;
+ using EntityMap = std::map<std::string, scoped_ptr<ProcessorEntityTracker>>;
using UpdateMap = std::map<std::string, scoped_ptr<UpdateResponseData>>;
// Callback for ModelTypeService::GetData(). Used when we need to load data
@@ -108,17 +108,18 @@ class SYNC_EXPORT SharedModelTypeProcessor : public ModelTypeProcessor,
std::string GetHashForTag(const std::string& tag);
// Gets the entity for the given tag, or null if there isn't one.
- ModelTypeEntity* GetEntityForTag(const std::string& tag);
+ ProcessorEntityTracker* GetEntityForTag(const std::string& tag);
// Gets the entity for the given tag hash, or null if there isn't one.
- ModelTypeEntity* GetEntityForTagHash(const std::string& tag_hash);
+ ProcessorEntityTracker* GetEntityForTagHash(const std::string& tag_hash);
// Create an entity in the entity map for |tag| and return a pointer to it.
// Requires that no entity for |tag| already exists in the map.
- ModelTypeEntity* CreateEntity(const std::string& tag, const EntityData& data);
+ ProcessorEntityTracker* CreateEntity(const std::string& tag,
+ const EntityData& data);
// Version of the above that generates a tag for |data|.
- ModelTypeEntity* CreateEntity(const EntityData& data);
+ ProcessorEntityTracker* CreateEntity(const EntityData& data);
syncer::ModelType type_;
sync_pb::DataTypeState data_type_state_;
diff --git a/sync/internal_api/public/util/proto_value_ptr.h b/sync/internal_api/public/util/proto_value_ptr.h
index 164f2db..0ac9db7 100644
--- a/sync/internal_api/public/util/proto_value_ptr.h
+++ b/sync/internal_api/public/util/proto_value_ptr.h
@@ -10,7 +10,7 @@
namespace syncer_v2 {
struct EntityData;
-class ModelTypeEntity;
+class ProcessorEntityTracker;
} // namespace syncer_v2
namespace syncer {
@@ -92,7 +92,7 @@ class ProtoValuePtr {
private:
friend struct syncable::EntryKernel;
friend struct syncer_v2::EntityData;
- friend class syncer_v2::ModelTypeEntity;
+ friend class syncer_v2::ProcessorEntityTracker;
FRIEND_TEST_ALL_PREFIXES(ProtoValuePtrTest, ValueAssignment);
FRIEND_TEST_ALL_PREFIXES(ProtoValuePtrTest, ValueSwap);
FRIEND_TEST_ALL_PREFIXES(ProtoValuePtrTest, SharingTest);
diff --git a/sync/internal_api/shared_model_type_processor.cc b/sync/internal_api/shared_model_type_processor.cc
index 757e12d..93fcdac 100644
--- a/sync/internal_api/shared_model_type_processor.cc
+++ b/sync/internal_api/shared_model_type_processor.cc
@@ -12,7 +12,7 @@
#include "base/thread_task_runner_handle.h"
#include "sync/engine/commit_queue.h"
#include "sync/internal_api/public/activation_context.h"
-#include "sync/internal_api/public/model_type_entity.h"
+#include "sync/internal_api/public/processor_entity_tracker.h"
#include "sync/syncable/syncable_util.h"
namespace syncer_v2 {
@@ -105,8 +105,8 @@ void SharedModelTypeProcessor::OnMetadataLoaded(
std::vector<std::string> entities_to_commit;
for (auto it = metadata_map.begin(); it != metadata_map.end(); it++) {
- scoped_ptr<ModelTypeEntity> entity =
- ModelTypeEntity::CreateFromMetadata(it->first, &it->second);
+ scoped_ptr<ProcessorEntityTracker> entity =
+ ProcessorEntityTracker::CreateFromMetadata(it->first, &it->second);
if (entity->RequiresCommitData()) {
entities_to_commit.push_back(entity->client_tag());
}
@@ -133,7 +133,7 @@ void SharedModelTypeProcessor::OnDataLoaded(syncer::SyncError error,
scoped_ptr<DataBatch> data_batch) {
while (data_batch->HasNext()) {
TagAndData data = data_batch->Next();
- ModelTypeEntity* entity = GetEntityForTag(data.first);
+ ProcessorEntityTracker* entity = GetEntityForTag(data.first);
// If the entity wasn't deleted or updated with new commit.
if (entity != nullptr && entity->RequiresCommitData()) {
entity->CacheCommitData(data.second.get());
@@ -233,7 +233,7 @@ void SharedModelTypeProcessor::Put(const std::string& tag,
data->modification_time = base::Time::Now();
}
- ModelTypeEntity* entity = GetEntityForTagHash(data->client_tag_hash);
+ ProcessorEntityTracker* entity = GetEntityForTagHash(data->client_tag_hash);
if (entity == nullptr) {
// The service is creating a new entity.
@@ -261,7 +261,7 @@ void SharedModelTypeProcessor::Delete(
return;
}
- ModelTypeEntity* entity = GetEntityForTag(tag);
+ ProcessorEntityTracker* entity = GetEntityForTag(tag);
if (entity == nullptr) {
// That's unusual, but not necessarily a bad thing.
// Missing is as good as deleted as far as the model is concerned.
@@ -292,7 +292,7 @@ void SharedModelTypeProcessor::FlushPendingCommitRequests() {
// TODO(rlarocque): Do something smarter than iterate here.
for (auto it = entities_.begin(); it != entities_.end(); ++it) {
- ModelTypeEntity* entity = it->second.get();
+ ProcessorEntityTracker* entity = it->second.get();
if (entity->RequiresCommitRequest()) {
DCHECK(!entity->RequiresCommitData());
CommitRequestData request;
@@ -315,7 +315,7 @@ void SharedModelTypeProcessor::OnCommitCompleted(
change_list->UpdateDataTypeState(data_type_state_);
for (const CommitResponseData& data : response_list) {
- ModelTypeEntity* entity = GetEntityForTagHash(data.client_tag_hash);
+ ProcessorEntityTracker* entity = GetEntityForTagHash(data.client_tag_hash);
if (entity == nullptr) {
NOTREACHED() << "Received commit response for missing item."
<< " type: " << type_
@@ -358,7 +358,7 @@ void SharedModelTypeProcessor::OnUpdateReceived(
const EntityData& data = update.entity.value();
const std::string& client_tag_hash = data.client_tag_hash;
- ModelTypeEntity* entity = GetEntityForTagHash(client_tag_hash);
+ ProcessorEntityTracker* entity = GetEntityForTagHash(client_tag_hash);
if (entity == nullptr) {
if (data.is_deleted()) {
DLOG(WARNING) << "Received remote delete for a non-existing item."
@@ -434,7 +434,7 @@ void SharedModelTypeProcessor::OnInitialUpdateReceived(
metadata_changes->UpdateDataTypeState(data_type_state_);
for (const UpdateResponseData& update : updates) {
- ModelTypeEntity* entity = CreateEntity(update.entity.value());
+ ProcessorEntityTracker* entity = CreateEntity(update.entity.value());
const std::string& tag = entity->client_tag();
entity->ApplyUpdateFromServer(update);
metadata_changes->UpdateMetadata(tag, entity->metadata());
@@ -453,29 +453,29 @@ std::string SharedModelTypeProcessor::GetHashForTag(const std::string& tag) {
return syncer::syncable::GenerateSyncableHash(type_, tag);
}
-ModelTypeEntity* SharedModelTypeProcessor::GetEntityForTag(
+ProcessorEntityTracker* SharedModelTypeProcessor::GetEntityForTag(
const std::string& tag) {
return GetEntityForTagHash(GetHashForTag(tag));
}
-ModelTypeEntity* SharedModelTypeProcessor::GetEntityForTagHash(
+ProcessorEntityTracker* SharedModelTypeProcessor::GetEntityForTagHash(
const std::string& tag_hash) {
auto it = entities_.find(tag_hash);
return it != entities_.end() ? it->second.get() : nullptr;
}
-ModelTypeEntity* SharedModelTypeProcessor::CreateEntity(
+ProcessorEntityTracker* SharedModelTypeProcessor::CreateEntity(
const std::string& tag,
const EntityData& data) {
DCHECK(entities_.find(data.client_tag_hash) == entities_.end());
- scoped_ptr<ModelTypeEntity> entity = ModelTypeEntity::CreateNew(
+ scoped_ptr<ProcessorEntityTracker> entity = ProcessorEntityTracker::CreateNew(
tag, data.client_tag_hash, data.id, data.creation_time);
- ModelTypeEntity* entity_ptr = entity.get();
+ ProcessorEntityTracker* entity_ptr = entity.get();
entities_[data.client_tag_hash] = std::move(entity);
return entity_ptr;
}
-ModelTypeEntity* SharedModelTypeProcessor::CreateEntity(
+ProcessorEntityTracker* SharedModelTypeProcessor::CreateEntity(
const EntityData& data) {
// Let the service define |client_tag| based on the entity data.
const std::string tag = service_->GetClientTag(data);
diff --git a/sync/internal_api/shared_model_type_processor_unittest.cc b/sync/internal_api/shared_model_type_processor_unittest.cc
index fb5363b..53d1735 100644
--- a/sync/internal_api/shared_model_type_processor_unittest.cc
+++ b/sync/internal_api/shared_model_type_processor_unittest.cc
@@ -326,8 +326,8 @@ class SharedModelTypeProcessorTest : public ::testing::Test,
void UpdateDesiredEncryptionKey(const std::string& key_name) {
sync_pb::DataTypeState data_type_state(db_.data_type_state());
data_type_state.set_encryption_key_name(key_name);
- type_processor()->OnUpdateReceived(
- data_type_state, UpdateResponseDataList());
+ type_processor()->OnUpdateReceived(data_type_state,
+ UpdateResponseDataList());
}
// Sets the key_name that the mock CommitQueue will claim is in use
@@ -1116,7 +1116,8 @@ TEST_F(SharedModelTypeProcessorTest, DISABLED_Disable) {
// Test re-encrypt everything when desired encryption key changes.
// TODO(stanisc): crbug/561814: Disabled due to data caching changes in
-// ModelTypeEntity. Revisit the test once fetching of data is implemented.
+// ProcessorEntityTracker. Revisit the test once fetching of data is
+// implemented.
TEST_F(SharedModelTypeProcessorTest, DISABLED_ReEncryptCommitsWithNewKey) {
InitializeToReadyState();
@@ -1147,7 +1148,8 @@ TEST_F(SharedModelTypeProcessorTest, DISABLED_ReEncryptCommitsWithNewKey) {
// Test receipt of updates with new and old keys.
// TODO(stanisc): crbug/561814: Disabled due to data caching changes in
-// ModelTypeEntity. Revisit the test once fetching of data is implemented.
+// ProcessorEntityTracker. Revisit the test once fetching of data is
+// implemented.
TEST_F(SharedModelTypeProcessorTest, DISABLED_ReEncryptUpdatesWithNewKey) {
InitializeToReadyState();
diff --git a/sync/sync.gyp b/sync/sync.gyp
index f5303cb..6a5f3b1 100644
--- a/sync/sync.gyp
+++ b/sync/sync.gyp
@@ -137,8 +137,6 @@
'engine/directory_commit_contributor.h',
'engine/directory_update_handler.cc',
'engine/directory_update_handler.h',
- 'engine/entity_tracker.cc',
- 'engine/entity_tracker.h',
'engine/get_commit_ids.cc',
'engine/get_commit_ids.h',
'engine/get_updates_delegate.cc',
@@ -180,6 +178,8 @@
'engine/update_applicator.h',
'engine/update_handler.cc',
'engine/update_handler.h',
+ 'engine/worker_entity_tracker.cc',
+ 'engine/worker_entity_tracker.h',
'internal_api/activation_context.cc',
'internal_api/attachments/attachment_downloader.cc',
'internal_api/attachments/attachment_downloader_impl.cc',
@@ -222,9 +222,9 @@
'internal_api/js_sync_encryption_handler_observer.h',
'internal_api/js_sync_manager_observer.cc',
'internal_api/js_sync_manager_observer.h',
- 'internal_api/model_type_entity.cc',
'internal_api/model_type_store_backend.cc',
'internal_api/model_type_store_impl.cc',
+ 'internal_api/processor_entity_tracker.cc',
'internal_api/protocol_event_buffer.cc',
'internal_api/protocol_event_buffer.h',
'internal_api/public/activation_context.h',
@@ -297,7 +297,6 @@
'internal_api/public/http_post_provider_interface.h',
'internal_api/public/internal_components_factory.h',
'internal_api/public/internal_components_factory_impl.h',
- 'internal_api/public/model_type_entity.h',
'internal_api/public/model_type_processor.cc',
'internal_api/public/model_type_processor.h',
'internal_api/public/model_type_store_backend.h',
@@ -305,6 +304,7 @@
'internal_api/public/network_resources.h',
'internal_api/public/non_blocking_sync_common.cc',
'internal_api/public/non_blocking_sync_common.h',
+ 'internal_api/public/processor_entity_tracker.h',
'internal_api/public/read_node.h',
'internal_api/public/read_transaction.h',
'internal_api/public/sessions/commit_counters.cc',
diff --git a/sync/sync_tests.gypi b/sync/sync_tests.gypi
index bacf837..06c82f2 100644
--- a/sync/sync_tests.gypi
+++ b/sync/sync_tests.gypi
@@ -280,13 +280,13 @@
'engine/backoff_delay_provider_unittest.cc',
'engine/directory_commit_contribution_unittest.cc',
'engine/directory_update_handler_unittest.cc',
- 'engine/entity_tracker_unittest.cc',
'engine/get_updates_processor_unittest.cc',
'engine/model_type_worker_unittest.cc',
'engine/sync_scheduler_unittest.cc',
'engine/syncer_proto_util_unittest.cc',
'engine/syncer_unittest.cc',
'engine/syncer_util_unittest.cc',
+ 'engine/worker_entity_tracker_unittest.cc',
'internal_api/attachments/attachment_downloader_impl_unittest.cc',
'internal_api/attachments/attachment_service_impl_unittest.cc',
'internal_api/attachments/attachment_service_proxy_unittest.cc',
@@ -303,9 +303,9 @@
'internal_api/js_mutation_event_observer_unittest.cc',
'internal_api/js_sync_encryption_handler_observer_unittest.cc',
'internal_api/js_sync_manager_observer_unittest.cc',
- 'internal_api/model_type_entity_unittest.cc',
'internal_api/model_type_store_backend_unittest.cc',
'internal_api/model_type_store_impl_unittest.cc',
+ 'internal_api/processor_entity_tracker_unittest.cc',
'internal_api/protocol_event_buffer_unittest.cc',
'internal_api/public/base/attachment_id_proto_unittest.cc',
'internal_api/public/base/cancelation_signal_unittest.cc',