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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 memory->Close(); | 148 memory->Close(); |
149 return make_scoped_ptr(new DiscardableMemoryImpl( | 149 return make_scoped_ptr(new DiscardableMemoryImpl( |
150 memory.Pass(), | 150 memory.Pass(), |
151 base::Bind( | 151 base::Bind( |
152 &HostDiscardableSharedMemoryManager::DeletedDiscardableSharedMemory, | 152 &HostDiscardableSharedMemoryManager::DeletedDiscardableSharedMemory, |
153 base::Unretained(this), new_id, ChildProcessHost::kInvalidUniqueID))); | 153 base::Unretained(this), new_id, ChildProcessHost::kInvalidUniqueID))); |
154 } | 154 } |
155 | 155 |
156 bool HostDiscardableSharedMemoryManager::OnMemoryDump( | 156 bool HostDiscardableSharedMemoryManager::OnMemoryDump( |
157 base::trace_event::ProcessMemoryDump* pmd) { | 157 base::trace_event::ProcessMemoryDump* pmd) { |
| 158 DiscardableMemoryAllocator::CreateMemoryPoolDumpForTracing(pmd); |
| 159 |
158 base::AutoLock lock(lock_); | 160 base::AutoLock lock(lock_); |
159 for (const auto& process_entry : processes_) { | 161 for (const auto& process_entry : processes_) { |
160 const int child_process_id = process_entry.first; | 162 const int child_process_id = process_entry.first; |
161 const MemorySegmentMap& process_segments = process_entry.second; | 163 const MemorySegmentMap& process_segments = process_entry.second; |
162 for (const auto& segment_entry : process_segments) { | 164 for (const auto& segment_entry : process_segments) { |
163 const int segment_id = segment_entry.first; | 165 const int segment_id = segment_entry.first; |
164 const MemorySegment* segment = segment_entry.second.get(); | 166 const MemorySegment* segment = segment_entry.second.get(); |
165 std::string dump_name = base::StringPrintf( | 167 std::string dump_name = |
166 "discardable/process_%x/segment_%d", child_process_id, segment_id); | 168 base::StringPrintf("discardable/segments/process_%x/segment_%d", |
| 169 child_process_id, segment_id); |
167 base::trace_event::MemoryAllocatorDump* dump = | 170 base::trace_event::MemoryAllocatorDump* dump = |
168 pmd->CreateAllocatorDump(dump_name); | 171 pmd->CreateAllocatorDump(dump_name); |
169 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 172 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
170 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 173 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
171 segment->memory()->mapped_size()); | 174 segment->memory()->mapped_size()); |
172 | 175 |
173 // Create the cross-process ownership edge. If the child creates a | 176 // Create the cross-process ownership edge. If the child creates a |
174 // corresponding dump for the same segment, this will avoid to | 177 // corresponding dump for the same segment, this will avoid to |
175 // double-count them in tracing. If, instead, no other process will emit a | 178 // double-count them in tracing. If, instead, no other process will emit a |
176 // dump with the same guid, the segment will be accounted to the browser. | 179 // dump with the same guid, the segment will be accounted to the browser. |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 | 458 |
456 enforce_memory_policy_pending_ = true; | 459 enforce_memory_policy_pending_ = true; |
457 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 460 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
458 FROM_HERE, | 461 FROM_HERE, |
459 base::Bind(&HostDiscardableSharedMemoryManager::EnforceMemoryPolicy, | 462 base::Bind(&HostDiscardableSharedMemoryManager::EnforceMemoryPolicy, |
460 weak_ptr_factory_.GetWeakPtr()), | 463 weak_ptr_factory_.GetWeakPtr()), |
461 base::TimeDelta::FromMilliseconds(kEnforceMemoryPolicyDelayMs)); | 464 base::TimeDelta::FromMilliseconds(kEnforceMemoryPolicyDelayMs)); |
462 } | 465 } |
463 | 466 |
464 } // namespace content | 467 } // namespace content |
OLD | NEW |