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 | 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 const MemorySegment* segment = segment_entry.second.get(); | 178 const MemorySegment* segment = segment_entry.second.get(); |
| 179 std::string dump_name = base::StringPrintf( | 179 std::string dump_name = base::StringPrintf( |
| 180 "discardable/process_%x/segment_%d", child_process_id, segment_id); | 180 "discardable/process_%x/segment_%d", child_process_id, segment_id); |
| 181 base::trace_event::MemoryAllocatorDump* dump = | 181 base::trace_event::MemoryAllocatorDump* dump = |
| 182 pmd->CreateAllocatorDump(dump_name); | 182 pmd->CreateAllocatorDump(dump_name); |
| 183 | 183 |
| 184 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 184 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 185 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 185 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 186 segment->memory()->mapped_size()); | 186 segment->memory()->mapped_size()); |
| 187 | 187 |
| 188 #if defined(COUNT_RESIDENT_BYTES_SUPPORTED) | |
| 189 if (args.level_of_detail == | |
| 190 base::trace_event::MemoryDumpLevelOfDetail::DETAILED) { | |
| 191 int64 resident_size = | |
|
reveman
2015/10/07 13:41:44
nit: size_t as that's now the return type for Coun
ssid
2015/10/07 14:46:45
Done.
| |
| 192 base::trace_event::ProcessMemoryDump::CountResidentBytes( | |
| 193 segment->memory()->memory(), segment->memory()->mapped_size()); | |
| 194 if (resident_size >= 0) { | |
|
reveman
2015/10/07 13:41:44
nit: s/resident_size >= 0/resident_size/ after swi
ssid
2015/10/07 14:46:45
0 is still reported. removing if.
| |
| 195 dump->AddScalar("resident_size", | |
| 196 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | |
| 197 static_cast<uint64>(resident_size)); | |
| 198 } | |
| 199 } | |
| 200 #endif // defined(COUNT_RESIDENT_BYTES_SUPPORTED) | |
| 201 | |
| 188 // Host can only tell if whole segment is locked or not. | 202 // Host can only tell if whole segment is locked or not. |
| 189 dump->AddScalar( | 203 dump->AddScalar( |
| 190 "locked_size", base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 204 "locked_size", base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 191 segment->memory()->IsMemoryLocked() ? segment->memory()->mapped_size() | 205 segment->memory()->IsMemoryLocked() ? segment->memory()->mapped_size() |
| 192 : 0u); | 206 : 0u); |
| 193 | 207 |
| 194 // Create the cross-process ownership edge. If the child creates a | 208 // Create the cross-process ownership edge. If the child creates a |
| 195 // corresponding dump for the same segment, this will avoid to | 209 // corresponding dump for the same segment, this will avoid to |
| 196 // double-count them in tracing. If, instead, no other process will emit a | 210 // 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. | 211 // dump with the same guid, the segment will be accounted to the browser. |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 | 487 |
| 474 enforce_memory_policy_pending_ = true; | 488 enforce_memory_policy_pending_ = true; |
| 475 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 489 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 476 FROM_HERE, | 490 FROM_HERE, |
| 477 base::Bind(&HostDiscardableSharedMemoryManager::EnforceMemoryPolicy, | 491 base::Bind(&HostDiscardableSharedMemoryManager::EnforceMemoryPolicy, |
| 478 weak_ptr_factory_.GetWeakPtr()), | 492 weak_ptr_factory_.GetWeakPtr()), |
| 479 base::TimeDelta::FromMilliseconds(kEnforceMemoryPolicyDelayMs)); | 493 base::TimeDelta::FromMilliseconds(kEnforceMemoryPolicyDelayMs)); |
| 480 } | 494 } |
| 481 | 495 |
| 482 } // namespace content | 496 } // namespace content |
| OLD | NEW |