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

Side by Side Diff: components/sync/model/model_type_debug_info.cc

Issue 2949923004: Reland: [Sync] Record sync memory usage in histogram broken by datatypes (Closed)
Patch Set: Fix linker error Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/model/model_type_debug_info.h" 5 #include "components/sync/model/model_type_debug_info.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "components/sync/base/data_type_histogram.h"
12 #include "components/sync/model_impl/processor_entity_tracker.h" 13 #include "components/sync/model_impl/processor_entity_tracker.h"
13 #include "components/sync/protocol/proto_value_conversions.h" 14 #include "components/sync/protocol/proto_value_conversions.h"
14 15
15 using base::DictionaryValue; 16 using base::DictionaryValue;
16 using base::ListValue; 17 using base::ListValue;
17 18
18 namespace syncer { 19 namespace syncer {
19 20
20 namespace { 21 namespace {
21 22
(...skipping 30 matching lines...) Expand all
52 counters.num_entries_and_tombstones = processor->entities_.size(); 53 counters.num_entries_and_tombstones = processor->entities_.size();
53 for (const auto& kv : processor->entities_) { 54 for (const auto& kv : processor->entities_) {
54 if (!kv.second->metadata().is_deleted()) { 55 if (!kv.second->metadata().is_deleted()) {
55 ++counters.num_entries; 56 ++counters.num_entries;
56 } 57 }
57 } 58 }
58 callback.Run(processor->type_, counters); 59 callback.Run(processor->type_, counters);
59 } 60 }
60 } 61 }
61 62
63 // static
64 void ModelTypeDebugInfo::RecordMemoryUsageHistogram(
65 ModelTypeSyncBridge* bridge) {
66 SharedModelTypeProcessor* processor = GetProcessorFromBridge(bridge);
67 size_t memory_usage = processor->EstimateMemoryUsage();
68 SyncRecordMemoryKbHistogram(kModelTypeMemoryHistogramPrefix, processor->type_,
69 memory_usage);
70 }
71
62 ModelTypeDebugInfo::ModelTypeDebugInfo() {} 72 ModelTypeDebugInfo::ModelTypeDebugInfo() {}
63 73
64 // static 74 // static
65 void ModelTypeDebugInfo::MergeDataWithMetadata( 75 void ModelTypeDebugInfo::MergeDataWithMetadata(
66 SharedModelTypeProcessor* processor, 76 SharedModelTypeProcessor* processor,
67 const base::Callback<void(const ModelType, std::unique_ptr<ListValue>)>& 77 const base::Callback<void(const ModelType, std::unique_ptr<ListValue>)>&
68 callback, 78 callback,
69 std::unique_ptr<DataBatch> batch) { 79 std::unique_ptr<DataBatch> batch) {
70 std::unique_ptr<ListValue> all_nodes = base::MakeUnique<ListValue>(); 80 std::unique_ptr<ListValue> all_nodes = base::MakeUnique<ListValue>();
71 std::string type_string = ModelTypeToString(processor->type_); 81 std::string type_string = ModelTypeToString(processor->type_);
(...skipping 24 matching lines...) Expand all
96 rootnode->SetString("UNIQUE_SERVER_TAG", type_string); 106 rootnode->SetString("UNIQUE_SERVER_TAG", type_string);
97 rootnode->SetBoolean("IS_DIR", true); 107 rootnode->SetBoolean("IS_DIR", true);
98 rootnode->SetString("modelType", type_string); 108 rootnode->SetString("modelType", type_string);
99 rootnode->SetString("NON_UNIQUE_NAME", type_string); 109 rootnode->SetString("NON_UNIQUE_NAME", type_string);
100 all_nodes->Append(std::move(rootnode)); 110 all_nodes->Append(std::move(rootnode));
101 111
102 callback.Run(processor->type_, std::move(all_nodes)); 112 callback.Run(processor->type_, std::move(all_nodes));
103 } 113 }
104 114
105 } // namespace syncer 115 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/model/model_type_debug_info.h ('k') | components/sync/protocol/proto_memory_estimations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698