| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/memory/discardable_memory_allocator.h" | 5 #include "base/memory/discardable_memory_allocator.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/trace_event/memory_allocator_dump.h" |
| 9 #include "base/trace_event/process_memory_dump.h" |
| 8 | 10 |
| 9 namespace base { | 11 namespace base { |
| 10 namespace { | 12 namespace { |
| 11 | 13 |
| 12 DiscardableMemoryAllocator* g_allocator = nullptr; | 14 DiscardableMemoryAllocator* g_allocator = nullptr; |
| 13 | 15 |
| 14 } // namespace | 16 } // namespace |
| 15 | 17 |
| 16 // static | 18 // static |
| 17 void DiscardableMemoryAllocator::SetInstance( | 19 void DiscardableMemoryAllocator::SetInstance( |
| 18 DiscardableMemoryAllocator* allocator) { | 20 DiscardableMemoryAllocator* allocator) { |
| 19 DCHECK(allocator); | 21 DCHECK(allocator); |
| 20 | 22 |
| 21 // Make sure this function is only called once before the first call | 23 // Make sure this function is only called once before the first call |
| 22 // to GetInstance(). | 24 // to GetInstance(). |
| 23 DCHECK(!g_allocator); | 25 DCHECK(!g_allocator); |
| 24 | 26 |
| 25 g_allocator = allocator; | 27 g_allocator = allocator; |
| 26 } | 28 } |
| 27 | 29 |
| 28 // static | 30 // static |
| 29 DiscardableMemoryAllocator* DiscardableMemoryAllocator::GetInstance() { | 31 DiscardableMemoryAllocator* DiscardableMemoryAllocator::GetInstance() { |
| 30 DCHECK(g_allocator); | 32 DCHECK(g_allocator); |
| 31 return g_allocator; | 33 return g_allocator; |
| 32 } | 34 } |
| 33 | 35 |
| 36 // static |
| 37 const char* DiscardableMemoryAllocator::GetMemoryPoolNameForTracing() { |
| 38 return "discardable/allocated_objects"; |
| 39 } |
| 40 |
| 34 } // namespace base | 41 } // namespace base |
| OLD | NEW |