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 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_ | 5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_ |
6 #define BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_ | 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_ |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 | 10 |
11 namespace base { | 11 namespace base { |
12 namespace trace_event { | |
13 class ProcessMemoryDump; | |
14 } | |
15 | |
12 class DiscardableMemory; | 16 class DiscardableMemory; |
13 | 17 |
14 class BASE_EXPORT DiscardableMemoryAllocator { | 18 class BASE_EXPORT DiscardableMemoryAllocator { |
15 public: | 19 public: |
16 // Returns the allocator instance. | 20 // Returns the allocator instance. |
17 static DiscardableMemoryAllocator* GetInstance(); | 21 static DiscardableMemoryAllocator* GetInstance(); |
18 | 22 |
19 // Sets the allocator instance. Can only be called once, e.g. on startup. | 23 // Sets the allocator instance. Can only be called once, e.g. on startup. |
20 // Ownership of |instance| remains with the caller. | 24 // Ownership of |instance| remains with the caller. |
21 static void SetInstance(DiscardableMemoryAllocator* allocator); | 25 static void SetInstance(DiscardableMemoryAllocator* allocator); |
22 | 26 |
23 virtual scoped_ptr<DiscardableMemory> AllocateLockedDiscardableMemory( | 27 virtual scoped_ptr<DiscardableMemory> AllocateLockedDiscardableMemory( |
24 size_t size) = 0; | 28 size_t size) = 0; |
25 | 29 |
30 // Used by other allocators to expess sub-allocation from discardable memory | |
reveman
2015/07/30 21:27:56
express
ssid
2015/07/31 12:59:40
Done.
| |
31 // heap for tracing. To expess any suballocation, the dump providers need to | |
32 // create a sub-allocation edge from this node. | |
33 // E.g.: ProcessMemoryDump::AddSuballocation(skia_dump_guid, | |
34 // GetMemoryPoolNameForTracing()); | |
reveman
2015/07/30 21:27:56
Not sure we need this much detail in this comment.
ssid
2015/07/31 12:59:40
Done.
| |
35 static const char* GetMemoryPoolNameForTracing(); | |
36 | |
26 protected: | 37 protected: |
27 virtual ~DiscardableMemoryAllocator() {} | 38 virtual ~DiscardableMemoryAllocator() {} |
39 | |
40 // Used by the discqardable allocator implementation to create the memory dump | |
41 // of the memory pool, for tracing. | |
42 static void CreateMemoryPoolDumpForTracing( | |
43 trace_event::ProcessMemoryDump* pmd); | |
reveman
2015/07/30 21:27:56
Not sure it's worth having this here just for code
ssid
2015/07/31 12:59:40
Moved it to the impl. Thanks
| |
28 }; | 44 }; |
29 | 45 |
30 } // namespace base | 46 } // namespace base |
31 | 47 |
32 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_ | 48 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_ALLOCATOR_H_ |
OLD | NEW |