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

Side by Side Diff: components/sync/model_impl/shared_model_type_processor.cc

Issue 2781863004: [Sync] Implement EstimateMemoryUsage for SharedModelTypeProcessor and ModelTypeWorker (Closed)
Patch Set: Address comments Created 3 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_impl/shared_model_type_processor.h" 5 #include "components/sync/model_impl/shared_model_type_processor.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "base/trace_event/memory_usage_estimator.h"
15 #include "components/sync/base/hash_util.h" 16 #include "components/sync/base/hash_util.h"
16 #include "components/sync/engine/activation_context.h" 17 #include "components/sync/engine/activation_context.h"
17 #include "components/sync/engine/commit_queue.h" 18 #include "components/sync/engine/commit_queue.h"
18 #include "components/sync/engine/model_type_processor_proxy.h" 19 #include "components/sync/engine/model_type_processor_proxy.h"
19 #include "components/sync/model_impl/processor_entity_tracker.h" 20 #include "components/sync/model_impl/processor_entity_tracker.h"
21 #include "components/sync/protocol/proto_memory_estimations.h"
20 22
21 namespace syncer { 23 namespace syncer {
22 24
23 SharedModelTypeProcessor::SharedModelTypeProcessor( 25 SharedModelTypeProcessor::SharedModelTypeProcessor(
24 ModelType type, 26 ModelType type,
25 ModelTypeSyncBridge* bridge, 27 ModelTypeSyncBridge* bridge,
26 const base::RepeatingClosure& dump_stack) 28 const base::RepeatingClosure& dump_stack)
27 : type_(type), 29 : type_(type),
28 bridge_(bridge), 30 bridge_(bridge),
29 dump_stack_(dump_stack), 31 dump_stack_(dump_stack),
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 return entity_ptr; 659 return entity_ptr;
658 } 660 }
659 661
660 ProcessorEntityTracker* SharedModelTypeProcessor::CreateEntity( 662 ProcessorEntityTracker* SharedModelTypeProcessor::CreateEntity(
661 const EntityData& data) { 663 const EntityData& data) {
662 // Verify the tag hash matches, may be relaxed in the future. 664 // Verify the tag hash matches, may be relaxed in the future.
663 DCHECK_EQ(data.client_tag_hash, GetHashForTag(bridge_->GetClientTag(data))); 665 DCHECK_EQ(data.client_tag_hash, GetHashForTag(bridge_->GetClientTag(data)));
664 return CreateEntity(bridge_->GetStorageKey(data), data); 666 return CreateEntity(bridge_->GetStorageKey(data), data);
665 } 667 }
666 668
669 size_t SharedModelTypeProcessor::EstimateMemoryUsage() const {
670 using base::trace_event::EstimateMemoryUsage;
671 size_t memory_usage = 0;
672 memory_usage += EstimateMemoryUsage(model_type_state_);
673 memory_usage += EstimateMemoryUsage(entities_);
674 memory_usage += EstimateMemoryUsage(storage_key_to_tag_hash_);
675 return memory_usage;
676 }
677
667 } // namespace syncer 678 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/model_impl/shared_model_type_processor.h ('k') | components/sync/protocol/proto_memory_estimations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698