Commit 02520366 authored by Jan Krcal's avatar Jan Krcal Committed by Commit Bot

[USS] Rename the SharedModelTypeProcessor

This CL renames the class to ClientTagBasesModelTypeProcessor that
 a) does not make the impression that its instance is shared
 b) uses a specific trait that distinguish this from other
    ModelTypeProcessors.

Bug: none
Change-Id: Ib5b3d9bb746a5667345dca07fe2a2306d315fca8
Reviewed-on: https://chromium-review.googlesource.com/951245Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541398}
parent 9525f6ab
...@@ -424,6 +424,8 @@ jumbo_static_library("sync") { ...@@ -424,6 +424,8 @@ jumbo_static_library("sync") {
"model/time.h", "model/time.h",
"model_impl/accumulating_metadata_change_list.cc", "model_impl/accumulating_metadata_change_list.cc",
"model_impl/accumulating_metadata_change_list.h", "model_impl/accumulating_metadata_change_list.h",
"model_impl/client_tag_based_model_type_processor.cc",
"model_impl/client_tag_based_model_type_processor.h",
"model_impl/in_memory_metadata_change_list.cc", "model_impl/in_memory_metadata_change_list.cc",
"model_impl/in_memory_metadata_change_list.h", "model_impl/in_memory_metadata_change_list.h",
"model_impl/model_type_store_backend.cc", "model_impl/model_type_store_backend.cc",
...@@ -434,8 +436,6 @@ jumbo_static_library("sync") { ...@@ -434,8 +436,6 @@ jumbo_static_library("sync") {
"model_impl/passthrough_metadata_change_list.h", "model_impl/passthrough_metadata_change_list.h",
"model_impl/processor_entity_tracker.cc", "model_impl/processor_entity_tracker.cc",
"model_impl/processor_entity_tracker.h", "model_impl/processor_entity_tracker.h",
"model_impl/shared_model_type_processor.cc",
"model_impl/shared_model_type_processor.h",
"model_impl/sync_metadata_store_change_list.cc", "model_impl/sync_metadata_store_change_list.cc",
"model_impl/sync_metadata_store_change_list.h", "model_impl/sync_metadata_store_change_list.h",
"protocol/proto_enum_conversions.cc", "protocol/proto_enum_conversions.cc",
...@@ -874,11 +874,11 @@ source_set("unit_tests") { ...@@ -874,11 +874,11 @@ source_set("unit_tests") {
"model/sync_error_unittest.cc", "model/sync_error_unittest.cc",
"model/sync_merge_result_unittest.cc", "model/sync_merge_result_unittest.cc",
"model_impl/accumulating_metadata_change_list_unittest.cc", "model_impl/accumulating_metadata_change_list_unittest.cc",
"model_impl/client_tag_based_model_type_processor_unittest.cc",
"model_impl/model_type_store_backend_unittest.cc", "model_impl/model_type_store_backend_unittest.cc",
"model_impl/model_type_store_impl_unittest.cc", "model_impl/model_type_store_impl_unittest.cc",
"model_impl/passthrough_metadata_change_list_unittest.cc", "model_impl/passthrough_metadata_change_list_unittest.cc",
"model_impl/processor_entity_tracker_unittest.cc", "model_impl/processor_entity_tracker_unittest.cc",
"model_impl/shared_model_type_processor_unittest.cc",
"protocol/proto_enum_conversions_unittest.cc", "protocol/proto_enum_conversions_unittest.cc",
"protocol/proto_value_conversions_unittest.cc", "protocol/proto_value_conversions_unittest.cc",
"syncable/change_record_unittest.cc", "syncable/change_record_unittest.cc",
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "components/sync/model/model_type_change_processor.h" #include "components/sync/model/model_type_change_processor.h"
#include "components/sync/model_impl/shared_model_type_processor.h" #include "components/sync/model_impl/client_tag_based_model_type_processor.h"
namespace syncer { namespace syncer {
...@@ -13,7 +13,7 @@ std::unique_ptr<ModelTypeChangeProcessor> ModelTypeChangeProcessor::Create( ...@@ -13,7 +13,7 @@ std::unique_ptr<ModelTypeChangeProcessor> ModelTypeChangeProcessor::Create(
const base::RepeatingClosure& dump_stack, const base::RepeatingClosure& dump_stack,
ModelType type, ModelType type,
ModelTypeSyncBridge* bridge) { ModelTypeSyncBridge* bridge) {
return std::make_unique<SharedModelTypeProcessor>( return std::make_unique<ClientTagBasedModelTypeProcessor>(
type, bridge, dump_stack, CommitOnlyTypes().Has(type)); type, bridge, dump_stack, CommitOnlyTypes().Has(type));
} }
......
...@@ -19,13 +19,15 @@ namespace syncer { ...@@ -19,13 +19,15 @@ namespace syncer {
namespace { namespace {
SharedModelTypeProcessor* GetProcessorFromBridge(ModelTypeSyncBridge* bridge) { ClientTagBasedModelTypeProcessor* GetProcessorFromBridge(
ModelTypeSyncBridge* bridge) {
ModelTypeChangeProcessor* processor = bridge->change_processor(); ModelTypeChangeProcessor* processor = bridge->change_processor();
if (processor == nullptr) { if (processor == nullptr) {
LOG(WARNING) << "SharedModelTypeProcessor destroyed before debug info was " LOG(WARNING)
<< "ClientTagBasedModelTypeProcessor destroyed before debug info was "
"retrieved."; "retrieved.";
} }
return static_cast<SharedModelTypeProcessor*>(processor); return static_cast<ClientTagBasedModelTypeProcessor*>(processor);
} }
} // namespace } // namespace
...@@ -35,7 +37,7 @@ void ModelTypeDebugInfo::GetAllNodes( ...@@ -35,7 +37,7 @@ void ModelTypeDebugInfo::GetAllNodes(
const base::Callback<void(const ModelType, std::unique_ptr<ListValue>)>& const base::Callback<void(const ModelType, std::unique_ptr<ListValue>)>&
callback, callback,
ModelTypeSyncBridge* bridge) { ModelTypeSyncBridge* bridge) {
SharedModelTypeProcessor* processor = GetProcessorFromBridge(bridge); ClientTagBasedModelTypeProcessor* processor = GetProcessorFromBridge(bridge);
if (processor) { if (processor) {
bridge->GetAllData(base::Bind(&ModelTypeDebugInfo::MergeDataWithMetadata, bridge->GetAllData(base::Bind(&ModelTypeDebugInfo::MergeDataWithMetadata,
base::Unretained(processor), callback)); base::Unretained(processor), callback));
...@@ -46,7 +48,7 @@ void ModelTypeDebugInfo::GetAllNodes( ...@@ -46,7 +48,7 @@ void ModelTypeDebugInfo::GetAllNodes(
void ModelTypeDebugInfo::GetStatusCounters( void ModelTypeDebugInfo::GetStatusCounters(
const base::Callback<void(ModelType, const StatusCounters&)>& callback, const base::Callback<void(ModelType, const StatusCounters&)>& callback,
ModelTypeSyncBridge* bridge) { ModelTypeSyncBridge* bridge) {
SharedModelTypeProcessor* processor = GetProcessorFromBridge(bridge); ClientTagBasedModelTypeProcessor* processor = GetProcessorFromBridge(bridge);
if (processor) { if (processor) {
StatusCounters counters; StatusCounters counters;
counters.num_entries_and_tombstones = processor->entities_.size(); counters.num_entries_and_tombstones = processor->entities_.size();
...@@ -62,7 +64,7 @@ void ModelTypeDebugInfo::GetStatusCounters( ...@@ -62,7 +64,7 @@ void ModelTypeDebugInfo::GetStatusCounters(
// static // static
void ModelTypeDebugInfo::RecordMemoryUsageHistogram( void ModelTypeDebugInfo::RecordMemoryUsageHistogram(
ModelTypeSyncBridge* bridge) { ModelTypeSyncBridge* bridge) {
SharedModelTypeProcessor* processor = GetProcessorFromBridge(bridge); ClientTagBasedModelTypeProcessor* processor = GetProcessorFromBridge(bridge);
size_t memory_usage = processor->EstimateMemoryUsage(); size_t memory_usage = processor->EstimateMemoryUsage();
SyncRecordMemoryKbHistogram(kModelTypeMemoryHistogramPrefix, processor->type_, SyncRecordMemoryKbHistogram(kModelTypeMemoryHistogramPrefix, processor->type_,
memory_usage); memory_usage);
...@@ -72,7 +74,7 @@ ModelTypeDebugInfo::ModelTypeDebugInfo() {} ...@@ -72,7 +74,7 @@ ModelTypeDebugInfo::ModelTypeDebugInfo() {}
// static // static
void ModelTypeDebugInfo::MergeDataWithMetadata( void ModelTypeDebugInfo::MergeDataWithMetadata(
SharedModelTypeProcessor* processor, ClientTagBasedModelTypeProcessor* processor,
const base::Callback<void(const ModelType, std::unique_ptr<ListValue>)>& const base::Callback<void(const ModelType, std::unique_ptr<ListValue>)>&
callback, callback,
std::unique_ptr<DataBatch> batch) { std::unique_ptr<DataBatch> batch) {
......
...@@ -11,14 +11,14 @@ ...@@ -11,14 +11,14 @@
#include "base/values.h" #include "base/values.h"
#include "components/sync/base/model_type.h" #include "components/sync/base/model_type.h"
#include "components/sync/model/model_type_sync_bridge.h" #include "components/sync/model/model_type_sync_bridge.h"
#include "components/sync/model_impl/shared_model_type_processor.h" #include "components/sync/model_impl/client_tag_based_model_type_processor.h"
namespace syncer { namespace syncer {
// This class holds static functions used for extracting debug information for a // This class holds static functions used for extracting debug information for a
// model type. They should be run on the model thread. These functions are // model type. They should be run on the model thread. These functions are
// static so they can be posted to from the UI thread, and they live inside a // static so they can be posted to from the UI thread, and they live inside a
// class because it is a friend class to SharedModelTypeProcessor. // class because it is a friend class to ClientTagBasedModelTypeProcessor.
class ModelTypeDebugInfo { class ModelTypeDebugInfo {
public: public:
// Returns a ListValue representing all nodes for the type to |callback|. // Returns a ListValue representing all nodes for the type to |callback|.
...@@ -46,7 +46,7 @@ class ModelTypeDebugInfo { ...@@ -46,7 +46,7 @@ class ModelTypeDebugInfo {
// function will merge real data from |batch| with metadata extracted from // function will merge real data from |batch| with metadata extracted from
// the |processor|, then pass it all to |callback|. // the |processor|, then pass it all to |callback|.
static void MergeDataWithMetadata( static void MergeDataWithMetadata(
SharedModelTypeProcessor* processor, ClientTagBasedModelTypeProcessor* processor,
const base::Callback<void(const ModelType, const base::Callback<void(const ModelType,
std::unique_ptr<base::ListValue>)>& callback, std::unique_ptr<base::ListValue>)>& callback,
std::unique_ptr<DataBatch> batch); std::unique_ptr<DataBatch> batch);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/sync/model_impl/shared_model_type_processor.h" #include "components/sync/model_impl/client_tag_based_model_type_processor.h"
#include <utility> #include <utility>
#include <vector> #include <vector>
...@@ -44,7 +44,7 @@ int64_t FindTheNthBigestProtoTimeStamp(std::vector<int64_t> time_stamps, ...@@ -44,7 +44,7 @@ int64_t FindTheNthBigestProtoTimeStamp(std::vector<int64_t> time_stamps,
} }
} // namespace } // namespace
SharedModelTypeProcessor::SharedModelTypeProcessor( ClientTagBasedModelTypeProcessor::ClientTagBasedModelTypeProcessor(
ModelType type, ModelType type,
ModelTypeSyncBridge* bridge, ModelTypeSyncBridge* bridge,
const base::RepeatingClosure& dump_stack, const base::RepeatingClosure& dump_stack,
...@@ -59,11 +59,11 @@ SharedModelTypeProcessor::SharedModelTypeProcessor( ...@@ -59,11 +59,11 @@ SharedModelTypeProcessor::SharedModelTypeProcessor(
DCHECK(bridge); DCHECK(bridge);
} }
SharedModelTypeProcessor::~SharedModelTypeProcessor() { ClientTagBasedModelTypeProcessor::~ClientTagBasedModelTypeProcessor() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
} }
void SharedModelTypeProcessor::OnSyncStarting( void ClientTagBasedModelTypeProcessor::OnSyncStarting(
const ModelErrorHandler& error_handler, const ModelErrorHandler& error_handler,
const StartCallback& start_callback) { const StartCallback& start_callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
...@@ -77,7 +77,7 @@ void SharedModelTypeProcessor::OnSyncStarting( ...@@ -77,7 +77,7 @@ void SharedModelTypeProcessor::OnSyncStarting(
ConnectIfReady(); ConnectIfReady();
} }
void SharedModelTypeProcessor::ModelReadyToSync( void ClientTagBasedModelTypeProcessor::ModelReadyToSync(
std::unique_ptr<MetadataBatch> batch) { std::unique_ptr<MetadataBatch> batch) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(waiting_for_metadata_); DCHECK(waiting_for_metadata_);
...@@ -108,7 +108,8 @@ void SharedModelTypeProcessor::ModelReadyToSync( ...@@ -108,7 +108,8 @@ void SharedModelTypeProcessor::ModelReadyToSync(
waiting_for_pending_data_ = true; waiting_for_pending_data_ = true;
bridge_->GetData( bridge_->GetData(
std::move(entities_to_commit), std::move(entities_to_commit),
base::Bind(&SharedModelTypeProcessor::OnInitialPendingDataLoaded, base::BindOnce(
&ClientTagBasedModelTypeProcessor::OnInitialPendingDataLoaded,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
} else { } else {
...@@ -121,11 +122,11 @@ void SharedModelTypeProcessor::ModelReadyToSync( ...@@ -121,11 +122,11 @@ void SharedModelTypeProcessor::ModelReadyToSync(
ConnectIfReady(); ConnectIfReady();
} }
bool SharedModelTypeProcessor::IsModelReadyOrError() const { bool ClientTagBasedModelTypeProcessor::IsModelReadyOrError() const {
return model_error_ || (!waiting_for_metadata_ && !waiting_for_pending_data_); return model_error_ || (!waiting_for_metadata_ && !waiting_for_pending_data_);
} }
void SharedModelTypeProcessor::ConnectIfReady() { void ClientTagBasedModelTypeProcessor::ConnectIfReady() {
if (!IsModelReadyOrError() || !start_callback_) if (!IsModelReadyOrError() || !start_callback_)
return; return;
...@@ -144,18 +145,18 @@ void SharedModelTypeProcessor::ConnectIfReady() { ...@@ -144,18 +145,18 @@ void SharedModelTypeProcessor::ConnectIfReady() {
start_callback_.Reset(); start_callback_.Reset();
} }
bool SharedModelTypeProcessor::IsAllowingChanges() const { bool ClientTagBasedModelTypeProcessor::IsAllowingChanges() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Changes can be handled correctly even before pending data is loaded. // Changes can be handled correctly even before pending data is loaded.
return !waiting_for_metadata_; return !waiting_for_metadata_;
} }
bool SharedModelTypeProcessor::IsConnected() const { bool ClientTagBasedModelTypeProcessor::IsConnected() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return !!worker_; return !!worker_;
} }
void SharedModelTypeProcessor::DisableSync() { void ClientTagBasedModelTypeProcessor::DisableSync() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
std::unique_ptr<MetadataChangeList> change_list = std::unique_ptr<MetadataChangeList> change_list =
bridge_->CreateMetadataChangeList(); bridge_->CreateMetadataChangeList();
...@@ -167,11 +168,11 @@ void SharedModelTypeProcessor::DisableSync() { ...@@ -167,11 +168,11 @@ void SharedModelTypeProcessor::DisableSync() {
bridge_->ApplySyncChanges(std::move(change_list), EntityChangeList()); bridge_->ApplySyncChanges(std::move(change_list), EntityChangeList());
} }
bool SharedModelTypeProcessor::IsTrackingMetadata() { bool ClientTagBasedModelTypeProcessor::IsTrackingMetadata() {
return model_type_state_.initial_sync_done(); return model_type_state_.initial_sync_done();
} }
void SharedModelTypeProcessor::ReportError(const ModelError& error) { void ClientTagBasedModelTypeProcessor::ReportError(const ModelError& error) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Ignore all errors after the first. // Ignore all errors after the first.
...@@ -195,7 +196,7 @@ void SharedModelTypeProcessor::ReportError(const ModelError& error) { ...@@ -195,7 +196,7 @@ void SharedModelTypeProcessor::ReportError(const ModelError& error) {
} }
} }
void SharedModelTypeProcessor::ConnectSync( void ClientTagBasedModelTypeProcessor::ConnectSync(
std::unique_ptr<CommitQueue> worker) { std::unique_ptr<CommitQueue> worker) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DVLOG(1) << "Successfully connected " << ModelTypeToString(type_); DVLOG(1) << "Successfully connected " << ModelTypeToString(type_);
...@@ -205,7 +206,7 @@ void SharedModelTypeProcessor::ConnectSync( ...@@ -205,7 +206,7 @@ void SharedModelTypeProcessor::ConnectSync(
NudgeForCommitIfNeeded(); NudgeForCommitIfNeeded();
} }
void SharedModelTypeProcessor::DisconnectSync() { void ClientTagBasedModelTypeProcessor::DisconnectSync() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(IsConnected()); DCHECK(IsConnected());
...@@ -218,7 +219,8 @@ void SharedModelTypeProcessor::DisconnectSync() { ...@@ -218,7 +219,8 @@ void SharedModelTypeProcessor::DisconnectSync() {
} }
} }
void SharedModelTypeProcessor::Put(const std::string& storage_key, void ClientTagBasedModelTypeProcessor::Put(
const std::string& storage_key,
std::unique_ptr<EntityData> data, std::unique_ptr<EntityData> data,
MetadataChangeList* metadata_change_list) { MetadataChangeList* metadata_change_list) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
...@@ -253,7 +255,7 @@ void SharedModelTypeProcessor::Put(const std::string& storage_key, ...@@ -253,7 +255,7 @@ void SharedModelTypeProcessor::Put(const std::string& storage_key,
NudgeForCommitIfNeeded(); NudgeForCommitIfNeeded();
} }
void SharedModelTypeProcessor::Delete( void ClientTagBasedModelTypeProcessor::Delete(
const std::string& storage_key, const std::string& storage_key,
MetadataChangeList* metadata_change_list) { MetadataChangeList* metadata_change_list) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
...@@ -281,7 +283,7 @@ void SharedModelTypeProcessor::Delete( ...@@ -281,7 +283,7 @@ void SharedModelTypeProcessor::Delete(
NudgeForCommitIfNeeded(); NudgeForCommitIfNeeded();
} }
void SharedModelTypeProcessor::UpdateStorageKey( void ClientTagBasedModelTypeProcessor::UpdateStorageKey(
const EntityData& entity_data, const EntityData& entity_data,
const std::string& storage_key, const std::string& storage_key,
MetadataChangeList* metadata_change_list) { MetadataChangeList* metadata_change_list) {
...@@ -299,14 +301,15 @@ void SharedModelTypeProcessor::UpdateStorageKey( ...@@ -299,14 +301,15 @@ void SharedModelTypeProcessor::UpdateStorageKey(
metadata_change_list->UpdateMetadata(storage_key, entity->metadata()); metadata_change_list->UpdateMetadata(storage_key, entity->metadata());
} }
void SharedModelTypeProcessor::UntrackEntity(const EntityData& entity_data) { void ClientTagBasedModelTypeProcessor::UntrackEntity(
const EntityData& entity_data) {
const std::string& client_tag_hash = entity_data.client_tag_hash; const std::string& client_tag_hash = entity_data.client_tag_hash;
DCHECK(!client_tag_hash.empty()); DCHECK(!client_tag_hash.empty());
DCHECK(GetEntityForTagHash(client_tag_hash)->storage_key().empty()); DCHECK(GetEntityForTagHash(client_tag_hash)->storage_key().empty());
entities_.erase(client_tag_hash); entities_.erase(client_tag_hash);
} }
void SharedModelTypeProcessor::NudgeForCommitIfNeeded() { void ClientTagBasedModelTypeProcessor::NudgeForCommitIfNeeded() {
// Don't bother sending anything if there's no one to send to. // Don't bother sending anything if there's no one to send to.
if (!IsConnected()) if (!IsConnected())
return; return;
...@@ -329,7 +332,7 @@ void SharedModelTypeProcessor::NudgeForCommitIfNeeded() { ...@@ -329,7 +332,7 @@ void SharedModelTypeProcessor::NudgeForCommitIfNeeded() {
worker_->NudgeForCommit(); worker_->NudgeForCommit();
} }
void SharedModelTypeProcessor::GetLocalChanges( void ClientTagBasedModelTypeProcessor::GetLocalChanges(
size_t max_entries, size_t max_entries,
const GetLocalChangesCallback& callback) { const GetLocalChangesCallback& callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
...@@ -352,7 +355,7 @@ void SharedModelTypeProcessor::GetLocalChanges( ...@@ -352,7 +355,7 @@ void SharedModelTypeProcessor::GetLocalChanges(
callback.Run(std::move(commit_requests)); callback.Run(std::move(commit_requests));
} }
void SharedModelTypeProcessor::OnCommitCompleted( void ClientTagBasedModelTypeProcessor::OnCommitCompleted(
const sync_pb::ModelTypeState& model_type_state, const sync_pb::ModelTypeState& model_type_state,
const CommitResponseDataList& response_list) { const CommitResponseDataList& response_list) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
...@@ -412,7 +415,7 @@ void SharedModelTypeProcessor::OnCommitCompleted( ...@@ -412,7 +415,7 @@ void SharedModelTypeProcessor::OnCommitCompleted(
} }
} }
void SharedModelTypeProcessor::OnUpdateReceived( void ClientTagBasedModelTypeProcessor::OnUpdateReceived(
const sync_pb::ModelTypeState& model_type_state, const sync_pb::ModelTypeState& model_type_state,
const UpdateResponseDataList& updates) { const UpdateResponseDataList& updates) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
...@@ -486,7 +489,7 @@ void SharedModelTypeProcessor::OnUpdateReceived( ...@@ -486,7 +489,7 @@ void SharedModelTypeProcessor::OnUpdateReceived(
NudgeForCommitIfNeeded(); NudgeForCommitIfNeeded();
} }
ProcessorEntityTracker* SharedModelTypeProcessor::ProcessUpdate( ProcessorEntityTracker* ClientTagBasedModelTypeProcessor::ProcessUpdate(
const UpdateResponseData& update, const UpdateResponseData& update,
EntityChangeList* entity_changes) { EntityChangeList* entity_changes) {
const EntityData& data = update.entity.value(); const EntityData& data = update.entity.value();
...@@ -551,7 +554,7 @@ ProcessorEntityTracker* SharedModelTypeProcessor::ProcessUpdate( ...@@ -551,7 +554,7 @@ ProcessorEntityTracker* SharedModelTypeProcessor::ProcessUpdate(
return entity; return entity;
} }
ConflictResolution::Type SharedModelTypeProcessor::ResolveConflict( ConflictResolution::Type ClientTagBasedModelTypeProcessor::ResolveConflict(
const UpdateResponseData& update, const UpdateResponseData& update,
ProcessorEntityTracker* entity, ProcessorEntityTracker* entity,
EntityChangeList* changes) { EntityChangeList* changes) {
...@@ -621,7 +624,7 @@ ConflictResolution::Type SharedModelTypeProcessor::ResolveConflict( ...@@ -621,7 +624,7 @@ ConflictResolution::Type SharedModelTypeProcessor::ResolveConflict(
return resolution_type; return resolution_type;
} }
void SharedModelTypeProcessor::RecommitAllForEncryption( void ClientTagBasedModelTypeProcessor::RecommitAllForEncryption(
std::unordered_set<std::string> already_updated, std::unordered_set<std::string> already_updated,
MetadataChangeList* metadata_changes) { MetadataChangeList* metadata_changes) {
ModelTypeSyncBridge::StorageKeyList entities_needing_data; ModelTypeSyncBridge::StorageKeyList entities_needing_data;
...@@ -646,12 +649,13 @@ void SharedModelTypeProcessor::RecommitAllForEncryption( ...@@ -646,12 +649,13 @@ void SharedModelTypeProcessor::RecommitAllForEncryption(
if (!entities_needing_data.empty()) { if (!entities_needing_data.empty()) {
bridge_->GetData( bridge_->GetData(
std::move(entities_needing_data), std::move(entities_needing_data),
base::Bind(&SharedModelTypeProcessor::OnDataLoadedForReEncryption, base::BindOnce(
&ClientTagBasedModelTypeProcessor::OnDataLoadedForReEncryption,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
} }
void SharedModelTypeProcessor::OnInitialUpdateReceived( void ClientTagBasedModelTypeProcessor::OnInitialUpdateReceived(
const sync_pb::ModelTypeState& model_type_state, const sync_pb::ModelTypeState& model_type_state,
const UpdateResponseDataList& updates) { const UpdateResponseDataList& updates) {
DCHECK(entities_.empty()); DCHECK(entities_.empty());
...@@ -697,7 +701,7 @@ void SharedModelTypeProcessor::OnInitialUpdateReceived( ...@@ -697,7 +701,7 @@ void SharedModelTypeProcessor::OnInitialUpdateReceived(
NudgeForCommitIfNeeded(); NudgeForCommitIfNeeded();
} }
void SharedModelTypeProcessor::OnInitialPendingDataLoaded( void ClientTagBasedModelTypeProcessor::OnInitialPendingDataLoaded(
std::unique_ptr<DataBatch> data_batch) { std::unique_ptr<DataBatch> data_batch) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(waiting_for_pending_data_); DCHECK(waiting_for_pending_data_);
...@@ -712,7 +716,7 @@ void SharedModelTypeProcessor::OnInitialPendingDataLoaded( ...@@ -712,7 +716,7 @@ void SharedModelTypeProcessor::OnInitialPendingDataLoaded(
ConnectIfReady(); ConnectIfReady();
} }
void SharedModelTypeProcessor::OnDataLoadedForReEncryption( void ClientTagBasedModelTypeProcessor::OnDataLoadedForReEncryption(
std::unique_ptr<DataBatch> data_batch) { std::unique_ptr<DataBatch> data_batch) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!waiting_for_pending_data_); DCHECK(!waiting_for_pending_data_);
...@@ -721,7 +725,7 @@ void SharedModelTypeProcessor::OnDataLoadedForReEncryption( ...@@ -721,7 +725,7 @@ void SharedModelTypeProcessor::OnDataLoadedForReEncryption(
NudgeForCommitIfNeeded(); NudgeForCommitIfNeeded();
} }
void SharedModelTypeProcessor::ConsumeDataBatch( void ClientTagBasedModelTypeProcessor::ConsumeDataBatch(
std::unique_ptr<DataBatch> data_batch) { std::unique_ptr<DataBatch> data_batch) {
while (data_batch->HasNext()) { while (data_batch->HasNext()) {
KeyAndData data = data_batch->Next(); KeyAndData data = data_batch->Next();
...@@ -735,11 +739,12 @@ void SharedModelTypeProcessor::ConsumeDataBatch( ...@@ -735,11 +739,12 @@ void SharedModelTypeProcessor::ConsumeDataBatch(
} }
} }
std::string SharedModelTypeProcessor::GetHashForTag(const std::string& tag) { std::string ClientTagBasedModelTypeProcessor::GetHashForTag(
const std::string& tag) {
return GenerateSyncableHash(type_, tag); return GenerateSyncableHash(type_, tag);
} }
std::string SharedModelTypeProcessor::GetClientTagHash( std::string ClientTagBasedModelTypeProcessor::GetClientTagHash(
const std::string& storage_key, const std::string& storage_key,
const EntityData& data) { const EntityData& data) {
auto iter = storage_key_to_tag_hash_.find(storage_key); auto iter = storage_key_to_tag_hash_.find(storage_key);
...@@ -748,7 +753,8 @@ std::string SharedModelTypeProcessor::GetClientTagHash( ...@@ -748,7 +753,8 @@ std::string SharedModelTypeProcessor::GetClientTagHash(
: iter->second; : iter->second;
} }
ProcessorEntityTracker* SharedModelTypeProcessor::GetEntityForStorageKey( ProcessorEntityTracker*
ClientTagBasedModelTypeProcessor::GetEntityForStorageKey(
const std::string& storage_key) { const std::string& storage_key) {
auto iter = storage_key_to_tag_hash_.find(storage_key); auto iter = storage_key_to_tag_hash_.find(storage_key);
return iter == storage_key_to_tag_hash_.end() return iter == storage_key_to_tag_hash_.end()
...@@ -756,13 +762,13 @@ ProcessorEntityTracker* SharedModelTypeProcessor::GetEntityForStorageKey( ...@@ -756,13 +762,13 @@ ProcessorEntityTracker* SharedModelTypeProcessor::GetEntityForStorageKey(
: GetEntityForTagHash(iter->second); : GetEntityForTagHash(iter->second);
} }
ProcessorEntityTracker* SharedModelTypeProcessor::GetEntityForTagHash( ProcessorEntityTracker* ClientTagBasedModelTypeProcessor::GetEntityForTagHash(
const std::string& tag_hash) { const std::string& tag_hash) {
auto it = entities_.find(tag_hash); auto it = entities_.find(tag_hash);
return it != entities_.end() ? it->second.get() : nullptr; return it != entities_.end() ? it->second.get() : nullptr;
} }
ProcessorEntityTracker* SharedModelTypeProcessor::CreateEntity( ProcessorEntityTracker* ClientTagBasedModelTypeProcessor::CreateEntity(
const std::string& storage_key, const std::string& storage_key,
const EntityData& data) { const EntityData& data) {
DCHECK(entities_.find(data.client_tag_hash) == entities_.end()); DCHECK(entities_.find(data.client_tag_hash) == entities_.end());
...@@ -779,7 +785,7 @@ ProcessorEntityTracker* SharedModelTypeProcessor::CreateEntity( ...@@ -779,7 +785,7 @@ ProcessorEntityTracker* SharedModelTypeProcessor::CreateEntity(
return entity_ptr; return entity_ptr;
} }
ProcessorEntityTracker* SharedModelTypeProcessor::CreateEntity( ProcessorEntityTracker* ClientTagBasedModelTypeProcessor::CreateEntity(
const EntityData& data) { const EntityData& data) {
// Verify the tag hash matches, may be relaxed in the future. // Verify the tag hash matches, may be relaxed in the future.
DCHECK_EQ(data.client_tag_hash, GetHashForTag(bridge_->GetClientTag(data))); DCHECK_EQ(data.client_tag_hash, GetHashForTag(bridge_->GetClientTag(data)));
...@@ -789,7 +795,7 @@ ProcessorEntityTracker* SharedModelTypeProcessor::CreateEntity( ...@@ -789,7 +795,7 @@ ProcessorEntityTracker* SharedModelTypeProcessor::CreateEntity(
return CreateEntity(storage_key, data); return CreateEntity(storage_key, data);
} }
bool SharedModelTypeProcessor::AllStorageKeysPopulated() const { bool ClientTagBasedModelTypeProcessor::AllStorageKeysPopulated() const {
for (const auto& kv : entities_) { for (const auto& kv : entities_) {
ProcessorEntityTracker* entity = kv.second.get(); ProcessorEntityTracker* entity = kv.second.get();
if (entity->storage_key().empty()) if (entity->storage_key().empty())
...@@ -798,7 +804,7 @@ bool SharedModelTypeProcessor::AllStorageKeysPopulated() const { ...@@ -798,7 +804,7 @@ bool SharedModelTypeProcessor::AllStorageKeysPopulated() const {
return true; return true;
} }
size_t SharedModelTypeProcessor::EstimateMemoryUsage() const { size_t ClientTagBasedModelTypeProcessor::EstimateMemoryUsage() const {
using base::trace_event::EstimateMemoryUsage; using base::trace_event::EstimateMemoryUsage;
size_t memory_usage = 0; size_t memory_usage = 0;
memory_usage += EstimateMemoryUsage(model_type_state_); memory_usage += EstimateMemoryUsage(model_type_state_);
...@@ -807,7 +813,7 @@ size_t SharedModelTypeProcessor::EstimateMemoryUsage() const { ...@@ -807,7 +813,7 @@ size_t SharedModelTypeProcessor::EstimateMemoryUsage() const {
return memory_usage; return memory_usage;
} }
void SharedModelTypeProcessor::ExpireEntriesIfNeeded( void ClientTagBasedModelTypeProcessor::ExpireEntriesIfNeeded(
const sync_pb::DataTypeProgressMarker& progress_marker) { const sync_pb::DataTypeProgressMarker& progress_marker) {
if (!progress_marker.has_gc_directive()) if (!progress_marker.has_gc_directive())
return; return;
...@@ -853,7 +859,7 @@ void SharedModelTypeProcessor::ExpireEntriesIfNeeded( ...@@ -853,7 +859,7 @@ void SharedModelTypeProcessor::ExpireEntriesIfNeeded(
bridge_->ApplySyncChanges(std::move(metadata_changes), EntityChangeList()); bridge_->ApplySyncChanges(std::move(metadata_changes), EntityChangeList());
} }
void SharedModelTypeProcessor::ClearMetadataForEntries( void ClientTagBasedModelTypeProcessor::ClearMetadataForEntries(
const std::vector<std::string>& storage_key_to_be_deleted, const std::vector<std::string>& storage_key_to_be_deleted,
MetadataChangeList* metadata_changes) { MetadataChangeList* metadata_changes) {
for (const std::string& key : storage_key_to_be_deleted) { for (const std::string& key : storage_key_to_be_deleted) {
...@@ -865,7 +871,7 @@ void SharedModelTypeProcessor::ClearMetadataForEntries( ...@@ -865,7 +871,7 @@ void SharedModelTypeProcessor::ClearMetadataForEntries(
} }
} }
void SharedModelTypeProcessor::ExpireEntriesByVersion( void ClientTagBasedModelTypeProcessor::ExpireEntriesByVersion(
int64_t version_watermark, int64_t version_watermark,
MetadataChangeList* metadata_changes) { MetadataChangeList* metadata_changes) {
DCHECK(metadata_changes); DCHECK(metadata_changes);
...@@ -882,7 +888,7 @@ void SharedModelTypeProcessor::ExpireEntriesByVersion( ...@@ -882,7 +888,7 @@ void SharedModelTypeProcessor::ExpireEntriesByVersion(
ClearMetadataForEntries(storage_key_to_be_deleted, metadata_changes); ClearMetadataForEntries(storage_key_to_be_deleted, metadata_changes);
} }
void SharedModelTypeProcessor::ExpireEntriesByAge( void ClientTagBasedModelTypeProcessor::ExpireEntriesByAge(
int32_t age_watermark_in_days, int32_t age_watermark_in_days,
MetadataChangeList* metadata_changes) { MetadataChangeList* metadata_changes) {
DCHECK(metadata_changes); DCHECK(metadata_changes);
...@@ -902,7 +908,7 @@ void SharedModelTypeProcessor::ExpireEntriesByAge( ...@@ -902,7 +908,7 @@ void SharedModelTypeProcessor::ExpireEntriesByAge(
ClearMetadataForEntries(storage_key_to_be_deleted, metadata_changes); ClearMetadataForEntries(storage_key_to_be_deleted, metadata_changes);
} }
void SharedModelTypeProcessor::ExpireEntriesByItemLimit( void ClientTagBasedModelTypeProcessor::ExpireEntriesByItemLimit(
int32_t max_number_of_items, int32_t max_number_of_items,
MetadataChangeList* metadata_changes) { MetadataChangeList* metadata_changes) {
DCHECK(metadata_changes); DCHECK(metadata_changes);
...@@ -931,7 +937,7 @@ void SharedModelTypeProcessor::ExpireEntriesByItemLimit( ...@@ -931,7 +937,7 @@ void SharedModelTypeProcessor::ExpireEntriesByItemLimit(
ClearMetadataForEntries(storage_key_to_be_deleted, metadata_changes); ClearMetadataForEntries(storage_key_to_be_deleted, metadata_changes);
} }
void SharedModelTypeProcessor::RemoveEntity( void ClientTagBasedModelTypeProcessor::RemoveEntity(
ProcessorEntityTracker* entity, ProcessorEntityTracker* entity,
MetadataChangeList* metadata_change_list) { MetadataChangeList* metadata_change_list) {
metadata_change_list->ClearMetadata(entity->storage_key()); metadata_change_list->ClearMetadata(entity->storage_key());
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_SYNC_MODEL_IMPL_SHARED_MODEL_TYPE_PROCESSOR_H_ #ifndef COMPONENTS_SYNC_MODEL_IMPL_CLIENT_TAG_BASED_MODEL_TYPE_PROCESSOR_H_
#define COMPONENTS_SYNC_MODEL_IMPL_SHARED_MODEL_TYPE_PROCESSOR_H_ #define COMPONENTS_SYNC_MODEL_IMPL_CLIENT_TAG_BASED_MODEL_TYPE_PROCESSOR_H_
#include <map> #include <map>
#include <memory> #include <memory>
...@@ -34,16 +34,17 @@ class ProcessorEntityTracker; ...@@ -34,16 +34,17 @@ class ProcessorEntityTracker;
// A sync component embedded on the model type's thread that tracks entity // A sync component embedded on the model type's thread that tracks entity
// metadata in the model store and coordinates communication between sync and // metadata in the model store and coordinates communication between sync and
// model type threads. See //docs/sync/uss/shared_model_type_processor.md for a // model type threads. See
// more thorough description. // //docs/sync/uss/client_tag_based_model_type_processor.md for a more thorough
class SharedModelTypeProcessor : public ModelTypeProcessor, // description.
class ClientTagBasedModelTypeProcessor : public ModelTypeProcessor,
public ModelTypeChangeProcessor { public ModelTypeChangeProcessor {
public: public:
SharedModelTypeProcessor(ModelType type, ClientTagBasedModelTypeProcessor(ModelType type,
ModelTypeSyncBridge* bridge, ModelTypeSyncBridge* bridge,
const base::RepeatingClosure& dump_stack, const base::RepeatingClosure& dump_stack,
bool commit_only); bool commit_only);
~SharedModelTypeProcessor() override; ~ClientTagBasedModelTypeProcessor() override;
// Whether the processor is allowing changes to its model type. If this is // Whether the processor is allowing changes to its model type. If this is
// false, the bridge should not allow any changes to its data. // false, the bridge should not allow any changes to its data.
...@@ -84,7 +85,7 @@ class SharedModelTypeProcessor : public ModelTypeProcessor, ...@@ -84,7 +85,7 @@ class SharedModelTypeProcessor : public ModelTypeProcessor,
private: private:
friend class ModelTypeDebugInfo; friend class ModelTypeDebugInfo;
friend class SharedModelTypeProcessorTest; friend class ClientTagBasedModelTypeProcessorTest;
// Returns true if the model is ready or encountered an error. // Returns true if the model is ready or encountered an error.
bool IsModelReadyOrError() const; bool IsModelReadyOrError() const;
...@@ -270,11 +271,11 @@ class SharedModelTypeProcessor : public ModelTypeProcessor, ...@@ -270,11 +271,11 @@ class SharedModelTypeProcessor : public ModelTypeProcessor,
SEQUENCE_CHECKER(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_);
// WeakPtrFactory for this processor which will be sent to sync thread. // WeakPtrFactory for this processor which will be sent to sync thread.
base::WeakPtrFactory<SharedModelTypeProcessor> weak_ptr_factory_; base::WeakPtrFactory<ClientTagBasedModelTypeProcessor> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(SharedModelTypeProcessor); DISALLOW_COPY_AND_ASSIGN(ClientTagBasedModelTypeProcessor);
}; };
} // namespace syncer } // namespace syncer
#endif // COMPONENTS_SYNC_MODEL_IMPL_SHARED_MODEL_TYPE_PROCESSOR_H_ #endif // COMPONENTS_SYNC_MODEL_IMPL_CLIENT_TAG_BASED_MODEL_TYPE_PROCESSOR_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/sync/model_impl/shared_model_type_processor.h" #include "components/sync/model_impl/client_tag_based_model_type_processor.h"
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
#include "components/sync/test/engine/mock_model_type_worker.h" #include "components/sync/test/engine/mock_model_type_worker.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using sync_pb::EntitySpecifics;
using sync_pb::EntityMetadata; using sync_pb::EntityMetadata;
using sync_pb::EntitySpecifics;
using sync_pb::ModelTypeState; using sync_pb::ModelTypeState;
namespace syncer { namespace syncer {
...@@ -58,7 +58,7 @@ std::unique_ptr<EntityData> GenerateEntityData(const std::string& key, ...@@ -58,7 +58,7 @@ std::unique_ptr<EntityData> GenerateEntityData(const std::string& key,
std::unique_ptr<ModelTypeChangeProcessor> std::unique_ptr<ModelTypeChangeProcessor>
CreateProcessor(bool commit_only, ModelType type, ModelTypeSyncBridge* bridge) { CreateProcessor(bool commit_only, ModelType type, ModelTypeSyncBridge* bridge) {
return std::make_unique<SharedModelTypeProcessor>( return std::make_unique<ClientTagBasedModelTypeProcessor>(
type, bridge, base::RepeatingClosure(), commit_only); type, bridge, base::RepeatingClosure(), commit_only);
} }
...@@ -162,7 +162,7 @@ class TestModelTypeSyncBridge : public FakeModelTypeSyncBridge { ...@@ -162,7 +162,7 @@ class TestModelTypeSyncBridge : public FakeModelTypeSyncBridge {
} // namespace } // namespace
// Tests the various functionality of SharedModelTypeProcessor. // Tests the various functionality of ClientTagBasedModelTypeProcessor.
// //
// The processor sits between the bridge (implemented by this test class) and // The processor sits between the bridge (implemented by this test class) and
// the worker, which is represented by a MockModelTypeWorker. This test suite // the worker, which is represented by a MockModelTypeWorker. This test suite
...@@ -177,12 +177,12 @@ class TestModelTypeSyncBridge : public FakeModelTypeSyncBridge { ...@@ -177,12 +177,12 @@ class TestModelTypeSyncBridge : public FakeModelTypeSyncBridge {
// storage and the correct commit requests on the worker side. // storage and the correct commit requests on the worker side.
// - Updates and commit responses from the worker correctly affect data and // - Updates and commit responses from the worker correctly affect data and
// metadata in storage on the bridge side. // metadata in storage on the bridge side.
class SharedModelTypeProcessorTest : public ::testing::Test { class ClientTagBasedModelTypeProcessorTest : public ::testing::Test {
public: public:
SharedModelTypeProcessorTest() ClientTagBasedModelTypeProcessorTest()
: bridge_(std::make_unique<TestModelTypeSyncBridge>(false)) {} : bridge_(std::make_unique<TestModelTypeSyncBridge>(false)) {}
~SharedModelTypeProcessorTest() override { CheckPostConditions(); } ~ClientTagBasedModelTypeProcessorTest() override { CheckPostConditions(); }
void InitializeToMetadataLoaded() { void InitializeToMetadataLoaded() {
bridge()->SetInitialSyncDone(true); bridge()->SetInitialSyncDone(true);
...@@ -204,9 +204,10 @@ class SharedModelTypeProcessorTest : public ::testing::Test { ...@@ -204,9 +204,10 @@ class SharedModelTypeProcessorTest : public ::testing::Test {
void OnSyncStarting() { void OnSyncStarting() {
type_processor()->OnSyncStarting( type_processor()->OnSyncStarting(
base::BindRepeating(&SharedModelTypeProcessorTest::ErrorReceived, base::BindRepeating(
&ClientTagBasedModelTypeProcessorTest::ErrorReceived,
base::Unretained(this)), base::Unretained(this)),
base::Bind(&SharedModelTypeProcessorTest::OnReadyToConnect, base::Bind(&ClientTagBasedModelTypeProcessorTest::OnReadyToConnect,
base::Unretained(this))); base::Unretained(this)));
} }
...@@ -286,8 +287,9 @@ class SharedModelTypeProcessorTest : public ::testing::Test { ...@@ -286,8 +287,9 @@ class SharedModelTypeProcessorTest : public ::testing::Test {
MockModelTypeWorker* worker() const { return worker_; } MockModelTypeWorker* worker() const { return worker_; }
SharedModelTypeProcessor* type_processor() const { ClientTagBasedModelTypeProcessor* type_processor() const {
return static_cast<SharedModelTypeProcessor*>(bridge()->change_processor()); return static_cast<ClientTagBasedModelTypeProcessor*>(
bridge()->change_processor());
} }
private: private:
...@@ -323,7 +325,7 @@ class SharedModelTypeProcessorTest : public ::testing::Test { ...@@ -323,7 +325,7 @@ class SharedModelTypeProcessorTest : public ::testing::Test {
}; };
// Test that an initial sync handles local and remote items properly. // Test that an initial sync handles local and remote items properly.
TEST_F(SharedModelTypeProcessorTest, InitialSync) { TEST_F(ClientTagBasedModelTypeProcessorTest, InitialSync) {
ModelReadyToSync(); ModelReadyToSync();
OnSyncStarting(); OnSyncStarting();
...@@ -352,7 +354,7 @@ TEST_F(SharedModelTypeProcessorTest, InitialSync) { ...@@ -352,7 +354,7 @@ TEST_F(SharedModelTypeProcessorTest, InitialSync) {
} }
// Test that an initial sync filters out tombstones in the processor. // Test that an initial sync filters out tombstones in the processor.
TEST_F(SharedModelTypeProcessorTest, InitialSyncWithTombstone) { TEST_F(ClientTagBasedModelTypeProcessorTest, InitialSyncWithTombstone) {
ModelReadyToSync(); ModelReadyToSync();
OnSyncStarting(); OnSyncStarting();
...@@ -370,7 +372,7 @@ TEST_F(SharedModelTypeProcessorTest, InitialSyncWithTombstone) { ...@@ -370,7 +372,7 @@ TEST_F(SharedModelTypeProcessorTest, InitialSyncWithTombstone) {
} }
// Test that subsequent starts don't call MergeSyncData. // Test that subsequent starts don't call MergeSyncData.
TEST_F(SharedModelTypeProcessorTest, NonInitialSync) { TEST_F(ClientTagBasedModelTypeProcessorTest, NonInitialSync) {
// This sets initial_sync_done to true. // This sets initial_sync_done to true.
InitializeToMetadataLoaded(); InitializeToMetadataLoaded();
...@@ -388,7 +390,7 @@ TEST_F(SharedModelTypeProcessorTest, NonInitialSync) { ...@@ -388,7 +390,7 @@ TEST_F(SharedModelTypeProcessorTest, NonInitialSync) {
} }
// Test that an error during the merge is propagated to the error handler. // Test that an error during the merge is propagated to the error handler.
TEST_F(SharedModelTypeProcessorTest, MergeError) { TEST_F(ClientTagBasedModelTypeProcessorTest, MergeError) {
ModelReadyToSync(); ModelReadyToSync();
OnSyncStarting(); OnSyncStarting();
...@@ -398,7 +400,7 @@ TEST_F(SharedModelTypeProcessorTest, MergeError) { ...@@ -398,7 +400,7 @@ TEST_F(SharedModelTypeProcessorTest, MergeError) {
} }
// Test that errors before it's called are passed to |start_callback| correctly. // Test that errors before it's called are passed to |start_callback| correctly.
TEST_F(SharedModelTypeProcessorTest, StartErrors) { TEST_F(ClientTagBasedModelTypeProcessorTest, StartErrors) {
type_processor()->ReportError({FROM_HERE, "boom"}); type_processor()->ReportError({FROM_HERE, "boom"});
ExpectError(); ExpectError();
OnSyncStarting(); OnSyncStarting();
...@@ -442,7 +444,7 @@ TEST_F(SharedModelTypeProcessorTest, StartErrors) { ...@@ -442,7 +444,7 @@ TEST_F(SharedModelTypeProcessorTest, StartErrors) {
// - Optionally, a put or delete happens to the item. // - Optionally, a put or delete happens to the item.
// //
// This results in 2 + 12 = 14 orderings of the events. // This results in 2 + 12 = 14 orderings of the events.
TEST_F(SharedModelTypeProcessorTest, LoadPendingCommit) { TEST_F(ClientTagBasedModelTypeProcessorTest, LoadPendingCommit) {
// Data, connect. // Data, connect.
EntitySpecifics specifics1 = ResetStateWriteItem(kKey1, kValue1); EntitySpecifics specifics1 = ResetStateWriteItem(kKey1, kValue1);
InitializeToMetadataLoaded(); InitializeToMetadataLoaded();
...@@ -578,7 +580,7 @@ TEST_F(SharedModelTypeProcessorTest, LoadPendingCommit) { ...@@ -578,7 +580,7 @@ TEST_F(SharedModelTypeProcessorTest, LoadPendingCommit) {
} }
// Tests cases where pending data loads synchronously. // Tests cases where pending data loads synchronously.
TEST_F(SharedModelTypeProcessorTest, LoadPendingSynchronous) { TEST_F(ClientTagBasedModelTypeProcessorTest, LoadPendingSynchronous) {
// Model, sync. // Model, sync.
EntitySpecifics specifics1 = ResetStateWriteItem(kKey1, kValue1); EntitySpecifics specifics1 = ResetStateWriteItem(kKey1, kValue1);
bridge()->ExpectSynchronousDataCallback(); bridge()->ExpectSynchronousDataCallback();
...@@ -606,7 +608,7 @@ TEST_F(SharedModelTypeProcessorTest, LoadPendingSynchronous) { ...@@ -606,7 +608,7 @@ TEST_F(SharedModelTypeProcessorTest, LoadPendingSynchronous) {
// handled properly). // handled properly).
// //
// This results in 1 + 4 = 5 orderings of the events. // This results in 1 + 4 = 5 orderings of the events.
TEST_F(SharedModelTypeProcessorTest, LoadPendingDelete) { TEST_F(ClientTagBasedModelTypeProcessorTest, LoadPendingDelete) {
// Connect. // Connect.
ResetStateDeleteItem(kKey1, kValue1); ResetStateDeleteItem(kKey1, kValue1);
InitializeToMetadataLoaded(); InitializeToMetadataLoaded();
...@@ -652,7 +654,7 @@ TEST_F(SharedModelTypeProcessorTest, LoadPendingDelete) { ...@@ -652,7 +654,7 @@ TEST_F(SharedModelTypeProcessorTest, LoadPendingDelete) {
} }
// Test that loading a committed item does not queue another commit. // Test that loading a committed item does not queue another commit.
TEST_F(SharedModelTypeProcessorTest, LoadCommited) { TEST_F(ClientTagBasedModelTypeProcessorTest, LoadCommited) {
InitializeToReadyState(); InitializeToReadyState();
WriteItemAndAck(kKey1, kValue1); WriteItemAndAck(kKey1, kValue1);
ResetState(true); ResetState(true);
...@@ -665,7 +667,7 @@ TEST_F(SharedModelTypeProcessorTest, LoadCommited) { ...@@ -665,7 +667,7 @@ TEST_F(SharedModelTypeProcessorTest, LoadCommited) {
// Creates a new item locally. // Creates a new item locally.
// Thoroughly tests the data generated by a local item creation. // Thoroughly tests the data generated by a local item creation.
TEST_F(SharedModelTypeProcessorTest, LocalCreateItem) { TEST_F(ClientTagBasedModelTypeProcessorTest, LocalCreateItem) {
InitializeToReadyState(); InitializeToReadyState();
EXPECT_EQ(0U, worker()->GetNumPendingCommits()); EXPECT_EQ(0U, worker()->GetNumPendingCommits());
...@@ -708,7 +710,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalCreateItem) { ...@@ -708,7 +710,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalCreateItem) {
} }
// Test that commit only types are deleted after commit response. // Test that commit only types are deleted after commit response.
TEST_F(SharedModelTypeProcessorTest, CommitOnlySimple) { TEST_F(ClientTagBasedModelTypeProcessorTest, CommitOnlySimple) {
ResetState(false, true); ResetState(false, true);
InitializeToReadyState(); InitializeToReadyState();
...@@ -724,7 +726,7 @@ TEST_F(SharedModelTypeProcessorTest, CommitOnlySimple) { ...@@ -724,7 +726,7 @@ TEST_F(SharedModelTypeProcessorTest, CommitOnlySimple) {
// Test that commit only types maintain tracking of entities while unsynced // Test that commit only types maintain tracking of entities while unsynced
// changes exist. // changes exist.
TEST_F(SharedModelTypeProcessorTest, CommitOnlyUnsyncedChanges) { TEST_F(ClientTagBasedModelTypeProcessorTest, CommitOnlyUnsyncedChanges) {
ResetState(false, true); ResetState(false, true);
InitializeToReadyState(); InitializeToReadyState();
...@@ -753,7 +755,7 @@ TEST_F(SharedModelTypeProcessorTest, CommitOnlyUnsyncedChanges) { ...@@ -753,7 +755,7 @@ TEST_F(SharedModelTypeProcessorTest, CommitOnlyUnsyncedChanges) {
// Test that an error applying metadata changes from a commit response is // Test that an error applying metadata changes from a commit response is
// propagated to the error handler. // propagated to the error handler.
TEST_F(SharedModelTypeProcessorTest, ErrorApplyingAck) { TEST_F(ClientTagBasedModelTypeProcessorTest, ErrorApplyingAck) {
InitializeToReadyState(); InitializeToReadyState();
bridge()->WriteItem(kKey1, kValue1); bridge()->WriteItem(kKey1, kValue1);
bridge()->ErrorOnNextCall(); bridge()->ErrorOnNextCall();
...@@ -763,7 +765,7 @@ TEST_F(SharedModelTypeProcessorTest, ErrorApplyingAck) { ...@@ -763,7 +765,7 @@ TEST_F(SharedModelTypeProcessorTest, ErrorApplyingAck) {
// The purpose of this test case is to test setting |client_tag_hash| and |id| // The purpose of this test case is to test setting |client_tag_hash| and |id|
// on the EntityData object as we pass it into the Put method of the processor. // on the EntityData object as we pass it into the Put method of the processor.
TEST_F(SharedModelTypeProcessorTest, LocalUpdateItemWithOverrides) { TEST_F(ClientTagBasedModelTypeProcessorTest, LocalUpdateItemWithOverrides) {
const std::string kId1 = "cid1"; const std::string kId1 = "cid1";
const std::string kId2 = "cid2"; const std::string kId2 = "cid2";
...@@ -824,7 +826,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalUpdateItemWithOverrides) { ...@@ -824,7 +826,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalUpdateItemWithOverrides) {
// Creates a new local item then modifies it. // Creates a new local item then modifies it.
// Thoroughly tests data generated by modification of server-unknown item. // Thoroughly tests data generated by modification of server-unknown item.
TEST_F(SharedModelTypeProcessorTest, LocalUpdateItem) { TEST_F(ClientTagBasedModelTypeProcessorTest, LocalUpdateItem) {
InitializeToReadyState(); InitializeToReadyState();
bridge()->WriteItem(kKey1, kValue1); bridge()->WriteItem(kKey1, kValue1);
...@@ -877,7 +879,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalUpdateItem) { ...@@ -877,7 +879,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalUpdateItem) {
// Tests that a local update that doesn't change specifics doesn't generate a // Tests that a local update that doesn't change specifics doesn't generate a
// commit request. // commit request.
TEST_F(SharedModelTypeProcessorTest, LocalUpdateItemRedundant) { TEST_F(ClientTagBasedModelTypeProcessorTest, LocalUpdateItemRedundant) {
InitializeToReadyState(); InitializeToReadyState();
bridge()->WriteItem(kKey1, kValue1); bridge()->WriteItem(kKey1, kValue1);
EXPECT_EQ(1U, db().metadata_count()); EXPECT_EQ(1U, db().metadata_count());
...@@ -888,7 +890,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalUpdateItemRedundant) { ...@@ -888,7 +890,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalUpdateItemRedundant) {
} }
// Thoroughly tests the data generated by a server item creation. // Thoroughly tests the data generated by a server item creation.
TEST_F(SharedModelTypeProcessorTest, ServerCreateItem) { TEST_F(ClientTagBasedModelTypeProcessorTest, ServerCreateItem) {
InitializeToReadyState(); InitializeToReadyState();
worker()->UpdateFromServer(kHash1, GenerateSpecifics(kKey1, kValue1)); worker()->UpdateFromServer(kHash1, GenerateSpecifics(kKey1, kValue1));
EXPECT_EQ(1U, db().data_count()); EXPECT_EQ(1U, db().data_count());
...@@ -919,7 +921,7 @@ TEST_F(SharedModelTypeProcessorTest, ServerCreateItem) { ...@@ -919,7 +921,7 @@ TEST_F(SharedModelTypeProcessorTest, ServerCreateItem) {
// Test that an error applying changes from a server update is // Test that an error applying changes from a server update is
// propagated to the error handler. // propagated to the error handler.
TEST_F(SharedModelTypeProcessorTest, ErrorApplyingUpdate) { TEST_F(ClientTagBasedModelTypeProcessorTest, ErrorApplyingUpdate) {
InitializeToReadyState(); InitializeToReadyState();
bridge()->ErrorOnNextCall(); bridge()->ErrorOnNextCall();
ExpectError(); ExpectError();
...@@ -927,7 +929,7 @@ TEST_F(SharedModelTypeProcessorTest, ErrorApplyingUpdate) { ...@@ -927,7 +929,7 @@ TEST_F(SharedModelTypeProcessorTest, ErrorApplyingUpdate) {
} }
// Thoroughly tests the data generated by a server item creation. // Thoroughly tests the data generated by a server item creation.
TEST_F(SharedModelTypeProcessorTest, ServerUpdateItem) { TEST_F(ClientTagBasedModelTypeProcessorTest, ServerUpdateItem) {
InitializeToReadyState(); InitializeToReadyState();
// Local add writes data and metadata; ack writes metadata again. // Local add writes data and metadata; ack writes metadata again.
...@@ -948,7 +950,7 @@ TEST_F(SharedModelTypeProcessorTest, ServerUpdateItem) { ...@@ -948,7 +950,7 @@ TEST_F(SharedModelTypeProcessorTest, ServerUpdateItem) {
} }
// Tests locally deleting an acknowledged item. // Tests locally deleting an acknowledged item.
TEST_F(SharedModelTypeProcessorTest, LocalDeleteItem) { TEST_F(ClientTagBasedModelTypeProcessorTest, LocalDeleteItem) {
InitializeToReadyState(); InitializeToReadyState();
WriteItemAndAck(kKey1, kValue1); WriteItemAndAck(kKey1, kValue1);
EXPECT_EQ(0U, worker()->GetNumPendingCommits()); EXPECT_EQ(0U, worker()->GetNumPendingCommits());
...@@ -987,7 +989,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalDeleteItem) { ...@@ -987,7 +989,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalDeleteItem) {
} }
// Tests that item created and deleted before sync cycle doesn't get committed. // Tests that item created and deleted before sync cycle doesn't get committed.
TEST_F(SharedModelTypeProcessorTest, LocalDeleteItemUncommitted) { TEST_F(ClientTagBasedModelTypeProcessorTest, LocalDeleteItemUncommitted) {
InitializeToMetadataLoaded(); InitializeToMetadataLoaded();
bridge()->WriteItem(kKey1, kValue1); bridge()->WriteItem(kKey1, kValue1);
bridge()->DeleteItem(kKey1); bridge()->DeleteItem(kKey1);
...@@ -998,7 +1000,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalDeleteItemUncommitted) { ...@@ -998,7 +1000,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalDeleteItemUncommitted) {
// Tests creating and deleting an item locally before receiving a commit // Tests creating and deleting an item locally before receiving a commit
// response, then getting the commit responses. // response, then getting the commit responses.
TEST_F(SharedModelTypeProcessorTest, LocalDeleteItemInterleaved) { TEST_F(ClientTagBasedModelTypeProcessorTest, LocalDeleteItemInterleaved) {
InitializeToReadyState(); InitializeToReadyState();
bridge()->WriteItem(kKey1, kValue1); bridge()->WriteItem(kKey1, kValue1);
worker()->VerifyPendingCommits({kHash1}); worker()->VerifyPendingCommits({kHash1});
...@@ -1048,7 +1050,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalDeleteItemInterleaved) { ...@@ -1048,7 +1050,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalDeleteItemInterleaved) {
EXPECT_EQ(0U, ProcessorEntityCount()); EXPECT_EQ(0U, ProcessorEntityCount());
} }
TEST_F(SharedModelTypeProcessorTest, ServerDeleteItem) { TEST_F(ClientTagBasedModelTypeProcessorTest, ServerDeleteItem) {
InitializeToReadyState(); InitializeToReadyState();
WriteItemAndAck(kKey1, kValue1); WriteItemAndAck(kKey1, kValue1);
EXPECT_EQ(1U, ProcessorEntityCount()); EXPECT_EQ(1U, ProcessorEntityCount());
...@@ -1074,7 +1076,7 @@ TEST_F(SharedModelTypeProcessorTest, ServerDeleteItem) { ...@@ -1074,7 +1076,7 @@ TEST_F(SharedModelTypeProcessorTest, ServerDeleteItem) {
// Deletes an item we've never seen before. // Deletes an item we've never seen before.
// Should have no effect and not crash. // Should have no effect and not crash.
TEST_F(SharedModelTypeProcessorTest, LocalDeleteUnknown) { TEST_F(ClientTagBasedModelTypeProcessorTest, LocalDeleteUnknown) {
InitializeToReadyState(); InitializeToReadyState();
bridge()->DeleteItem(kKey1); bridge()->DeleteItem(kKey1);
EXPECT_EQ(0U, db().data_count()); EXPECT_EQ(0U, db().data_count());
...@@ -1085,7 +1087,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalDeleteUnknown) { ...@@ -1085,7 +1087,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalDeleteUnknown) {
// Deletes an item we've never seen before. // Deletes an item we've never seen before.
// Should have no effect and not crash. // Should have no effect and not crash.
TEST_F(SharedModelTypeProcessorTest, ServerDeleteUnknown) { TEST_F(ClientTagBasedModelTypeProcessorTest, ServerDeleteUnknown) {
InitializeToReadyState(); InitializeToReadyState();
worker()->TombstoneFromServer(kHash1); worker()->TombstoneFromServer(kHash1);
EXPECT_EQ(0U, db().data_count()); EXPECT_EQ(0U, db().data_count());
...@@ -1096,7 +1098,7 @@ TEST_F(SharedModelTypeProcessorTest, ServerDeleteUnknown) { ...@@ -1096,7 +1098,7 @@ TEST_F(SharedModelTypeProcessorTest, ServerDeleteUnknown) {
// Tests that after committing entity fails, processor includes this entity in // Tests that after committing entity fails, processor includes this entity in
// consecutive commits. // consecutive commits.
TEST_F(SharedModelTypeProcessorTest, CommitFailedOnServer) { TEST_F(ClientTagBasedModelTypeProcessorTest, CommitFailedOnServer) {
InitializeToReadyState(); InitializeToReadyState();
bridge()->WriteItem(kKey1, kValue1); bridge()->WriteItem(kKey1, kValue1);
worker()->VerifyPendingCommits({kHash1}); worker()->VerifyPendingCommits({kHash1});
...@@ -1117,7 +1119,7 @@ TEST_F(SharedModelTypeProcessorTest, CommitFailedOnServer) { ...@@ -1117,7 +1119,7 @@ TEST_F(SharedModelTypeProcessorTest, CommitFailedOnServer) {
} }
// Tests that GetLocalChanges honors max_entries parameter. // Tests that GetLocalChanges honors max_entries parameter.
TEST_F(SharedModelTypeProcessorTest, LocalChangesPagination) { TEST_F(ClientTagBasedModelTypeProcessorTest, LocalChangesPagination) {
InitializeToMetadataLoaded(); InitializeToMetadataLoaded();
bridge()->WriteItem(kKey1, kValue1); bridge()->WriteItem(kKey1, kValue1);
bridge()->WriteItem(kKey2, kValue2); bridge()->WriteItem(kKey2, kValue2);
...@@ -1131,7 +1133,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalChangesPagination) { ...@@ -1131,7 +1133,7 @@ TEST_F(SharedModelTypeProcessorTest, LocalChangesPagination) {
// Creates two different sync items. // Creates two different sync items.
// Verifies that the second has no effect on the first. // Verifies that the second has no effect on the first.
TEST_F(SharedModelTypeProcessorTest, TwoIndependentItems) { TEST_F(ClientTagBasedModelTypeProcessorTest, TwoIndependentItems) {
InitializeToReadyState(); InitializeToReadyState();
EXPECT_EQ(0U, worker()->GetNumPendingCommits()); EXPECT_EQ(0U, worker()->GetNumPendingCommits());
...@@ -1162,7 +1164,7 @@ TEST_F(SharedModelTypeProcessorTest, TwoIndependentItems) { ...@@ -1162,7 +1164,7 @@ TEST_F(SharedModelTypeProcessorTest, TwoIndependentItems) {
EXPECT_EQ(kUncommittedVersion, metadata2.server_version()); EXPECT_EQ(kUncommittedVersion, metadata2.server_version());
} }
TEST_F(SharedModelTypeProcessorTest, ConflictResolutionChangesMatch) { TEST_F(ClientTagBasedModelTypeProcessorTest, ConflictResolutionChangesMatch) {
InitializeToReadyState(); InitializeToReadyState();
EntitySpecifics specifics = bridge()->WriteItem(kKey1, kValue1); EntitySpecifics specifics = bridge()->WriteItem(kKey1, kValue1);
EXPECT_EQ(1U, db().data_change_count()); EXPECT_EQ(1U, db().data_change_count());
...@@ -1181,7 +1183,7 @@ TEST_F(SharedModelTypeProcessorTest, ConflictResolutionChangesMatch) { ...@@ -1181,7 +1183,7 @@ TEST_F(SharedModelTypeProcessorTest, ConflictResolutionChangesMatch) {
worker()->VerifyPendingCommits({kHash1}); worker()->VerifyPendingCommits({kHash1});
} }
TEST_F(SharedModelTypeProcessorTest, ConflictResolutionUseLocal) { TEST_F(ClientTagBasedModelTypeProcessorTest, ConflictResolutionUseLocal) {
InitializeToReadyState(); InitializeToReadyState();
// WriteAndAck entity to get id from the server. // WriteAndAck entity to get id from the server.
WriteItemAndAck(kKey1, kValue1); WriteItemAndAck(kKey1, kValue1);
...@@ -1200,7 +1202,7 @@ TEST_F(SharedModelTypeProcessorTest, ConflictResolutionUseLocal) { ...@@ -1200,7 +1202,7 @@ TEST_F(SharedModelTypeProcessorTest, ConflictResolutionUseLocal) {
worker()->VerifyNthPendingCommit(1, kHash1, specifics2); worker()->VerifyNthPendingCommit(1, kHash1, specifics2);
} }
TEST_F(SharedModelTypeProcessorTest, ConflictResolutionUseRemote) { TEST_F(ClientTagBasedModelTypeProcessorTest, ConflictResolutionUseRemote) {
InitializeToReadyState(); InitializeToReadyState();
bridge()->WriteItem(kKey1, kValue1); bridge()->WriteItem(kKey1, kValue1);
bridge()->SetConflictResolution(ConflictResolution::UseRemote()); bridge()->SetConflictResolution(ConflictResolution::UseRemote());
...@@ -1214,7 +1216,7 @@ TEST_F(SharedModelTypeProcessorTest, ConflictResolutionUseRemote) { ...@@ -1214,7 +1216,7 @@ TEST_F(SharedModelTypeProcessorTest, ConflictResolutionUseRemote) {
worker()->VerifyPendingCommits({kHash1}); worker()->VerifyPendingCommits({kHash1});
} }
TEST_F(SharedModelTypeProcessorTest, ConflictResolutionUseNew) { TEST_F(ClientTagBasedModelTypeProcessorTest, ConflictResolutionUseNew) {
InitializeToReadyState(); InitializeToReadyState();
bridge()->WriteItem(kKey1, kValue1); bridge()->WriteItem(kKey1, kValue1);
bridge()->SetConflictResolution( bridge()->SetConflictResolution(
...@@ -1234,7 +1236,7 @@ TEST_F(SharedModelTypeProcessorTest, ConflictResolutionUseNew) { ...@@ -1234,7 +1236,7 @@ TEST_F(SharedModelTypeProcessorTest, ConflictResolutionUseNew) {
// //
// Creates items in various states of commit and verifies they re-attempt to // Creates items in various states of commit and verifies they re-attempt to
// commit on reconnect. // commit on reconnect.
TEST_F(SharedModelTypeProcessorTest, Disconnect) { TEST_F(ClientTagBasedModelTypeProcessorTest, Disconnect) {
InitializeToReadyState(); InitializeToReadyState();
// The first item is fully committed. // The first item is fully committed.
...@@ -1269,7 +1271,7 @@ TEST_F(SharedModelTypeProcessorTest, Disconnect) { ...@@ -1269,7 +1271,7 @@ TEST_F(SharedModelTypeProcessorTest, Disconnect) {
// //
// Creates items in various states of commit and verifies they re-attempt to // Creates items in various states of commit and verifies they re-attempt to
// commit on re-enable. // commit on re-enable.
TEST_F(SharedModelTypeProcessorTest, Disable) { TEST_F(ClientTagBasedModelTypeProcessorTest, Disable) {
InitializeToReadyState(); InitializeToReadyState();
// The first item is fully committed. // The first item is fully committed.
...@@ -1296,7 +1298,7 @@ TEST_F(SharedModelTypeProcessorTest, Disable) { ...@@ -1296,7 +1298,7 @@ TEST_F(SharedModelTypeProcessorTest, Disable) {
} }
// Test re-encrypt everything when desired encryption key changes. // Test re-encrypt everything when desired encryption key changes.
TEST_F(SharedModelTypeProcessorTest, ReEncryptCommitsWithNewKey) { TEST_F(ClientTagBasedModelTypeProcessorTest, ReEncryptCommitsWithNewKey) {
InitializeToReadyState(); InitializeToReadyState();
// Commit an item. // Commit an item.
...@@ -1324,7 +1326,7 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptCommitsWithNewKey) { ...@@ -1324,7 +1326,7 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptCommitsWithNewKey) {
// Test that an error loading pending commit data for re-encryption is // Test that an error loading pending commit data for re-encryption is
// propagated to the error handler. // propagated to the error handler.
TEST_F(SharedModelTypeProcessorTest, ReEncryptErrorLoadingData) { TEST_F(ClientTagBasedModelTypeProcessorTest, ReEncryptErrorLoadingData) {
InitializeToReadyState(); InitializeToReadyState();
WriteItemAndAck(kKey1, kValue1); WriteItemAndAck(kKey1, kValue1);
bridge()->ErrorOnNextCall(); bridge()->ErrorOnNextCall();
...@@ -1333,7 +1335,7 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptErrorLoadingData) { ...@@ -1333,7 +1335,7 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptErrorLoadingData) {
} }
// Test receipt of updates with new and old keys. // Test receipt of updates with new and old keys.
TEST_F(SharedModelTypeProcessorTest, ReEncryptUpdatesWithNewKey) { TEST_F(ClientTagBasedModelTypeProcessorTest, ReEncryptUpdatesWithNewKey) {
InitializeToReadyState(); InitializeToReadyState();
// Receive an unencrypted update. // Receive an unencrypted update.
...@@ -1370,7 +1372,8 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptUpdatesWithNewKey) { ...@@ -1370,7 +1372,8 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptUpdatesWithNewKey) {
} }
// Test that re-encrypting enqueues the right data for USE_LOCAL conflicts. // Test that re-encrypting enqueues the right data for USE_LOCAL conflicts.
TEST_F(SharedModelTypeProcessorTest, ReEncryptConflictResolutionUseLocal) { TEST_F(ClientTagBasedModelTypeProcessorTest,
ReEncryptConflictResolutionUseLocal) {
InitializeToReadyState(); InitializeToReadyState();
// WriteAndAck entity to get id from the server. // WriteAndAck entity to get id from the server.
WriteItemAndAck(kKey1, kValue1); WriteItemAndAck(kKey1, kValue1);
...@@ -1395,7 +1398,8 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptConflictResolutionUseLocal) { ...@@ -1395,7 +1398,8 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptConflictResolutionUseLocal) {
} }
// Test that re-encrypting enqueues the right data for USE_REMOTE conflicts. // Test that re-encrypting enqueues the right data for USE_REMOTE conflicts.
TEST_F(SharedModelTypeProcessorTest, ReEncryptConflictResolutionUseRemote) { TEST_F(ClientTagBasedModelTypeProcessorTest,
ReEncryptConflictResolutionUseRemote) {
InitializeToReadyState(); InitializeToReadyState();
worker()->UpdateWithEncryptionKey("k1"); worker()->UpdateWithEncryptionKey("k1");
bridge()->WriteItem(kKey1, kValue1); bridge()->WriteItem(kKey1, kValue1);
...@@ -1412,7 +1416,8 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptConflictResolutionUseRemote) { ...@@ -1412,7 +1416,8 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptConflictResolutionUseRemote) {
} }
// Test that re-encrypting enqueues the right data for USE_NEW conflicts. // Test that re-encrypting enqueues the right data for USE_NEW conflicts.
TEST_F(SharedModelTypeProcessorTest, ReEncryptConflictResolutionUseNew) { TEST_F(ClientTagBasedModelTypeProcessorTest,
ReEncryptConflictResolutionUseNew) {
InitializeToReadyState(); InitializeToReadyState();
worker()->UpdateWithEncryptionKey("k1"); worker()->UpdateWithEncryptionKey("k1");
bridge()->WriteItem(kKey1, kValue1); bridge()->WriteItem(kKey1, kValue1);
...@@ -1429,7 +1434,7 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptConflictResolutionUseNew) { ...@@ -1429,7 +1434,7 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptConflictResolutionUseNew) {
EXPECT_EQ(kValue3, db().GetValue(kKey1)); EXPECT_EQ(kValue3, db().GetValue(kKey1));
} }
TEST_F(SharedModelTypeProcessorTest, ReEncryptConflictWhileLoading) { TEST_F(ClientTagBasedModelTypeProcessorTest, ReEncryptConflictWhileLoading) {
InitializeToReadyState(); InitializeToReadyState();
// Create item and ack so its data is no longer cached. // Create item and ack so its data is no longer cached.
WriteItemAndAck(kKey1, kValue1); WriteItemAndAck(kKey1, kValue1);
...@@ -1452,7 +1457,7 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptConflictWhileLoading) { ...@@ -1452,7 +1457,7 @@ TEST_F(SharedModelTypeProcessorTest, ReEncryptConflictWhileLoading) {
} }
// Tests that a real remote change wins over a local encryption-only change. // Tests that a real remote change wins over a local encryption-only change.
TEST_F(SharedModelTypeProcessorTest, IgnoreLocalEncryption) { TEST_F(ClientTagBasedModelTypeProcessorTest, IgnoreLocalEncryption) {
InitializeToReadyState(); InitializeToReadyState();
EntitySpecifics specifics = WriteItemAndAck(kKey1, kValue1); EntitySpecifics specifics = WriteItemAndAck(kKey1, kValue1);
worker()->UpdateWithEncryptionKey("k1"); worker()->UpdateWithEncryptionKey("k1");
...@@ -1465,7 +1470,7 @@ TEST_F(SharedModelTypeProcessorTest, IgnoreLocalEncryption) { ...@@ -1465,7 +1470,7 @@ TEST_F(SharedModelTypeProcessorTest, IgnoreLocalEncryption) {
} }
// Tests that a real local change wins over a remote encryption-only change. // Tests that a real local change wins over a remote encryption-only change.
TEST_F(SharedModelTypeProcessorTest, IgnoreRemoteEncryption) { TEST_F(ClientTagBasedModelTypeProcessorTest, IgnoreRemoteEncryption) {
InitializeToReadyState(); InitializeToReadyState();
EntitySpecifics specifics1 = WriteItemAndAck(kKey1, kValue1); EntitySpecifics specifics1 = WriteItemAndAck(kKey1, kValue1);
...@@ -1479,7 +1484,8 @@ TEST_F(SharedModelTypeProcessorTest, IgnoreRemoteEncryption) { ...@@ -1479,7 +1484,8 @@ TEST_F(SharedModelTypeProcessorTest, IgnoreRemoteEncryption) {
} }
// Same as above but with two commit requests before one ack. // Same as above but with two commit requests before one ack.
TEST_F(SharedModelTypeProcessorTest, IgnoreRemoteEncryptionInterleaved) { TEST_F(ClientTagBasedModelTypeProcessorTest,
IgnoreRemoteEncryptionInterleaved) {
InitializeToReadyState(); InitializeToReadyState();
// WriteAndAck entity to get id from the server. // WriteAndAck entity to get id from the server.
WriteItemAndAck(kKey1, kValue1); WriteItemAndAck(kKey1, kValue1);
...@@ -1502,7 +1508,7 @@ TEST_F(SharedModelTypeProcessorTest, IgnoreRemoteEncryptionInterleaved) { ...@@ -1502,7 +1508,7 @@ TEST_F(SharedModelTypeProcessorTest, IgnoreRemoteEncryptionInterleaved) {
// and updates corresponding entity's metadata in MetadataChangeList, and // and updates corresponding entity's metadata in MetadataChangeList, and
// UntrackEntity will remove corresponding ProcessorEntityTracker and do not add // UntrackEntity will remove corresponding ProcessorEntityTracker and do not add
// any entity's metadata into MetadataChangeList. // any entity's metadata into MetadataChangeList.
TEST_F(SharedModelTypeProcessorTest, UpdateStorageKey) { TEST_F(ClientTagBasedModelTypeProcessorTest, UpdateStorageKey) {
// Setup bridge to not support calls to GetStorageKey. This will cause // Setup bridge to not support calls to GetStorageKey. This will cause
// FakeModelTypeSyncBridge to call UpdateStorageKey for new entities and will // FakeModelTypeSyncBridge to call UpdateStorageKey for new entities and will
// DCHECK if GetStorageKey gets called. // DCHECK if GetStorageKey gets called.
...@@ -1546,7 +1552,7 @@ TEST_F(SharedModelTypeProcessorTest, UpdateStorageKey) { ...@@ -1546,7 +1552,7 @@ TEST_F(SharedModelTypeProcessorTest, UpdateStorageKey) {
// GetStorageKey(). When update from server delivers updated encryption key, all // GetStorageKey(). When update from server delivers updated encryption key, all
// entities should be reencrypted including new entity that just got received // entities should be reencrypted including new entity that just got received
// from server. // from server.
TEST_F(SharedModelTypeProcessorTest, ReencryptionWithEmptyStorageKeys) { TEST_F(ClientTagBasedModelTypeProcessorTest, ReencryptionWithEmptyStorageKeys) {
bridge()->SetSupportsGetStorageKey(false); bridge()->SetSupportsGetStorageKey(false);
InitializeToReadyState(); InitializeToReadyState();
...@@ -1560,7 +1566,7 @@ TEST_F(SharedModelTypeProcessorTest, ReencryptionWithEmptyStorageKeys) { ...@@ -1560,7 +1566,7 @@ TEST_F(SharedModelTypeProcessorTest, ReencryptionWithEmptyStorageKeys) {
// Tests that UntrackEntity won't propagate storage key to // Tests that UntrackEntity won't propagate storage key to
// ProcessorEntityTracker, and no entity's metadata are added into // ProcessorEntityTracker, and no entity's metadata are added into
// MetadataChangeList. // MetadataChangeList.
TEST_F(SharedModelTypeProcessorTest, UntrackEntity) { TEST_F(ClientTagBasedModelTypeProcessorTest, UntrackEntity) {
// Setup bridge to not support calls to GetStorageKey. This will cause // Setup bridge to not support calls to GetStorageKey. This will cause
// FakeModelTypeSyncBridge to call UpdateStorageKey for new entities and will // FakeModelTypeSyncBridge to call UpdateStorageKey for new entities and will
// DCHECK if GetStorageKey gets called. // DCHECK if GetStorageKey gets called.
...@@ -1581,10 +1587,10 @@ TEST_F(SharedModelTypeProcessorTest, UntrackEntity) { ...@@ -1581,10 +1587,10 @@ TEST_F(SharedModelTypeProcessorTest, UntrackEntity) {
EXPECT_EQ(0, bridge()->get_storage_key_call_count()); EXPECT_EQ(0, bridge()->get_storage_key_call_count());
} }
// Tests that SharedModelTypeProcessor can do garbage collection by version. // Tests that ClientTagBasedModelTypeProcessor can do garbage collection by
// Create 2 entries, one is version 1, another is version 3. Check if sync // version. Create 2 entries, one is version 1, another is version 3. Check if
// will delete version 1 entry when server set expired version is 2. // sync will delete version 1 entry when server set expired version is 2.
TEST_F(SharedModelTypeProcessorTest, GarbageCollectionByVersion) { TEST_F(ClientTagBasedModelTypeProcessorTest, GarbageCollectionByVersion) {
InitializeToReadyState(); InitializeToReadyState();
// Create 2 entries, one is version 3, another is version 1. // Create 2 entries, one is version 3, another is version 1.
...@@ -1612,10 +1618,10 @@ TEST_F(SharedModelTypeProcessorTest, GarbageCollectionByVersion) { ...@@ -1612,10 +1618,10 @@ TEST_F(SharedModelTypeProcessorTest, GarbageCollectionByVersion) {
EXPECT_EQ(0U, worker()->GetNumPendingCommits()); EXPECT_EQ(0U, worker()->GetNumPendingCommits());
} }
// Tests that SharedModelTypeProcessor can do garbage collection by age. // Tests that ClientTagBasedModelTypeProcessor can do garbage collection by age.
// Create 2 entries, one is 15-days-old, another is 5-days-old. Check if sync // Create 2 entries, one is 15-days-old, another is 5-days-old. Check if sync
// will delete 15-days-old entry when server set expired age is 10 days. // will delete 15-days-old entry when server set expired age is 10 days.
TEST_F(SharedModelTypeProcessorTest, GarbageCollectionByAge) { TEST_F(ClientTagBasedModelTypeProcessorTest, GarbageCollectionByAge) {
InitializeToReadyState(); InitializeToReadyState();
// Create 2 entries, one is 15-days-old, another is 5-days-old. // Create 2 entries, one is 15-days-old, another is 5-days-old.
...@@ -1646,11 +1652,11 @@ TEST_F(SharedModelTypeProcessorTest, GarbageCollectionByAge) { ...@@ -1646,11 +1652,11 @@ TEST_F(SharedModelTypeProcessorTest, GarbageCollectionByAge) {
EXPECT_EQ(0U, worker()->GetNumPendingCommits()); EXPECT_EQ(0U, worker()->GetNumPendingCommits());
} }
// Tests that SharedModelTypeProcessor can do garbage collection by item limit. // Tests that ClientTagBasedModelTypeProcessor can do garbage collection by item
// Create 3 entries, one is 15-days-old, one is 10-days-old, another is // limit. Create 3 entries, one is 15-days-old, one is 10-days-old, another is
// 5-days-old. Check if sync will delete 15-days-old entry when server set // 5-days-old. Check if sync will delete 15-days-old entry when server set
// limited item is 2 days. // limited item is 2 days.
TEST_F(SharedModelTypeProcessorTest, GarbageCollectionByItemLimit) { TEST_F(ClientTagBasedModelTypeProcessorTest, GarbageCollectionByItemLimit) {
InitializeToReadyState(); InitializeToReadyState();
// Create 3 entries, one is 15-days-old, one is 10-days-old, another is // Create 3 entries, one is 15-days-old, one is 10-days-old, another is
......
...@@ -127,7 +127,7 @@ used when committed. ...@@ -127,7 +127,7 @@ used when committed.
* [base::Optional](optional.md) - How to use `base::Optional` in C++ code. * [base::Optional](optional.md) - How to use `base::Optional` in C++ code.
* [Using the Origin Trials Framework](origin_trials_integration.md) - A * [Using the Origin Trials Framework](origin_trials_integration.md) - A
framework for conditionally enabling experimental APIs for testing. framework for conditionally enabling experimental APIs for testing.
* [`SharedModelTypeProcessor` in Unified Sync and Storage](sync/uss/shared_model_type_processor.md) - * [`ClientTagBasedModelTypeProcessor` in Unified Sync and Storage](sync/uss/client_tag_based_model_type_processor.md) -
Notes on the central data structure used in Chrome Sync. Notes on the central data structure used in Chrome Sync.
* [Chrome Sync's Model API](sync/model_api.md) - Data models used for syncing * [Chrome Sync's Model API](sync/model_api.md) - Data models used for syncing
information across devices using Chrome Sync. information across devices using Chrome Sync.
......
# SharedModelTypeProcessor # ClientTagBasedModelTypeProcessor
The [`SharedModelTypeProcessor`][SMTP] is a crucial piece of the USS codepath. The [`ClientTagBasedModelTypeProcessor`][SMTP] is a crucial piece of the USS codepath.
It lives on the model thread and performs the tracking of sync metadata for the It lives on the model thread and performs the tracking of sync metadata for the
[`ModelTypeSyncBridge`][MTSB] that owns it by implementing the [`ModelTypeSyncBridge`][MTSB] that owns it by implementing the
[`ModelTypeChangeProcessor`][MTCP] interface, as well as sending commit requests [`ModelTypeChangeProcessor`][MTCP] interface, as well as sending commit requests
...@@ -8,7 +8,7 @@ to the [`ModelTypeWorker`][MTW] on the sync thread via the [`CommitQueue`][CQ] ...@@ -8,7 +8,7 @@ to the [`ModelTypeWorker`][MTW] on the sync thread via the [`CommitQueue`][CQ]
interface and receiving updates from the same worker via the interface and receiving updates from the same worker via the
[`ModelTypeProcessor`][MTP] interface. [`ModelTypeProcessor`][MTP] interface.
[SMTP]: https://cs.chromium.org/chromium/src/components/sync/model_impl/shared_model_type_processor.h [SMTP]: https://cs.chromium.org/chromium/src/components/sync/model_impl/client_tag_based_model_type_processor.h
[MTSB]: https://cs.chromium.org/chromium/src/components/sync/model/model_type_sync_bridge.h [MTSB]: https://cs.chromium.org/chromium/src/components/sync/model/model_type_sync_bridge.h
[MTCP]: https://cs.chromium.org/chromium/src/components/sync/model/model_type_change_processor.h [MTCP]: https://cs.chromium.org/chromium/src/components/sync/model/model_type_change_processor.h
[MTW]: https://cs.chromium.org/chromium/src/components/sync/engine_impl/model_type_worker.h [MTW]: https://cs.chromium.org/chromium/src/components/sync/engine_impl/model_type_worker.h
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment