| OLD | NEW |
| 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/host_discardable_shared_memory_manager.h" | 5 #include "content/common/host_discardable_shared_memory_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 // Create the cross-process ownership edge. If the child creates a | 194 // Create the cross-process ownership edge. If the child creates a |
| 195 // corresponding dump for the same segment, this will avoid to | 195 // corresponding dump for the same segment, this will avoid to |
| 196 // double-count them in tracing. If, instead, no other process will emit a | 196 // double-count them in tracing. If, instead, no other process will emit a |
| 197 // dump with the same guid, the segment will be accounted to the browser. | 197 // dump with the same guid, the segment will be accounted to the browser. |
| 198 const uint64 child_tracing_process_id = | 198 const uint64 child_tracing_process_id = |
| 199 ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( | 199 ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( |
| 200 child_process_id); | 200 child_process_id); |
| 201 base::trace_event::MemoryAllocatorDumpGuid shared_segment_guid = | 201 base::trace_event::MemoryAllocatorDumpGuid shared_segment_guid = |
| 202 DiscardableSharedMemoryHeap::GetSegmentGUIDForTracing( | 202 DiscardableSharedMemoryHeap::GetSegmentGUIDForTracing( |
| 203 child_tracing_process_id, segment_id); | 203 child_tracing_process_id, segment_id); |
| 204 pmd->CreateSharedGlobalAllocatorDump(shared_segment_guid); | 204 base::trace_event::MemoryAllocatorDump* global_dump = |
| 205 pmd->CreateSharedGlobalAllocatorDump(shared_segment_guid); |
| 205 pmd->AddOwnershipEdge(dump->guid(), shared_segment_guid); | 206 pmd->AddOwnershipEdge(dump->guid(), shared_segment_guid); |
| 207 |
| 208 #if defined(COUNT_RESIDENT_BYTES_SUPPORTED) |
| 209 if (args.level_of_detail == |
| 210 base::trace_event::MemoryDumpLevelOfDetail::DETAILED) { |
| 211 size_t resident_size = |
| 212 base::trace_event::ProcessMemoryDump::CountResidentBytes( |
| 213 segment->memory()->memory(), segment->memory()->mapped_size()); |
| 214 |
| 215 // This is added to the global dump since it has to be attributed to |
| 216 // both the allocator dumps involved. |
| 217 global_dump->AddScalar( |
| 218 "resident_size", |
| 219 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 220 static_cast<uint64>(resident_size)); |
| 221 } |
| 222 #endif // defined(COUNT_RESIDENT_BYTES_SUPPORTED) |
| 206 } | 223 } |
| 207 } | 224 } |
| 208 return true; | 225 return true; |
| 209 } | 226 } |
| 210 | 227 |
| 211 void HostDiscardableSharedMemoryManager:: | 228 void HostDiscardableSharedMemoryManager:: |
| 212 AllocateLockedDiscardableSharedMemoryForChild( | 229 AllocateLockedDiscardableSharedMemoryForChild( |
| 213 base::ProcessHandle process_handle, | 230 base::ProcessHandle process_handle, |
| 214 int child_process_id, | 231 int child_process_id, |
| 215 size_t size, | 232 size_t size, |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 | 490 |
| 474 enforce_memory_policy_pending_ = true; | 491 enforce_memory_policy_pending_ = true; |
| 475 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 492 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 476 FROM_HERE, | 493 FROM_HERE, |
| 477 base::Bind(&HostDiscardableSharedMemoryManager::EnforceMemoryPolicy, | 494 base::Bind(&HostDiscardableSharedMemoryManager::EnforceMemoryPolicy, |
| 478 weak_ptr_factory_.GetWeakPtr()), | 495 weak_ptr_factory_.GetWeakPtr()), |
| 479 base::TimeDelta::FromMilliseconds(kEnforceMemoryPolicyDelayMs)); | 496 base::TimeDelta::FromMilliseconds(kEnforceMemoryPolicyDelayMs)); |
| 480 } | 497 } |
| 481 | 498 |
| 482 } // namespace content | 499 } // namespace content |
| OLD | NEW |