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

Side by Side Diff: components/discardable_memory/service/discardable_shared_memory_manager.cc

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: (rebase) Created 3 years, 7 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/discardable_memory/service/discardable_shared_memory_manage r.h" 5 #include "components/discardable_memory/service/discardable_shared_memory_manage r.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/atomic_sequence_num.h" 10 #include "base/atomic_sequence_num.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 // double-count them in tracing. If, instead, no other process will emit a 323 // double-count them in tracing. If, instead, no other process will emit a
324 // dump with the same guid, the segment will be accounted to the browser. 324 // dump with the same guid, the segment will be accounted to the browser.
325 const uint64_t client_tracing_id = 325 const uint64_t client_tracing_id =
326 ClientProcessUniqueIdToTracingProcessId(client_id); 326 ClientProcessUniqueIdToTracingProcessId(client_id);
327 base::trace_event::MemoryAllocatorDumpGuid shared_segment_guid = 327 base::trace_event::MemoryAllocatorDumpGuid shared_segment_guid =
328 DiscardableSharedMemoryHeap::GetSegmentGUIDForTracing( 328 DiscardableSharedMemoryHeap::GetSegmentGUIDForTracing(
329 client_tracing_id, segment_id); 329 client_tracing_id, segment_id);
330 pmd->CreateSharedGlobalAllocatorDump(shared_segment_guid); 330 pmd->CreateSharedGlobalAllocatorDump(shared_segment_guid);
331 pmd->AddOwnershipEdge(dump->guid(), shared_segment_guid); 331 pmd->AddOwnershipEdge(dump->guid(), shared_segment_guid);
332 332
333 // TODO(hajimehoshi): base::SharedMemoryTracker::AddOwnershipEdges should
334 // be used instead of CreateSharedGlobalAllocatorDump, but the |dump|
335 // doesn't have 'size' attribute here and it wouldn't make sense so far.
336
333 #if defined(COUNT_RESIDENT_BYTES_SUPPORTED) 337 #if defined(COUNT_RESIDENT_BYTES_SUPPORTED)
334 if (args.level_of_detail == 338 if (args.level_of_detail ==
335 base::trace_event::MemoryDumpLevelOfDetail::DETAILED) { 339 base::trace_event::MemoryDumpLevelOfDetail::DETAILED) {
336 size_t resident_size = 340 size_t resident_size =
337 base::trace_event::ProcessMemoryDump::CountResidentBytes( 341 base::trace_event::ProcessMemoryDump::CountResidentBytes(
338 segment->memory()->memory(), segment->memory()->mapped_size()); 342 segment->memory()->memory(), segment->memory()->mapped_size());
339 343
340 // This is added to the global dump since it has to be attributed to 344 // This is added to the global dump since it has to be attributed to
341 // both the allocator dumps involved. 345 // both the allocator dumps involved.
342 pmd->GetSharedGlobalAllocatorDump(shared_segment_guid) 346 pmd->GetSharedGlobalAllocatorDump(shared_segment_guid)
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 return; 630 return;
627 631
628 enforce_memory_policy_pending_ = true; 632 enforce_memory_policy_pending_ = true;
629 DCHECK(enforce_memory_policy_task_runner_); 633 DCHECK(enforce_memory_policy_task_runner_);
630 enforce_memory_policy_task_runner_->PostDelayedTask( 634 enforce_memory_policy_task_runner_->PostDelayedTask(
631 FROM_HERE, enforce_memory_policy_callback_, 635 FROM_HERE, enforce_memory_policy_callback_,
632 base::TimeDelta::FromMilliseconds(kEnforceMemoryPolicyDelayMs)); 636 base::TimeDelta::FromMilliseconds(kEnforceMemoryPolicyDelayMs));
633 } 637 }
634 638
635 } // namespace discardable_memory 639 } // namespace discardable_memory
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698