| 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/child/child_discardable_shared_memory_manager.h" | 5 #include "content/child/child_discardable_shared_memory_manager.h" |
| 6 | 6 |
| 7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
| 10 #include "base/memory/discardable_memory.h" | 10 #include "base/memory/discardable_memory.h" |
| 11 #include "base/memory/discardable_shared_memory.h" | 11 #include "base/memory/discardable_shared_memory.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/process/memory.h" | 13 #include "base/process/memory.h" |
| 14 #include "base/process/process_metrics.h" | 14 #include "base/process/process_metrics.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
| 17 #include "base/trace_event/memory_dump_manager.h" | 17 #include "base/trace_event/memory_dump_manager.h" |
| 18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
| 19 #include "content/common/child_process_messages.h" | 19 #include "content/common/child_process_messages.h" |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // Default allocation size. | 24 // Default allocation size. |
| 25 #if defined(OS_ANDROID) | |
| 26 // Larger allocation size on Android to avoid reaching the FD-limit. | |
| 27 const size_t kAllocationSize = 32 * 1024 * 1024; | |
| 28 #else | |
| 29 const size_t kAllocationSize = 4 * 1024 * 1024; | 25 const size_t kAllocationSize = 4 * 1024 * 1024; |
| 30 #endif | |
| 31 | 26 |
| 32 // Global atomic to generate unique discardable shared memory IDs. | 27 // Global atomic to generate unique discardable shared memory IDs. |
| 33 base::StaticAtomicSequenceNumber g_next_discardable_shared_memory_id; | 28 base::StaticAtomicSequenceNumber g_next_discardable_shared_memory_id; |
| 34 | 29 |
| 35 class DiscardableMemoryImpl : public base::DiscardableMemory { | 30 class DiscardableMemoryImpl : public base::DiscardableMemory { |
| 36 public: | 31 public: |
| 37 DiscardableMemoryImpl(ChildDiscardableSharedMemoryManager* manager, | 32 DiscardableMemoryImpl(ChildDiscardableSharedMemoryManager* manager, |
| 38 scoped_ptr<DiscardableSharedMemoryHeap::Span> span) | 33 scoped_ptr<DiscardableSharedMemoryHeap::Span> span) |
| 39 : manager_(manager), span_(span.Pass()), is_locked_(true) {} | 34 : manager_(manager), span_(span.Pass()), is_locked_(true) {} |
| 40 | 35 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 "discardable-memory-allocated"; | 289 "discardable-memory-allocated"; |
| 295 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey, | 290 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey, |
| 296 base::Uint64ToString(new_bytes_total)); | 291 base::Uint64ToString(new_bytes_total)); |
| 297 | 292 |
| 298 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free"; | 293 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free"; |
| 299 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey, | 294 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey, |
| 300 base::Uint64ToString(new_bytes_free)); | 295 base::Uint64ToString(new_bytes_free)); |
| 301 } | 296 } |
| 302 | 297 |
| 303 } // namespace content | 298 } // namespace content |
| OLD | NEW |