| Index: sync/engine/model_type_sync_proxy_impl.cc
|
| diff --git a/sync/engine/non_blocking_type_processor.cc b/sync/engine/model_type_sync_proxy_impl.cc
|
| similarity index 68%
|
| rename from sync/engine/non_blocking_type_processor.cc
|
| rename to sync/engine/model_type_sync_proxy_impl.cc
|
| index 9b80543c618d0e824f1a782e9fd1c39551c76724..d865998f3af7b876ef47e5eb84d2fd7a559afd7c 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();
|
|
|