summaryrefslogtreecommitdiffstats
path: root/sync/engine
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-25 05:52:32 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-25 05:52:32 +0000
commit973a446349b8b98f8ebb35da2ae204ee71047d0c (patch)
tree1893a2d9fef2d0023ec9a561d77911e7634f3cdb /sync/engine
parent633a10a8162d96014ecb1ddcd01e1bb1e584d6c1 (diff)
downloadchromium_src-973a446349b8b98f8ebb35da2ae204ee71047d0c.zip
chromium_src-973a446349b8b98f8ebb35da2ae204ee71047d0c.tar.gz
chromium_src-973a446349b8b98f8ebb35da2ae204ee71047d0c.tar.bz2
sync: Mass rename of non-blocking sync classes
Renames many of the classes involved in non-blocking sync: - Renames SyncCore, SyncCoreProxy to SyncContext and SyncContextProxy. - Renames NonBlockingTypeProcessor and NonBlockingTypeProcessorInterface to ModelTypeSyncProxyImpl and ModelTypeSyncProxy, respectively. - Renames NonBlockingTypeProcessorCore and NonBlockingTypeProcessorCoreInterface to ModelTypeSyncWorkerImpl and ModelTypeSyncWorker, respectively. - Renames ModelThreadSyncEntity to ModelTypeEntity. - Renames SyncThreadSyncEntity to EntityTracker. Renames any Mock, Test, Wrapper, or Impl classes associated with the above, too. This is only the first part of the planned refactoring. The second part, which involves some changes to the inheritance hierarchy, will be implemented in a future CL. BUG=351005 Review URL: https://codereview.chromium.org/351523003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279618 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/engine')
-rw-r--r--sync/engine/entity_tracker.cc (renamed from sync/engine/sync_thread_sync_entity.cc)109
-rw-r--r--sync/engine/entity_tracker.h (renamed from sync/engine/sync_thread_sync_entity.h)55
-rw-r--r--sync/engine/entity_tracker_unittest.cc (renamed from sync/engine/sync_thread_sync_entity_unittest.cc)101
-rw-r--r--sync/engine/model_type_entity.cc (renamed from sync/engine/model_thread_sync_entity.cc)94
-rw-r--r--sync/engine/model_type_entity.h (renamed from sync/engine/model_thread_sync_entity.h)40
-rw-r--r--sync/engine/model_type_entity_unittest.cc (renamed from sync/engine/model_thread_sync_entity_unittest.cc)125
-rw-r--r--sync/engine/model_type_sync_proxy.cc (renamed from sync/engine/non_blocking_type_processor_interface.cc)6
-rw-r--r--sync/engine/model_type_sync_proxy.h (renamed from sync/engine/non_blocking_type_processor_interface.h)13
-rw-r--r--sync/engine/model_type_sync_proxy_impl.cc (renamed from sync/engine/non_blocking_type_processor.cc)99
-rw-r--r--sync/engine/model_type_sync_proxy_impl.h (renamed from sync/engine/non_blocking_type_processor.h)47
-rw-r--r--sync/engine/model_type_sync_proxy_impl_unittest.cc (renamed from sync/engine/non_blocking_type_processor_unittest.cc)177
-rw-r--r--sync/engine/model_type_sync_worker.cc15
-rw-r--r--sync/engine/model_type_sync_worker.h23
-rw-r--r--sync/engine/model_type_sync_worker_impl.cc (renamed from sync/engine/non_blocking_type_processor_core.cc)92
-rw-r--r--sync/engine/model_type_sync_worker_impl.h (renamed from sync/engine/non_blocking_type_processor_core.h)47
-rw-r--r--sync/engine/model_type_sync_worker_impl_unittest.cc (renamed from sync/engine/non_blocking_type_processor_core_unittest.cc)204
-rw-r--r--sync/engine/non_blocking_sync_common.h2
-rw-r--r--sync/engine/non_blocking_type_commit_contribution.cc8
-rw-r--r--sync/engine/non_blocking_type_commit_contribution.h8
-rw-r--r--sync/engine/non_blocking_type_processor_core_interface.cc16
-rw-r--r--sync/engine/non_blocking_type_processor_core_interface.h24
21 files changed, 637 insertions, 668 deletions
diff --git a/sync/engine/sync_thread_sync_entity.cc b/sync/engine/entity_tracker.cc
index 21899d2..c9738b2 100644
--- a/sync/engine/sync_thread_sync_entity.cc
+++ b/sync/engine/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/sync_thread_sync_entity.h"
+#include "sync/engine/entity_tracker.h"
#include "base/logging.h"
#include "sync/engine/non_blocking_sync_common.h"
@@ -12,15 +12,14 @@
namespace syncer {
-SyncThreadSyncEntity* SyncThreadSyncEntity::FromServerUpdate(
+EntityTracker* EntityTracker::FromServerUpdate(
const std::string& id_string,
const std::string& client_tag_hash,
int64 received_version) {
- return new SyncThreadSyncEntity(
- id_string, client_tag_hash, 0, received_version);
+ return new EntityTracker(id_string, client_tag_hash, 0, received_version);
}
-SyncThreadSyncEntity* SyncThreadSyncEntity::FromCommitRequest(
+EntityTracker* EntityTracker::FromCommitRequest(
const std::string& id_string,
const std::string& client_tag_hash,
int64 sequence_number,
@@ -30,26 +29,25 @@ SyncThreadSyncEntity* SyncThreadSyncEntity::FromCommitRequest(
const std::string& non_unique_name,
bool deleted,
const sync_pb::EntitySpecifics& specifics) {
- return new SyncThreadSyncEntity(id_string,
- client_tag_hash,
- 0,
- 0,
- true,
- sequence_number,
- base_version,
- ctime,
- mtime,
- non_unique_name,
- deleted,
- specifics);
+ return new EntityTracker(id_string,
+ client_tag_hash,
+ 0,
+ 0,
+ true,
+ sequence_number,
+ base_version,
+ ctime,
+ mtime,
+ non_unique_name,
+ deleted,
+ specifics);
}
// Constructor that does not set any pending commit fields.
-SyncThreadSyncEntity::SyncThreadSyncEntity(
- const std::string& id,
- const std::string& client_tag_hash,
- int64 highest_commit_response_version,
- int64 highest_gu_response_version)
+EntityTracker::EntityTracker(const std::string& id,
+ const std::string& client_tag_hash,
+ int64 highest_commit_response_version,
+ int64 highest_gu_response_version)
: id_(id),
client_tag_hash_(client_tag_hash),
highest_commit_response_version_(highest_commit_response_version),
@@ -60,19 +58,18 @@ SyncThreadSyncEntity::SyncThreadSyncEntity(
deleted_(false) {
}
-SyncThreadSyncEntity::SyncThreadSyncEntity(
- const std::string& id,
- const std::string& client_tag_hash,
- int64 highest_commit_response_version,
- int64 highest_gu_response_version,
- bool is_commit_pending,
- int64 sequence_number,
- int64 base_version,
- base::Time ctime,
- base::Time mtime,
- const std::string& non_unique_name,
- bool deleted,
- const sync_pb::EntitySpecifics& specifics)
+EntityTracker::EntityTracker(const std::string& id,
+ const std::string& client_tag_hash,
+ int64 highest_commit_response_version,
+ int64 highest_gu_response_version,
+ bool is_commit_pending,
+ int64 sequence_number,
+ int64 base_version,
+ base::Time ctime,
+ base::Time mtime,
+ const std::string& non_unique_name,
+ bool deleted,
+ const sync_pb::EntitySpecifics& specifics)
: id_(id),
client_tag_hash_(client_tag_hash),
highest_commit_response_version_(highest_commit_response_version),
@@ -87,16 +84,15 @@ SyncThreadSyncEntity::SyncThreadSyncEntity(
specifics_(specifics) {
}
-SyncThreadSyncEntity::~SyncThreadSyncEntity() {
+EntityTracker::~EntityTracker() {
}
-bool SyncThreadSyncEntity::IsCommitPending() const {
+bool EntityTracker::IsCommitPending() const {
return is_commit_pending_;
}
-void SyncThreadSyncEntity::PrepareCommitProto(
- sync_pb::SyncEntity* commit_entity,
- int64* sequence_number) const {
+void EntityTracker::PrepareCommitProto(sync_pb::SyncEntity* commit_entity,
+ int64* sequence_number) const {
// Set ID if we have a server-assigned ID. Otherwise, it will be up to
// our caller to assign a client-unique initial ID.
if (base_version_ != kUncommittedVersion) {
@@ -117,16 +113,15 @@ void SyncThreadSyncEntity::PrepareCommitProto(
*sequence_number = sequence_number_;
}
-void SyncThreadSyncEntity::RequestCommit(
- const std::string& id,
- const std::string& client_tag_hash,
- int64 sequence_number,
- int64 base_version,
- base::Time ctime,
- base::Time mtime,
- const std::string& non_unique_name,
- bool deleted,
- const sync_pb::EntitySpecifics& specifics) {
+void EntityTracker::RequestCommit(const std::string& id,
+ const std::string& client_tag_hash,
+ int64 sequence_number,
+ int64 base_version,
+ base::Time ctime,
+ base::Time mtime,
+ const std::string& non_unique_name,
+ bool deleted,
+ const sync_pb::EntitySpecifics& specifics) {
DCHECK_GE(base_version, base_version_)
<< "Base version should never decrease";
@@ -172,9 +167,9 @@ void SyncThreadSyncEntity::RequestCommit(
specifics_ = specifics;
}
-void SyncThreadSyncEntity::ReceiveCommitResponse(const std::string& response_id,
- int64 response_version,
- int64 sequence_number) {
+void EntityTracker::ReceiveCommitResponse(const std::string& response_id,
+ int64 response_version,
+ int64 sequence_number) {
// Commit responses, especially after the first commit, can update our ID.
id_ = response_id;
@@ -197,7 +192,7 @@ void SyncThreadSyncEntity::ReceiveCommitResponse(const std::string& response_id,
ClearPendingCommit();
}
-void SyncThreadSyncEntity::ReceiveUpdate(int64 version) {
+void EntityTracker::ReceiveUpdate(int64 version) {
highest_gu_response_version_ =
std::max(highest_gu_response_version_, version);
@@ -208,7 +203,7 @@ void SyncThreadSyncEntity::ReceiveUpdate(int64 version) {
}
}
-bool SyncThreadSyncEntity::IsInConflict() const {
+bool EntityTracker::IsInConflict() const {
if (!is_commit_pending_)
return false;
@@ -228,11 +223,11 @@ bool SyncThreadSyncEntity::IsInConflict() const {
}
}
-bool SyncThreadSyncEntity::IsServerKnown() const {
+bool EntityTracker::IsServerKnown() const {
return base_version_ != kUncommittedVersion;
}
-void SyncThreadSyncEntity::ClearPendingCommit() {
+void EntityTracker::ClearPendingCommit() {
is_commit_pending_ = false;
// Clearing the specifics might free up some memory. It can't hurt to try.
diff --git a/sync/engine/sync_thread_sync_entity.h b/sync/engine/entity_tracker.h
index 6ed9685..db2d09b 100644
--- a/sync/engine/sync_thread_sync_entity.h
+++ b/sync/engine/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_SYNC_THREAD_SYNC_ENTITY_H_
-#define SYNC_ENGINE_SYNC_THREAD_SYNC_ENTITY_H_
+#ifndef SYNC_ENGINE_ENTITY_TRACKER_H_
+#define SYNC_ENGINE_ENTITY_TRACKER_H_
#include <string>
@@ -18,7 +18,7 @@ namespace syncer {
// thread.
//
// It should be considered a helper class internal to the
-// NonBlockingTypeProcessorCore.
+// ModelTypeSyncWorker.
//
// Maintains the state associated with a particular sync entity which is
// necessary for decision-making on the sync thread. It can track pending
@@ -27,18 +27,17 @@ namespace syncer {
// This object may or may not contain state associated with a pending commit.
// If no commit is pending, the |is_commit_pending_| flag will be set to false
// and many of this object's fields will be cleared.
-class SYNC_EXPORT SyncThreadSyncEntity {
+class SYNC_EXPORT EntityTracker {
public:
- ~SyncThreadSyncEntity();
+ ~EntityTracker();
// Initialize a new entity based on an update response.
- static SyncThreadSyncEntity* FromServerUpdate(
- const std::string& id_string,
- const std::string& client_tag_hash,
- int64 version);
+ static EntityTracker* FromServerUpdate(const std::string& id_string,
+ const std::string& client_tag_hash,
+ int64 version);
// Initialize a new entity based on a commit request.
- static SyncThreadSyncEntity* FromCommitRequest(
+ static EntityTracker* FromCommitRequest(
const std::string& id_string,
const std::string& client_tag_hash,
int64 sequence_number,
@@ -85,24 +84,24 @@ class SYNC_EXPORT SyncThreadSyncEntity {
private:
// Initializes received update state. Does not initialize state related to
// pending commits and sets |is_commit_pending_| to false.
- SyncThreadSyncEntity(const std::string& id,
- const std::string& client_tag_hash,
- int64 highest_commit_response_version,
- int64 highest_gu_response_version);
+ EntityTracker(const std::string& id,
+ const std::string& client_tag_hash,
+ int64 highest_commit_response_version,
+ int64 highest_gu_response_version);
// Initializes all fields. Sets |is_commit_pending_| to true.
- SyncThreadSyncEntity(const std::string& id,
- const std::string& client_tag_hash,
- int64 highest_commit_response_version,
- int64 highest_gu_response_version,
- bool is_commit_pending,
- int64 sequence_number,
- int64 base_version,
- base::Time ctime,
- base::Time mtime,
- const std::string& non_unique_name,
- bool deleted,
- const sync_pb::EntitySpecifics& specifics);
+ EntityTracker(const std::string& id,
+ const std::string& client_tag_hash,
+ int64 highest_commit_response_version,
+ int64 highest_gu_response_version,
+ bool is_commit_pending,
+ int64 sequence_number,
+ int64 base_version,
+ base::Time ctime,
+ base::Time mtime,
+ const std::string& non_unique_name,
+ bool deleted,
+ const sync_pb::EntitySpecifics& specifics);
// Checks if the current state indicates a conflict.
//
@@ -147,9 +146,9 @@ class SYNC_EXPORT SyncThreadSyncEntity {
bool deleted_;
sync_pb::EntitySpecifics specifics_;
- DISALLOW_COPY_AND_ASSIGN(SyncThreadSyncEntity);
+ DISALLOW_COPY_AND_ASSIGN(EntityTracker);
};
} // namespace syncer
-#endif // SYNC_ENGINE_SYNC_THREAD_SYNC_ENTITY_H_
+#endif // SYNC_ENGINE_ENTITY_TRACKER_H_
diff --git a/sync/engine/sync_thread_sync_entity_unittest.cc b/sync/engine/entity_tracker_unittest.cc
index be2604b..7a1b04b 100644
--- a/sync/engine/sync_thread_sync_entity_unittest.cc
+++ b/sync/engine/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/sync_thread_sync_entity.h"
+#include "sync/engine/entity_tracker.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
@@ -14,18 +14,17 @@
namespace syncer {
-// Some simple tests for the SyncThreadSyncEntity.
+// Some simple tests for the EntityTracker.
//
-// The SyncThreadSyncEntity is an implementation detail of the
-// NonBlockingTypeProcessorCore. As such, it doesn't make much sense to test
-// it exhaustively, since it already gets a lot of test coverage from the
-// NonBlockingTypeProcessorCore unit tests.
+// The EntityTracker is an implementation detail of the ModelTypeSyncWorker.
+// As such, it doesn't make much sense to test it exhaustively, since it
+// already gets a lot of test coverage from the ModelTypeSyncWorker unit tests.
//
// These tests are intended as a basic sanity check. Anything more complicated
// would be redundant.
-class SyncThreadSyncEntityTest : public ::testing::Test {
+class EntityTrackerTest : public ::testing::Test {
public:
- SyncThreadSyncEntityTest()
+ EntityTrackerTest()
: kServerId("ServerID"),
kClientTag("some.sample.tag"),
kClientTagHash(syncable::GenerateSyncableHash(PREFERENCES, kClientTag)),
@@ -35,7 +34,7 @@ class SyncThreadSyncEntityTest : public ::testing::Test {
specifics.mutable_preference()->set_value("pref.value");
}
- virtual ~SyncThreadSyncEntityTest() {}
+ virtual ~EntityTrackerTest() {}
const std::string kServerId;
const std::string kClientTag;
@@ -46,9 +45,9 @@ class SyncThreadSyncEntityTest : public ::testing::Test {
};
// Construct a new entity from a server update. Then receive another update.
-TEST_F(SyncThreadSyncEntityTest, FromServerUpdate) {
- scoped_ptr<SyncThreadSyncEntity> entity(
- SyncThreadSyncEntity::FromServerUpdate(kServerId, kClientTagHash, 10));
+TEST_F(EntityTrackerTest, FromServerUpdate) {
+ scoped_ptr<EntityTracker> entity(
+ EntityTracker::FromServerUpdate(kServerId, kClientTagHash, 10));
EXPECT_FALSE(entity->IsCommitPending());
entity->ReceiveUpdate(20);
@@ -56,17 +55,17 @@ TEST_F(SyncThreadSyncEntityTest, FromServerUpdate) {
}
// Construct a new entity from a commit request. Then serialize it.
-TEST_F(SyncThreadSyncEntityTest, FromCommitRequest) {
- scoped_ptr<SyncThreadSyncEntity> entity(
- SyncThreadSyncEntity::FromCommitRequest(kServerId,
- kClientTagHash,
- 22,
- 33,
- kCtime,
- kMtime,
- kClientTag,
- false,
- specifics));
+TEST_F(EntityTrackerTest, FromCommitRequest) {
+ scoped_ptr<EntityTracker> entity(
+ EntityTracker::FromCommitRequest(kServerId,
+ kClientTagHash,
+ 22,
+ 33,
+ kCtime,
+ kMtime,
+ kClientTag,
+ false,
+ specifics));
ASSERT_TRUE(entity->IsCommitPending());
sync_pb::SyncEntity pb_entity;
@@ -86,9 +85,9 @@ TEST_F(SyncThreadSyncEntityTest, FromCommitRequest) {
}
// Start with a server initiated entity. Commit over top of it.
-TEST_F(SyncThreadSyncEntityTest, RequestCommit) {
- scoped_ptr<SyncThreadSyncEntity> entity(
- SyncThreadSyncEntity::FromServerUpdate(kServerId, kClientTagHash, 10));
+TEST_F(EntityTrackerTest, RequestCommit) {
+ scoped_ptr<EntityTracker> entity(
+ EntityTracker::FromServerUpdate(kServerId, kClientTagHash, 10));
entity->RequestCommit(kServerId,
kClientTagHash,
@@ -105,9 +104,9 @@ TEST_F(SyncThreadSyncEntityTest, RequestCommit) {
// Start with a server initiated entity. Fail to request a commit because of
// an out of date base version.
-TEST_F(SyncThreadSyncEntityTest, RequestCommitFailure) {
- scoped_ptr<SyncThreadSyncEntity> entity(
- SyncThreadSyncEntity::FromServerUpdate(kServerId, kClientTagHash, 10));
+TEST_F(EntityTrackerTest, RequestCommitFailure) {
+ scoped_ptr<EntityTracker> entity(
+ EntityTracker::FromServerUpdate(kServerId, kClientTagHash, 10));
EXPECT_FALSE(entity->IsCommitPending());
entity->RequestCommit(kServerId,
@@ -123,17 +122,17 @@ TEST_F(SyncThreadSyncEntityTest, RequestCommitFailure) {
}
// Start with a pending commit. Clobber it with an incoming update.
-TEST_F(SyncThreadSyncEntityTest, UpdateClobbersCommit) {
- scoped_ptr<SyncThreadSyncEntity> entity(
- SyncThreadSyncEntity::FromCommitRequest(kServerId,
- kClientTagHash,
- 22,
- 33,
- kCtime,
- kMtime,
- kClientTag,
- false,
- specifics));
+TEST_F(EntityTrackerTest, UpdateClobbersCommit) {
+ scoped_ptr<EntityTracker> entity(
+ EntityTracker::FromCommitRequest(kServerId,
+ kClientTagHash,
+ 22,
+ 33,
+ kCtime,
+ kMtime,
+ kClientTag,
+ false,
+ specifics));
EXPECT_TRUE(entity->IsCommitPending());
@@ -143,17 +142,17 @@ TEST_F(SyncThreadSyncEntityTest, UpdateClobbersCommit) {
// Start with a pending commit. Send it a reflected update that
// will not override the in-progress commit.
-TEST_F(SyncThreadSyncEntityTest, ReflectedUpdateDoesntClobberCommit) {
- scoped_ptr<SyncThreadSyncEntity> entity(
- SyncThreadSyncEntity::FromCommitRequest(kServerId,
- kClientTagHash,
- 22,
- 33,
- kCtime,
- kMtime,
- kClientTag,
- false,
- specifics));
+TEST_F(EntityTrackerTest, ReflectedUpdateDoesntClobberCommit) {
+ scoped_ptr<EntityTracker> entity(
+ EntityTracker::FromCommitRequest(kServerId,
+ kClientTagHash,
+ 22,
+ 33,
+ kCtime,
+ kMtime,
+ kClientTag,
+ false,
+ specifics));
EXPECT_TRUE(entity->IsCommitPending());
diff --git a/sync/engine/model_thread_sync_entity.cc b/sync/engine/model_type_entity.cc
index 053a6c8..5acf5db 100644
--- a/sync/engine/model_thread_sync_entity.cc
+++ b/sync/engine/model_type_entity.cc
@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "sync/engine/model_thread_sync_entity.h"
+#include "sync/engine/model_type_entity.h"
#include "sync/syncable/syncable_util.h"
namespace syncer {
-scoped_ptr<ModelThreadSyncEntity> ModelThreadSyncEntity::NewLocalItem(
+scoped_ptr<ModelTypeEntity> ModelTypeEntity::NewLocalItem(
const std::string& client_tag,
const sync_pb::EntitySpecifics& specifics,
base::Time now) {
- return scoped_ptr<ModelThreadSyncEntity>(new ModelThreadSyncEntity(
+ return scoped_ptr<ModelTypeEntity>(new ModelTypeEntity(
1,
0,
0,
@@ -27,7 +27,7 @@ scoped_ptr<ModelThreadSyncEntity> ModelThreadSyncEntity::NewLocalItem(
now));
}
-scoped_ptr<ModelThreadSyncEntity> ModelThreadSyncEntity::FromServerUpdate(
+scoped_ptr<ModelTypeEntity> ModelTypeEntity::FromServerUpdate(
const std::string& id,
const std::string& client_tag_hash,
const std::string& non_unique_name,
@@ -36,34 +36,32 @@ scoped_ptr<ModelThreadSyncEntity> ModelThreadSyncEntity::FromServerUpdate(
bool deleted,
base::Time ctime,
base::Time mtime) {
- return scoped_ptr<ModelThreadSyncEntity>(
- new ModelThreadSyncEntity(0,
- 0,
- 0,
- version,
- true,
- id,
- client_tag_hash,
- non_unique_name,
- specifics,
- deleted,
- ctime,
- mtime));
-}
-
-ModelThreadSyncEntity::ModelThreadSyncEntity(
- int64 sequence_number,
- int64 commit_requested_sequence_number,
- int64 acked_sequence_number,
- int64 base_version,
- bool is_dirty,
- const std::string& id,
- const std::string& client_tag_hash,
- const std::string& non_unique_name,
- const sync_pb::EntitySpecifics& specifics,
- bool deleted,
- base::Time ctime,
- base::Time mtime)
+ return scoped_ptr<ModelTypeEntity>(new ModelTypeEntity(0,
+ 0,
+ 0,
+ version,
+ true,
+ id,
+ client_tag_hash,
+ non_unique_name,
+ specifics,
+ deleted,
+ ctime,
+ mtime));
+}
+
+ModelTypeEntity::ModelTypeEntity(int64 sequence_number,
+ int64 commit_requested_sequence_number,
+ int64 acked_sequence_number,
+ int64 base_version,
+ bool is_dirty,
+ const std::string& id,
+ const std::string& client_tag_hash,
+ const std::string& non_unique_name,
+ const sync_pb::EntitySpecifics& specifics,
+ bool deleted,
+ base::Time ctime,
+ base::Time mtime)
: sequence_number_(sequence_number),
commit_requested_sequence_number_(commit_requested_sequence_number),
acked_sequence_number_(acked_sequence_number),
@@ -78,30 +76,30 @@ ModelThreadSyncEntity::ModelThreadSyncEntity(
mtime_(mtime) {
}
-ModelThreadSyncEntity::~ModelThreadSyncEntity() {
+ModelTypeEntity::~ModelTypeEntity() {
}
-bool ModelThreadSyncEntity::IsWriteRequired() const {
+bool ModelTypeEntity::IsWriteRequired() const {
return is_dirty_;
}
-bool ModelThreadSyncEntity::IsUnsynced() const {
+bool ModelTypeEntity::IsUnsynced() const {
return sequence_number_ > acked_sequence_number_;
}
-bool ModelThreadSyncEntity::RequiresCommitRequest() const {
+bool ModelTypeEntity::RequiresCommitRequest() const {
return sequence_number_ > commit_requested_sequence_number_;
}
-bool ModelThreadSyncEntity::UpdateIsReflection(int64 update_version) const {
+bool ModelTypeEntity::UpdateIsReflection(int64 update_version) const {
return base_version_ >= update_version;
}
-bool ModelThreadSyncEntity::UpdateIsInConflict(int64 update_version) const {
+bool ModelTypeEntity::UpdateIsInConflict(int64 update_version) const {
return IsUnsynced() && !UpdateIsReflection(update_version);
}
-void ModelThreadSyncEntity::ApplyUpdateFromServer(
+void ModelTypeEntity::ApplyUpdateFromServer(
int64 update_version,
bool deleted,
const sync_pb::EntitySpecifics& specifics,
@@ -117,19 +115,19 @@ void ModelThreadSyncEntity::ApplyUpdateFromServer(
mtime_ = mtime;
}
-void ModelThreadSyncEntity::MakeLocalChange(
+void ModelTypeEntity::MakeLocalChange(
const sync_pb::EntitySpecifics& specifics) {
sequence_number_++;
specifics_ = specifics;
}
-void ModelThreadSyncEntity::Delete() {
+void ModelTypeEntity::Delete() {
sequence_number_++;
specifics_.Clear();
deleted_ = true;
}
-void ModelThreadSyncEntity::InitializeCommitRequestData(
+void ModelTypeEntity::InitializeCommitRequestData(
CommitRequestData* request) const {
request->id = id_;
request->client_tag_hash = client_tag_hash_;
@@ -142,25 +140,25 @@ void ModelThreadSyncEntity::InitializeCommitRequestData(
request->specifics.CopyFrom(specifics_);
}
-void ModelThreadSyncEntity::SetCommitRequestInProgress() {
+void ModelTypeEntity::SetCommitRequestInProgress() {
commit_requested_sequence_number_ = sequence_number_;
}
-void ModelThreadSyncEntity::ReceiveCommitResponse(const std::string& id,
- int64 sequence_number,
- int64 response_version) {
+void ModelTypeEntity::ReceiveCommitResponse(const std::string& id,
+ int64 sequence_number,
+ int64 response_version) {
id_ = id; // The server can assign us a new ID in a commit response.
acked_sequence_number_ = sequence_number;
base_version_ = response_version;
}
-void ModelThreadSyncEntity::ClearTransientSyncState() {
+void ModelTypeEntity::ClearTransientSyncState() {
// If we have any unacknowledged commit requests outstatnding, they've been
// dropped and we should forget about them.
commit_requested_sequence_number_ = acked_sequence_number_;
}
-void ModelThreadSyncEntity::ClearSyncState() {
+void ModelTypeEntity::ClearSyncState() {
base_version_ = kUncommittedVersion;
is_dirty_ = true;
sequence_number_ = 1;
diff --git a/sync/engine/model_thread_sync_entity.h b/sync/engine/model_type_entity.h
index 03a6d27..a457cb3 100644
--- a/sync/engine/model_thread_sync_entity.h
+++ b/sync/engine/model_type_entity.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_MODEL_THREAD_SYNC_ENTITY_H_
-#define SYNC_ENGINE_MODEL_THREAD_SYNC_ENTITY_H_
+#ifndef SYNC_ENGINE_MODEL_TYPE_ENTITY_H_
+#define SYNC_ENGINE_MODEL_TYPE_ENTITY_H_
#include <string>
@@ -17,7 +17,7 @@ namespace syncer {
// This is the model thread's representation of a SyncEntity.
//
-// The model thread sync entity receives updates from the model itself and
+// The model type entity receives updates from the model itself and
// (asynchronously) from the sync server via the sync thread. From the point
// of view of this class, updates from the server take precedence over local
// changes, though the model may be given an opportunity to overwrite this
@@ -29,16 +29,16 @@ namespace syncer {
// Most of the logic related to those processes live outside this class. This
// class helps out a bit by offering some functions to serialize its data to
// various formats and query the entity's status.
-class SYNC_EXPORT_PRIVATE ModelThreadSyncEntity {
+class SYNC_EXPORT_PRIVATE ModelTypeEntity {
public:
// Construct an instance representing a new locally-created item.
- static scoped_ptr<ModelThreadSyncEntity> NewLocalItem(
+ static scoped_ptr<ModelTypeEntity> NewLocalItem(
const std::string& client_tag,
const sync_pb::EntitySpecifics& specifics,
base::Time now);
// Construct an instance representing an item newly received from the server.
- static scoped_ptr<ModelThreadSyncEntity> FromServerUpdate(
+ static scoped_ptr<ModelTypeEntity> FromServerUpdate(
const std::string& id,
const std::string& client_tag_hash,
const std::string& non_unique_name,
@@ -50,7 +50,7 @@ class SYNC_EXPORT_PRIVATE ModelThreadSyncEntity {
// TODO(rlarocque): Implement FromDisk constructor when we implement storage.
- ~ModelThreadSyncEntity();
+ ~ModelTypeEntity();
// Returns true if this data is out of sync with local storage.
bool IsWriteRequired() const;
@@ -113,18 +113,18 @@ class SYNC_EXPORT_PRIVATE ModelThreadSyncEntity {
void ClearSyncState();
private:
- ModelThreadSyncEntity(int64 sequence_number,
- int64 commit_requested_sequence_number,
- int64 acked_sequence_number,
- int64 base_version,
- bool is_dirty,
- const std::string& id,
- const std::string& client_tag_hash,
- const std::string& non_unique_name,
- const sync_pb::EntitySpecifics& specifics,
- bool deleted,
- base::Time ctime,
- base::Time mtime);
+ ModelTypeEntity(int64 sequence_number,
+ int64 commit_requested_sequence_number,
+ int64 acked_sequence_number,
+ int64 base_version,
+ bool is_dirty,
+ const std::string& id,
+ const std::string& client_tag_hash,
+ const std::string& non_unique_name,
+ const sync_pb::EntitySpecifics& specifics,
+ bool deleted,
+ base::Time ctime,
+ base::Time mtime);
// A sequence number used to track in-progress commits. Each local change
// increments this number.
@@ -189,4 +189,4 @@ class SYNC_EXPORT_PRIVATE ModelThreadSyncEntity {
} // namespace syncer
-#endif // SYNC_ENGINE_MODEL_THREAD_SYNC_ENTITY_H_
+#endif // SYNC_ENGINE_MODEL_TYPE_ENTITY_H_
diff --git a/sync/engine/model_thread_sync_entity_unittest.cc b/sync/engine/model_type_entity_unittest.cc
index 6b158dd..c605732 100644
--- a/sync/engine/model_thread_sync_entity_unittest.cc
+++ b/sync/engine/model_type_entity_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/engine/model_thread_sync_entity.h"
+#include "sync/engine/model_type_entity.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
@@ -14,18 +14,18 @@
namespace syncer {
-// Some simple sanity tests for the ModelThreadSyncEntity.
+// Some simple sanity tests for the ModelTypeEntity.
//
// A lot of the more complicated sync logic is implemented in the
-// NonBlockingTypeProcessor that owns the ModelThreadSyncEntity. We
-// can't unit test it here.
+// ModelTypeSyncProxyImpl that owns the ModelTypeEntity. 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 NonBlockingTypeProcessor tests.
-class ModelThreadSyncEntityTest : public ::testing::Test {
+// be a redundant and incomplete version of the ModelTypeSyncProxyImpl tests.
+class ModelTypeEntityTest : public ::testing::Test {
public:
- ModelThreadSyncEntityTest()
+ ModelTypeEntityTest()
: kServerId("ServerID"),
kClientTag("sample.pref.name"),
kClientTagHash(syncable::GenerateSyncableHash(PREFERENCES, kClientTag)),
@@ -45,9 +45,9 @@ class ModelThreadSyncEntityTest : public ::testing::Test {
sync_pb::EntitySpecifics specifics;
};
-TEST_F(ModelThreadSyncEntityTest, NewLocalItem) {
- scoped_ptr<ModelThreadSyncEntity> entity(
- ModelThreadSyncEntity::NewLocalItem("asdf", specifics, kCtime));
+TEST_F(ModelTypeEntityTest, NewLocalItem) {
+ scoped_ptr<ModelTypeEntity> entity(
+ ModelTypeEntity::NewLocalItem("asdf", specifics, kCtime));
EXPECT_TRUE(entity->IsWriteRequired());
EXPECT_TRUE(entity->IsUnsynced());
@@ -55,17 +55,16 @@ TEST_F(ModelThreadSyncEntityTest, NewLocalItem) {
EXPECT_TRUE(entity->UpdateIsInConflict(1));
}
-TEST_F(ModelThreadSyncEntityTest, FromServerUpdate) {
- scoped_ptr<ModelThreadSyncEntity> entity(
- ModelThreadSyncEntity::FromServerUpdate(
- kServerId,
- kClientTagHash,
- kClientTag, // As non-unique name.
- 10,
- specifics,
- false,
- kCtime,
- kMtime));
+TEST_F(ModelTypeEntityTest, FromServerUpdate) {
+ scoped_ptr<ModelTypeEntity> entity(
+ ModelTypeEntity::FromServerUpdate(kServerId,
+ kClientTagHash,
+ kClientTag, // As non-unique name.
+ 10,
+ specifics,
+ false,
+ kCtime,
+ kMtime));
EXPECT_TRUE(entity->IsWriteRequired());
EXPECT_FALSE(entity->IsUnsynced());
@@ -79,17 +78,16 @@ TEST_F(ModelThreadSyncEntityTest, 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(ModelThreadSyncEntityTest, TombstoneUpdate) {
- scoped_ptr<ModelThreadSyncEntity> entity(
- ModelThreadSyncEntity::FromServerUpdate(
- kServerId,
- kClientTagHash,
- kClientTag, // As non-unique name.
- 10,
- sync_pb::EntitySpecifics(),
- true,
- kCtime,
- kMtime));
+TEST_F(ModelTypeEntityTest, TombstoneUpdate) {
+ scoped_ptr<ModelTypeEntity> entity(
+ ModelTypeEntity::FromServerUpdate(kServerId,
+ kClientTagHash,
+ kClientTag, // As non-unique name.
+ 10,
+ sync_pb::EntitySpecifics(),
+ true,
+ kCtime,
+ kMtime));
EXPECT_TRUE(entity->IsWriteRequired());
EXPECT_FALSE(entity->IsUnsynced());
@@ -100,17 +98,16 @@ TEST_F(ModelThreadSyncEntityTest, TombstoneUpdate) {
}
// Apply a deletion update.
-TEST_F(ModelThreadSyncEntityTest, ApplyUpdate) {
- scoped_ptr<ModelThreadSyncEntity> entity(
- ModelThreadSyncEntity::FromServerUpdate(
- kServerId,
- kClientTagHash,
- kClientTag, // As non-unique name.
- 10,
- specifics,
- false,
- kCtime,
- kMtime));
+TEST_F(ModelTypeEntityTest, ApplyUpdate) {
+ scoped_ptr<ModelTypeEntity> entity(
+ ModelTypeEntity::FromServerUpdate(kServerId,
+ kClientTagHash,
+ kClientTag, // As non-unique name.
+ 10,
+ specifics,
+ false,
+ kCtime,
+ kMtime));
// A deletion update one version later.
entity->ApplyUpdateFromServer(11,
@@ -124,17 +121,16 @@ TEST_F(ModelThreadSyncEntityTest, ApplyUpdate) {
EXPECT_FALSE(entity->UpdateIsReflection(12));
}
-TEST_F(ModelThreadSyncEntityTest, LocalChange) {
- scoped_ptr<ModelThreadSyncEntity> entity(
- ModelThreadSyncEntity::FromServerUpdate(
- kServerId,
- kClientTagHash,
- kClientTag, // As non-unique name.
- 10,
- specifics,
- false,
- kCtime,
- kMtime));
+TEST_F(ModelTypeEntityTest, LocalChange) {
+ scoped_ptr<ModelTypeEntity> entity(
+ ModelTypeEntity::FromServerUpdate(kServerId,
+ kClientTagHash,
+ kClientTag, // As non-unique name.
+ 10,
+ specifics,
+ false,
+ kCtime,
+ kMtime));
sync_pb::EntitySpecifics specifics2;
specifics2.CopyFrom(specifics);
@@ -151,17 +147,16 @@ TEST_F(ModelThreadSyncEntityTest, LocalChange) {
EXPECT_TRUE(entity->UpdateIsInConflict(11));
}
-TEST_F(ModelThreadSyncEntityTest, LocalDeletion) {
- scoped_ptr<ModelThreadSyncEntity> entity(
- ModelThreadSyncEntity::FromServerUpdate(
- kServerId,
- kClientTagHash,
- kClientTag, // As non-unique name.
- 10,
- specifics,
- false,
- kCtime,
- kMtime));
+TEST_F(ModelTypeEntityTest, LocalDeletion) {
+ scoped_ptr<ModelTypeEntity> entity(
+ ModelTypeEntity::FromServerUpdate(kServerId,
+ kClientTagHash,
+ kClientTag, // As non-unique name.
+ 10,
+ specifics,
+ false,
+ kCtime,
+ kMtime));
entity->Delete();
diff --git a/sync/engine/non_blocking_type_processor_interface.cc b/sync/engine/model_type_sync_proxy.cc
index b936239..974dc61 100644
--- a/sync/engine/non_blocking_type_processor_interface.cc
+++ b/sync/engine/model_type_sync_proxy.cc
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "sync/engine/non_blocking_type_processor_interface.h"
+#include "sync/engine/model_type_sync_proxy.h"
namespace syncer {
-NonBlockingTypeProcessorInterface::NonBlockingTypeProcessorInterface() {
+ModelTypeSyncProxy::ModelTypeSyncProxy() {
}
-NonBlockingTypeProcessorInterface::~NonBlockingTypeProcessorInterface() {
+ModelTypeSyncProxy::~ModelTypeSyncProxy() {
}
} // namespace syncer
diff --git a/sync/engine/non_blocking_type_processor_interface.h b/sync/engine/model_type_sync_proxy.h
index bafd141..2851a09 100644
--- a/sync/engine/non_blocking_type_processor_interface.h
+++ b/sync/engine/model_type_sync_proxy.h
@@ -2,18 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef SYNC_ENGINE_NON_BLOCKING_TYPE_PROCESSOR_INTERFACE_H_
-#define SYNC_ENGINE_NON_BLOCKING_TYPE_PROCESSOR_INTERFACE_H_
+#ifndef SYNC_ENGINE_MODEL_TYPE_SYNC_PROXY_H_
+#define SYNC_ENGINE_MODEL_TYPE_SYNC_PROXY_H_
#include "sync/base/sync_export.h"
#include "sync/engine/non_blocking_sync_common.h"
namespace syncer {
-class SYNC_EXPORT_PRIVATE NonBlockingTypeProcessorInterface {
+// Interface used by sync backend to issue requests to a synced data type.
+class SYNC_EXPORT_PRIVATE ModelTypeSyncProxy {
public:
- NonBlockingTypeProcessorInterface();
- virtual ~NonBlockingTypeProcessorInterface();
+ ModelTypeSyncProxy();
+ virtual ~ModelTypeSyncProxy();
virtual void ReceiveCommitResponse(
const DataTypeState& type_state,
@@ -25,4 +26,4 @@ class SYNC_EXPORT_PRIVATE NonBlockingTypeProcessorInterface {
} // namespace syncer
-#endif // SYNC_ENGINE_NON_BLOCKING_TYPE_PROCESSOR_INTERFACE_H_
+#endif // SYNC_ENGINE_MODEL_TYPE_SYNC_PROXY_H_
diff --git a/sync/engine/non_blocking_type_processor.cc b/sync/engine/model_type_sync_proxy_impl.cc
index 9b80543..d865998 100644
--- a/sync/engine/non_blocking_type_processor.cc
+++ b/sync/engine/model_type_sync_proxy_impl.cc
@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "sync/engine/non_blocking_type_processor.h"
+#include "sync/engine/model_type_sync_proxy_impl.h"
#include "base/bind.h"
#include "base/location.h"
#include "base/message_loop/message_loop_proxy.h"
-#include "sync/engine/model_thread_sync_entity.h"
-#include "sync/engine/non_blocking_type_processor_core_interface.h"
-#include "sync/internal_api/public/sync_core_proxy.h"
+#include "sync/engine/model_type_entity.h"
+#include "sync/engine/model_type_sync_worker.h"
+#include "sync/internal_api/public/sync_context_proxy.h"
#include "sync/syncable/syncable_util.h"
namespace syncer {
-NonBlockingTypeProcessor::NonBlockingTypeProcessor(ModelType type)
+ModelTypeSyncProxyImpl::ModelTypeSyncProxyImpl(ModelType type)
: type_(type),
is_preferred_(false),
is_connected_(false),
@@ -23,26 +23,26 @@ NonBlockingTypeProcessor::NonBlockingTypeProcessor(ModelType type)
weak_ptr_factory_for_sync_(this) {
}
-NonBlockingTypeProcessor::~NonBlockingTypeProcessor() {
+ModelTypeSyncProxyImpl::~ModelTypeSyncProxyImpl() {
}
-bool NonBlockingTypeProcessor::IsPreferred() const {
+bool ModelTypeSyncProxyImpl::IsPreferred() const {
DCHECK(CalledOnValidThread());
return is_preferred_;
}
-bool NonBlockingTypeProcessor::IsConnected() const {
+bool ModelTypeSyncProxyImpl::IsConnected() const {
DCHECK(CalledOnValidThread());
return is_connected_;
}
-ModelType NonBlockingTypeProcessor::GetModelType() const {
+ModelType ModelTypeSyncProxyImpl::GetModelType() const {
DCHECK(CalledOnValidThread());
return type_;
}
-void NonBlockingTypeProcessor::Enable(
- scoped_ptr<SyncCoreProxy> sync_core_proxy) {
+void ModelTypeSyncProxyImpl::Enable(
+ scoped_ptr<SyncContextProxy> sync_context_proxy) {
DCHECK(CalledOnValidThread());
DVLOG(1) << "Asked to enable " << ModelTypeToString(type_);
@@ -52,13 +52,14 @@ void NonBlockingTypeProcessor::Enable(
data_type_state_.progress_marker.set_data_type_id(
GetSpecificsFieldNumberFromModelType(type_));
- sync_core_proxy_ = sync_core_proxy.Pass();
- sync_core_proxy_->ConnectTypeToCore(GetModelType(),
- data_type_state_,
- weak_ptr_factory_for_sync_.GetWeakPtr());
+ sync_context_proxy_ = sync_context_proxy.Pass();
+ sync_context_proxy_->ConnectTypeToSync(
+ GetModelType(),
+ data_type_state_,
+ weak_ptr_factory_for_sync_.GetWeakPtr());
}
-void NonBlockingTypeProcessor::Disable() {
+void ModelTypeSyncProxyImpl::Disable() {
DCHECK(CalledOnValidThread());
is_preferred_ = false;
Disconnect();
@@ -66,41 +67,39 @@ void NonBlockingTypeProcessor::Disable() {
ClearSyncState();
}
-void NonBlockingTypeProcessor::Disconnect() {
+void ModelTypeSyncProxyImpl::Disconnect() {
DCHECK(CalledOnValidThread());
DVLOG(1) << "Asked to disconnect " << ModelTypeToString(type_);
is_connected_ = false;
- if (sync_core_proxy_) {
- sync_core_proxy_->Disconnect(GetModelType());
- sync_core_proxy_.reset();
+ if (sync_context_proxy_) {
+ sync_context_proxy_->Disconnect(GetModelType());
+ sync_context_proxy_.reset();
}
weak_ptr_factory_for_sync_.InvalidateWeakPtrs();
- core_interface_.reset();
+ worker_.reset();
ClearTransientSyncState();
}
-base::WeakPtr<NonBlockingTypeProcessor>
-NonBlockingTypeProcessor::AsWeakPtrForUI() {
+base::WeakPtr<ModelTypeSyncProxyImpl> ModelTypeSyncProxyImpl::AsWeakPtrForUI() {
DCHECK(CalledOnValidThread());
return weak_ptr_factory_for_ui_.GetWeakPtr();
}
-void NonBlockingTypeProcessor::OnConnect(
- scoped_ptr<NonBlockingTypeProcessorCoreInterface> core_interface) {
+void ModelTypeSyncProxyImpl::OnConnect(scoped_ptr<ModelTypeSyncWorker> worker) {
DCHECK(CalledOnValidThread());
DVLOG(1) << "Successfully connected " << ModelTypeToString(type_);
is_connected_ = true;
- core_interface_ = core_interface.Pass();
+ worker_ = worker.Pass();
FlushPendingCommitRequests();
}
-void NonBlockingTypeProcessor::Put(const std::string& client_tag,
- const sync_pb::EntitySpecifics& specifics) {
+void ModelTypeSyncProxyImpl::Put(const std::string& client_tag,
+ const sync_pb::EntitySpecifics& specifics) {
DCHECK_EQ(type_, GetModelTypeFromSpecifics(specifics));
const std::string client_tag_hash(
@@ -108,19 +107,18 @@ void NonBlockingTypeProcessor::Put(const std::string& client_tag,
EntityMap::iterator it = entities_.find(client_tag_hash);
if (it == entities_.end()) {
- scoped_ptr<ModelThreadSyncEntity> entity(
- ModelThreadSyncEntity::NewLocalItem(
- client_tag, specifics, base::Time::Now()));
+ scoped_ptr<ModelTypeEntity> entity(ModelTypeEntity::NewLocalItem(
+ client_tag, specifics, base::Time::Now()));
entities_.insert(std::make_pair(client_tag_hash, entity.release()));
} else {
- ModelThreadSyncEntity* entity = it->second;
+ ModelTypeEntity* entity = it->second;
entity->MakeLocalChange(specifics);
}
FlushPendingCommitRequests();
}
-void NonBlockingTypeProcessor::Delete(const std::string& client_tag) {
+void ModelTypeSyncProxyImpl::Delete(const std::string& client_tag) {
const std::string client_tag_hash(
syncable::GenerateSyncableHash(type_, client_tag));
@@ -131,14 +129,14 @@ void NonBlockingTypeProcessor::Delete(const std::string& client_tag) {
DLOG(WARNING) << "Attempted to delete missing item."
<< " client tag: " << client_tag;
} else {
- ModelThreadSyncEntity* entity = it->second;
+ ModelTypeEntity* entity = it->second;
entity->Delete();
}
FlushPendingCommitRequests();
}
-void NonBlockingTypeProcessor::FlushPendingCommitRequests() {
+void ModelTypeSyncProxyImpl::FlushPendingCommitRequests() {
CommitRequestDataList commit_requests;
// Don't bother sending anything if there's no one to send to.
@@ -161,10 +159,10 @@ void NonBlockingTypeProcessor::FlushPendingCommitRequests() {
}
if (!commit_requests.empty())
- core_interface_->RequestCommits(commit_requests);
+ worker_->RequestCommits(commit_requests);
}
-void NonBlockingTypeProcessor::OnCommitCompletion(
+void ModelTypeSyncProxyImpl::OnCommitCompletion(
const DataTypeState& type_state,
const CommitResponseDataList& response_list) {
data_type_state_ = type_state;
@@ -188,7 +186,7 @@ void NonBlockingTypeProcessor::OnCommitCompletion(
}
}
-void NonBlockingTypeProcessor::OnUpdateReceived(
+void ModelTypeSyncProxyImpl::OnUpdateReceived(
const DataTypeState& data_type_state,
const UpdateResponseDataList& response_list) {
bool initial_sync_just_finished =
@@ -204,19 +202,18 @@ void NonBlockingTypeProcessor::OnUpdateReceived(
EntityMap::iterator it = entities_.find(client_tag_hash);
if (it == entities_.end()) {
- scoped_ptr<ModelThreadSyncEntity> entity =
- ModelThreadSyncEntity::FromServerUpdate(
- response_data.id,
- response_data.client_tag_hash,
- response_data.non_unique_name,
- response_data.response_version,
- response_data.specifics,
- response_data.deleted,
- response_data.ctime,
- response_data.mtime);
+ scoped_ptr<ModelTypeEntity> entity =
+ ModelTypeEntity::FromServerUpdate(response_data.id,
+ response_data.client_tag_hash,
+ response_data.non_unique_name,
+ response_data.response_version,
+ response_data.specifics,
+ response_data.deleted,
+ response_data.ctime,
+ response_data.mtime);
entities_.insert(std::make_pair(client_tag_hash, entity.release()));
} else {
- ModelThreadSyncEntity* entity = it->second;
+ ModelTypeEntity* entity = it->second;
entity->ApplyUpdateFromServer(response_data.response_version,
response_data.deleted,
response_data.specifics,
@@ -231,14 +228,14 @@ void NonBlockingTypeProcessor::OnUpdateReceived(
// TODO: Inform the model of the new or updated data.
}
-void NonBlockingTypeProcessor::ClearTransientSyncState() {
+void ModelTypeSyncProxyImpl::ClearTransientSyncState() {
for (EntityMap::iterator it = entities_.begin(); it != entities_.end();
++it) {
it->second->ClearTransientSyncState();
}
}
-void NonBlockingTypeProcessor::ClearSyncState() {
+void ModelTypeSyncProxyImpl::ClearSyncState() {
for (EntityMap::iterator it = entities_.begin(); it != entities_.end();
++it) {
it->second->ClearSyncState();
diff --git a/sync/engine/non_blocking_type_processor.h b/sync/engine/model_type_sync_proxy_impl.h
index da680f1..0091112 100644
--- a/sync/engine/non_blocking_type_processor.h
+++ b/sync/engine/model_type_sync_proxy_impl.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_NON_BLOCKING_TYPE_PROCESSOR_H_
-#define SYNC_ENGINE_NON_BLOCKING_TYPE_PROCESSOR_H_
+#ifndef SYNC_ENGINE_MODEL_TYPE_SYNC_PROXY_IMPL_H_
+#define SYNC_ENGINE_MODEL_TYPE_SYNC_PROXY_IMPL_H_
#include "base/memory/weak_ptr.h"
#include "base/stl_util.h"
@@ -15,16 +15,16 @@
namespace syncer {
-class SyncCoreProxy;
-class ModelThreadSyncEntity;
-class NonBlockingTypeProcessorCoreInterface;
+class SyncContextProxy;
+class ModelTypeEntity;
+class ModelTypeSyncWorker;
// A sync component embedded on the synced type's thread that helps to handle
// communication between sync and model type threads.
-class SYNC_EXPORT_PRIVATE NonBlockingTypeProcessor : base::NonThreadSafe {
+class SYNC_EXPORT_PRIVATE ModelTypeSyncProxyImpl : base::NonThreadSafe {
public:
- NonBlockingTypeProcessor(ModelType type);
- virtual ~NonBlockingTypeProcessor();
+ ModelTypeSyncProxyImpl(ModelType type);
+ virtual ~ModelTypeSyncProxyImpl();
// Returns true if this object believes that sync is preferred for this type.
//
@@ -41,11 +41,11 @@ class SYNC_EXPORT_PRIVATE NonBlockingTypeProcessor : base::NonThreadSafe {
// Returns true if the handshake with sync thread is complete.
bool IsConnected() const;
- // Returns the model type handled by this processor.
+ // Returns the model type handled by this type sync proxy.
ModelType GetModelType() const;
// Starts the handshake with the sync thread.
- void Enable(scoped_ptr<SyncCoreProxy> core_proxy);
+ void Enable(scoped_ptr<SyncContextProxy> context_proxy);
// Severs all ties to the sync thread and may delete local sync state.
// Another call to Enable() can be used to re-establish this connection.
@@ -56,8 +56,7 @@ class SYNC_EXPORT_PRIVATE NonBlockingTypeProcessor : base::NonThreadSafe {
void Disconnect();
// Callback used to process the handshake response.
- void OnConnect(
- scoped_ptr<NonBlockingTypeProcessorCoreInterface> core_interface);
+ void OnConnect(scoped_ptr<ModelTypeSyncWorker> worker);
// Requests that an item be stored in sync.
void Put(const std::string& client_tag,
@@ -78,17 +77,17 @@ class SYNC_EXPORT_PRIVATE NonBlockingTypeProcessor : base::NonThreadSafe {
// Returns the long-lived WeakPtr that is intended to be registered with the
// ProfileSyncService.
- base::WeakPtr<NonBlockingTypeProcessor> AsWeakPtrForUI();
+ base::WeakPtr<ModelTypeSyncProxyImpl> AsWeakPtrForUI();
private:
- typedef std::map<std::string, ModelThreadSyncEntity*> EntityMap;
+ typedef std::map<std::string, ModelTypeEntity*> EntityMap;
// Sends all commit requests that are due to be sent to the sync thread.
void FlushPendingCommitRequests();
// Clears any state related to outstanding communications with the
- // NonBlockingTypeProcessorCore. Used when we want to disconnect from
- // the current core.
+ // ModelTypeSyncWorker. Used when we want to disconnect from
+ // the current worker.
void ClearTransientSyncState();
// Clears any state related to our communications with the current sync
@@ -103,7 +102,7 @@ class SYNC_EXPORT_PRIVATE NonBlockingTypeProcessor : base::NonThreadSafe {
bool is_preferred_;
// Whether or not this object has completed its initial handshake with the
- // SyncCoreProxy.
+ // SyncContextProxy.
bool is_connected_;
// Our link to data type management on the sync thread.
@@ -111,14 +110,14 @@ class SYNC_EXPORT_PRIVATE NonBlockingTypeProcessor : base::NonThreadSafe {
//
// Beware of NULL pointers: This object is uninitialized when we are not
// connected to sync.
- scoped_ptr<SyncCoreProxy> sync_core_proxy_;
+ scoped_ptr<SyncContextProxy> sync_context_proxy_;
- // Reference to the NonBlockingTypeProcessorCore.
+ // Reference to the ModelTypeSyncWorker.
//
// The interface hides the posting of tasks across threads as well as the
- // NonBlockingTypeProcessorCore's implementation. Both of these features are
+ // ModelTypeSyncWorker's implementation. Both of these features are
// useful in tests.
- scoped_ptr<NonBlockingTypeProcessorCoreInterface> core_interface_;
+ scoped_ptr<ModelTypeSyncWorker> worker_;
// The set of sync entities known to this object.
EntityMap entities_;
@@ -129,10 +128,10 @@ class SYNC_EXPORT_PRIVATE NonBlockingTypeProcessor : base::NonThreadSafe {
// thread, we want to make sure that no tasks generated as part of the
// now-obsolete connection to affect us. But we also want the WeakPtr we
// sent to the UI thread to remain valid.
- base::WeakPtrFactory<NonBlockingTypeProcessor> weak_ptr_factory_for_ui_;
- base::WeakPtrFactory<NonBlockingTypeProcessor> weak_ptr_factory_for_sync_;
+ base::WeakPtrFactory<ModelTypeSyncProxyImpl> weak_ptr_factory_for_ui_;
+ base::WeakPtrFactory<ModelTypeSyncProxyImpl> weak_ptr_factory_for_sync_;
};
} // namespace syncer
-#endif // SYNC_ENGINE_NON_BLOCKING_TYPE_PROCESSOR_H_
+#endif // SYNC_ENGINE_MODEL_TYPE_SYNC_PROXY_IMPL_H_
diff --git a/sync/engine/non_blocking_type_processor_unittest.cc b/sync/engine/model_type_sync_proxy_impl_unittest.cc
index 2c42afc..810c6b6 100644
--- a/sync/engine/non_blocking_type_processor_unittest.cc
+++ b/sync/engine/model_type_sync_proxy_impl_unittest.cc
@@ -2,33 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "sync/engine/non_blocking_type_processor.h"
+#include "sync/engine/model_type_sync_proxy_impl.h"
+#include "sync/engine/model_type_sync_worker.h"
#include "sync/engine/non_blocking_sync_common.h"
-#include "sync/engine/non_blocking_type_processor_core_interface.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/sync_core_proxy.h"
+#include "sync/internal_api/public/sync_context_proxy.h"
#include "sync/protocol/sync.pb.h"
#include "sync/syncable/syncable_util.h"
-#include "sync/test/engine/injectable_sync_core_proxy.h"
-#include "sync/test/engine/mock_non_blocking_type_processor_core.h"
+#include "sync/test/engine/injectable_sync_context_proxy.h"
+#include "sync/test/engine/mock_model_type_sync_worker.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace syncer {
static const ModelType kModelType = PREFERENCES;
-// Tests the sync engine parts of NonBlockingTypeProcessor.
+// Tests the sync engine parts of ModelTypeSyncProxyImpl.
//
-// The NonBlockingTypeProcessor contains a non-trivial amount of code dedicated
+// The ModelTypeSyncProxyImpl contains a non-trivial amount of code dedicated
// to turning the sync engine on and off again. That code is fairly well
// tested in the NonBlockingDataTypeController unit tests and it doesn't need
// to be re-tested here.
//
// These tests skip past initialization and focus on steady state sync engine
-// behvior. This is where we test how the processor responds to the model's
-// requests to make changes to its data, the messages incoming fro the sync
-// server, and what happens when the two conflict.
+// behvior. This is where we test how the type sync proxy responds to the
+// model's requests to make changes to its data, the messages incoming from the
+// sync server, and what happens when the two conflict.
//
// Inputs:
// - Initial state from permanent storage. (TODO)
@@ -38,25 +38,24 @@ static const ModelType kModelType = PREFERENCES;
// Outputs:
// - Writes to permanent storage. (TODO)
// - Callbacks into the model. (TODO)
-// - Requests to the sync thread. Tested with MockNonBlockingTypeProcessorCore.
-class NonBlockingTypeProcessorTest : public ::testing::Test {
+// - Requests to the sync thread. Tested with MockModelTypeSyncWorker.
+class ModelTypeSyncProxyImplTest : public ::testing::Test {
public:
- NonBlockingTypeProcessorTest();
- virtual ~NonBlockingTypeProcessorTest();
+ ModelTypeSyncProxyImplTest();
+ virtual ~ModelTypeSyncProxyImplTest();
- // Initialize with no local state. The processor will be unable to commit
- // until it receives notification that initial sync has completed.
+ // Initialize with no local state. The type sync proxy will be unable to
+ // commit until it receives notification that initial sync has completed.
void FirstTimeInitialize();
// Initialize to a "ready-to-commit" state.
void InitializeToReadyState();
- // Disconnect the NonBlockingTypeProcessorCore from our
- // NonBlockingTypeProcessor.
+ // Disconnect the ModelTypeSyncWorker from our ModelTypeSyncProxyImpl.
void Disconnect();
- // Disable sync for this NonBlockingTypeProcessor. Should cause sync state
- // to be discarded.
+ // Disable sync for this ModelTypeSyncProxyImpl. Should cause sync state to
+ // be discarded.
void Disable();
// Re-enable sync after Disconnect() or Disable().
@@ -67,7 +66,7 @@ class NonBlockingTypeProcessorTest : public ::testing::Test {
void DeleteItem(const std::string& tag);
// Emulates an "initial sync done" message from the
- // NonBlockingTypeProcessorCore.
+ // ModelTypeSyncWorker.
void OnInitialSyncDone();
// Emulate updates from the server.
@@ -86,7 +85,7 @@ class NonBlockingTypeProcessorTest : public ::testing::Test {
bool HasCommitRequestForTag(const std::string& tag);
CommitRequestData GetLatestCommitRequestForTag(const std::string& tag);
- // Sends the processor a successful commit response.
+ // Sends the type sync proxy a successful commit response.
void SuccessfulCommitResponse(const CommitRequestData& request_data);
private:
@@ -97,116 +96,116 @@ class NonBlockingTypeProcessorTest : public ::testing::Test {
int64 GetServerVersion(const std::string& tag);
void SetServerVersion(const std::string& tag, int64 version);
- MockNonBlockingTypeProcessorCore* mock_processor_core_;
- scoped_ptr<InjectableSyncCoreProxy> injectable_sync_core_proxy_;
- scoped_ptr<NonBlockingTypeProcessor> processor_;
+ MockModelTypeSyncWorker* mock_worker_;
+ scoped_ptr<InjectableSyncContextProxy> injectable_sync_context_proxy_;
+ scoped_ptr<ModelTypeSyncProxyImpl> type_sync_proxy_;
DataTypeState data_type_state_;
};
-NonBlockingTypeProcessorTest::NonBlockingTypeProcessorTest()
- : mock_processor_core_(new MockNonBlockingTypeProcessorCore()),
- injectable_sync_core_proxy_(
- new InjectableSyncCoreProxy(mock_processor_core_)),
- processor_(new NonBlockingTypeProcessor(kModelType)) {
+ModelTypeSyncProxyImplTest::ModelTypeSyncProxyImplTest()
+ : mock_worker_(new MockModelTypeSyncWorker()),
+ injectable_sync_context_proxy_(
+ new InjectableSyncContextProxy(mock_worker_)),
+ type_sync_proxy_(new ModelTypeSyncProxyImpl(kModelType)) {
}
-NonBlockingTypeProcessorTest::~NonBlockingTypeProcessorTest() {
+ModelTypeSyncProxyImplTest::~ModelTypeSyncProxyImplTest() {
}
-void NonBlockingTypeProcessorTest::FirstTimeInitialize() {
- processor_->Enable(injectable_sync_core_proxy_->Clone());
+void ModelTypeSyncProxyImplTest::FirstTimeInitialize() {
+ type_sync_proxy_->Enable(injectable_sync_context_proxy_->Clone());
}
-void NonBlockingTypeProcessorTest::InitializeToReadyState() {
+void ModelTypeSyncProxyImplTest::InitializeToReadyState() {
// TODO(rlarocque): This should be updated to inject on-disk state.
// At the time this code was written, there was no support for on-disk
// state so this was the only way to inject a data_type_state into
- // the |processor_|.
+ // the |type_sync_proxy_|.
FirstTimeInitialize();
OnInitialSyncDone();
}
-void NonBlockingTypeProcessorTest::Disconnect() {
- processor_->Disconnect();
- injectable_sync_core_proxy_.reset();
- mock_processor_core_ = NULL;
+void ModelTypeSyncProxyImplTest::Disconnect() {
+ type_sync_proxy_->Disconnect();
+ injectable_sync_context_proxy_.reset();
+ mock_worker_ = NULL;
}
-void NonBlockingTypeProcessorTest::Disable() {
- processor_->Disable();
- injectable_sync_core_proxy_.reset();
- mock_processor_core_ = NULL;
+void ModelTypeSyncProxyImplTest::Disable() {
+ type_sync_proxy_->Disable();
+ injectable_sync_context_proxy_.reset();
+ mock_worker_ = NULL;
}
-void NonBlockingTypeProcessorTest::ReEnable() {
- DCHECK(!processor_->IsConnected());
+void ModelTypeSyncProxyImplTest::ReEnable() {
+ DCHECK(!type_sync_proxy_->IsConnected());
// Prepare a new NonBlockingTypeProcesorCore instance, just as we would
// if this happened in the real world.
- mock_processor_core_ = new MockNonBlockingTypeProcessorCore();
- injectable_sync_core_proxy_.reset(
- new InjectableSyncCoreProxy(mock_processor_core_));
+ mock_worker_ = new MockModelTypeSyncWorker();
+ injectable_sync_context_proxy_.reset(
+ new InjectableSyncContextProxy(mock_worker_));
- // Re-enable sync with the new NonBlockingTypeProcessorCore.
- processor_->Enable(injectable_sync_core_proxy_->Clone());
+ // Re-enable sync with the new ModelTypeSyncWorker.
+ type_sync_proxy_->Enable(injectable_sync_context_proxy_->Clone());
}
-void NonBlockingTypeProcessorTest::WriteItem(const std::string& tag,
- const std::string& value) {
+void ModelTypeSyncProxyImplTest::WriteItem(const std::string& tag,
+ const std::string& value) {
const std::string tag_hash = GenerateTagHash(tag);
- processor_->Put(tag, GenerateSpecifics(tag, value));
+ type_sync_proxy_->Put(tag, GenerateSpecifics(tag, value));
}
-void NonBlockingTypeProcessorTest::DeleteItem(const std::string& tag) {
- processor_->Delete(tag);
+void ModelTypeSyncProxyImplTest::DeleteItem(const std::string& tag) {
+ type_sync_proxy_->Delete(tag);
}
-void NonBlockingTypeProcessorTest::OnInitialSyncDone() {
+void ModelTypeSyncProxyImplTest::OnInitialSyncDone() {
data_type_state_.initial_sync_done = true;
UpdateResponseDataList empty_update_list;
- processor_->OnUpdateReceived(data_type_state_, empty_update_list);
+ type_sync_proxy_->OnUpdateReceived(data_type_state_, empty_update_list);
}
-void NonBlockingTypeProcessorTest::UpdateFromServer(int64 version_offset,
- const std::string& tag,
- const std::string& value) {
+void ModelTypeSyncProxyImplTest::UpdateFromServer(int64 version_offset,
+ const std::string& tag,
+ const std::string& value) {
const std::string tag_hash = GenerateTagHash(tag);
- UpdateResponseData data = mock_processor_core_->UpdateFromServer(
+ UpdateResponseData data = mock_worker_->UpdateFromServer(
version_offset, tag_hash, GenerateSpecifics(tag, value));
UpdateResponseDataList list;
list.push_back(data);
- processor_->OnUpdateReceived(data_type_state_, list);
+ type_sync_proxy_->OnUpdateReceived(data_type_state_, list);
}
-void NonBlockingTypeProcessorTest::TombstoneFromServer(int64 version_offset,
- const std::string& tag) {
+void ModelTypeSyncProxyImplTest::TombstoneFromServer(int64 version_offset,
+ const std::string& tag) {
// Overwrite the existing server version if this is the new highest version.
std::string tag_hash = GenerateTagHash(tag);
UpdateResponseData data =
- mock_processor_core_->TombstoneFromServer(version_offset, tag_hash);
+ mock_worker_->TombstoneFromServer(version_offset, tag_hash);
UpdateResponseDataList list;
list.push_back(data);
- processor_->OnUpdateReceived(data_type_state_, list);
+ type_sync_proxy_->OnUpdateReceived(data_type_state_, list);
}
-void NonBlockingTypeProcessorTest::SuccessfulCommitResponse(
+void ModelTypeSyncProxyImplTest::SuccessfulCommitResponse(
const CommitRequestData& request_data) {
CommitResponseDataList list;
- list.push_back(mock_processor_core_->SuccessfulCommitResponse(request_data));
- processor_->OnCommitCompletion(data_type_state_, list);
+ list.push_back(mock_worker_->SuccessfulCommitResponse(request_data));
+ type_sync_proxy_->OnCommitCompletion(data_type_state_, list);
}
-std::string NonBlockingTypeProcessorTest::GenerateTagHash(
+std::string ModelTypeSyncProxyImplTest::GenerateTagHash(
const std::string& tag) {
return syncable::GenerateSyncableHash(kModelType, tag);
}
-sync_pb::EntitySpecifics NonBlockingTypeProcessorTest::GenerateSpecifics(
+sync_pb::EntitySpecifics ModelTypeSyncProxyImplTest::GenerateSpecifics(
const std::string& tag,
const std::string& value) {
sync_pb::EntitySpecifics specifics;
@@ -215,30 +214,30 @@ sync_pb::EntitySpecifics NonBlockingTypeProcessorTest::GenerateSpecifics(
return specifics;
}
-size_t NonBlockingTypeProcessorTest::GetNumCommitRequestLists() {
- return mock_processor_core_->GetNumCommitRequestLists();
+size_t ModelTypeSyncProxyImplTest::GetNumCommitRequestLists() {
+ return mock_worker_->GetNumCommitRequestLists();
}
-CommitRequestDataList NonBlockingTypeProcessorTest::GetNthCommitRequestList(
+CommitRequestDataList ModelTypeSyncProxyImplTest::GetNthCommitRequestList(
size_t n) {
- return mock_processor_core_->GetNthCommitRequestList(n);
+ return mock_worker_->GetNthCommitRequestList(n);
}
-bool NonBlockingTypeProcessorTest::HasCommitRequestForTag(
+bool ModelTypeSyncProxyImplTest::HasCommitRequestForTag(
const std::string& tag) {
const std::string tag_hash = GenerateTagHash(tag);
- return mock_processor_core_->HasCommitRequestForTagHash(tag_hash);
+ return mock_worker_->HasCommitRequestForTagHash(tag_hash);
}
-CommitRequestData NonBlockingTypeProcessorTest::GetLatestCommitRequestForTag(
+CommitRequestData ModelTypeSyncProxyImplTest::GetLatestCommitRequestForTag(
const std::string& tag) {
const std::string tag_hash = GenerateTagHash(tag);
- return mock_processor_core_->GetLatestCommitRequestForTagHash(tag_hash);
+ return mock_worker_->GetLatestCommitRequestForTagHash(tag_hash);
}
// Creates a new item locally.
// Thoroughly tests the data generated by a local item creation.
-TEST_F(NonBlockingTypeProcessorTest, CreateLocalItem) {
+TEST_F(ModelTypeSyncProxyImplTest, CreateLocalItem) {
InitializeToReadyState();
EXPECT_EQ(0U, GetNumCommitRequestLists());
@@ -261,7 +260,7 @@ TEST_F(NonBlockingTypeProcessorTest, CreateLocalItem) {
// Creates a new local item then modifies it.
// Thoroughly tests data generated by modification of server-unknown item.
-TEST_F(NonBlockingTypeProcessorTest, CreateAndModifyLocalItem) {
+TEST_F(ModelTypeSyncProxyImplTest, CreateAndModifyLocalItem) {
InitializeToReadyState();
EXPECT_EQ(0U, GetNumCommitRequestLists());
@@ -293,7 +292,7 @@ TEST_F(NonBlockingTypeProcessorTest, CreateAndModifyLocalItem) {
// Deletes an item we've never seen before.
// Should have no effect and not crash.
-TEST_F(NonBlockingTypeProcessorTest, DeleteUnknown) {
+TEST_F(ModelTypeSyncProxyImplTest, DeleteUnknown) {
InitializeToReadyState();
DeleteItem("tag1");
@@ -305,7 +304,7 @@ TEST_F(NonBlockingTypeProcessorTest, DeleteUnknown) {
// In this test, no commit responses are received, so the deleted item is
// server-unknown as far as the model thread is concerned. That behavior
// is race-dependent; other tests are used to test other races.
-TEST_F(NonBlockingTypeProcessorTest, DeleteServerUnknown) {
+TEST_F(ModelTypeSyncProxyImplTest, DeleteServerUnknown) {
InitializeToReadyState();
WriteItem("tag1", "value1");
@@ -330,7 +329,7 @@ TEST_F(NonBlockingTypeProcessorTest, DeleteServerUnknown) {
// The item is created locally then enqueued for commit. The sync thread
// successfully commits it, but, before the commit response is picked up
// by the model thread, the item is deleted by the model thread.
-TEST_F(NonBlockingTypeProcessorTest, DeleteServerUnknown_RacyCommitResponse) {
+TEST_F(ModelTypeSyncProxyImplTest, DeleteServerUnknown_RacyCommitResponse) {
InitializeToReadyState();
WriteItem("tag1", "value1");
@@ -354,7 +353,7 @@ TEST_F(NonBlockingTypeProcessorTest, DeleteServerUnknown_RacyCommitResponse) {
// Creates two different sync items.
// Verifies that the second has no effect on the first.
-TEST_F(NonBlockingTypeProcessorTest, TwoIndependentItems) {
+TEST_F(ModelTypeSyncProxyImplTest, TwoIndependentItems) {
InitializeToReadyState();
EXPECT_EQ(0U, GetNumCommitRequestLists());
@@ -373,10 +372,10 @@ TEST_F(NonBlockingTypeProcessorTest, TwoIndependentItems) {
ASSERT_TRUE(HasCommitRequestForTag("tag2"));
}
-// Starts the processor with no local state.
+// Starts the type sync proxy with no local state.
// Verify that it waits until initial sync is complete before requesting
// commits.
-TEST_F(NonBlockingTypeProcessorTest, NoCommitsUntilInitialSyncDone) {
+TEST_F(ModelTypeSyncProxyImplTest, NoCommitsUntilInitialSyncDone) {
FirstTimeInitialize();
WriteItem("tag1", "value1");
@@ -391,7 +390,7 @@ TEST_F(NonBlockingTypeProcessorTest, NoCommitsUntilInitialSyncDone) {
//
// Creates items in various states of commit and verifies they re-attempt to
// commit on reconnect.
-TEST_F(NonBlockingTypeProcessorTest, Disconnect) {
+TEST_F(ModelTypeSyncProxyImplTest, Disconnect) {
InitializeToReadyState();
// The first item is fully committed.
@@ -427,7 +426,7 @@ TEST_F(NonBlockingTypeProcessorTest, Disconnect) {
//
// Creates items in various states of commit and verifies they re-attempt to
// commit on re-enable.
-TEST_F(NonBlockingTypeProcessorTest, Disable) {
+TEST_F(ModelTypeSyncProxyImplTest, Disable) {
InitializeToReadyState();
// The first item is fully committed.
diff --git a/sync/engine/model_type_sync_worker.cc b/sync/engine/model_type_sync_worker.cc
new file mode 100644
index 0000000..6037a52
--- /dev/null
+++ b/sync/engine/model_type_sync_worker.cc
@@ -0,0 +1,15 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/engine/model_type_sync_worker.h"
+
+namespace syncer {
+
+ModelTypeSyncWorker::ModelTypeSyncWorker() {
+}
+
+ModelTypeSyncWorker::~ModelTypeSyncWorker() {
+}
+
+} // namespace syncer
diff --git a/sync/engine/model_type_sync_worker.h b/sync/engine/model_type_sync_worker.h
new file mode 100644
index 0000000..9add845
--- /dev/null
+++ b/sync/engine/model_type_sync_worker.h
@@ -0,0 +1,23 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_ENGINE_MODEL_TYPE_SYNC_WORKER_H_
+#define SYNC_ENGINE_MODEL_TYPE_SYNC_WORKER_H_
+
+#include "sync/engine/non_blocking_sync_common.h"
+
+namespace syncer {
+
+// Interface used by a synced data type to issue requests to the sync backend.
+class SYNC_EXPORT_PRIVATE ModelTypeSyncWorker {
+ public:
+ ModelTypeSyncWorker();
+ virtual ~ModelTypeSyncWorker();
+
+ virtual void RequestCommits(const CommitRequestDataList& list) = 0;
+};
+
+} // namespace syncer
+
+#endif // SYNC_ENGINE_MODEL_TYPE_SYNC_WORKER_H_
diff --git a/sync/engine/non_blocking_type_processor_core.cc b/sync/engine/model_type_sync_worker_impl.cc
index a14a8d0..0e2ade0 100644
--- a/sync/engine/non_blocking_type_processor_core.cc
+++ b/sync/engine/model_type_sync_worker_impl.cc
@@ -2,54 +2,54 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "sync/engine/non_blocking_type_processor_core.h"
+#include "sync/engine/model_type_sync_worker_impl.h"
#include "base/bind.h"
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "sync/engine/commit_contribution.h"
+#include "sync/engine/entity_tracker.h"
+#include "sync/engine/model_type_sync_proxy.h"
#include "sync/engine/non_blocking_type_commit_contribution.h"
-#include "sync/engine/non_blocking_type_processor_interface.h"
-#include "sync/engine/sync_thread_sync_entity.h"
#include "sync/syncable/syncable_util.h"
#include "sync/util/time.h"
namespace syncer {
-NonBlockingTypeProcessorCore::NonBlockingTypeProcessorCore(
+ModelTypeSyncWorkerImpl::ModelTypeSyncWorkerImpl(
ModelType type,
const DataTypeState& initial_state,
- scoped_ptr<NonBlockingTypeProcessorInterface> processor_interface)
+ scoped_ptr<ModelTypeSyncProxy> type_sync_proxy)
: type_(type),
data_type_state_(initial_state),
- processor_interface_(processor_interface.Pass()),
+ type_sync_proxy_(type_sync_proxy.Pass()),
entities_deleter_(&entities_),
weak_ptr_factory_(this) {
}
-NonBlockingTypeProcessorCore::~NonBlockingTypeProcessorCore() {
+ModelTypeSyncWorkerImpl::~ModelTypeSyncWorkerImpl() {
}
-ModelType NonBlockingTypeProcessorCore::GetModelType() const {
+ModelType ModelTypeSyncWorkerImpl::GetModelType() const {
DCHECK(CalledOnValidThread());
return type_;
}
// UpdateHandler implementation.
-void NonBlockingTypeProcessorCore::GetDownloadProgress(
+void ModelTypeSyncWorkerImpl::GetDownloadProgress(
sync_pb::DataTypeProgressMarker* progress_marker) const {
DCHECK(CalledOnValidThread());
progress_marker->CopyFrom(data_type_state_.progress_marker);
}
-void NonBlockingTypeProcessorCore::GetDataTypeContext(
+void ModelTypeSyncWorkerImpl::GetDataTypeContext(
sync_pb::DataTypeContext* context) const {
DCHECK(CalledOnValidThread());
context->CopyFrom(data_type_state_.type_context);
}
-SyncerError NonBlockingTypeProcessorCore::ProcessGetUpdatesResponse(
+SyncerError ModelTypeSyncWorkerImpl::ProcessGetUpdatesResponse(
const sync_pb::DataTypeProgressMarker& progress_marker,
const sync_pb::DataTypeContext& mutated_context,
const SyncEntityList& applicable_updates,
@@ -82,13 +82,13 @@ SyncerError NonBlockingTypeProcessorCore::ProcessGetUpdatesResponse(
DCHECK(!client_tag_hash.empty());
EntityMap::const_iterator map_it = entities_.find(client_tag_hash);
if (map_it == entities_.end()) {
- SyncThreadSyncEntity* entity =
- SyncThreadSyncEntity::FromServerUpdate(update_entity->id_string(),
- client_tag_hash,
- update_entity->version());
+ EntityTracker* entity =
+ EntityTracker::FromServerUpdate(update_entity->id_string(),
+ client_tag_hash,
+ update_entity->version());
entities_.insert(std::make_pair(client_tag_hash, entity));
} else {
- SyncThreadSyncEntity* entity = map_it->second;
+ EntityTracker* entity = map_it->second;
entity->ReceiveUpdate(update_entity->version());
}
@@ -108,35 +108,34 @@ SyncerError NonBlockingTypeProcessorCore::ProcessGetUpdatesResponse(
}
// Forward these updates to the model thread so it can do the rest.
- processor_interface_->ReceiveUpdateResponse(data_type_state_, response_datas);
+ type_sync_proxy_->ReceiveUpdateResponse(data_type_state_, response_datas);
return SYNCER_OK;
}
-void NonBlockingTypeProcessorCore::ApplyUpdates(
- sessions::StatusController* status) {
+void ModelTypeSyncWorkerImpl::ApplyUpdates(sessions::StatusController* status) {
DCHECK(CalledOnValidThread());
// This function is called only when we've finished a download cycle, ie. we
// got a response with changes_remaining == 0. If this is our first download
- // cycle, we should update our state so the NonBlockingTypeProcessor knows
- // that it's safe to commit items now.
+ // cycle, we should update our state so the ModelTypeSyncProxy knows that
+ // it's safe to commit items now.
if (!data_type_state_.initial_sync_done) {
data_type_state_.initial_sync_done = true;
UpdateResponseDataList empty_update_list;
- processor_interface_->ReceiveUpdateResponse(data_type_state_,
- empty_update_list);
+ type_sync_proxy_->ReceiveUpdateResponse(data_type_state_,
+ empty_update_list);
}
}
-void NonBlockingTypeProcessorCore::PassiveApplyUpdates(
+void ModelTypeSyncWorkerImpl::PassiveApplyUpdates(
sessions::StatusController* status) {
NOTREACHED()
<< "Non-blocking types should never apply updates on sync thread. "
<< "ModelType is: " << ModelTypeToString(type_);
}
-void NonBlockingTypeProcessorCore::EnqueueForCommit(
+void ModelTypeSyncWorkerImpl::EnqueueForCommit(
const CommitRequestDataList& list) {
DCHECK(CalledOnValidThread());
@@ -152,8 +151,8 @@ void NonBlockingTypeProcessorCore::EnqueueForCommit(
}
// CommitContributor implementation.
-scoped_ptr<CommitContribution>
-NonBlockingTypeProcessorCore::GetContribution(size_t max_entries) {
+scoped_ptr<CommitContribution> ModelTypeSyncWorkerImpl::GetContribution(
+ size_t max_entries) {
DCHECK(CalledOnValidThread());
size_t space_remaining = max_entries;
@@ -167,7 +166,7 @@ NonBlockingTypeProcessorCore::GetContribution(size_t max_entries) {
for (EntityMap::const_iterator it = entities_.begin();
it != entities_.end() && space_remaining > 0;
++it) {
- SyncThreadSyncEntity* entity = it->second;
+ EntityTracker* entity = it->second;
if (entity->IsCommitPending()) {
sync_pb::SyncEntity* commit_entity = commit_entities.Add();
int64 sequence_number = -1;
@@ -187,7 +186,7 @@ NonBlockingTypeProcessorCore::GetContribution(size_t max_entries) {
data_type_state_.type_context, commit_entities, sequence_numbers, this));
}
-void NonBlockingTypeProcessorCore::StorePendingCommit(
+void ModelTypeSyncWorkerImpl::StorePendingCommit(
const CommitRequestData& request) {
if (!request.deleted) {
DCHECK_EQ(type_, GetModelTypeFromSpecifics(request.specifics));
@@ -195,19 +194,19 @@ void NonBlockingTypeProcessorCore::StorePendingCommit(
EntityMap::iterator map_it = entities_.find(request.client_tag_hash);
if (map_it == entities_.end()) {
- SyncThreadSyncEntity* entity =
- SyncThreadSyncEntity::FromCommitRequest(request.id,
- request.client_tag_hash,
- request.sequence_number,
- request.base_version,
- request.ctime,
- request.mtime,
- request.non_unique_name,
- request.deleted,
- request.specifics);
+ EntityTracker* entity =
+ EntityTracker::FromCommitRequest(request.id,
+ request.client_tag_hash,
+ request.sequence_number,
+ request.base_version,
+ request.ctime,
+ request.mtime,
+ request.non_unique_name,
+ request.deleted,
+ request.specifics);
entities_.insert(std::make_pair(request.client_tag_hash, entity));
} else {
- SyncThreadSyncEntity* entity = map_it->second;
+ EntityTracker* entity = map_it->second;
entity->RequestCommit(request.id,
request.client_tag_hash,
request.sequence_number,
@@ -222,7 +221,7 @@ void NonBlockingTypeProcessorCore::StorePendingCommit(
// TODO: Nudge SyncScheduler.
}
-void NonBlockingTypeProcessorCore::OnCommitResponse(
+void ModelTypeSyncWorkerImpl::OnCommitResponse(
const CommitResponseDataList& response_list) {
for (CommitResponseDataList::const_iterator response_it =
response_list.begin();
@@ -239,7 +238,7 @@ void NonBlockingTypeProcessorCore::OnCommitResponse(
continue;
}
- SyncThreadSyncEntity* entity = map_it->second;
+ EntityTracker* entity = map_it->second;
entity->ReceiveCommitResponse(response_it->id,
response_it->response_version,
response_it->sequence_number);
@@ -248,22 +247,21 @@ void NonBlockingTypeProcessorCore::OnCommitResponse(
// Send the responses back to the model thread. It needs to know which
// items have been successfully committed so it can save that information in
// permanent storage.
- processor_interface_->ReceiveCommitResponse(data_type_state_, response_list);
+ type_sync_proxy_->ReceiveCommitResponse(data_type_state_, response_list);
}
-base::WeakPtr<NonBlockingTypeProcessorCore>
-NonBlockingTypeProcessorCore::AsWeakPtr() {
+base::WeakPtr<ModelTypeSyncWorkerImpl> ModelTypeSyncWorkerImpl::AsWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
-bool NonBlockingTypeProcessorCore::CanCommitItems() const {
+bool ModelTypeSyncWorkerImpl::CanCommitItems() const {
// We can't commit anything until we know the type's parent node.
// We'll get it in the first update response.
return !data_type_state_.type_root_id.empty() &&
data_type_state_.initial_sync_done;
}
-void NonBlockingTypeProcessorCore::HelpInitializeCommitEntity(
+void ModelTypeSyncWorkerImpl::HelpInitializeCommitEntity(
sync_pb::SyncEntity* sync_entity) {
// Initial commits need our help to generate a client ID.
if (!sync_entity->has_id_string()) {
diff --git a/sync/engine/non_blocking_type_processor_core.h b/sync/engine/model_type_sync_worker_impl.h
index 93d4215..a0e87b1 100644
--- a/sync/engine/non_blocking_type_processor_core.h
+++ b/sync/engine/model_type_sync_worker_impl.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_NON_BLOCKING_TYPE_PROCESSOR_CORE_H_
-#define SYNC_ENGINE_NON_BLOCKING_TYPE_PROCESSOR_CORE_H_
+#ifndef SYNC_ENGINE_MODEL_TYPE_SYNC_WORKER_IMPL_H_
+#define SYNC_ENGINE_MODEL_TYPE_SYNC_WORKER_IMPL_H_
#include "base/memory/weak_ptr.h"
#include "base/stl_util.h"
@@ -21,8 +21,8 @@ class SingleThreadTaskRunner;
namespace syncer {
-class NonBlockingTypeProcessorInterface;
-class SyncThreadSyncEntity;
+class ModelTypeSyncProxy;
+class EntityTracker;
// A smart cache for sync types that use message passing (rather than
// transactions and the syncable::Directory) to communicate with the sync
@@ -44,24 +44,22 @@ class SyncThreadSyncEntity;
// example, if the sync server sends down an update for a sync entity that is
// currently pending for commit, this object will detect this condition and
// cancel the pending commit.
-class SYNC_EXPORT NonBlockingTypeProcessorCore
- : public UpdateHandler,
- public CommitContributor,
- public base::NonThreadSafe {
+class SYNC_EXPORT ModelTypeSyncWorkerImpl : public UpdateHandler,
+ public CommitContributor,
+ public base::NonThreadSafe {
public:
- NonBlockingTypeProcessorCore(
- ModelType type,
- const DataTypeState& initial_state,
- scoped_ptr<NonBlockingTypeProcessorInterface> processor_interface);
- virtual ~NonBlockingTypeProcessorCore();
+ ModelTypeSyncWorkerImpl(ModelType type,
+ const DataTypeState& initial_state,
+ scoped_ptr<ModelTypeSyncProxy> type_sync_proxy);
+ virtual ~ModelTypeSyncWorkerImpl();
ModelType GetModelType() const;
// UpdateHandler implementation.
virtual void GetDownloadProgress(
sync_pb::DataTypeProgressMarker* progress_marker) const OVERRIDE;
- virtual void GetDataTypeContext(sync_pb::DataTypeContext* context) const
- OVERRIDE;
+ virtual void GetDataTypeContext(
+ sync_pb::DataTypeContext* context) const OVERRIDE;
virtual SyncerError ProcessGetUpdatesResponse(
const sync_pb::DataTypeProgressMarker& progress_marker,
const sync_pb::DataTypeContext& mutated_context,
@@ -70,7 +68,7 @@ class SYNC_EXPORT NonBlockingTypeProcessorCore
virtual void ApplyUpdates(sessions::StatusController* status) OVERRIDE;
virtual void PassiveApplyUpdates(sessions::StatusController* status) OVERRIDE;
- // Entry point for NonBlockingTypeProcessor to send commit requests.
+ // Entry point for the ModelTypeSyncProxy to send commit requests.
void EnqueueForCommit(const CommitRequestDataList& request_list);
// CommitContributor implementation.
@@ -80,10 +78,10 @@ class SYNC_EXPORT NonBlockingTypeProcessorCore
// Callback for when our contribution gets a response.
void OnCommitResponse(const CommitResponseDataList& response_list);
- base::WeakPtr<NonBlockingTypeProcessorCore> AsWeakPtr();
+ base::WeakPtr<ModelTypeSyncWorkerImpl> AsWeakPtr();
private:
- typedef std::map<std::string, SyncThreadSyncEntity*> EntityMap;
+ typedef std::map<std::string, EntityTracker*> EntityMap;
// Stores a single commit request in this object's internal state.
void StorePendingCommit(const CommitRequestData& request);
@@ -94,7 +92,7 @@ class SYNC_EXPORT NonBlockingTypeProcessorCore
bool CanCommitItems() const;
// Initializes the parts of a commit entity that are the responsibility of
- // this class, and not the SyncThreadSyncEntity. Some fields, like the
+ // this class, and not the EntityTracker. 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);
@@ -104,10 +102,9 @@ class SYNC_EXPORT NonBlockingTypeProcessorCore
// State that applies to the entire model type.
DataTypeState data_type_state_;
- // Abstraction around the NonBlockingTypeProcessor so this class
- // doesn't need to know about its specific implementation or
- // which thread it's on. This makes it easier to write tests.
- scoped_ptr<NonBlockingTypeProcessorInterface> processor_interface_;
+ // Pointer to the ModelTypeSyncProxy associated with this worker.
+ // This is NULL when no proxy is connected..
+ scoped_ptr<ModelTypeSyncProxy> type_sync_proxy_;
// A map of per-entity information known to this object.
//
@@ -123,9 +120,9 @@ class SYNC_EXPORT NonBlockingTypeProcessorCore
EntityMap entities_;
STLValueDeleter<EntityMap> entities_deleter_;
- base::WeakPtrFactory<NonBlockingTypeProcessorCore> weak_ptr_factory_;
+ base::WeakPtrFactory<ModelTypeSyncWorkerImpl> weak_ptr_factory_;
};
} // namespace syncer
-#endif // SYNC_ENGINE_NON_BLOCKING_TYPE_PROCESSOR_CORE_H_
+#endif // SYNC_ENGINE_MODEL_TYPE_SYNC_WORKER_IMPL_H_
diff --git a/sync/engine/non_blocking_type_processor_core_unittest.cc b/sync/engine/model_type_sync_worker_impl_unittest.cc
index c775a33..09b47ad 100644
--- a/sync/engine/non_blocking_type_processor_core_unittest.cc
+++ b/sync/engine/model_type_sync_worker_impl_unittest.cc
@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "sync/engine/non_blocking_type_processor_core.h"
+#include "sync/engine/model_type_sync_worker_impl.h"
#include "sync/engine/commit_contribution.h"
+#include "sync/engine/model_type_sync_proxy.h"
#include "sync/engine/non_blocking_sync_common.h"
-#include "sync/engine/non_blocking_type_processor_interface.h"
#include "sync/internal_api/public/base/model_type.h"
#include "sync/protocol/sync.pb.h"
#include "sync/sessions/status_controller.h"
#include "sync/syncable/syncable_util.h"
-#include "sync/test/engine/mock_non_blocking_type_processor.h"
+#include "sync/test/engine/mock_model_type_sync_proxy.h"
#include "sync/test/engine/single_type_mock_server.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -21,7 +21,7 @@ static const syncer::ModelType kModelType = syncer::PREFERENCES;
namespace syncer {
-// Tests the NonBlockingTypeProcessorCore.
+// Tests the ModelTypeSyncWorkerImpl.
//
// This class passes messages between the model thread and sync server.
// As such, its code is subject to lots of different race conditions. This
@@ -40,17 +40,17 @@ namespace syncer {
// - Update responses to the model thread.
// - Nudges to the sync scheduler.
//
-// We use the MockNonBlockingTypeProcessor to stub out all communication
+// We use the MockModelTypeSyncProxy to stub out all communication
// with the model thread. That interface is synchronous, which makes it
// much easier to test races.
//
// The interface with the server is built around "pulling" data from this
// class, so we don't have to mock out any of it. We wrap it with some
// convenience functions to we can emulate server behavior.
-class NonBlockingTypeProcessorCoreTest : public ::testing::Test {
+class ModelTypeSyncWorkerImplTest : public ::testing::Test {
public:
- NonBlockingTypeProcessorCoreTest();
- virtual ~NonBlockingTypeProcessorCoreTest();
+ ModelTypeSyncWorkerImplTest();
+ virtual ~ModelTypeSyncWorkerImplTest();
// One of these Initialize functions should be called at the beginning of
// each test.
@@ -67,7 +67,7 @@ class NonBlockingTypeProcessorCoreTest : public ::testing::Test {
// Initialize with a custom initial DataTypeState.
void InitializeWithState(const DataTypeState& state);
- // Modifications on the model thread that get sent to the core under test.
+ // Modifications on the model thread that get sent to the worker under test.
void CommitRequest(const std::string& tag, const std::string& value);
void DeleteRequest(const std::string& tag);
@@ -82,20 +82,20 @@ class NonBlockingTypeProcessorCoreTest : public ::testing::Test {
// thread are executed immediately. However, this is not necessarily true.
// The model's TaskRunner has a queue, and the tasks we post to it could
// linger there for a while. In the meantime, the model thread could
- // continue posting tasks to the core based on its stale state.
+ // continue posting tasks to the worker based on its stale state.
//
// If you want to test those race cases, then these functions are for you.
void SetModelThreadIsSynchronous(bool is_synchronous);
void PumpModelThread();
- // Returns true if the |core_| is ready to commit something.
+ // Returns true if the |worker_| is ready to commit something.
bool WillCommit();
// Pretend to successfully commit all outstanding unsynced items.
// It is safe to call this only if WillCommit() returns true.
void DoSuccessfulCommit();
- // Read commit messages the core_ sent to the emulated server.
+ // Read commit messages the worker_ sent to the emulated server.
size_t GetNumCommitMessagesOnServer() const;
sync_pb::ClientToServerMessage GetNthCommitMessageOnServer(size_t n) const;
@@ -138,27 +138,27 @@ class NonBlockingTypeProcessorCoreTest : public ::testing::Test {
const std::string& value);
private:
- // The NonBlockingTypeProcessorCore being tested.
- scoped_ptr<NonBlockingTypeProcessorCore> core_;
+ // The ModelTypeSyncWorkerImpl being tested.
+ scoped_ptr<ModelTypeSyncWorkerImpl> worker_;
// Non-owned, possibly NULL pointer. This object belongs to the
- // NonBlockingTypeProcessorCore under test.
- MockNonBlockingTypeProcessor* mock_processor_;
+ // ModelTypeSyncWorkerImpl under test.
+ MockModelTypeSyncProxy* mock_type_sync_proxy_;
// A mock that emulates enough of the sync server that it can be used
// a single UpdateHandler and CommitContributor pair. In this test
- // harness, the |core_| is both of them.
+ // harness, the |worker_| is both of them.
SingleTypeMockServer mock_server_;
};
-NonBlockingTypeProcessorCoreTest::NonBlockingTypeProcessorCoreTest()
- : mock_processor_(NULL), mock_server_(kModelType) {
+ModelTypeSyncWorkerImplTest::ModelTypeSyncWorkerImplTest()
+ : mock_type_sync_proxy_(NULL), mock_server_(kModelType) {
}
-NonBlockingTypeProcessorCoreTest::~NonBlockingTypeProcessorCoreTest() {
+ModelTypeSyncWorkerImplTest::~ModelTypeSyncWorkerImplTest() {
}
-void NonBlockingTypeProcessorCoreTest::FirstInitialize() {
+void ModelTypeSyncWorkerImplTest::FirstInitialize() {
DataTypeState initial_state;
initial_state.progress_marker.set_data_type_id(
GetSpecificsFieldNumberFromModelType(kModelType));
@@ -167,7 +167,7 @@ void NonBlockingTypeProcessorCoreTest::FirstInitialize() {
InitializeWithState(initial_state);
}
-void NonBlockingTypeProcessorCoreTest::NormalInitialize() {
+void ModelTypeSyncWorkerImplTest::NormalInitialize() {
DataTypeState initial_state;
initial_state.progress_marker.set_data_type_id(
GetSpecificsFieldNumberFromModelType(kModelType));
@@ -180,51 +180,50 @@ void NonBlockingTypeProcessorCoreTest::NormalInitialize() {
InitializeWithState(initial_state);
}
-void NonBlockingTypeProcessorCoreTest::InitializeWithState(
+void ModelTypeSyncWorkerImplTest::InitializeWithState(
const DataTypeState& state) {
- DCHECK(!core_);
+ DCHECK(!worker_);
- // We don't get to own this interace. The |core_| keeps a scoped_ptr to it.
- mock_processor_ = new MockNonBlockingTypeProcessor();
- scoped_ptr<NonBlockingTypeProcessorInterface> interface(mock_processor_);
+ // We don't get to own this object. The |worker_| keeps a scoped_ptr to it.
+ mock_type_sync_proxy_ = new MockModelTypeSyncProxy();
+ scoped_ptr<ModelTypeSyncProxy> proxy(mock_type_sync_proxy_);
- core_.reset(
- new NonBlockingTypeProcessorCore(kModelType, state, interface.Pass()));
+ worker_.reset(new ModelTypeSyncWorkerImpl(kModelType, state, proxy.Pass()));
}
-void NonBlockingTypeProcessorCoreTest::CommitRequest(const std::string& name,
- const std::string& value) {
+void ModelTypeSyncWorkerImplTest::CommitRequest(const std::string& name,
+ const std::string& value) {
const std::string tag_hash = GenerateTagHash(name);
- CommitRequestData data =
- mock_processor_->CommitRequest(tag_hash, GenerateSpecifics(name, value));
+ CommitRequestData data = mock_type_sync_proxy_->CommitRequest(
+ tag_hash, GenerateSpecifics(name, value));
CommitRequestDataList list;
list.push_back(data);
- core_->EnqueueForCommit(list);
+ worker_->EnqueueForCommit(list);
}
-void NonBlockingTypeProcessorCoreTest::DeleteRequest(const std::string& tag) {
+void ModelTypeSyncWorkerImplTest::DeleteRequest(const std::string& tag) {
const std::string tag_hash = GenerateTagHash(tag);
- CommitRequestData data = mock_processor_->DeleteRequest(tag_hash);
+ CommitRequestData data = mock_type_sync_proxy_->DeleteRequest(tag_hash);
CommitRequestDataList list;
list.push_back(data);
- core_->EnqueueForCommit(list);
+ worker_->EnqueueForCommit(list);
}
-void NonBlockingTypeProcessorCoreTest::TriggerTypeRootUpdateFromServer() {
+void ModelTypeSyncWorkerImplTest::TriggerTypeRootUpdateFromServer() {
sync_pb::SyncEntity entity = mock_server_.TypeRootUpdate();
SyncEntityList entity_list;
entity_list.push_back(&entity);
sessions::StatusController dummy_status;
- core_->ProcessGetUpdatesResponse(mock_server_.GetProgress(),
- mock_server_.GetContext(),
- entity_list,
- &dummy_status);
- core_->ApplyUpdates(&dummy_status);
+ worker_->ProcessGetUpdatesResponse(mock_server_.GetProgress(),
+ mock_server_.GetContext(),
+ entity_list,
+ &dummy_status);
+ worker_->ApplyUpdates(&dummy_status);
}
-void NonBlockingTypeProcessorCoreTest::TriggerUpdateFromServer(
+void ModelTypeSyncWorkerImplTest::TriggerUpdateFromServer(
int64 version_offset,
const std::string& tag,
const std::string& value) {
@@ -235,14 +234,14 @@ void NonBlockingTypeProcessorCoreTest::TriggerUpdateFromServer(
sessions::StatusController dummy_status;
- core_->ProcessGetUpdatesResponse(mock_server_.GetProgress(),
- mock_server_.GetContext(),
- entity_list,
- &dummy_status);
- core_->ApplyUpdates(&dummy_status);
+ worker_->ProcessGetUpdatesResponse(mock_server_.GetProgress(),
+ mock_server_.GetContext(),
+ entity_list,
+ &dummy_status);
+ worker_->ApplyUpdates(&dummy_status);
}
-void NonBlockingTypeProcessorCoreTest::TriggerTombstoneFromServer(
+void ModelTypeSyncWorkerImplTest::TriggerTombstoneFromServer(
int64 version_offset,
const std::string& tag) {
sync_pb::SyncEntity entity =
@@ -252,24 +251,25 @@ void NonBlockingTypeProcessorCoreTest::TriggerTombstoneFromServer(
sessions::StatusController dummy_status;
- core_->ProcessGetUpdatesResponse(mock_server_.GetProgress(),
- mock_server_.GetContext(),
- entity_list,
- &dummy_status);
- core_->ApplyUpdates(&dummy_status);
+ worker_->ProcessGetUpdatesResponse(mock_server_.GetProgress(),
+ mock_server_.GetContext(),
+ entity_list,
+ &dummy_status);
+ worker_->ApplyUpdates(&dummy_status);
}
-void NonBlockingTypeProcessorCoreTest::SetModelThreadIsSynchronous(
+void ModelTypeSyncWorkerImplTest::SetModelThreadIsSynchronous(
bool is_synchronous) {
- mock_processor_->SetSynchronousExecution(is_synchronous);
+ mock_type_sync_proxy_->SetSynchronousExecution(is_synchronous);
}
-void NonBlockingTypeProcessorCoreTest::PumpModelThread() {
- mock_processor_->RunQueuedTasks();
+void ModelTypeSyncWorkerImplTest::PumpModelThread() {
+ mock_type_sync_proxy_->RunQueuedTasks();
}
-bool NonBlockingTypeProcessorCoreTest::WillCommit() {
- scoped_ptr<CommitContribution> contribution(core_->GetContribution(INT_MAX));
+bool ModelTypeSyncWorkerImplTest::WillCommit() {
+ scoped_ptr<CommitContribution> contribution(
+ worker_->GetContribution(INT_MAX));
if (contribution) {
contribution->CleanUp(); // Gracefully abort the commit.
@@ -283,9 +283,10 @@ bool NonBlockingTypeProcessorCoreTest::WillCommit() {
// remains blocked while the commit is in progress, so we don't need to worry
// about other tasks being run between the time when the commit request is
// issued and the time when the commit response is received.
-void NonBlockingTypeProcessorCoreTest::DoSuccessfulCommit() {
+void ModelTypeSyncWorkerImplTest::DoSuccessfulCommit() {
DCHECK(WillCommit());
- scoped_ptr<CommitContribution> contribution(core_->GetContribution(INT_MAX));
+ scoped_ptr<CommitContribution> contribution(
+ worker_->GetContribution(INT_MAX));
sync_pb::ClientToServerMessage message;
contribution->AddToCommitMessage(&message);
@@ -298,101 +299,94 @@ void NonBlockingTypeProcessorCoreTest::DoSuccessfulCommit() {
contribution->CleanUp();
}
-size_t NonBlockingTypeProcessorCoreTest::GetNumCommitMessagesOnServer() const {
+size_t ModelTypeSyncWorkerImplTest::GetNumCommitMessagesOnServer() const {
return mock_server_.GetNumCommitMessages();
}
sync_pb::ClientToServerMessage
-NonBlockingTypeProcessorCoreTest::GetNthCommitMessageOnServer(size_t n) const {
+ModelTypeSyncWorkerImplTest::GetNthCommitMessageOnServer(size_t n) const {
DCHECK_LT(n, GetNumCommitMessagesOnServer());
return mock_server_.GetNthCommitMessage(n);
}
-bool NonBlockingTypeProcessorCoreTest::HasCommitEntityOnServer(
+bool ModelTypeSyncWorkerImplTest::HasCommitEntityOnServer(
const std::string& tag) const {
const std::string tag_hash = GenerateTagHash(tag);
return mock_server_.HasCommitEntity(tag_hash);
}
-sync_pb::SyncEntity
-NonBlockingTypeProcessorCoreTest::GetLatestCommitEntityOnServer(
+sync_pb::SyncEntity ModelTypeSyncWorkerImplTest::GetLatestCommitEntityOnServer(
const std::string& tag) const {
DCHECK(HasCommitEntityOnServer(tag));
const std::string tag_hash = GenerateTagHash(tag);
return mock_server_.GetLastCommittedEntity(tag_hash);
}
-size_t NonBlockingTypeProcessorCoreTest::GetNumModelThreadUpdateResponses()
- const {
- return mock_processor_->GetNumUpdateResponses();
+size_t ModelTypeSyncWorkerImplTest::GetNumModelThreadUpdateResponses() const {
+ return mock_type_sync_proxy_->GetNumUpdateResponses();
}
UpdateResponseDataList
-NonBlockingTypeProcessorCoreTest::GetNthModelThreadUpdateResponse(
- size_t n) const {
+ModelTypeSyncWorkerImplTest::GetNthModelThreadUpdateResponse(size_t n) const {
DCHECK_LT(n, GetNumModelThreadUpdateResponses());
- return mock_processor_->GetNthUpdateResponse(n);
+ return mock_type_sync_proxy_->GetNthUpdateResponse(n);
}
-DataTypeState NonBlockingTypeProcessorCoreTest::GetNthModelThreadUpdateState(
+DataTypeState ModelTypeSyncWorkerImplTest::GetNthModelThreadUpdateState(
size_t n) const {
DCHECK_LT(n, GetNumModelThreadUpdateResponses());
- return mock_processor_->GetNthTypeStateReceivedInUpdateResponse(n);
+ return mock_type_sync_proxy_->GetNthTypeStateReceivedInUpdateResponse(n);
}
-bool NonBlockingTypeProcessorCoreTest::HasUpdateResponseOnModelThread(
+bool ModelTypeSyncWorkerImplTest::HasUpdateResponseOnModelThread(
const std::string& tag) const {
const std::string tag_hash = GenerateTagHash(tag);
- return mock_processor_->HasUpdateResponse(tag_hash);
+ return mock_type_sync_proxy_->HasUpdateResponse(tag_hash);
}
-UpdateResponseData
-NonBlockingTypeProcessorCoreTest::GetUpdateResponseOnModelThread(
+UpdateResponseData ModelTypeSyncWorkerImplTest::GetUpdateResponseOnModelThread(
const std::string& tag) const {
const std::string tag_hash = GenerateTagHash(tag);
- return mock_processor_->GetUpdateResponse(tag_hash);
+ return mock_type_sync_proxy_->GetUpdateResponse(tag_hash);
}
-size_t NonBlockingTypeProcessorCoreTest::GetNumModelThreadCommitResponses()
- const {
- return mock_processor_->GetNumCommitResponses();
+size_t ModelTypeSyncWorkerImplTest::GetNumModelThreadCommitResponses() const {
+ return mock_type_sync_proxy_->GetNumCommitResponses();
}
CommitResponseDataList
-NonBlockingTypeProcessorCoreTest::GetNthModelThreadCommitResponse(
- size_t n) const {
+ModelTypeSyncWorkerImplTest::GetNthModelThreadCommitResponse(size_t n) const {
DCHECK_LT(n, GetNumModelThreadCommitResponses());
- return mock_processor_->GetNthCommitResponse(n);
+ return mock_type_sync_proxy_->GetNthCommitResponse(n);
}
-DataTypeState NonBlockingTypeProcessorCoreTest::GetNthModelThreadCommitState(
+DataTypeState ModelTypeSyncWorkerImplTest::GetNthModelThreadCommitState(
size_t n) const {
DCHECK_LT(n, GetNumModelThreadCommitResponses());
- return mock_processor_->GetNthTypeStateReceivedInCommitResponse(n);
+ return mock_type_sync_proxy_->GetNthTypeStateReceivedInCommitResponse(n);
}
-bool NonBlockingTypeProcessorCoreTest::HasCommitResponseOnModelThread(
+bool ModelTypeSyncWorkerImplTest::HasCommitResponseOnModelThread(
const std::string& tag) const {
const std::string tag_hash = GenerateTagHash(tag);
- return mock_processor_->HasCommitResponse(tag_hash);
+ return mock_type_sync_proxy_->HasCommitResponse(tag_hash);
}
-CommitResponseData
-NonBlockingTypeProcessorCoreTest::GetCommitResponseOnModelThread(
+CommitResponseData ModelTypeSyncWorkerImplTest::GetCommitResponseOnModelThread(
const std::string& tag) const {
DCHECK(HasCommitResponseOnModelThread(tag));
const std::string tag_hash = GenerateTagHash(tag);
- return mock_processor_->GetCommitResponse(tag_hash);
+ return mock_type_sync_proxy_->GetCommitResponse(tag_hash);
}
-std::string NonBlockingTypeProcessorCoreTest::GenerateTagHash(
+std::string ModelTypeSyncWorkerImplTest::GenerateTagHash(
const std::string& tag) {
const std::string& client_tag_hash =
syncable::GenerateSyncableHash(kModelType, tag);
return client_tag_hash;
}
-sync_pb::EntitySpecifics NonBlockingTypeProcessorCoreTest::GenerateSpecifics(
+sync_pb::EntitySpecifics ModelTypeSyncWorkerImplTest::GenerateSpecifics(
const std::string& tag,
const std::string& value) {
sync_pb::EntitySpecifics specifics;
@@ -406,10 +400,10 @@ sync_pb::EntitySpecifics NonBlockingTypeProcessorCoreTest::GenerateSpecifics(
//
// This test performs sanity checks on most of the fields in these messages.
// For the most part this is checking that the test code behaves as expected
-// and the |core_| doesn't mess up its simple task of moving around these
+// and the |worker_| doesn't mess up its simple task of moving around these
// values. It makes sense to have one or two tests that are this thorough, but
// we shouldn't be this verbose in all tests.
-TEST_F(NonBlockingTypeProcessorCoreTest, SimpleCommit) {
+TEST_F(ModelTypeSyncWorkerImplTest, SimpleCommit) {
NormalInitialize();
EXPECT_FALSE(WillCommit());
@@ -454,7 +448,7 @@ TEST_F(NonBlockingTypeProcessorCoreTest, SimpleCommit) {
EXPECT_LT(0, commit_response.response_version);
}
-TEST_F(NonBlockingTypeProcessorCoreTest, SimpleDelete) {
+TEST_F(ModelTypeSyncWorkerImplTest, SimpleDelete) {
NormalInitialize();
// We can't delete an entity that was never committed.
@@ -502,7 +496,7 @@ TEST_F(NonBlockingTypeProcessorCoreTest, SimpleDelete) {
// The server doesn't like it when we try to delete an entity it's never heard
// of before. This test helps ensure we avoid that scenario.
-TEST_F(NonBlockingTypeProcessorCoreTest, NoDeleteUncommitted) {
+TEST_F(ModelTypeSyncWorkerImplTest, NoDeleteUncommitted) {
NormalInitialize();
// Request the commit of a new, never-before-seen item.
@@ -515,7 +509,7 @@ TEST_F(NonBlockingTypeProcessorCoreTest, NoDeleteUncommitted) {
}
// Verifies the sending of an "initial sync done" signal.
-TEST_F(NonBlockingTypeProcessorCoreTest, SendInitialSyncDone) {
+TEST_F(ModelTypeSyncWorkerImplTest, SendInitialSyncDone) {
FirstInitialize(); // Initialize with no saved sync state.
EXPECT_EQ(0U, GetNumModelThreadUpdateResponses());
@@ -524,7 +518,7 @@ TEST_F(NonBlockingTypeProcessorCoreTest, SendInitialSyncDone) {
// Two updates:
// - One triggered by process updates to forward the type root ID.
- // - One triggered by apply updates, which the core interprets to mean
+ // - One triggered by apply updates, which the worker interprets to mean
// "initial sync done". This triggers a model thread update, too.
EXPECT_EQ(2U, GetNumModelThreadUpdateResponses());
@@ -539,7 +533,7 @@ TEST_F(NonBlockingTypeProcessorCoreTest, SendInitialSyncDone) {
}
// Commit two new entities in two separate commit messages.
-TEST_F(NonBlockingTypeProcessorCoreTest, TwoNewItemsCommittedSeparately) {
+TEST_F(ModelTypeSyncWorkerImplTest, TwoNewItemsCommittedSeparately) {
NormalInitialize();
// Commit the first of two entities.
@@ -564,7 +558,7 @@ TEST_F(NonBlockingTypeProcessorCoreTest, TwoNewItemsCommittedSeparately) {
EXPECT_FALSE(WillCommit());
- // The IDs assigned by the |core_| should be unique.
+ // The IDs assigned by the |worker_| should be unique.
EXPECT_NE(tag1_entity.id_string(), tag2_entity.id_string());
// Check that the committed specifics values are sane.
@@ -576,7 +570,7 @@ TEST_F(NonBlockingTypeProcessorCoreTest, TwoNewItemsCommittedSeparately) {
EXPECT_EQ(2U, GetNumModelThreadCommitResponses());
}
-TEST_F(NonBlockingTypeProcessorCoreTest, ReceiveUpdates) {
+TEST_F(ModelTypeSyncWorkerImplTest, ReceiveUpdates) {
NormalInitialize();
const std::string& tag_hash = GenerateTagHash("tag1");
diff --git a/sync/engine/non_blocking_sync_common.h b/sync/engine/non_blocking_sync_common.h
index d0e0f9d..cefccfe 100644
--- a/sync/engine/non_blocking_sync_common.h
+++ b/sync/engine/non_blocking_sync_common.h
@@ -47,7 +47,7 @@ struct SYNC_EXPORT_PRIVATE DataTypeState {
int64 next_client_id;
// This flag is set to true when the first download cycle is complete. The
- // NonBlockingTypeProcessor should not attempt to commit any items until this
+ // ModelTypeSyncProxy should not attempt to commit any items until this
// flag is set.
bool initial_sync_done;
};
diff --git a/sync/engine/non_blocking_type_commit_contribution.cc b/sync/engine/non_blocking_type_commit_contribution.cc
index 9e48ad6..39823a5 100644
--- a/sync/engine/non_blocking_type_commit_contribution.cc
+++ b/sync/engine/non_blocking_type_commit_contribution.cc
@@ -4,8 +4,8 @@
#include "sync/engine/non_blocking_type_commit_contribution.h"
+#include "sync/engine/model_type_sync_worker_impl.h"
#include "sync/engine/non_blocking_sync_common.h"
-#include "sync/engine/non_blocking_type_processor_core.h"
#include "sync/protocol/proto_value_conversions.h"
namespace syncer {
@@ -14,8 +14,8 @@ NonBlockingTypeCommitContribution::NonBlockingTypeCommitContribution(
const sync_pb::DataTypeContext& context,
const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities,
const std::vector<int64>& sequence_numbers,
- NonBlockingTypeProcessorCore* processor_core)
- : processor_core_(processor_core),
+ ModelTypeSyncWorkerImpl* worker)
+ : worker_(worker),
context_(context),
entities_(entities),
sequence_numbers_(sequence_numbers),
@@ -90,7 +90,7 @@ SyncerError NonBlockingTypeCommitContribution::ProcessCommitResponse(
// Send whatever successful responses we did get back to our parent.
// It's the schedulers job to handle the failures.
- processor_core_->OnCommitResponse(response_list);
+ worker_->OnCommitResponse(response_list);
// Let the scheduler know about the failures.
if (unknown_error) {
diff --git a/sync/engine/non_blocking_type_commit_contribution.h b/sync/engine/non_blocking_type_commit_contribution.h
index 4d415ca..d732130 100644
--- a/sync/engine/non_blocking_type_commit_contribution.h
+++ b/sync/engine/non_blocking_type_commit_contribution.h
@@ -13,19 +13,19 @@
namespace syncer {
-class NonBlockingTypeProcessorCore;
+class ModelTypeSyncWorkerImpl;
// A non-blocking sync type's contribution to an outgoing commit message.
//
// Helps build a commit message and process its response. It collaborates
-// closely with the NonBlockingTypeProcessorCore.
+// closely with the ModelTypeSyncWorkerImpl.
class NonBlockingTypeCommitContribution : public CommitContribution {
public:
NonBlockingTypeCommitContribution(
const sync_pb::DataTypeContext& context,
const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities,
const std::vector<int64>& sequence_numbers,
- NonBlockingTypeProcessorCore* processor_core);
+ ModelTypeSyncWorkerImpl* worker);
virtual ~NonBlockingTypeCommitContribution();
// Implementation of CommitContribution
@@ -38,7 +38,7 @@ class NonBlockingTypeCommitContribution : public CommitContribution {
private:
// A non-owned pointer back to the object that created this contribution.
- NonBlockingTypeProcessorCore* const processor_core_;
+ ModelTypeSyncWorkerImpl* const worker_;
// The type-global context information.
const sync_pb::DataTypeContext context_;
diff --git a/sync/engine/non_blocking_type_processor_core_interface.cc b/sync/engine/non_blocking_type_processor_core_interface.cc
deleted file mode 100644
index 6ce74cc..0000000
--- a/sync/engine/non_blocking_type_processor_core_interface.cc
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "sync/engine/non_blocking_type_processor_core_interface.h"
-
-namespace syncer {
-
-NonBlockingTypeProcessorCoreInterface::NonBlockingTypeProcessorCoreInterface() {
-}
-
-NonBlockingTypeProcessorCoreInterface::
- ~NonBlockingTypeProcessorCoreInterface() {
-}
-
-} // namespace syncer
diff --git a/sync/engine/non_blocking_type_processor_core_interface.h b/sync/engine/non_blocking_type_processor_core_interface.h
deleted file mode 100644
index 56675c2..0000000
--- a/sync/engine/non_blocking_type_processor_core_interface.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef SYNC_ENGINE_NON_BLOCKING_TYPE_CORE_INTERFACE_H_
-#define SYNC_ENGINE_NON_BLOCKING_TYPE_CORE_INTERFACE_H_
-
-#include "sync/engine/non_blocking_sync_common.h"
-
-namespace syncer {
-
-// An interface representing a NonBlockingTypeProcessorCore and its thread.
-// This abstraction is useful in tests.
-class SYNC_EXPORT_PRIVATE NonBlockingTypeProcessorCoreInterface {
- public:
- NonBlockingTypeProcessorCoreInterface();
- virtual ~NonBlockingTypeProcessorCoreInterface();
-
- virtual void RequestCommits(const CommitRequestDataList& list) = 0;
-};
-
-} // namespace syncer
-
-#endif // SYNC_ENGINE_NON_BLOCKING_TYPE_CORE_INTERFACE_H_