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

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

Issue 2452713003: [Sync] Implement MemoryDumpProvider. (Closed)
Patch Set: Fix presumit; fix Windows; git cl format Created 4 years, 1 month 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/syncable/entry_kernel.h ('k') | components/sync/syncable/parent_child_index.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..45f61a1d0da3ea0adf13c5f503dae8337a4e5b1f 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/memory_usage_estimator.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,18 @@ 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());
« no previous file with comments | « components/sync/syncable/entry_kernel.h ('k') | components/sync/syncable/parent_child_index.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698