summaryrefslogtreecommitdiffstats
path: root/sync/internal_api
diff options
context:
space:
mode:
Diffstat (limited to 'sync/internal_api')
-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
7 files changed, 113 insertions, 107 deletions
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();