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

Side by Side 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 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/sync/syncable/entry_kernel.h" 5 #include "components/sync/syncable/entry_kernel.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/json/string_escape.h" 9 #include "base/json/string_escape.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/trace_event/memory_usage_estimator.h"
11 #include "components/sync/base/cryptographer.h" 12 #include "components/sync/base/cryptographer.h"
13 #include "components/sync/protocol/proto_memory_estimations.h"
12 #include "components/sync/protocol/proto_value_conversions.h" 14 #include "components/sync/protocol/proto_value_conversions.h"
13 #include "components/sync/syncable/syncable_columns.h" 15 #include "components/sync/syncable/syncable_columns.h"
14 #include "components/sync/syncable/syncable_enum_conversions.h" 16 #include "components/sync/syncable/syncable_enum_conversions.h"
15 17
16 namespace syncer { 18 namespace syncer {
17 namespace syncable { 19 namespace syncable {
18 20
19 EntryKernel::EntryKernel() : dirty_(false) { 21 EntryKernel::EntryKernel() : dirty_(false), memory_usage_(kMemoryUsageUnknown) {
20 // Everything else should already be default-initialized. 22 // Everything else should already be default-initialized.
21 for (int i = 0; i < INT64_FIELDS_COUNT; ++i) { 23 for (int i = 0; i < INT64_FIELDS_COUNT; ++i) {
22 int64_fields[i] = 0; 24 int64_fields[i] = 0;
23 } 25 }
24 } 26 }
25 27
26 EntryKernel::EntryKernel(const EntryKernel& other) = default; 28 EntryKernel::EntryKernel(const EntryKernel& other) = default;
27 29
28 EntryKernel::~EntryKernel() {} 30 EntryKernel::~EntryKernel() {}
29 31
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 &AttachmentMetadataToValue, ATTACHMENT_METADATA_FIELDS_BEGIN, 206 &AttachmentMetadataToValue, ATTACHMENT_METADATA_FIELDS_BEGIN,
205 ATTACHMENT_METADATA_FIELDS_END - 1); 207 ATTACHMENT_METADATA_FIELDS_END - 1);
206 208
207 // Bit temps. 209 // Bit temps.
208 SetFieldValues(*this, kernel_info, &GetBitTempString, &BooleanToValue, 210 SetFieldValues(*this, kernel_info, &GetBitTempString, &BooleanToValue,
209 BIT_TEMPS_BEGIN, BIT_TEMPS_END - 1); 211 BIT_TEMPS_BEGIN, BIT_TEMPS_END - 1);
210 212
211 return kernel_info; 213 return kernel_info;
212 } 214 }
213 215
216 size_t EntryKernel::EstimateMemoryUsage() const {
217 if (memory_usage_ == kMemoryUsageUnknown) {
218 using base::trace_event::EstimateMemoryUsage;
219 memory_usage_ = EstimateMemoryUsage(string_fields) +
220 EstimateMemoryUsage(specifics_fields) +
221 EstimateMemoryUsage(id_fields) +
222 EstimateMemoryUsage(unique_position_fields) +
223 EstimateMemoryUsage(attachment_metadata_fields);
224 }
225 return memory_usage_;
226 }
227
214 std::unique_ptr<base::ListValue> EntryKernelMutationMapToValue( 228 std::unique_ptr<base::ListValue> EntryKernelMutationMapToValue(
215 const EntryKernelMutationMap& mutations) { 229 const EntryKernelMutationMap& mutations) {
216 std::unique_ptr<base::ListValue> list(new base::ListValue()); 230 std::unique_ptr<base::ListValue> list(new base::ListValue());
217 for (EntryKernelMutationMap::const_iterator it = mutations.begin(); 231 for (EntryKernelMutationMap::const_iterator it = mutations.begin();
218 it != mutations.end(); ++it) { 232 it != mutations.end(); ++it) {
219 list->Append(EntryKernelMutationToValue(it->second)); 233 list->Append(EntryKernelMutationToValue(it->second));
220 } 234 }
221 return list; 235 return list;
222 } 236 }
223 237
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 os << "TempFlags: "; 287 os << "TempFlags: ";
274 for (; i < BIT_TEMPS_END; ++i) { 288 for (; i < BIT_TEMPS_END; ++i) {
275 if (kernel->ref(static_cast<BitTemp>(i))) 289 if (kernel->ref(static_cast<BitTemp>(i)))
276 os << "#" << i - BIT_TEMPS_BEGIN << ", "; 290 os << "#" << i - BIT_TEMPS_BEGIN << ", ";
277 } 291 }
278 return os; 292 return os;
279 } 293 }
280 294
281 } // namespace syncable 295 } // namespace syncable
282 } // namespace syncer 296 } // namespace syncer
OLDNEW
« 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