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 CONTENT_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H_ | 5 #ifndef COMPONENTS_DISCARDABLE_MEMORY_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H_ |
6 #define CONTENT_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 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
15 #include "base/containers/linked_list.h" | 15 #include "base/containers/linked_list.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/scoped_vector.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 "content/common/content_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 content { | 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 |
28 // is used to keep track of free blocks. | 28 // is used to keep track of free blocks. |
29 class CONTENT_EXPORT DiscardableSharedMemoryHeap { | 29 class DISCARDABLE_MEMORY_EXPORT DiscardableSharedMemoryHeap { |
30 public: | 30 public: |
31 class CONTENT_EXPORT Span : public base::LinkNode<Span> { | 31 class DISCARDABLE_MEMORY_EXPORT Span : public base::LinkNode<Span> { |
32 public: | 32 public: |
33 ~Span(); | 33 ~Span(); |
34 | 34 |
35 base::DiscardableSharedMemory* shared_memory() { return shared_memory_; } | 35 base::DiscardableSharedMemory* shared_memory() { return shared_memory_; } |
36 size_t start() const { return start_; } | 36 size_t start() const { return start_; } |
37 size_t length() const { return length_; } | 37 size_t length() const { return length_; } |
38 void set_is_locked(bool is_locked) { is_locked_ = is_locked; } | 38 void set_is_locked(bool is_locked) { is_locked_ = is_locked; } |
39 | 39 |
40 private: | 40 private: |
41 friend class DiscardableSharedMemoryHeap; | 41 friend class DiscardableSharedMemoryHeap; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 content | 184 } // namespace discardable_memory |
185 | 185 |
186 #endif // CONTENT_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H_ | 186 #endif // COMPONENTS_DISCARDABLE_MEMORY_COMMON_DISCARDABLE_SHARED_MEMORY_HEAP_H
_ |
OLD | NEW |