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

Unified Diff: components/sync/syncable/entry_kernel.cc

Issue 2452713003: [Sync] Implement MemoryDumpProvider. (Closed)
Patch Set: Created 4 years, 2 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
Index: components/sync/syncable/entry_kernel.cc
diff --git a/components/sync/syncable/entry_kernel.cc b/components/sync/syncable/entry_kernel.cc
index 2aaf8d1dcd9126f672aab637395ce27e64d3aea5..b707ffe2a1633b206953c6909f85894c7f87f9f1 100644
--- a/components/sync/syncable/entry_kernel.cc
+++ b/components/sync/syncable/entry_kernel.cc
@@ -8,7 +8,9 @@
#include "base/json/string_escape.h"
#include "base/strings/string_number_conversions.h"
+#include "base/trace_event/estimate_memory_usage.h"
#include "components/sync/base/cryptographer.h"
+#include "components/sync/protocol/proto_memory_estimations.h"
#include "components/sync/protocol/proto_value_conversions.h"
#include "components/sync/syncable/syncable_columns.h"
#include "components/sync/syncable/syncable_enum_conversions.h"
@@ -16,7 +18,7 @@
namespace syncer {
namespace syncable {
-EntryKernel::EntryKernel() : dirty_(false) {
+EntryKernel::EntryKernel() : dirty_(false), memory_usage_(kMemoryUsageUnknown) {
// Everything else should already be default-initialized.
for (int i = 0; i < INT64_FIELDS_COUNT; ++i) {
int64_fields[i] = 0;
@@ -211,6 +213,19 @@ base::DictionaryValue* EntryKernel::ToValue(
return kernel_info;
}
+size_t EntryKernel::EstimateMemoryUsage() const {
+ if (memory_usage_ == kMemoryUsageUnknown) {
+ using base::trace_event::EstimateMemoryUsage;
+ memory_usage_ =
+ EstimateMemoryUsage(string_fields) +
+ EstimateMemoryUsage(specifics_fields) +
+ EstimateMemoryUsage(id_fields) +
+ EstimateMemoryUsage(unique_position_fields) +
+ EstimateMemoryUsage(attachment_metadata_fields);
+ }
+ return memory_usage_;
+}
+
std::unique_ptr<base::ListValue> EntryKernelMutationMapToValue(
const EntryKernelMutationMap& mutations) {
std::unique_ptr<base::ListValue> list(new base::ListValue());

Powered by Google App Engine
This is Rietveld 408576698