| 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 #ifndef COMPONENTS_DISCARDABLE_MEMORY_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H_ | 5 #ifndef COMPONENTS_DISCARDABLE_MEMORY_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H_ |
| 6 #define COMPONENTS_DISCARDABLE_MEMORY_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H_ | 6 #define COMPONENTS_DISCARDABLE_MEMORY_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <vector> | |
| 13 | 12 |
| 14 #include "base/callback.h" | 13 #include "base/callback.h" |
| 15 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 16 #include "base/containers/linked_list.h" | 15 #include "base/containers/linked_list.h" |
| 17 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/scoped_vector.h" |
| 18 #include "base/trace_event/process_memory_dump.h" | 18 #include "base/trace_event/process_memory_dump.h" |
| 19 #include "components/discardable_memory/common/discardable_memory_export.h" | 19 #include "components/discardable_memory/common/discardable_memory_export.h" |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 class DiscardableSharedMemory; | 22 class DiscardableSharedMemory; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace discardable_memory { | 25 namespace discardable_memory { |
| 26 | 26 |
| 27 // Implements a heap of discardable shared memory. An array of free lists | 27 // Implements a heap of discardable shared memory. An array of free lists |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 void OnMemoryDump(const base::DiscardableSharedMemory* shared_memory, | 159 void OnMemoryDump(const base::DiscardableSharedMemory* shared_memory, |
| 160 size_t size, | 160 size_t size, |
| 161 int32_t segment_id, | 161 int32_t segment_id, |
| 162 base::trace_event::ProcessMemoryDump* pmd); | 162 base::trace_event::ProcessMemoryDump* pmd); |
| 163 | 163 |
| 164 size_t block_size_; | 164 size_t block_size_; |
| 165 size_t num_blocks_; | 165 size_t num_blocks_; |
| 166 size_t num_free_blocks_; | 166 size_t num_free_blocks_; |
| 167 | 167 |
| 168 // Vector of memory segments. | 168 // Vector of memory segments. |
| 169 std::vector<std::unique_ptr<ScopedMemorySegment>> memory_segments_; | 169 ScopedVector<ScopedMemorySegment> memory_segments_; |
| 170 | 170 |
| 171 // Mapping from first/last block of span to Span instance. | 171 // Mapping from first/last block of span to Span instance. |
| 172 typedef base::hash_map<size_t, Span*> SpanMap; | 172 typedef base::hash_map<size_t, Span*> SpanMap; |
| 173 SpanMap spans_; | 173 SpanMap spans_; |
| 174 | 174 |
| 175 // Array of linked-lists with free discardable memory regions. For i < 256, | 175 // Array of linked-lists with free discardable memory regions. For i < 256, |
| 176 // where the 1st entry is located at index 0 of the array, the kth entry | 176 // where the 1st entry is located at index 0 of the array, the kth entry |
| 177 // is a free list of runs that consist of k blocks. The 256th entry is a | 177 // is a free list of runs that consist of k blocks. The 256th entry is a |
| 178 // free list of runs that have length >= 256 blocks. | 178 // free list of runs that have length >= 256 blocks. |
| 179 base::LinkedList<Span> free_spans_[256]; | 179 base::LinkedList<Span> free_spans_[256]; |
| 180 | 180 |
| 181 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemoryHeap); | 181 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemoryHeap); |
| 182 }; | 182 }; |
| 183 | 183 |
| 184 } // namespace discardable_memory | 184 } // namespace discardable_memory |
| 185 | 185 |
| 186 #endif // COMPONENTS_DISCARDABLE_MEMORY_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H
_ | 186 #endif // COMPONENTS_DISCARDABLE_MEMORY_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H
_ |
| OLD | NEW |