| 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 "base/base_export.h" | 8 #include "base/base_export.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| 11 #include "base/threading/thread_collision_warner.h" | 11 #include "base/threading/thread_collision_warner.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 | 13 |
| 14 #if DCHECK_IS_ON() | 14 #if DCHECK_IS_ON() |
| 15 #include <set> | 15 #include <set> |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 #if defined(OS_WIN) |
| 19 #include "base/win/windows_version.h" |
| 20 #endif |
| 21 |
| 18 // Linux (including Android) support the MADV_REMOVE argument with madvise() | 22 // Linux (including Android) support the MADV_REMOVE argument with madvise() |
| 19 // which has the behavior of reliably causing zero-fill-on-demand pages to | 23 // which has the behavior of reliably causing zero-fill-on-demand pages to |
| 20 // be returned after a call. Here we define | 24 // be returned after a call. Here we define |
| 21 // DISCARDABLE_SHARED_MEMORY_ZERO_FILL_ON_DEMAND_PAGES_AFTER_PURGE on Linux | 25 // DISCARDABLE_SHARED_MEMORY_ZERO_FILL_ON_DEMAND_PAGES_AFTER_PURGE on Linux |
| 22 // and Android to indicate that this type of behavior can be expected on | 26 // and Android to indicate that this type of behavior can be expected on |
| 23 // those platforms. Note that madvise() will still be used on other POSIX | 27 // those platforms. Note that madvise() will still be used on other POSIX |
| 24 // platforms but doesn't provide the zero-fill-on-demand pages guarantee. | 28 // platforms but doesn't provide the zero-fill-on-demand pages guarantee. |
| 25 #if defined(OS_LINUX) || defined(OS_ANDROID) | 29 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 26 #define DISCARDABLE_SHARED_MEMORY_ZERO_FILL_ON_DEMAND_PAGES_AFTER_PURGE | 30 #define DISCARDABLE_SHARED_MEMORY_ZERO_FILL_ON_DEMAND_PAGES_AFTER_PURGE |
| 27 #endif | 31 #endif |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 size_t mapped_size_; | 141 size_t mapped_size_; |
| 138 size_t locked_page_count_; | 142 size_t locked_page_count_; |
| 139 #if DCHECK_IS_ON() | 143 #if DCHECK_IS_ON() |
| 140 std::set<size_t> locked_pages_; | 144 std::set<size_t> locked_pages_; |
| 141 #endif | 145 #endif |
| 142 // Implementation is not thread-safe but still usable if clients are | 146 // Implementation is not thread-safe but still usable if clients are |
| 143 // synchronized somehow. Use a collision warner to detect incorrect usage. | 147 // synchronized somehow. Use a collision warner to detect incorrect usage. |
| 144 DFAKE_MUTEX(thread_collision_warner_); | 148 DFAKE_MUTEX(thread_collision_warner_); |
| 145 Time last_known_usage_; | 149 Time last_known_usage_; |
| 146 | 150 |
| 151 #if defined(OS_WIN) |
| 152 // Static Windows version. |
| 153 // Not const as we'll first initialize, then lazy init this value. |
| 154 static base::win::Version osVersion; |
| 155 #endif |
| 156 |
| 147 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemory); | 157 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemory); |
| 148 }; | 158 }; |
| 149 | 159 |
| 150 } // namespace base | 160 } // namespace base |
| 151 | 161 |
| 152 #endif // BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_ | 162 #endif // BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_ |
| OLD | NEW |