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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 child_process_id); | 203 child_process_id); |
204 base::trace_event::MemoryAllocatorDumpGuid shared_segment_guid = | 204 base::trace_event::MemoryAllocatorDumpGuid shared_segment_guid = |
205 DiscardableSharedMemoryHeap::GetSegmentGUIDForTracing( | 205 DiscardableSharedMemoryHeap::GetSegmentGUIDForTracing( |
206 child_tracing_process_id, segment_id); | 206 child_tracing_process_id, segment_id); |
207 pmd->CreateSharedGlobalAllocatorDump(shared_segment_guid); | 207 pmd->CreateSharedGlobalAllocatorDump(shared_segment_guid); |
208 pmd->AddOwnershipEdge(dump->guid(), shared_segment_guid); | 208 pmd->AddOwnershipEdge(dump->guid(), shared_segment_guid); |
209 | 209 |
210 #if defined(COUNT_RESIDENT_BYTES_SUPPORTED) | 210 #if defined(COUNT_RESIDENT_BYTES_SUPPORTED) |
211 if (args.level_of_detail == | 211 if (args.level_of_detail == |
212 base::trace_event::MemoryDumpLevelOfDetail::DETAILED) { | 212 base::trace_event::MemoryDumpLevelOfDetail::DETAILED) { |
213 size_t resident_size = | 213 size_t resident_size; |
214 base::trace_event::ProcessMemoryDump::CountResidentBytes( | |
215 segment->memory()->memory(), segment->memory()->mapped_size()); | |
216 | 214 |
217 // This is added to the global dump since it has to be attributed to | 215 // This is added to the global dump since it has to be attributed to |
218 // both the allocator dumps involved. | 216 // both the allocator dumps involved. |
219 pmd->GetSharedGlobalAllocatorDump(shared_segment_guid) | 217 if (base::trace_event::ProcessMemoryDump::CountResidentBytes( |
220 ->AddScalar("resident_size", | 218 segment->memory()->memory(), segment->memory()->mapped_size(), |
221 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 219 &resident_size)) { |
222 static_cast<uint64>(resident_size)); | 220 pmd->GetSharedGlobalAllocatorDump(shared_segment_guid) |
221 ->AddScalar("resident_size", | |
222 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | |
223 static_cast<uint64>(resident_size)); | |
224 } else { | |
225 NOTREACHED(); | |
reveman
2015/10/14 12:31:29
please
bool rv = base::trace_event::ProcessMemory
ssid
2015/10/14 12:44:29
In general it should not fail. What I want is in r
reveman
2015/10/14 13:03:53
ok, sounds good. I don't like when NOTREACHED/DCHE
ssid
2015/10/14 13:35:55
Done.
| |
226 } | |
223 } | 227 } |
224 #endif // defined(COUNT_RESIDENT_BYTES_SUPPORTED) | 228 #endif // defined(COUNT_RESIDENT_BYTES_SUPPORTED) |
225 } | 229 } |
226 } | 230 } |
227 return true; | 231 return true; |
228 } | 232 } |
229 | 233 |
230 void HostDiscardableSharedMemoryManager:: | 234 void HostDiscardableSharedMemoryManager:: |
231 AllocateLockedDiscardableSharedMemoryForChild( | 235 AllocateLockedDiscardableSharedMemoryForChild( |
232 base::ProcessHandle process_handle, | 236 base::ProcessHandle process_handle, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
492 | 496 |
493 enforce_memory_policy_pending_ = true; | 497 enforce_memory_policy_pending_ = true; |
494 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 498 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
495 FROM_HERE, | 499 FROM_HERE, |
496 base::Bind(&HostDiscardableSharedMemoryManager::EnforceMemoryPolicy, | 500 base::Bind(&HostDiscardableSharedMemoryManager::EnforceMemoryPolicy, |
497 weak_ptr_factory_.GetWeakPtr()), | 501 weak_ptr_factory_.GetWeakPtr()), |
498 base::TimeDelta::FromMilliseconds(kEnforceMemoryPolicyDelayMs)); | 502 base::TimeDelta::FromMilliseconds(kEnforceMemoryPolicyDelayMs)); |
499 } | 503 } |
500 | 504 |
501 } // namespace content | 505 } // namespace content |
OLD | NEW |