Chromium Code Reviews| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 return base::WrapUnique(new DiscardableMemoryImpl( | 215 return base::WrapUnique(new DiscardableMemoryImpl( |
| 216 std::move(memory), | 216 std::move(memory), |
| 217 base::Bind( | 217 base::Bind( |
| 218 &HostDiscardableSharedMemoryManager::DeletedDiscardableSharedMemory, | 218 &HostDiscardableSharedMemoryManager::DeletedDiscardableSharedMemory, |
| 219 base::Unretained(this), new_id, ChildProcessHost::kInvalidUniqueID))); | 219 base::Unretained(this), new_id, ChildProcessHost::kInvalidUniqueID))); |
| 220 } | 220 } |
| 221 | 221 |
| 222 bool HostDiscardableSharedMemoryManager::OnMemoryDump( | 222 bool HostDiscardableSharedMemoryManager::OnMemoryDump( |
| 223 const base::trace_event::MemoryDumpArgs& args, | 223 const base::trace_event::MemoryDumpArgs& args, |
| 224 base::trace_event::ProcessMemoryDump* pmd) { | 224 base::trace_event::ProcessMemoryDump* pmd) { |
| 225 if (args.level_of_detail == | |
| 226 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND) { | |
| 227 base::trace_event::MemoryAllocatorDump* total_dump = | |
| 228 pmd->CreateAllocatorDump("discardable"); | |
| 229 total_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | |
| 230 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | |
| 231 GetBytesAllocated()); | |
|
Primiano Tucci (use gerrit)
2016/06/02 19:31:41
can you call this without the lock?
ssid
2016/06/03 00:27:47
Hmm, we can only be stalling the memory-infra thre
| |
| 232 return true; | |
| 233 } | |
| 234 | |
| 225 base::AutoLock lock(lock_); | 235 base::AutoLock lock(lock_); |
| 226 for (const auto& process_entry : processes_) { | 236 for (const auto& process_entry : processes_) { |
| 227 const int child_process_id = process_entry.first; | 237 const int child_process_id = process_entry.first; |
| 228 const MemorySegmentMap& process_segments = process_entry.second; | 238 const MemorySegmentMap& process_segments = process_entry.second; |
| 229 for (const auto& segment_entry : process_segments) { | 239 for (const auto& segment_entry : process_segments) { |
| 230 const int segment_id = segment_entry.first; | 240 const int segment_id = segment_entry.first; |
| 231 const MemorySegment* segment = segment_entry.second.get(); | 241 const MemorySegment* segment = segment_entry.second.get(); |
| 232 if (!segment->memory()->mapped_size()) | 242 if (!segment->memory()->mapped_size()) |
| 233 continue; | 243 continue; |
| 234 | 244 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 return; | 550 return; |
| 541 | 551 |
| 542 enforce_memory_policy_pending_ = true; | 552 enforce_memory_policy_pending_ = true; |
| 543 DCHECK(enforce_memory_policy_task_runner_); | 553 DCHECK(enforce_memory_policy_task_runner_); |
| 544 enforce_memory_policy_task_runner_->PostDelayedTask( | 554 enforce_memory_policy_task_runner_->PostDelayedTask( |
| 545 FROM_HERE, enforce_memory_policy_callback_, | 555 FROM_HERE, enforce_memory_policy_callback_, |
| 546 base::TimeDelta::FromMilliseconds(kEnforceMemoryPolicyDelayMs)); | 556 base::TimeDelta::FromMilliseconds(kEnforceMemoryPolicyDelayMs)); |
| 547 } | 557 } |
| 548 | 558 |
| 549 } // namespace content | 559 } // namespace content |
| OLD | NEW |