diff options
author | pavely <pavely@chromium.org> | 2015-09-03 10:23:45 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-03 17:24:30 +0000 |
commit | 61d3c01274c509f728bfe1d8db514d6d8d1d0ace (patch) | |
tree | 30f310ab6b25148d8ad224c0622e1ed0436d4964 /sync | |
parent | f333696a0a014fae2a762cdac48776f3153d9284 (diff) | |
download | chromium_src-61d3c01274c509f728bfe1d8db514d6d8d1d0ace.zip chromium_src-61d3c01274c509f728bfe1d8db514d6d8d1d0ace.tar.gz chromium_src-61d3c01274c509f728bfe1d8db514d6d8d1d0ace.tar.bz2 |
[Sync] Rename ModelTypeSyncWorkerImpl to ModelTypeWorker
Following renames are in this change:
ModelTypeSyncWorkerImpl -> ModelTypeWorker
ModelTypeSyncWorkerWrapper -> CommitQueueProxy
BUG=515964
R=stanisc@chromium.org
Review URL: https://codereview.chromium.org/1328743004
Cr-Commit-Position: refs/heads/master@{#347173}
Diffstat (limited to 'sync')
-rw-r--r-- | sync/BUILD.gn | 6 | ||||
-rw-r--r-- | sync/engine/model_type_worker.cc (renamed from sync/engine/model_type_sync_worker_impl.cc) | 96 | ||||
-rw-r--r-- | sync/engine/model_type_worker.h (renamed from sync/engine/model_type_sync_worker_impl.h) | 34 | ||||
-rw-r--r-- | sync/engine/model_type_worker_unittest.cc (renamed from sync/engine/model_type_sync_worker_impl_unittest.cc) | 228 | ||||
-rw-r--r-- | sync/engine/non_blocking_type_commit_contribution.cc | 7 | ||||
-rw-r--r-- | sync/engine/non_blocking_type_commit_contribution.h | 8 | ||||
-rw-r--r-- | sync/sessions/model_type_registry.cc | 63 | ||||
-rw-r--r-- | sync/sessions/model_type_registry.h | 4 | ||||
-rw-r--r-- | sync/sync.gyp | 4 | ||||
-rw-r--r-- | sync/sync_tests.gypi | 2 |
10 files changed, 208 insertions, 244 deletions
diff --git a/sync/BUILD.gn b/sync/BUILD.gn index 110f7c5..2bc56fd 100644 --- a/sync/BUILD.gn +++ b/sync/BUILD.gn @@ -86,8 +86,8 @@ source_set("sync_core") { "engine/model_type_processor.h", "engine/model_type_processor_impl.cc", "engine/model_type_processor_impl.h", - "engine/model_type_sync_worker_impl.cc", - "engine/model_type_sync_worker_impl.h", + "engine/model_type_worker.cc", + "engine/model_type_worker.h", "engine/net/server_connection_manager.cc", "engine/net/server_connection_manager.h", "engine/net/url_translator.cc", @@ -607,7 +607,7 @@ test("sync_unit_tests") { "engine/get_updates_processor_unittest.cc", "engine/model_type_entity_unittest.cc", "engine/model_type_processor_impl_unittest.cc", - "engine/model_type_sync_worker_impl_unittest.cc", + "engine/model_type_worker_unittest.cc", "engine/sync_scheduler_unittest.cc", "engine/syncer_proto_util_unittest.cc", "engine/syncer_unittest.cc", diff --git a/sync/engine/model_type_sync_worker_impl.cc b/sync/engine/model_type_worker.cc index 0670c3f..0643cd7 100644 --- a/sync/engine/model_type_sync_worker_impl.cc +++ b/sync/engine/model_type_worker.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_type_sync_worker_impl.h" +#include "sync/engine/model_type_worker.h" #include "base/bind.h" #include "base/format_macros.h" @@ -25,16 +25,16 @@ using syncer::ModelType; using syncer::NudgeHandler; using syncer::SyncerError; -ModelTypeSyncWorkerImpl::ModelTypeSyncWorkerImpl( +ModelTypeWorker::ModelTypeWorker( ModelType type, const DataTypeState& initial_state, const UpdateResponseDataList& saved_pending_updates, scoped_ptr<Cryptographer> cryptographer, NudgeHandler* nudge_handler, - scoped_ptr<ModelTypeProcessor> type_sync_proxy) + scoped_ptr<ModelTypeProcessor> model_type_processor) : type_(type), data_type_state_(initial_state), - type_sync_proxy_(type_sync_proxy.Pass()), + model_type_processor_(model_type_processor.Pass()), cryptographer_(cryptographer.Pass()), nudge_handler_(nudge_handler), weak_ptr_factory_(this) { @@ -59,19 +59,18 @@ ModelTypeSyncWorkerImpl::ModelTypeSyncWorkerImpl( } } -ModelTypeSyncWorkerImpl::~ModelTypeSyncWorkerImpl() { -} +ModelTypeWorker::~ModelTypeWorker() {} -ModelType ModelTypeSyncWorkerImpl::GetModelType() const { +ModelType ModelTypeWorker::GetModelType() const { DCHECK(CalledOnValidThread()); return type_; } -bool ModelTypeSyncWorkerImpl::IsEncryptionRequired() const { +bool ModelTypeWorker::IsEncryptionRequired() const { return !!cryptographer_; } -void ModelTypeSyncWorkerImpl::UpdateCryptographer( +void ModelTypeWorker::UpdateCryptographer( scoped_ptr<Cryptographer> cryptographer) { DCHECK(cryptographer); cryptographer_ = cryptographer.Pass(); @@ -85,19 +84,19 @@ void ModelTypeSyncWorkerImpl::UpdateCryptographer( } // UpdateHandler implementation. -void ModelTypeSyncWorkerImpl::GetDownloadProgress( +void ModelTypeWorker::GetDownloadProgress( sync_pb::DataTypeProgressMarker* progress_marker) const { DCHECK(CalledOnValidThread()); progress_marker->CopyFrom(data_type_state_.progress_marker); } -void ModelTypeSyncWorkerImpl::GetDataTypeContext( +void ModelTypeWorker::GetDataTypeContext( sync_pb::DataTypeContext* context) const { DCHECK(CalledOnValidThread()); context->CopyFrom(data_type_state_.type_context); } -SyncerError ModelTypeSyncWorkerImpl::ProcessGetUpdatesResponse( +SyncerError ModelTypeWorker::ProcessGetUpdatesResponse( const sync_pb::DataTypeProgressMarker& progress_marker, const sync_pb::DataTypeContext& mutated_context, const SyncEntityList& applicable_updates, @@ -112,8 +111,7 @@ SyncerError ModelTypeSyncWorkerImpl::ProcessGetUpdatesResponse( UpdateResponseDataList pending_updates; for (SyncEntityList::const_iterator update_it = applicable_updates.begin(); - update_it != applicable_updates.end(); - ++update_it) { + update_it != applicable_updates.end(); ++update_it) { const sync_pb::SyncEntity* update_entity = *update_it; // Skip updates for permanent folders. @@ -162,8 +160,8 @@ SyncerError ModelTypeSyncWorkerImpl::ProcessGetUpdatesResponse( } else if (specifics.has_encrypted() && cryptographer_ && cryptographer_->CanDecrypt(specifics.encrypted())) { // Encrypted, but we know the key. - if (DecryptSpecifics( - cryptographer_.get(), specifics, &response_data.specifics)) { + if (DecryptSpecifics(cryptographer_.get(), specifics, + &response_data.specifics)) { entity_tracker->ReceiveUpdate(update_entity->version()); response_data.encryption_key_name = specifics.encrypted().key_name(); response_datas.push_back(response_data); @@ -184,18 +182,16 @@ SyncerError ModelTypeSyncWorkerImpl::ProcessGetUpdatesResponse( DVLOG(1) << ModelTypeToString(type_) << ": " << base::StringPrintf( "Delivering %zd applicable and %zd pending updates.", - response_datas.size(), - pending_updates.size()); + response_datas.size(), pending_updates.size()); // Forward these updates to the model thread so it can do the rest. - type_sync_proxy_->OnUpdateReceived( - data_type_state_, response_datas, pending_updates); + model_type_processor_->OnUpdateReceived(data_type_state_, response_datas, + pending_updates); return syncer::SYNCER_OK; } -void ModelTypeSyncWorkerImpl::ApplyUpdates( - syncer::sessions::StatusController* status) { +void ModelTypeWorker::ApplyUpdates(syncer::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 @@ -206,20 +202,19 @@ void ModelTypeSyncWorkerImpl::ApplyUpdates( data_type_state_.initial_sync_done = true; - type_sync_proxy_->OnUpdateReceived( + model_type_processor_->OnUpdateReceived( data_type_state_, UpdateResponseDataList(), UpdateResponseDataList()); } } -void ModelTypeSyncWorkerImpl::PassiveApplyUpdates( +void ModelTypeWorker::PassiveApplyUpdates( syncer::sessions::StatusController* status) { NOTREACHED() << "Non-blocking types should never apply updates on sync thread. " << "ModelType is: " << ModelTypeToString(type_); } -void ModelTypeSyncWorkerImpl::EnqueueForCommit( - const CommitRequestDataList& list) { +void ModelTypeWorker::EnqueueForCommit(const CommitRequestDataList& list) { DCHECK(CalledOnValidThread()); DCHECK(IsTypeInitialized()) @@ -236,7 +231,7 @@ void ModelTypeSyncWorkerImpl::EnqueueForCommit( } // CommitContributor implementation. -scoped_ptr<CommitContribution> ModelTypeSyncWorkerImpl::GetContribution( +scoped_ptr<CommitContribution> ModelTypeWorker::GetContribution( size_t max_entries) { DCHECK(CalledOnValidThread()); @@ -249,8 +244,7 @@ scoped_ptr<CommitContribution> ModelTypeSyncWorkerImpl::GetContribution( // TODO(rlarocque): Avoid iterating here. for (EntityMap::const_iterator it = entities_.begin(); - it != entities_.end() && space_remaining > 0; - ++it) { + it != entities_.end() && space_remaining > 0; ++it) { EntityTracker* entity = it->second; if (entity->IsCommitPending()) { sync_pb::SyncEntity* commit_entity = commit_entities.Add(); @@ -271,8 +265,7 @@ scoped_ptr<CommitContribution> ModelTypeSyncWorkerImpl::GetContribution( data_type_state_.type_context, commit_entities, sequence_numbers, this)); } -void ModelTypeSyncWorkerImpl::StorePendingCommit( - const CommitRequestData& request) { +void ModelTypeWorker::StorePendingCommit(const CommitRequestData& request) { if (!request.deleted) { DCHECK_EQ(type_, syncer::GetModelTypeFromSpecifics(request.specifics)); } @@ -286,19 +279,14 @@ void ModelTypeSyncWorkerImpl::StorePendingCommit( entities_.insert(request.client_tag_hash, entity.Pass()); } else { EntityTracker* entity = map_it->second; - entity->RequestCommit(request.id, - request.client_tag_hash, - request.sequence_number, - request.base_version, - request.ctime, - request.mtime, - request.non_unique_name, - request.deleted, - request.specifics); + entity->RequestCommit(request.id, request.client_tag_hash, + request.sequence_number, request.base_version, + request.ctime, request.mtime, request.non_unique_name, + request.deleted, request.specifics); } } -void ModelTypeSyncWorkerImpl::OnCommitResponse( +void ModelTypeWorker::OnCommitResponse( const CommitResponseDataList& response_list) { for (CommitResponseDataList::const_iterator response_it = response_list.begin(); @@ -323,19 +311,19 @@ void ModelTypeSyncWorkerImpl::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. - type_sync_proxy_->OnCommitCompleted(data_type_state_, response_list); + model_type_processor_->OnCommitCompleted(data_type_state_, response_list); } -base::WeakPtr<ModelTypeSyncWorkerImpl> ModelTypeSyncWorkerImpl::AsWeakPtr() { +base::WeakPtr<ModelTypeWorker> ModelTypeWorker::AsWeakPtr() { return weak_ptr_factory_.GetWeakPtr(); } -bool ModelTypeSyncWorkerImpl::IsTypeInitialized() const { +bool ModelTypeWorker::IsTypeInitialized() const { return data_type_state_.initial_sync_done && !data_type_state_.progress_marker.token().empty(); } -bool ModelTypeSyncWorkerImpl::CanCommitItems() const { +bool ModelTypeWorker::CanCommitItems() const { // We can't commit anything until we know the type's parent node. // We'll get it in the first update response. if (!IsTypeInitialized()) @@ -350,7 +338,7 @@ bool ModelTypeSyncWorkerImpl::CanCommitItems() const { return true; } -void ModelTypeSyncWorkerImpl::HelpInitializeCommitEntity( +void ModelTypeWorker::HelpInitializeCommitEntity( sync_pb::SyncEntity* sync_entity) { DCHECK(CanCommitItems()); @@ -387,7 +375,7 @@ void ModelTypeSyncWorkerImpl::HelpInitializeCommitEntity( // Call sync_entity->set_parent_id_string(...) for hierarchical entities here. } -void ModelTypeSyncWorkerImpl::OnCryptographerUpdated() { +void ModelTypeWorker::OnCryptographerUpdated() { DCHECK(cryptographer_); bool new_encryption_key = false; @@ -414,8 +402,7 @@ void ModelTypeSyncWorkerImpl::OnCryptographerUpdated() { if (cryptographer_->CanDecrypt(saved_pending.specifics.encrypted())) { UpdateResponseData decrypted_response = saved_pending; - if (DecryptSpecifics(cryptographer_.get(), - saved_pending.specifics, + if (DecryptSpecifics(cryptographer_.get(), saved_pending.specifics, &decrypted_response.specifics)) { decrypted_response.encryption_key_name = saved_pending.specifics.encrypted().key_name(); @@ -432,15 +419,14 @@ void ModelTypeSyncWorkerImpl::OnCryptographerUpdated() { << base::StringPrintf( "Delivering encryption key and %zd decrypted updates.", response_datas.size()); - type_sync_proxy_->OnUpdateReceived(data_type_state_, response_datas, - UpdateResponseDataList()); + model_type_processor_->OnUpdateReceived(data_type_state_, response_datas, + UpdateResponseDataList()); } } -bool ModelTypeSyncWorkerImpl::DecryptSpecifics( - Cryptographer* cryptographer, - const sync_pb::EntitySpecifics& in, - sync_pb::EntitySpecifics* out) { +bool ModelTypeWorker::DecryptSpecifics(Cryptographer* cryptographer, + const sync_pb::EntitySpecifics& in, + sync_pb::EntitySpecifics* out) { DCHECK(in.has_encrypted()); DCHECK(cryptographer->CanDecrypt(in.encrypted())); diff --git a/sync/engine/model_type_sync_worker_impl.h b/sync/engine/model_type_worker.h index 991274f..dbc0d2a 100644 --- a/sync/engine/model_type_sync_worker_impl.h +++ b/sync/engine/model_type_worker.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_TYPE_SYNC_WORKER_IMPL_H_ -#define SYNC_ENGINE_MODEL_TYPE_SYNC_WORKER_IMPL_H_ +#ifndef SYNC_ENGINE_MODEL_TYPE_WORKER_H_ +#define SYNC_ENGINE_MODEL_TYPE_WORKER_H_ #include "base/containers/scoped_ptr_map.h" #include "base/memory/scoped_ptr.h" @@ -49,18 +49,18 @@ class EntityTracker; // 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 ModelTypeSyncWorkerImpl : public syncer::UpdateHandler, - public syncer::CommitContributor, - public CommitQueue, - public base::NonThreadSafe { +class SYNC_EXPORT ModelTypeWorker : public syncer::UpdateHandler, + public syncer::CommitContributor, + public CommitQueue, + public base::NonThreadSafe { public: - ModelTypeSyncWorkerImpl(syncer::ModelType type, - const DataTypeState& initial_state, - const UpdateResponseDataList& saved_pending_updates, - scoped_ptr<syncer::Cryptographer> cryptographer, - syncer::NudgeHandler* nudge_handler, - scoped_ptr<ModelTypeProcessor> type_sync_proxy); - ~ModelTypeSyncWorkerImpl() override; + ModelTypeWorker(syncer::ModelType type, + const DataTypeState& initial_state, + const UpdateResponseDataList& saved_pending_updates, + scoped_ptr<syncer::Cryptographer> cryptographer, + syncer::NudgeHandler* nudge_handler, + scoped_ptr<ModelTypeProcessor> model_type_processor); + ~ModelTypeWorker() override; syncer::ModelType GetModelType() const; @@ -89,7 +89,7 @@ class SYNC_EXPORT ModelTypeSyncWorkerImpl : public syncer::UpdateHandler, // Callback for when our contribution gets a response. void OnCommitResponse(const CommitResponseDataList& response_list); - base::WeakPtr<ModelTypeSyncWorkerImpl> AsWeakPtr(); + base::WeakPtr<ModelTypeWorker> AsWeakPtr(); private: typedef base::ScopedPtrMap<std::string, scoped_ptr<EntityTracker>> EntityMap; @@ -139,7 +139,7 @@ class SYNC_EXPORT ModelTypeSyncWorkerImpl : public syncer::UpdateHandler, // Pointer to the ModelTypeProcessor associated with this worker. // This is NULL when no proxy is connected.. - scoped_ptr<ModelTypeProcessor> type_sync_proxy_; + scoped_ptr<ModelTypeProcessor> model_type_processor_; // A private copy of the most recent cryptographer known to sync. // Initialized at construction time and updated with UpdateCryptographer(). @@ -162,9 +162,9 @@ class SYNC_EXPORT ModelTypeSyncWorkerImpl : public syncer::UpdateHandler, // the steady state. EntityMap entities_; - base::WeakPtrFactory<ModelTypeSyncWorkerImpl> weak_ptr_factory_; + base::WeakPtrFactory<ModelTypeWorker> weak_ptr_factory_; }; } // namespace syncer -#endif // SYNC_ENGINE_MODEL_TYPE_SYNC_WORKER_IMPL_H_ +#endif // SYNC_ENGINE_MODEL_TYPE_WORKER_H_ diff --git a/sync/engine/model_type_sync_worker_impl_unittest.cc b/sync/engine/model_type_worker_unittest.cc index 1caae74..87701d1 100644 --- a/sync/engine/model_type_sync_worker_impl_unittest.cc +++ b/sync/engine/model_type_worker_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_type_sync_worker_impl.h" +#include "sync/engine/model_type_worker.h" #include "base/strings/stringprintf.h" #include "sync/engine/commit_contribution.h" @@ -32,7 +32,7 @@ using syncer::KeyParams; using syncer::Nigori; using syncer::sessions::StatusController; -// Tests the ModelTypeSyncWorkerImpl. +// Tests the ModelTypeWorker. // // This class passes messages between the model thread and sync server. // As such, its code is subject to lots of different race conditions. This @@ -58,11 +58,11 @@ using syncer::sessions::StatusController; // // 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 ModelTypeSyncWorkerImplTest : public ::testing::Test { +// convenience functions so we can emulate server behavior. +class ModelTypeWorkerTest : public ::testing::Test { public: - ModelTypeSyncWorkerImplTest(); - ~ModelTypeSyncWorkerImplTest() override; + ModelTypeWorkerTest(); + ~ModelTypeWorkerTest() override; // One of these Initialize functions should be called at the beginning of // each test. @@ -213,12 +213,12 @@ class ModelTypeSyncWorkerImplTest : public ::testing::Test { // value implies no encryption. int update_encryption_filter_index_; - // The ModelTypeSyncWorkerImpl being tested. - scoped_ptr<ModelTypeSyncWorkerImpl> worker_; + // The ModelTypeWorker being tested. + scoped_ptr<ModelTypeWorker> worker_; // Non-owned, possibly NULL pointer. This object belongs to the - // ModelTypeSyncWorkerImpl under test. - MockModelTypeProcessor* mock_type_sync_proxy_; + // ModelTypeWorker under test. + MockModelTypeProcessor* mock_type_processor_; // A mock that emulates enough of the sync server that it can be used // a single UpdateHandler and CommitContributor pair. In this test @@ -230,17 +230,15 @@ class ModelTypeSyncWorkerImplTest : public ::testing::Test { syncer::MockNudgeHandler mock_nudge_handler_; }; -ModelTypeSyncWorkerImplTest::ModelTypeSyncWorkerImplTest() +ModelTypeWorkerTest::ModelTypeWorkerTest() : foreign_encryption_key_index_(0), update_encryption_filter_index_(0), - mock_type_sync_proxy_(NULL), - mock_server_(kModelType) { -} + mock_type_processor_(NULL), + mock_server_(kModelType) {} -ModelTypeSyncWorkerImplTest::~ModelTypeSyncWorkerImplTest() { -} +ModelTypeWorkerTest::~ModelTypeWorkerTest() {} -void ModelTypeSyncWorkerImplTest::FirstInitialize() { +void ModelTypeWorkerTest::FirstInitialize() { DataTypeState initial_state; initial_state.progress_marker.set_data_type_id( GetSpecificsFieldNumberFromModelType(kModelType)); @@ -248,11 +246,11 @@ void ModelTypeSyncWorkerImplTest::FirstInitialize() { InitializeWithState(initial_state, UpdateResponseDataList()); } -void ModelTypeSyncWorkerImplTest::NormalInitialize() { +void ModelTypeWorkerTest::NormalInitialize() { InitializeWithPendingUpdates(UpdateResponseDataList()); } -void ModelTypeSyncWorkerImplTest::InitializeWithPendingUpdates( +void ModelTypeWorkerTest::InitializeWithPendingUpdates( const UpdateResponseDataList& initial_pending_updates) { DataTypeState initial_state; initial_state.progress_marker.set_data_type_id( @@ -266,29 +264,26 @@ void ModelTypeSyncWorkerImplTest::InitializeWithPendingUpdates( mock_nudge_handler_.ClearCounters(); } -void ModelTypeSyncWorkerImplTest::InitializeWithState( +void ModelTypeWorkerTest::InitializeWithState( const DataTypeState& state, const UpdateResponseDataList& initial_pending_updates) { DCHECK(!worker_); // We don't get to own this object. The |worker_| keeps a scoped_ptr to it. - mock_type_sync_proxy_ = new MockModelTypeProcessor(); - scoped_ptr<ModelTypeProcessor> proxy(mock_type_sync_proxy_); + mock_type_processor_ = new MockModelTypeProcessor(); + scoped_ptr<ModelTypeProcessor> proxy(mock_type_processor_); scoped_ptr<Cryptographer> cryptographer_copy; if (cryptographer_) { cryptographer_copy.reset(new Cryptographer(*cryptographer_)); } - worker_.reset(new ModelTypeSyncWorkerImpl(kModelType, - state, - initial_pending_updates, - cryptographer_copy.Pass(), - &mock_nudge_handler_, - proxy.Pass())); + worker_.reset(new ModelTypeWorker(kModelType, state, initial_pending_updates, + cryptographer_copy.Pass(), + &mock_nudge_handler_, proxy.Pass())); } -void ModelTypeSyncWorkerImplTest::NewForeignEncryptionKey() { +void ModelTypeWorkerTest::NewForeignEncryptionKey() { if (!cryptographer_) { cryptographer_.reset(new Cryptographer(&fake_encryptor_)); } @@ -305,16 +300,15 @@ void ModelTypeSyncWorkerImplTest::NewForeignEncryptionKey() { sync_pb::NigoriKey* key = bag.add_key(); key->set_name(GetNigoriName(nigori)); - nigori.ExportKeys(key->mutable_user_key(), - key->mutable_encryption_key(), + nigori.ExportKeys(key->mutable_user_key(), key->mutable_encryption_key(), key->mutable_mac_key()); } // Re-create the last nigori from that loop. Nigori last_nigori; KeyParams params = GetNthKeyParams(foreign_encryption_key_index_); - last_nigori.InitByDerivation( - params.hostname, params.username, params.password); + last_nigori.InitByDerivation(params.hostname, params.username, + params.password); // Serialize and encrypt the bag with the last nigori. std::string serialized_bag; @@ -334,7 +328,7 @@ void ModelTypeSyncWorkerImplTest::NewForeignEncryptionKey() { } } -void ModelTypeSyncWorkerImplTest::UpdateLocalCryptographer() { +void ModelTypeWorkerTest::UpdateLocalCryptographer() { if (!cryptographer_) { cryptographer_.reset(new Cryptographer(&fake_encryptor_)); } @@ -350,29 +344,29 @@ void ModelTypeSyncWorkerImplTest::UpdateLocalCryptographer() { } } -void ModelTypeSyncWorkerImplTest::SetUpdateEncryptionFilter(int n) { +void ModelTypeWorkerTest::SetUpdateEncryptionFilter(int n) { update_encryption_filter_index_ = n; } -void ModelTypeSyncWorkerImplTest::CommitRequest(const std::string& name, - const std::string& value) { +void ModelTypeWorkerTest::CommitRequest(const std::string& name, + const std::string& value) { const std::string tag_hash = GenerateTagHash(name); - CommitRequestData data = mock_type_sync_proxy_->CommitRequest( + CommitRequestData data = mock_type_processor_->CommitRequest( tag_hash, GenerateSpecifics(name, value)); CommitRequestDataList list; list.push_back(data); worker_->EnqueueForCommit(list); } -void ModelTypeSyncWorkerImplTest::DeleteRequest(const std::string& tag) { +void ModelTypeWorkerTest::DeleteRequest(const std::string& tag) { const std::string tag_hash = GenerateTagHash(tag); - CommitRequestData data = mock_type_sync_proxy_->DeleteRequest(tag_hash); + CommitRequestData data = mock_type_processor_->DeleteRequest(tag_hash); CommitRequestDataList list; list.push_back(data); worker_->EnqueueForCommit(list); } -void ModelTypeSyncWorkerImplTest::TriggerTypeRootUpdateFromServer() { +void ModelTypeWorkerTest::TriggerTypeRootUpdateFromServer() { sync_pb::SyncEntity entity = mock_server_.TypeRootUpdate(); SyncEntityList entity_list; entity_list.push_back(&entity); @@ -380,16 +374,14 @@ void ModelTypeSyncWorkerImplTest::TriggerTypeRootUpdateFromServer() { StatusController dummy_status; worker_->ProcessGetUpdatesResponse(mock_server_.GetProgress(), - mock_server_.GetContext(), - entity_list, + mock_server_.GetContext(), entity_list, &dummy_status); worker_->ApplyUpdates(&dummy_status); } -void ModelTypeSyncWorkerImplTest::TriggerUpdateFromServer( - int64 version_offset, - const std::string& tag, - const std::string& value) { +void ModelTypeWorkerTest::TriggerUpdateFromServer(int64 version_offset, + const std::string& tag, + const std::string& value) { sync_pb::SyncEntity entity = mock_server_.UpdateFromServer( version_offset, GenerateTagHash(tag), GenerateSpecifics(tag, value)); @@ -404,25 +396,21 @@ void ModelTypeSyncWorkerImplTest::TriggerUpdateFromServer( StatusController dummy_status; worker_->ProcessGetUpdatesResponse(mock_server_.GetProgress(), - mock_server_.GetContext(), - entity_list, + mock_server_.GetContext(), entity_list, &dummy_status); worker_->ApplyUpdates(&dummy_status); } -void ModelTypeSyncWorkerImplTest::DeliverRawUpdates( - const SyncEntityList& list) { +void ModelTypeWorkerTest::DeliverRawUpdates(const SyncEntityList& list) { StatusController dummy_status; worker_->ProcessGetUpdatesResponse(mock_server_.GetProgress(), - mock_server_.GetContext(), - list, + mock_server_.GetContext(), list, &dummy_status); worker_->ApplyUpdates(&dummy_status); } -void ModelTypeSyncWorkerImplTest::TriggerTombstoneFromServer( - int64 version_offset, - const std::string& tag) { +void ModelTypeWorkerTest::TriggerTombstoneFromServer(int64 version_offset, + const std::string& tag) { sync_pb::SyncEntity entity = mock_server_.TombstoneFromServer(version_offset, GenerateTagHash(tag)); @@ -437,22 +425,20 @@ void ModelTypeSyncWorkerImplTest::TriggerTombstoneFromServer( StatusController dummy_status; worker_->ProcessGetUpdatesResponse(mock_server_.GetProgress(), - mock_server_.GetContext(), - entity_list, + mock_server_.GetContext(), entity_list, &dummy_status); worker_->ApplyUpdates(&dummy_status); } -void ModelTypeSyncWorkerImplTest::SetModelThreadIsSynchronous( - bool is_synchronous) { - mock_type_sync_proxy_->SetSynchronousExecution(is_synchronous); +void ModelTypeWorkerTest::SetModelThreadIsSynchronous(bool is_synchronous) { + mock_type_processor_->SetSynchronousExecution(is_synchronous); } -void ModelTypeSyncWorkerImplTest::PumpModelThread() { - mock_type_sync_proxy_->RunQueuedTasks(); +void ModelTypeWorkerTest::PumpModelThread() { + mock_type_processor_->RunQueuedTasks(); } -bool ModelTypeSyncWorkerImplTest::WillCommit() { +bool ModelTypeWorkerTest::WillCommit() { scoped_ptr<CommitContribution> contribution( worker_->GetContribution(INT_MAX)); @@ -468,7 +454,7 @@ bool ModelTypeSyncWorkerImplTest::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 ModelTypeSyncWorkerImplTest::DoSuccessfulCommit() { +void ModelTypeWorkerTest::DoSuccessfulCommit() { DCHECK(WillCommit()); scoped_ptr<CommitContribution> contribution( worker_->GetContribution(INT_MAX)); @@ -484,101 +470,101 @@ void ModelTypeSyncWorkerImplTest::DoSuccessfulCommit() { contribution->CleanUp(); } -size_t ModelTypeSyncWorkerImplTest::GetNumCommitMessagesOnServer() const { +size_t ModelTypeWorkerTest::GetNumCommitMessagesOnServer() const { return mock_server_.GetNumCommitMessages(); } -sync_pb::ClientToServerMessage -ModelTypeSyncWorkerImplTest::GetNthCommitMessageOnServer(size_t n) const { +sync_pb::ClientToServerMessage ModelTypeWorkerTest::GetNthCommitMessageOnServer( + size_t n) const { DCHECK_LT(n, GetNumCommitMessagesOnServer()); return mock_server_.GetNthCommitMessage(n); } -bool ModelTypeSyncWorkerImplTest::HasCommitEntityOnServer( +bool ModelTypeWorkerTest::HasCommitEntityOnServer( const std::string& tag) const { const std::string tag_hash = GenerateTagHash(tag); return mock_server_.HasCommitEntity(tag_hash); } -sync_pb::SyncEntity ModelTypeSyncWorkerImplTest::GetLatestCommitEntityOnServer( +sync_pb::SyncEntity ModelTypeWorkerTest::GetLatestCommitEntityOnServer( const std::string& tag) const { DCHECK(HasCommitEntityOnServer(tag)); const std::string tag_hash = GenerateTagHash(tag); return mock_server_.GetLastCommittedEntity(tag_hash); } -size_t ModelTypeSyncWorkerImplTest::GetNumModelThreadUpdateResponses() const { - return mock_type_sync_proxy_->GetNumUpdateResponses(); +size_t ModelTypeWorkerTest::GetNumModelThreadUpdateResponses() const { + return mock_type_processor_->GetNumUpdateResponses(); } -UpdateResponseDataList -ModelTypeSyncWorkerImplTest::GetNthModelThreadUpdateResponse(size_t n) const { +UpdateResponseDataList ModelTypeWorkerTest::GetNthModelThreadUpdateResponse( + size_t n) const { DCHECK_LT(n, GetNumModelThreadUpdateResponses()); - return mock_type_sync_proxy_->GetNthUpdateResponse(n); + return mock_type_processor_->GetNthUpdateResponse(n); } -UpdateResponseDataList -ModelTypeSyncWorkerImplTest::GetNthModelThreadPendingUpdates(size_t n) const { +UpdateResponseDataList ModelTypeWorkerTest::GetNthModelThreadPendingUpdates( + size_t n) const { DCHECK_LT(n, GetNumModelThreadUpdateResponses()); - return mock_type_sync_proxy_->GetNthPendingUpdates(n); + return mock_type_processor_->GetNthPendingUpdates(n); } -DataTypeState ModelTypeSyncWorkerImplTest::GetNthModelThreadUpdateState( +DataTypeState ModelTypeWorkerTest::GetNthModelThreadUpdateState( size_t n) const { DCHECK_LT(n, GetNumModelThreadUpdateResponses()); - return mock_type_sync_proxy_->GetNthTypeStateReceivedInUpdateResponse(n); + return mock_type_processor_->GetNthTypeStateReceivedInUpdateResponse(n); } -bool ModelTypeSyncWorkerImplTest::HasUpdateResponseOnModelThread( +bool ModelTypeWorkerTest::HasUpdateResponseOnModelThread( const std::string& tag) const { const std::string tag_hash = GenerateTagHash(tag); - return mock_type_sync_proxy_->HasUpdateResponse(tag_hash); + return mock_type_processor_->HasUpdateResponse(tag_hash); } -UpdateResponseData ModelTypeSyncWorkerImplTest::GetUpdateResponseOnModelThread( +UpdateResponseData ModelTypeWorkerTest::GetUpdateResponseOnModelThread( const std::string& tag) const { const std::string tag_hash = GenerateTagHash(tag); - return mock_type_sync_proxy_->GetUpdateResponse(tag_hash); + return mock_type_processor_->GetUpdateResponse(tag_hash); } -size_t ModelTypeSyncWorkerImplTest::GetNumModelThreadCommitResponses() const { - return mock_type_sync_proxy_->GetNumCommitResponses(); +size_t ModelTypeWorkerTest::GetNumModelThreadCommitResponses() const { + return mock_type_processor_->GetNumCommitResponses(); } -CommitResponseDataList -ModelTypeSyncWorkerImplTest::GetNthModelThreadCommitResponse(size_t n) const { +CommitResponseDataList ModelTypeWorkerTest::GetNthModelThreadCommitResponse( + size_t n) const { DCHECK_LT(n, GetNumModelThreadCommitResponses()); - return mock_type_sync_proxy_->GetNthCommitResponse(n); + return mock_type_processor_->GetNthCommitResponse(n); } -DataTypeState ModelTypeSyncWorkerImplTest::GetNthModelThreadCommitState( +DataTypeState ModelTypeWorkerTest::GetNthModelThreadCommitState( size_t n) const { DCHECK_LT(n, GetNumModelThreadCommitResponses()); - return mock_type_sync_proxy_->GetNthTypeStateReceivedInCommitResponse(n); + return mock_type_processor_->GetNthTypeStateReceivedInCommitResponse(n); } -bool ModelTypeSyncWorkerImplTest::HasCommitResponseOnModelThread( +bool ModelTypeWorkerTest::HasCommitResponseOnModelThread( const std::string& tag) const { const std::string tag_hash = GenerateTagHash(tag); - return mock_type_sync_proxy_->HasCommitResponse(tag_hash); + return mock_type_processor_->HasCommitResponse(tag_hash); } -CommitResponseData ModelTypeSyncWorkerImplTest::GetCommitResponseOnModelThread( +CommitResponseData ModelTypeWorkerTest::GetCommitResponseOnModelThread( const std::string& tag) const { DCHECK(HasCommitResponseOnModelThread(tag)); const std::string tag_hash = GenerateTagHash(tag); - return mock_type_sync_proxy_->GetCommitResponse(tag_hash); + return mock_type_processor_->GetCommitResponse(tag_hash); } -int ModelTypeSyncWorkerImplTest::GetNumCommitNudges() const { +int ModelTypeWorkerTest::GetNumCommitNudges() const { return mock_nudge_handler_.GetNumCommitNudges(); } -int ModelTypeSyncWorkerImplTest::GetNumInitialDownloadNudges() const { +int ModelTypeWorkerTest::GetNumInitialDownloadNudges() const { return mock_nudge_handler_.GetNumInitialDownloadNudges(); } -std::string ModelTypeSyncWorkerImplTest::GetLocalCryptographerKeyName() const { +std::string ModelTypeWorkerTest::GetLocalCryptographerKeyName() const { if (!cryptographer_) { return std::string(); } @@ -587,15 +573,14 @@ std::string ModelTypeSyncWorkerImplTest::GetLocalCryptographerKeyName() const { } // static. -std::string ModelTypeSyncWorkerImplTest::GenerateTagHash( - const std::string& tag) { +std::string ModelTypeWorkerTest::GenerateTagHash(const std::string& tag) { const std::string& client_tag_hash = syncer::syncable::GenerateSyncableHash(kModelType, tag); return client_tag_hash; } // static. -sync_pb::EntitySpecifics ModelTypeSyncWorkerImplTest::GenerateSpecifics( +sync_pb::EntitySpecifics ModelTypeWorkerTest::GenerateSpecifics( const std::string& tag, const std::string& value) { sync_pb::EntitySpecifics specifics; @@ -605,7 +590,7 @@ sync_pb::EntitySpecifics ModelTypeSyncWorkerImplTest::GenerateSpecifics( } // static. -std::string ModelTypeSyncWorkerImplTest::GetNigoriName(const Nigori& nigori) { +std::string ModelTypeWorkerTest::GetNigoriName(const Nigori& nigori) { std::string name; if (!nigori.Permute(Nigori::Password, kNigoriKeyName, &name)) { NOTREACHED(); @@ -616,7 +601,7 @@ std::string ModelTypeSyncWorkerImplTest::GetNigoriName(const Nigori& nigori) { } // static. -KeyParams ModelTypeSyncWorkerImplTest::GetNthKeyParams(int n) { +KeyParams ModelTypeWorkerTest::GetNthKeyParams(int n) { KeyParams params; params.hostname = std::string("localhost"); params.username = std::string("userX"); @@ -625,9 +610,8 @@ KeyParams ModelTypeSyncWorkerImplTest::GetNthKeyParams(int n) { } // static. -void ModelTypeSyncWorkerImplTest::EncryptUpdate( - const KeyParams& params, - sync_pb::EntitySpecifics* specifics) { +void ModelTypeWorkerTest::EncryptUpdate(const KeyParams& params, + sync_pb::EntitySpecifics* specifics) { Nigori nigori; nigori.InitByDerivation(params.hostname, params.username, params.password); @@ -652,7 +636,7 @@ void ModelTypeSyncWorkerImplTest::EncryptUpdate( // 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(ModelTypeSyncWorkerImplTest, SimpleCommit) { +TEST_F(ModelTypeWorkerTest, SimpleCommit) { NormalInitialize(); EXPECT_FALSE(WillCommit()); @@ -698,7 +682,7 @@ TEST_F(ModelTypeSyncWorkerImplTest, SimpleCommit) { EXPECT_LT(0, commit_response.response_version); } -TEST_F(ModelTypeSyncWorkerImplTest, SimpleDelete) { +TEST_F(ModelTypeWorkerTest, SimpleDelete) { NormalInitialize(); // We can't delete an entity that was never committed. @@ -747,7 +731,7 @@ TEST_F(ModelTypeSyncWorkerImplTest, 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(ModelTypeSyncWorkerImplTest, NoDeleteUncommitted) { +TEST_F(ModelTypeWorkerTest, NoDeleteUncommitted) { NormalInitialize(); // Request the commit of a new, never-before-seen item. @@ -762,7 +746,7 @@ TEST_F(ModelTypeSyncWorkerImplTest, NoDeleteUncommitted) { } // Verifies the sending of an "initial sync done" signal. -TEST_F(ModelTypeSyncWorkerImplTest, SendInitialSyncDone) { +TEST_F(ModelTypeWorkerTest, SendInitialSyncDone) { FirstInitialize(); // Initialize with no saved sync state. EXPECT_EQ(0U, GetNumModelThreadUpdateResponses()); EXPECT_EQ(1, GetNumInitialDownloadNudges()); @@ -786,7 +770,7 @@ TEST_F(ModelTypeSyncWorkerImplTest, SendInitialSyncDone) { } // Commit two new entities in two separate commit messages. -TEST_F(ModelTypeSyncWorkerImplTest, TwoNewItemsCommittedSeparately) { +TEST_F(ModelTypeWorkerTest, TwoNewItemsCommittedSeparately) { NormalInitialize(); // Commit the first of two entities. @@ -826,7 +810,7 @@ TEST_F(ModelTypeSyncWorkerImplTest, TwoNewItemsCommittedSeparately) { } // Test normal update receipt code path. -TEST_F(ModelTypeSyncWorkerImplTest, ReceiveUpdates) { +TEST_F(ModelTypeWorkerTest, ReceiveUpdates) { NormalInitialize(); const std::string& tag_hash = GenerateTagHash("tag1"); @@ -852,7 +836,7 @@ TEST_F(ModelTypeSyncWorkerImplTest, ReceiveUpdates) { } // Test commit of encrypted updates. -TEST_F(ModelTypeSyncWorkerImplTest, EncryptedCommit) { +TEST_F(ModelTypeWorkerTest, EncryptedCommit) { NormalInitialize(); ASSERT_EQ(0U, GetNumModelThreadUpdateResponses()); @@ -885,7 +869,7 @@ TEST_F(ModelTypeSyncWorkerImplTest, EncryptedCommit) { } // Test items are not committed when encryption is required but unavailable. -TEST_F(ModelTypeSyncWorkerImplTest, EncryptionBlocksCommits) { +TEST_F(ModelTypeWorkerTest, EncryptionBlocksCommits) { NormalInitialize(); CommitRequest("tag1", "value1"); @@ -918,7 +902,7 @@ TEST_F(ModelTypeSyncWorkerImplTest, EncryptionBlocksCommits) { } // Test the receipt of decryptable entities. -TEST_F(ModelTypeSyncWorkerImplTest, ReceiveDecryptableEntities) { +TEST_F(ModelTypeWorkerTest, ReceiveDecryptableEntities) { NormalInitialize(); // Create a new Nigori and allow the cryptographer to decrypt it. @@ -950,7 +934,7 @@ TEST_F(ModelTypeSyncWorkerImplTest, ReceiveDecryptableEntities) { } // Test initializing a CommitQueue with a cryptographer at startup. -TEST_F(ModelTypeSyncWorkerImplTest, InitializeWithCryptographer) { +TEST_F(ModelTypeWorkerTest, InitializeWithCryptographer) { // Set up some encryption state. NewForeignEncryptionKey(); UpdateLocalCryptographer(); @@ -968,7 +952,7 @@ TEST_F(ModelTypeSyncWorkerImplTest, InitializeWithCryptographer) { // Receive updates that are initially undecryptable, then ensure they get // delivered to the model thread when decryption becomes possible. -TEST_F(ModelTypeSyncWorkerImplTest, ReceiveUndecryptableEntries) { +TEST_F(ModelTypeWorkerTest, ReceiveUndecryptableEntries) { NormalInitialize(); // Receive a new foreign encryption key that we can't decrypt. @@ -997,7 +981,7 @@ TEST_F(ModelTypeSyncWorkerImplTest, ReceiveUndecryptableEntries) { } // Ensure that even encrypted updates can cause conflicts. -TEST_F(ModelTypeSyncWorkerImplTest, EncryptedUpdateOverridesPendingCommit) { +TEST_F(ModelTypeWorkerTest, EncryptedUpdateOverridesPendingCommit) { NormalInitialize(); // Prepeare to commit an item. @@ -1020,7 +1004,7 @@ TEST_F(ModelTypeSyncWorkerImplTest, EncryptedUpdateOverridesPendingCommit) { } // Test decryption of pending updates saved across a restart. -TEST_F(ModelTypeSyncWorkerImplTest, RestorePendingEntries) { +TEST_F(ModelTypeWorkerTest, RestorePendingEntries) { // Create a fake pending update. UpdateResponseData update; @@ -1055,7 +1039,7 @@ TEST_F(ModelTypeSyncWorkerImplTest, RestorePendingEntries) { // Test decryption of pending updates saved across a restart. This test // differs from the previous one in that the restored updates can be decrypted // immediately after the CommitQueue is constructed. -TEST_F(ModelTypeSyncWorkerImplTest, RestoreApplicableEntries) { +TEST_F(ModelTypeWorkerTest, RestoreApplicableEntries) { // Update the cryptographer so it can decrypt that update. NewForeignEncryptionKey(); UpdateLocalCryptographer(); @@ -1087,7 +1071,7 @@ TEST_F(ModelTypeSyncWorkerImplTest, RestoreApplicableEntries) { // This should be rare in practice. Usually the cryptographer will be in an // unusable state when we receive undecryptable updates, and that alone will be // enough to prevent all commits. -TEST_F(ModelTypeSyncWorkerImplTest, CommitBlockedByPending) { +TEST_F(ModelTypeWorkerTest, CommitBlockedByPending) { NormalInitialize(); // Prepeare to commit an item. @@ -1111,7 +1095,7 @@ TEST_F(ModelTypeSyncWorkerImplTest, CommitBlockedByPending) { } // Verify that corrupted encrypted updates don't cause crashes. -TEST_F(ModelTypeSyncWorkerImplTest, ReceiveCorruptEncryption) { +TEST_F(ModelTypeWorkerTest, ReceiveCorruptEncryption) { // Initialize the worker with basic encryption state. NormalInitialize(); NewForeignEncryptionKey(); diff --git a/sync/engine/non_blocking_type_commit_contribution.cc b/sync/engine/non_blocking_type_commit_contribution.cc index 9896f2e..cdebda3 100644 --- a/sync/engine/non_blocking_type_commit_contribution.cc +++ b/sync/engine/non_blocking_type_commit_contribution.cc @@ -5,7 +5,7 @@ #include "sync/engine/non_blocking_type_commit_contribution.h" #include "base/values.h" -#include "sync/engine/model_type_sync_worker_impl.h" +#include "sync/engine/model_type_worker.h" #include "sync/internal_api/public/non_blocking_sync_common.h" #include "sync/protocol/proto_value_conversions.h" @@ -15,13 +15,12 @@ NonBlockingTypeCommitContribution::NonBlockingTypeCommitContribution( const sync_pb::DataTypeContext& context, const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities, const std::vector<int64>& sequence_numbers, - ModelTypeSyncWorkerImpl* worker) + ModelTypeWorker* worker) : worker_(worker), context_(context), entities_(entities), sequence_numbers_(sequence_numbers), - cleaned_up_(false) { -} + cleaned_up_(false) {} NonBlockingTypeCommitContribution::~NonBlockingTypeCommitContribution() { DCHECK(cleaned_up_); diff --git a/sync/engine/non_blocking_type_commit_contribution.h b/sync/engine/non_blocking_type_commit_contribution.h index 3a258b9..3247a2c 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_v2 { -class ModelTypeSyncWorkerImpl; +class ModelTypeWorker; // 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 ModelTypeSyncWorkerImpl. +// closely with the ModelTypeWorker. class NonBlockingTypeCommitContribution : public syncer::CommitContribution { public: NonBlockingTypeCommitContribution( const sync_pb::DataTypeContext& context, const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities, const std::vector<int64>& sequence_numbers, - ModelTypeSyncWorkerImpl* worker); + ModelTypeWorker* worker); ~NonBlockingTypeCommitContribution() override; // Implementation of CommitContribution @@ -38,7 +38,7 @@ class NonBlockingTypeCommitContribution : public syncer::CommitContribution { private: // A non-owned pointer back to the object that created this contribution. - ModelTypeSyncWorkerImpl* const worker_; + ModelTypeWorker* const worker_; // The type-global context information. const sync_pb::DataTypeContext context_; diff --git a/sync/sessions/model_type_registry.cc b/sync/sessions/model_type_registry.cc index fae2954..552f4b1 100644 --- a/sync/sessions/model_type_registry.cc +++ b/sync/sessions/model_type_registry.cc @@ -12,7 +12,7 @@ #include "sync/engine/directory_update_handler.h" #include "sync/engine/model_type_processor.h" #include "sync/engine/model_type_processor_impl.h" -#include "sync/engine/model_type_sync_worker_impl.h" +#include "sync/engine/model_type_worker.h" #include "sync/internal_api/public/non_blocking_sync_common.h" #include "sync/sessions/directory_type_debug_info_emitter.h" #include "sync/util/cryptographer.h" @@ -76,34 +76,31 @@ void ModelTypeProcessorProxy::OnUpdateReceived( processor_, type_state, response_list, pending_updates)); } -class ModelTypeSyncWorkerWrapper : public syncer_v2::CommitQueue { +class CommitQueueProxy : public syncer_v2::CommitQueue { public: - ModelTypeSyncWorkerWrapper( - const base::WeakPtr<syncer_v2::ModelTypeSyncWorkerImpl>& worker, - const scoped_refptr<base::SequencedTaskRunner>& sync_thread); - ~ModelTypeSyncWorkerWrapper() override; + CommitQueueProxy(const base::WeakPtr<syncer_v2::ModelTypeWorker>& worker, + const scoped_refptr<base::SequencedTaskRunner>& sync_thread); + ~CommitQueueProxy() override; void EnqueueForCommit(const syncer_v2::CommitRequestDataList& list) override; private: - base::WeakPtr<syncer_v2::ModelTypeSyncWorkerImpl> worker_; + base::WeakPtr<syncer_v2::ModelTypeWorker> worker_; scoped_refptr<base::SequencedTaskRunner> sync_thread_; }; -ModelTypeSyncWorkerWrapper::ModelTypeSyncWorkerWrapper( - const base::WeakPtr<syncer_v2::ModelTypeSyncWorkerImpl>& worker, +CommitQueueProxy::CommitQueueProxy( + const base::WeakPtr<syncer_v2::ModelTypeWorker>& worker, const scoped_refptr<base::SequencedTaskRunner>& sync_thread) : worker_(worker), sync_thread_(sync_thread) {} -ModelTypeSyncWorkerWrapper::~ModelTypeSyncWorkerWrapper() { -} +CommitQueueProxy::~CommitQueueProxy() {} -void ModelTypeSyncWorkerWrapper::EnqueueForCommit( +void CommitQueueProxy::EnqueueForCommit( const syncer_v2::CommitRequestDataList& list) { sync_thread_->PostTask( FROM_HERE, - base::Bind(&syncer_v2::ModelTypeSyncWorkerImpl::EnqueueForCommit, worker_, - list)); + base::Bind(&syncer_v2::ModelTypeWorker::EnqueueForCommit, worker_, list)); } } // namespace @@ -204,19 +201,17 @@ void ModelTypeRegistry::ConnectSyncTypeToWorker( if (encrypted_types_.Has(type)) cryptographer_copy.reset(new Cryptographer(*cryptographer_)); - scoped_ptr<syncer_v2::ModelTypeSyncWorkerImpl> worker( - new syncer_v2::ModelTypeSyncWorkerImpl( - type, data_type_state, saved_pending_updates, - cryptographer_copy.Pass(), nudge_handler_, processor.Pass())); + scoped_ptr<syncer_v2::ModelTypeWorker> worker(new syncer_v2::ModelTypeWorker( + type, data_type_state, saved_pending_updates, cryptographer_copy.Pass(), + nudge_handler_, processor.Pass())); // Initialize Processor -> Worker communication channel. - scoped_ptr<syncer_v2::CommitQueue> wrapped_worker( - new ModelTypeSyncWorkerWrapper(worker->AsWeakPtr(), - scoped_refptr<base::SequencedTaskRunner>( - base::ThreadTaskRunnerHandle::Get()))); + scoped_ptr<syncer_v2::CommitQueue> commit_queue_proxy(new CommitQueueProxy( + worker->AsWeakPtr(), scoped_refptr<base::SequencedTaskRunner>( + base::ThreadTaskRunnerHandle::Get()))); type_task_runner->PostTask( FROM_HERE, base::Bind(&syncer_v2::ModelTypeProcessorImpl::OnConnect, - processor_impl, base::Passed(&wrapped_worker))); + processor_impl, base::Passed(&commit_queue_proxy))); DCHECK(update_handler_map_.find(type) == update_handler_map_.end()); DCHECK(commit_contributor_map_.find(type) == commit_contributor_map_.end()); @@ -225,7 +220,7 @@ void ModelTypeRegistry::ConnectSyncTypeToWorker( commit_contributor_map_.insert(std::make_pair(type, worker.get())); // The container takes ownership. - model_type_sync_workers_.push_back(worker.Pass()); + model_type_workers_.push_back(worker.Pass()); DCHECK(Intersection(GetEnabledDirectoryTypes(), GetEnabledNonBlockingTypes()).Empty()); @@ -243,11 +238,11 @@ void ModelTypeRegistry::DisconnectSyncWorker(ModelType type) { DCHECK_EQ(1U, committers_erased); // Remove from the ScopedVector, deleting the worker in the process. - for (ScopedVector<syncer_v2::ModelTypeSyncWorkerImpl>::iterator it = - model_type_sync_workers_.begin(); - it != model_type_sync_workers_.end(); ++it) { + for (ScopedVector<syncer_v2::ModelTypeWorker>::iterator it = + model_type_workers_.begin(); + it != model_type_workers_.end(); ++it) { if ((*it)->GetModelType() == type) { - model_type_sync_workers_.erase(it); + model_type_workers_.erase(it); break; } } @@ -341,9 +336,9 @@ ModelTypeSet ModelTypeRegistry::GetEnabledDirectoryTypes() const { } void ModelTypeRegistry::OnEncryptionStateChanged() { - for (ScopedVector<syncer_v2::ModelTypeSyncWorkerImpl>::iterator it = - model_type_sync_workers_.begin(); - it != model_type_sync_workers_.end(); ++it) { + for (ScopedVector<syncer_v2::ModelTypeWorker>::iterator it = + model_type_workers_.begin(); + it != model_type_workers_.end(); ++it) { if (encrypted_types_.Has((*it)->GetModelType())) { (*it)->UpdateCryptographer( make_scoped_ptr(new Cryptographer(*cryptographer_))); @@ -353,9 +348,9 @@ void ModelTypeRegistry::OnEncryptionStateChanged() { ModelTypeSet ModelTypeRegistry::GetEnabledNonBlockingTypes() const { ModelTypeSet enabled_off_thread_types; - for (ScopedVector<syncer_v2::ModelTypeSyncWorkerImpl>::const_iterator it = - model_type_sync_workers_.begin(); - it != model_type_sync_workers_.end(); ++it) { + for (ScopedVector<syncer_v2::ModelTypeWorker>::const_iterator it = + model_type_workers_.begin(); + it != model_type_workers_.end(); ++it) { enabled_off_thread_types.Put((*it)->GetModelType()); } return enabled_off_thread_types; diff --git a/sync/sessions/model_type_registry.h b/sync/sessions/model_type_registry.h index 868b3c2..a27468e 100644 --- a/sync/sessions/model_type_registry.h +++ b/sync/sessions/model_type_registry.h @@ -22,8 +22,8 @@ namespace syncer_v2 { struct DataTypeState; -class ModelTypeSyncWorkerImpl; class ModelTypeProcessorImpl; +class ModelTypeWorker; } namespace syncer { @@ -120,7 +120,7 @@ class SYNC_EXPORT_PRIVATE ModelTypeRegistry ScopedVector<DirectoryTypeDebugInfoEmitter> directory_type_debug_info_emitters_; - ScopedVector<syncer_v2::ModelTypeSyncWorkerImpl> model_type_sync_workers_; + ScopedVector<syncer_v2::ModelTypeWorker> model_type_workers_; // Maps of UpdateHandlers and CommitContributors. // They do not own any of the objects they point to. diff --git a/sync/sync.gyp b/sync/sync.gyp index 1e21d77..37eb375 100644 --- a/sync/sync.gyp +++ b/sync/sync.gyp @@ -137,8 +137,8 @@ 'engine/model_type_processor.h', 'engine/model_type_processor_impl.cc', 'engine/model_type_processor_impl.h', - 'engine/model_type_sync_worker_impl.cc', - 'engine/model_type_sync_worker_impl.h', + 'engine/model_type_worker.cc', + 'engine/model_type_worker.h', 'engine/net/server_connection_manager.cc', 'engine/net/server_connection_manager.h', 'engine/net/url_translator.cc', diff --git a/sync/sync_tests.gypi b/sync/sync_tests.gypi index e2ca783..ea44901 100644 --- a/sync/sync_tests.gypi +++ b/sync/sync_tests.gypi @@ -279,7 +279,7 @@ 'engine/get_updates_processor_unittest.cc', 'engine/model_type_entity_unittest.cc', 'engine/model_type_processor_impl_unittest.cc', - 'engine/model_type_sync_worker_impl_unittest.cc', + 'engine/model_type_worker_unittest.cc', 'engine/sync_scheduler_unittest.cc', 'engine/syncer_proto_util_unittest.cc', 'engine/syncer_unittest.cc', |