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 BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_ | 5 #ifndef BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_ |
6 #define BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_ | 6 #define BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // Returns true if memory is still resident. | 116 // Returns true if memory is still resident. |
117 bool IsMemoryResident() const; | 117 bool IsMemoryResident() const; |
118 | 118 |
119 // Returns true if memory is locked. | 119 // Returns true if memory is locked. |
120 bool IsMemoryLocked() const; | 120 bool IsMemoryLocked() const; |
121 | 121 |
122 // Closes the open discardable memory segment. | 122 // Closes the open discardable memory segment. |
123 // It is safe to call Close repeatedly. | 123 // It is safe to call Close repeatedly. |
124 void Close(); | 124 void Close(); |
125 | 125 |
| 126 const SharedMemory& shared_memory() const { return shared_memory_; } |
| 127 |
126 private: | 128 private: |
127 // Virtual for tests. | 129 // Virtual for tests. |
128 virtual Time Now() const; | 130 virtual Time Now() const; |
129 | 131 |
130 SharedMemory shared_memory_; | 132 SharedMemory shared_memory_; |
131 size_t mapped_size_; | 133 size_t mapped_size_; |
132 size_t locked_page_count_; | 134 size_t locked_page_count_; |
133 #if DCHECK_IS_ON() | 135 #if DCHECK_IS_ON() |
134 std::set<size_t> locked_pages_; | 136 std::set<size_t> locked_pages_; |
135 #endif | 137 #endif |
136 // Implementation is not thread-safe but still usable if clients are | 138 // Implementation is not thread-safe but still usable if clients are |
137 // synchronized somehow. Use a collision warner to detect incorrect usage. | 139 // synchronized somehow. Use a collision warner to detect incorrect usage. |
138 DFAKE_MUTEX(thread_collision_warner_); | 140 DFAKE_MUTEX(thread_collision_warner_); |
139 Time last_known_usage_; | 141 Time last_known_usage_; |
140 | 142 |
141 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemory); | 143 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemory); |
142 }; | 144 }; |
143 | 145 |
144 } // namespace base | 146 } // namespace base |
145 | 147 |
146 #endif // BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_ | 148 #endif // BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_ |
OLD | NEW |