Index: sync/internal_api/shared_model_type_processor.cc |
diff --git a/sync/engine/model_type_processor_impl.cc b/sync/internal_api/shared_model_type_processor.cc |
similarity index 77% |
rename from sync/engine/model_type_processor_impl.cc |
rename to sync/internal_api/shared_model_type_processor.cc |
index 94e5c6311afc5489eee8ffcf492d44fa63ed3b0f..cfb1df17243437220c08c1b356b5d0ac4f2f5ac6 100644 |
--- a/sync/engine/model_type_processor_impl.cc |
+++ b/sync/internal_api/shared_model_type_processor.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_processor_impl.h" |
+#include "sync/internal_api/public/shared_model_type_processor.h" |
#include "base/bind.h" |
#include "base/location.h" |
@@ -15,7 +15,7 @@ |
namespace syncer_v2 { |
-ModelTypeProcessorImpl::ModelTypeProcessorImpl( |
+SharedModelTypeProcessor::SharedModelTypeProcessor( |
syncer::ModelType type, |
base::WeakPtr<ModelTypeStore> store) |
: type_(type), |
@@ -25,25 +25,24 @@ ModelTypeProcessorImpl::ModelTypeProcessorImpl( |
weak_ptr_factory_for_ui_(this), |
weak_ptr_factory_for_sync_(this) {} |
-ModelTypeProcessorImpl::~ModelTypeProcessorImpl() { |
-} |
+SharedModelTypeProcessor::~SharedModelTypeProcessor() {} |
-bool ModelTypeProcessorImpl::IsPreferred() const { |
+bool SharedModelTypeProcessor::IsPreferred() const { |
DCHECK(CalledOnValidThread()); |
return is_preferred_; |
} |
-bool ModelTypeProcessorImpl::IsConnected() const { |
+bool SharedModelTypeProcessor::IsConnected() const { |
DCHECK(CalledOnValidThread()); |
return is_connected_; |
} |
-syncer::ModelType ModelTypeProcessorImpl::GetModelType() const { |
+syncer::ModelType SharedModelTypeProcessor::GetModelType() const { |
DCHECK(CalledOnValidThread()); |
return type_; |
} |
-void ModelTypeProcessorImpl::Enable( |
+void SharedModelTypeProcessor::Enable( |
scoped_ptr<SyncContextProxy> sync_context_proxy) { |
DCHECK(CalledOnValidThread()); |
DVLOG(1) << "Asked to enable " << ModelTypeToString(type_); |
@@ -66,7 +65,7 @@ void ModelTypeProcessorImpl::Enable( |
activation_context.Pass()); |
} |
-void ModelTypeProcessorImpl::Disable() { |
+void SharedModelTypeProcessor::Disable() { |
DCHECK(CalledOnValidThread()); |
is_preferred_ = false; |
Disconnect(); |
@@ -74,7 +73,7 @@ void ModelTypeProcessorImpl::Disable() { |
ClearSyncState(); |
} |
-void ModelTypeProcessorImpl::Disconnect() { |
+void SharedModelTypeProcessor::Disconnect() { |
DCHECK(CalledOnValidThread()); |
DVLOG(1) << "Asked to disconnect " << ModelTypeToString(type_); |
is_connected_ = false; |
@@ -90,12 +89,13 @@ void ModelTypeProcessorImpl::Disconnect() { |
ClearTransientSyncState(); |
} |
-base::WeakPtr<ModelTypeProcessorImpl> ModelTypeProcessorImpl::AsWeakPtrForUI() { |
+base::WeakPtr<SharedModelTypeProcessor> |
+SharedModelTypeProcessor::AsWeakPtrForUI() { |
DCHECK(CalledOnValidThread()); |
return weak_ptr_factory_for_ui_.GetWeakPtr(); |
} |
-void ModelTypeProcessorImpl::OnConnect(scoped_ptr<CommitQueue> worker) { |
+void SharedModelTypeProcessor::OnConnect(scoped_ptr<CommitQueue> worker) { |
DCHECK(CalledOnValidThread()); |
DVLOG(1) << "Successfully connected " << ModelTypeToString(type_); |
@@ -105,8 +105,8 @@ void ModelTypeProcessorImpl::OnConnect(scoped_ptr<CommitQueue> worker) { |
FlushPendingCommitRequests(); |
} |
-void ModelTypeProcessorImpl::Put(const std::string& client_tag, |
- const sync_pb::EntitySpecifics& specifics) { |
+void SharedModelTypeProcessor::Put(const std::string& client_tag, |
+ const sync_pb::EntitySpecifics& specifics) { |
DCHECK_EQ(type_, syncer::GetModelTypeFromSpecifics(specifics)); |
const std::string client_tag_hash( |
@@ -125,7 +125,7 @@ void ModelTypeProcessorImpl::Put(const std::string& client_tag, |
FlushPendingCommitRequests(); |
} |
-void ModelTypeProcessorImpl::Delete(const std::string& client_tag) { |
+void SharedModelTypeProcessor::Delete(const std::string& client_tag) { |
const std::string client_tag_hash( |
syncer::syncable::GenerateSyncableHash(type_, client_tag)); |
@@ -143,7 +143,7 @@ void ModelTypeProcessorImpl::Delete(const std::string& client_tag) { |
FlushPendingCommitRequests(); |
} |
-void ModelTypeProcessorImpl::FlushPendingCommitRequests() { |
+void SharedModelTypeProcessor::FlushPendingCommitRequests() { |
CommitRequestDataList commit_requests; |
// Don't bother sending anything if there's no one to send to. |
@@ -169,7 +169,7 @@ void ModelTypeProcessorImpl::FlushPendingCommitRequests() { |
worker_->EnqueueForCommit(commit_requests); |
} |
-void ModelTypeProcessorImpl::OnCommitCompleted( |
+void SharedModelTypeProcessor::OnCommitCompleted( |
const DataTypeState& type_state, |
const CommitResponseDataList& response_list) { |
data_type_state_ = type_state; |
@@ -185,15 +185,14 @@ void ModelTypeProcessorImpl::OnCommitCompleted( |
<< " type: " << type_ << " client_tag: " << client_tag_hash; |
return; |
} else { |
- it->second->ReceiveCommitResponse(response_data.id, |
- response_data.sequence_number, |
- response_data.response_version, |
- data_type_state_.encryption_key_name); |
+ it->second->ReceiveCommitResponse( |
+ response_data.id, response_data.sequence_number, |
+ response_data.response_version, data_type_state_.encryption_key_name); |
} |
} |
} |
-void ModelTypeProcessorImpl::OnUpdateReceived( |
+void SharedModelTypeProcessor::OnUpdateReceived( |
const DataTypeState& data_type_state, |
const UpdateResponseDataList& response_list, |
const UpdateResponseDataList& pending_updates) { |
@@ -213,24 +212,18 @@ void ModelTypeProcessorImpl::OnUpdateReceived( |
EntityMap::const_iterator it = entities_.find(client_tag_hash); |
if (it == entities_.end()) { |
- 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, |
- response_data.encryption_key_name); |
+ 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, response_data.encryption_key_name); |
entities_.insert(client_tag_hash, entity.Pass()); |
} else { |
ModelTypeEntity* entity = it->second; |
- entity->ApplyUpdateFromServer(response_data.response_version, |
- response_data.deleted, |
- response_data.specifics, |
- response_data.mtime, |
- response_data.encryption_key_name); |
+ entity->ApplyUpdateFromServer( |
+ response_data.response_version, response_data.deleted, |
+ response_data.specifics, response_data.mtime, |
+ response_data.encryption_key_name); |
// TODO: Do something special when conflicts are detected. |
} |
@@ -283,24 +276,23 @@ void ModelTypeProcessorImpl::OnUpdateReceived( |
// TODO: Persist the new data on disk. |
} |
-UpdateResponseDataList ModelTypeProcessorImpl::GetPendingUpdates() { |
+UpdateResponseDataList SharedModelTypeProcessor::GetPendingUpdates() { |
UpdateResponseDataList pending_updates_list; |
for (UpdateMap::const_iterator it = pending_updates_map_.begin(); |
- it != pending_updates_map_.end(); |
- ++it) { |
+ it != pending_updates_map_.end(); ++it) { |
pending_updates_list.push_back(*it->second); |
} |
return pending_updates_list; |
} |
-void ModelTypeProcessorImpl::ClearTransientSyncState() { |
+void SharedModelTypeProcessor::ClearTransientSyncState() { |
for (EntityMap::const_iterator it = entities_.begin(); it != entities_.end(); |
++it) { |
it->second->ClearTransientSyncState(); |
} |
} |
-void ModelTypeProcessorImpl::ClearSyncState() { |
+void SharedModelTypeProcessor::ClearSyncState() { |
for (EntityMap::const_iterator it = entities_.begin(); it != entities_.end(); |
++it) { |
it->second->ClearSyncState(); |