| Index: components/sync/model/entity_data.cc
|
| diff --git a/components/sync/model/entity_data.cc b/components/sync/model/entity_data.cc
|
| index bbcc6cf5fb5eee6718f76a4a5ca93794247b3988..ddcd502d5290ecd6ef922afe8ede6cf71e04750a 100644
|
| --- a/components/sync/model/entity_data.cc
|
| +++ b/components/sync/model/entity_data.cc
|
| @@ -10,8 +10,10 @@
|
| #include "base/logging.h"
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/string_util.h"
|
| +#include "base/trace_event/memory_usage_estimator.h"
|
| #include "components/sync/base/time.h"
|
| #include "components/sync/base/unique_position.h"
|
| +#include "components/sync/protocol/proto_memory_estimations.h"
|
| #include "components/sync/protocol/proto_value_conversions.h"
|
|
|
| namespace syncer {
|
| @@ -48,23 +50,39 @@ EntityDataPtr EntityData::PassToPtr() {
|
| return target;
|
| }
|
|
|
| -#define ADD_TO_DICT(dict, value, transform) \
|
| +#define ADD_TO_DICT(dict, value) \
|
| + dict->SetString(base::ToUpperASCII(#value), value);
|
| +
|
| +#define ADD_TO_DICT_WITH_TRANSFORM(dict, value, transform) \
|
| dict->SetString(base::ToUpperASCII(#value), transform(value));
|
|
|
| std::unique_ptr<base::DictionaryValue> EntityData::ToDictionaryValue() {
|
| std::unique_ptr<base::DictionaryValue> dict =
|
| EntitySpecificsToValue(specifics);
|
| - ADD_TO_DICT(dict, id, );
|
| - ADD_TO_DICT(dict, client_tag_hash, );
|
| - ADD_TO_DICT(dict, non_unique_name, );
|
| - ADD_TO_DICT(dict, parent_id, );
|
| - ADD_TO_DICT(dict, creation_time, GetTimeDebugString);
|
| - ADD_TO_DICT(dict, modification_time, GetTimeDebugString);
|
| - ADD_TO_DICT(dict, unique_position, UniquePositionToString);
|
| + ADD_TO_DICT(dict, id);
|
| + ADD_TO_DICT(dict, client_tag_hash);
|
| + ADD_TO_DICT(dict, non_unique_name);
|
| + ADD_TO_DICT(dict, parent_id);
|
| + ADD_TO_DICT_WITH_TRANSFORM(dict, creation_time, GetTimeDebugString);
|
| + ADD_TO_DICT_WITH_TRANSFORM(dict, modification_time, GetTimeDebugString);
|
| + ADD_TO_DICT_WITH_TRANSFORM(dict, unique_position, UniquePositionToString);
|
| return dict;
|
| }
|
|
|
| #undef ADD_TO_DICT
|
| +#undef ADD_TO_DICT_WITH_TRANSFORM
|
| +
|
| +size_t EntityData::EstimateMemoryUsage() const {
|
| + using base::trace_event::EstimateMemoryUsage;
|
| + size_t memory_usage = 0;
|
| + memory_usage += EstimateMemoryUsage(id);
|
| + memory_usage += EstimateMemoryUsage(client_tag_hash);
|
| + memory_usage += EstimateMemoryUsage(non_unique_name);
|
| + memory_usage += EstimateMemoryUsage(specifics);
|
| + memory_usage += EstimateMemoryUsage(parent_id);
|
| + memory_usage += EstimateMemoryUsage(unique_position);
|
| + return memory_usage;
|
| +}
|
|
|
| void EntityDataTraits::SwapValue(EntityData* dest, EntityData* src) {
|
| dest->Swap(src);
|
|
|