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

Side by Side Diff: content/common/discardable_shared_memory_heap.cc

Issue 1583483002: [tracing] Add method to create "weak" global dumps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: back to weak dumps. Created 4 years, 11 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 "content/common/discardable_shared_memory_heap.h" 5 #include "content/common/discardable_shared_memory_heap.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 416
417 // Emit an ownership edge towards a global allocator dump node. This allows 417 // Emit an ownership edge towards a global allocator dump node. This allows
418 // to avoid double-counting segments when both browser and child process emit 418 // to avoid double-counting segments when both browser and child process emit
419 // them. In the special case of single-process-mode, this will be the only 419 // them. In the special case of single-process-mode, this will be the only
420 // dumper active and the single ownership edge will become a no-op in the UI. 420 // dumper active and the single ownership edge will become a no-op in the UI.
421 const uint64_t tracing_process_id = 421 const uint64_t tracing_process_id =
422 base::trace_event::MemoryDumpManager::GetInstance() 422 base::trace_event::MemoryDumpManager::GetInstance()
423 ->GetTracingProcessId(); 423 ->GetTracingProcessId();
424 base::trace_event::MemoryAllocatorDumpGuid shared_segment_guid = 424 base::trace_event::MemoryAllocatorDumpGuid shared_segment_guid =
425 GetSegmentGUIDForTracing(tracing_process_id, segment_id); 425 GetSegmentGUIDForTracing(tracing_process_id, segment_id);
426 pmd->CreateSharedGlobalAllocatorDump(shared_segment_guid); 426 base::trace_event::MemoryAllocatorDump* global_dump =
427 pmd->CreateSharedGlobalAllocatorDump(shared_segment_guid);
428
429 // Set the dump as weak so that it is invalidated if the browser had purged
430 // the segment.
431 global_dump->set_flags(base::trace_event::MemoryAllocatorDump::Flags::WEAK);
petrcermak 2016/01/13 17:46:14 This will work as long as there is no other user o
ssid 2016/01/15 17:14:56 Done.
427 432
428 // The size is added to the global dump so that it gets propagated to both the 433 // The size is added to the global dump so that it gets propagated to both the
429 // dumps associated. 434 // dumps associated.
430 pmd->GetSharedGlobalAllocatorDump(shared_segment_guid) 435 global_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
431 ->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 436 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
432 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 437 allocated_objects_size_in_bytes);
433 allocated_objects_size_in_bytes);
434 438
435 // By creating an edge with a higher |importance| (w.r.t. browser-side dumps) 439 // By creating an edge with a higher |importance| (w.r.t. browser-side dumps)
436 // the tracing UI will account the effective size of the segment to the child. 440 // the tracing UI will account the effective size of the segment to the child.
437 const int kImportance = 2; 441 const int kImportance = 2;
438 pmd->AddOwnershipEdge(segment_dump->guid(), shared_segment_guid, kImportance); 442 pmd->AddOwnershipEdge(segment_dump->guid(), shared_segment_guid, kImportance);
439 } 443 }
440 444
441 // static 445 // static
442 base::trace_event::MemoryAllocatorDumpGuid 446 base::trace_event::MemoryAllocatorDumpGuid
443 DiscardableSharedMemoryHeap::GetSegmentGUIDForTracing( 447 DiscardableSharedMemoryHeap::GetSegmentGUIDForTracing(
(...skipping 19 matching lines...) Expand all
463 ScopedVector<ScopedMemorySegment>::const_iterator it = 467 ScopedVector<ScopedMemorySegment>::const_iterator it =
464 std::find_if(memory_segments_.begin(), memory_segments_.end(), 468 std::find_if(memory_segments_.begin(), memory_segments_.end(),
465 [span](const ScopedMemorySegment* segment) { 469 [span](const ScopedMemorySegment* segment) {
466 return segment->ContainsSpan(span); 470 return segment->ContainsSpan(span);
467 }); 471 });
468 DCHECK(it != memory_segments_.end()); 472 DCHECK(it != memory_segments_.end());
469 return (*it)->CreateMemoryAllocatorDump(span, block_size_, name, pmd); 473 return (*it)->CreateMemoryAllocatorDump(span, block_size_, name, pmd);
470 } 474 }
471 475
472 } // namespace content 476 } // namespace content
OLDNEW
« base/trace_event/memory_allocator_dump.h ('K') | « base/trace_event/memory_allocator_dump.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698