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

Side by Side Diff: components/discardable_memory/common/discardable_shared_memory_heap.cc

Issue 2694083005: memory-infra: Finish moving memory_infra from TracingController (Closed)
Patch Set: review Created 3 years, 10 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/common/discardable_shared_memory_heap.h" 5 #include "components/discardable_memory/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 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 416 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
417 locked_objects_size_in_bytes); 417 locked_objects_size_in_bytes);
418 418
419 // Emit an ownership edge towards a global allocator dump node. This allows 419 // Emit an ownership edge towards a global allocator dump node. This allows
420 // to avoid double-counting segments when both browser and client process emit 420 // to avoid double-counting segments when both browser and client process emit
421 // them. In the special case of single-process-mode, this will be the only 421 // them. In the special case of single-process-mode, this will be the only
422 // dumper active and the single ownership edge will become a no-op in the UI. 422 // dumper active and the single ownership edge will become a no-op in the UI.
423 // The global dump is created as a weak dump so that the segment is removed if 423 // The global dump is created as a weak dump so that the segment is removed if
424 // the browser does not dump it (segment was purged). 424 // the browser does not dump it (segment was purged).
425 const uint64_t tracing_process_id = 425 const uint64_t tracing_process_id =
426 base::trace_event::MemoryDumpManager::GetInstance() 426 base::trace_event::MemoryDumpManager::GetInstance()->tracing_process_id();
427 ->GetTracingProcessId();
428 base::trace_event::MemoryAllocatorDumpGuid shared_segment_guid = 427 base::trace_event::MemoryAllocatorDumpGuid shared_segment_guid =
429 GetSegmentGUIDForTracing(tracing_process_id, segment_id); 428 GetSegmentGUIDForTracing(tracing_process_id, segment_id);
430 // TODO(ssid): Make this weak once the GUID created is consistent 429 // TODO(ssid): Make this weak once the GUID created is consistent
431 // crbug.com/661257. 430 // crbug.com/661257.
432 pmd->CreateSharedGlobalAllocatorDump(shared_segment_guid); 431 pmd->CreateSharedGlobalAllocatorDump(shared_segment_guid);
433 432
434 // 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
435 // dumps associated. 434 // dumps associated.
436 pmd->GetSharedGlobalAllocatorDump(shared_segment_guid) 435 pmd->GetSharedGlobalAllocatorDump(shared_segment_guid)
437 ->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 436 ->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 auto it = 469 auto it =
471 std::find_if(memory_segments_.begin(), memory_segments_.end(), 470 std::find_if(memory_segments_.begin(), memory_segments_.end(),
472 [span](const std::unique_ptr<ScopedMemorySegment>& segment) { 471 [span](const std::unique_ptr<ScopedMemorySegment>& segment) {
473 return segment->ContainsSpan(span); 472 return segment->ContainsSpan(span);
474 }); 473 });
475 DCHECK(it != memory_segments_.end()); 474 DCHECK(it != memory_segments_.end());
476 return (*it)->CreateMemoryAllocatorDump(span, block_size_, name, pmd); 475 return (*it)->CreateMemoryAllocatorDump(span, block_size_, name, pmd);
477 } 476 }
478 477
479 } // namespace discardable_memory 478 } // namespace discardable_memory
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698