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") {
"model/time.h",
"model_impl/accumulating_metadata_change_list.cc",
"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.h",
"model_impl/model_type_store_backend.cc",
......@@ -434,8 +436,6 @@ jumbo_static_library("sync") {
"model_impl/passthrough_metadata_change_list.h",
"model_impl/processor_entity_tracker.cc",
"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.h",
"protocol/proto_enum_conversions.cc",
......@@ -874,11 +874,11 @@ source_set("unit_tests") {
"model/sync_error_unittest.cc",
"model/sync_merge_result_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_impl_unittest.cc",
"model_impl/passthrough_metadata_change_list_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_value_conversions_unittest.cc",
"syncable/change_record_unittest.cc",
......
......@@ -4,7 +4,7 @@
#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 {
......@@ -13,7 +13,7 @@ std::unique_ptr<ModelTypeChangeProcessor> ModelTypeChangeProcessor::Create(
const base::RepeatingClosure& dump_stack,
ModelType type,
ModelTypeSyncBridge* bridge) {
return std::make_unique<SharedModelTypeProcessor>(
return std::make_unique<ClientTagBasedModelTypeProcessor>(
type, bridge, dump_stack, CommitOnlyTypes().Has(type));
}
......
......@@ -19,13 +19,15 @@ namespace syncer {
namespace {
SharedModelTypeProcessor* GetProcessorFromBridge(ModelTypeSyncBridge* bridge) {
ClientTagBasedModelTypeProcessor* GetProcessorFromBridge(
ModelTypeSyncBridge* bridge) {
ModelTypeChangeProcessor* processor = bridge->change_processor();
if (processor == nullptr) {
LOG(WARNING) << "SharedModelTypeProcessor destroyed before debug info was "
"retrieved.";
LOG(WARNING)
<< "ClientTagBasedModelTypeProcessor destroyed before debug info was "
"retrieved.";
}
return static_cast<SharedModelTypeProcessor*>(processor);
return static_cast<ClientTagBasedModelTypeProcessor*>(processor);
}
} // namespace
......@@ -35,7 +37,7 @@ void ModelTypeDebugInfo::GetAllNodes(
const base::Callback<void(const ModelType, std::unique_ptr<ListValue>)>&
callback,
ModelTypeSyncBridge* bridge) {
SharedModelTypeProcessor* processor = GetProcessorFromBridge(bridge);
ClientTagBasedModelTypeProcessor* processor = GetProcessorFromBridge(bridge);
if (processor) {
bridge->GetAllData(base::Bind(&ModelTypeDebugInfo::MergeDataWithMetadata,
base::Unretained(processor), callback));
......@@ -46,7 +48,7 @@ void ModelTypeDebugInfo::GetAllNodes(
void ModelTypeDebugInfo::GetStatusCounters(
const base::Callback<void(ModelType, const StatusCounters&)>& callback,
ModelTypeSyncBridge* bridge) {
SharedModelTypeProcessor* processor = GetProcessorFromBridge(bridge);
ClientTagBasedModelTypeProcessor* processor = GetProcessorFromBridge(bridge);
if (processor) {
StatusCounters counters;
counters.num_entries_and_tombstones = processor->entities_.size();
......@@ -62,7 +64,7 @@ void ModelTypeDebugInfo::GetStatusCounters(
// static
void ModelTypeDebugInfo::RecordMemoryUsageHistogram(
ModelTypeSyncBridge* bridge) {
SharedModelTypeProcessor* processor = GetProcessorFromBridge(bridge);
ClientTagBasedModelTypeProcessor* processor = GetProcessorFromBridge(bridge);
size_t memory_usage = processor->EstimateMemoryUsage();
SyncRecordMemoryKbHistogram(kModelTypeMemoryHistogramPrefix, processor->type_,
memory_usage);
......@@ -72,7 +74,7 @@ ModelTypeDebugInfo::ModelTypeDebugInfo() {}
// static
void ModelTypeDebugInfo::MergeDataWithMetadata(
SharedModelTypeProcessor* processor,
ClientTagBasedModelTypeProcessor* processor,
const base::Callback<void(const ModelType, std::unique_ptr<ListValue>)>&
callback,
std::unique_ptr<DataBatch> batch) {
......
......@@ -11,14 +11,14 @@
#include "base/values.h"
#include "components/sync/base/model_type.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 {
// 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
// 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 {
public:
// Returns a ListValue representing all nodes for the type to |callback|.
......@@ -46,7 +46,7 @@ class ModelTypeDebugInfo {
// function will merge real data from |batch| with metadata extracted from
// the |processor|, then pass it all to |callback|.
static void MergeDataWithMetadata(
SharedModelTypeProcessor* processor,
ClientTagBasedModelTypeProcessor* processor,
const base::Callback<void(const ModelType,
std::unique_ptr<base::ListValue>)>& callback,
std::unique_ptr<DataBatch> batch);
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_SYNC_MODEL_IMPL_SHARED_MODEL_TYPE_PROCESSOR_H_
#define 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_CLIENT_TAG_BASED_MODEL_TYPE_PROCESSOR_H_
#include <map>
#include <memory>
......@@ -34,16 +34,17 @@ class ProcessorEntityTracker;
// A sync component embedded on the model type's thread that tracks entity
// 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
// more thorough description.
class SharedModelTypeProcessor : public ModelTypeProcessor,
public ModelTypeChangeProcessor {
// model type threads. See
// //docs/sync/uss/client_tag_based_model_type_processor.md for a more thorough
// description.
class ClientTagBasedModelTypeProcessor : public ModelTypeProcessor,
public ModelTypeChangeProcessor {
public:
SharedModelTypeProcessor(ModelType type,
ModelTypeSyncBridge* bridge,
const base::RepeatingClosure& dump_stack,
bool commit_only);
~SharedModelTypeProcessor() override;
ClientTagBasedModelTypeProcessor(ModelType type,
ModelTypeSyncBridge* bridge,
const base::RepeatingClosure& dump_stack,
bool commit_only);
~ClientTagBasedModelTypeProcessor() override;
// Whether the processor is allowing changes to its model type. If this is
// false, the bridge should not allow any changes to its data.
......@@ -84,7 +85,7 @@ class SharedModelTypeProcessor : public ModelTypeProcessor,
private:
friend class ModelTypeDebugInfo;
friend class SharedModelTypeProcessorTest;
friend class ClientTagBasedModelTypeProcessorTest;
// Returns true if the model is ready or encountered an error.
bool IsModelReadyOrError() const;
......@@ -270,11 +271,11 @@ class SharedModelTypeProcessor : public ModelTypeProcessor,
SEQUENCE_CHECKER(sequence_checker_);
// 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
#endif // COMPONENTS_SYNC_MODEL_IMPL_SHARED_MODEL_TYPE_PROCESSOR_H_
#endif // COMPONENTS_SYNC_MODEL_IMPL_CLIENT_TAG_BASED_MODEL_TYPE_PROCESSOR_H_
......@@ -127,7 +127,7 @@ used when committed.
* [base::Optional](optional.md) - How to use `base::Optional` in C++ code.
* [Using the Origin Trials Framework](origin_trials_integration.md) - A
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.
* [Chrome Sync's Model API](sync/model_api.md) - Data models used for syncing
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
[`ModelTypeSyncBridge`][MTSB] that owns it by implementing the
[`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]
interface and receiving updates from the same worker via the
[`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
[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
......
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