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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 pmd->CreateSharedGlobalAllocatorDump(shared_segment_guid); |
205 pmd->AddOwnershipEdge(dump->guid(), shared_segment_guid); | 205 pmd->AddOwnershipEdge(dump->guid(), shared_segment_guid); |
| 206 |
| 207 #if defined(COUNT_RESIDENT_BYTES_SUPPORTED) |
| 208 if (args.level_of_detail == |
| 209 base::trace_event::MemoryDumpLevelOfDetail::DETAILED) { |
| 210 size_t resident_size = |
| 211 base::trace_event::ProcessMemoryDump::CountResidentBytes( |
| 212 segment->memory()->memory(), segment->memory()->mapped_size()); |
| 213 |
| 214 // This is added to the global dump since it has to be attributed to |
| 215 // both the allocator dumps involved. |
| 216 pmd->GetSharedGlobalAllocatorDump(shared_segment_guid) |
| 217 ->AddScalar("resident_size", |
| 218 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 219 static_cast<uint64>(resident_size)); |
| 220 } |
| 221 #endif // defined(COUNT_RESIDENT_BYTES_SUPPORTED) |
206 } | 222 } |
207 } | 223 } |
208 return true; | 224 return true; |
209 } | 225 } |
210 | 226 |
211 void HostDiscardableSharedMemoryManager:: | 227 void HostDiscardableSharedMemoryManager:: |
212 AllocateLockedDiscardableSharedMemoryForChild( | 228 AllocateLockedDiscardableSharedMemoryForChild( |
213 base::ProcessHandle process_handle, | 229 base::ProcessHandle process_handle, |
214 int child_process_id, | 230 int child_process_id, |
215 size_t size, | 231 size_t size, |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 489 |
474 enforce_memory_policy_pending_ = true; | 490 enforce_memory_policy_pending_ = true; |
475 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 491 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
476 FROM_HERE, | 492 FROM_HERE, |
477 base::Bind(&HostDiscardableSharedMemoryManager::EnforceMemoryPolicy, | 493 base::Bind(&HostDiscardableSharedMemoryManager::EnforceMemoryPolicy, |
478 weak_ptr_factory_.GetWeakPtr()), | 494 weak_ptr_factory_.GetWeakPtr()), |
479 base::TimeDelta::FromMilliseconds(kEnforceMemoryPolicyDelayMs)); | 495 base::TimeDelta::FromMilliseconds(kEnforceMemoryPolicyDelayMs)); |
480 } | 496 } |
481 | 497 |
482 } // namespace content | 498 } // namespace content |
OLD | NEW |