Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Unified Diff: components/sync/model/entity_data.cc

Issue 2781863004: [Sync] Implement EstimateMemoryUsage for SharedModelTypeProcessor and ModelTypeWorker (Closed)
Patch Set: Address comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/sync/model/entity_data.h ('k') | components/sync/model_impl/processor_entity_tracker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « components/sync/model/entity_data.h ('k') | components/sync/model_impl/processor_entity_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698