| 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 namespace base { | 18 namespace base { |
| 19 | 19 |
| 20 // Platform abstraction for discardable shared memory. | 20 // Platform abstraction for discardable shared memory. |
| 21 // | 21 // |
| 22 // This class is not thread-safe. Clients are responsible for synchronizing | 22 // This class is not thread-safe. Clients are responsible for synchronizing |
| 23 // access to an instance of this class. | 23 // access to an instance of this class. |
| 24 class BASE_EXPORT DiscardableSharedMemory { | 24 class BASE_EXPORT DiscardableSharedMemory { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 return shared_memory_.ShareToProcess(process_handle, new_handle); | 112 return shared_memory_.ShareToProcess(process_handle, new_handle); |
| 113 } | 113 } |
| 114 | 114 |
| 115 private: | 115 private: |
| 116 // Virtual for tests. | 116 // Virtual for tests. |
| 117 virtual Time Now() const; | 117 virtual Time Now() const; |
| 118 | 118 |
| 119 SharedMemory shared_memory_; | 119 SharedMemory shared_memory_; |
| 120 size_t mapped_size_; | 120 size_t mapped_size_; |
| 121 size_t locked_page_count_; | 121 size_t locked_page_count_; |
| 122 #if DCHECK_IS_ON | 122 #if DCHECK_IS_ON() |
| 123 std::set<size_t> locked_pages_; | 123 std::set<size_t> locked_pages_; |
| 124 #endif | 124 #endif |
| 125 // Implementation is not thread-safe but still usable if clients are | 125 // Implementation is not thread-safe but still usable if clients are |
| 126 // synchronized somehow. Use a collision warner to detect incorrect usage. | 126 // synchronized somehow. Use a collision warner to detect incorrect usage. |
| 127 DFAKE_MUTEX(thread_collision_warner_); | 127 DFAKE_MUTEX(thread_collision_warner_); |
| 128 Time last_known_usage_; | 128 Time last_known_usage_; |
| 129 | 129 |
| 130 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemory); | 130 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemory); |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 } // namespace base | 133 } // namespace base |
| 134 | 134 |
| 135 #endif // BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_ | 135 #endif // BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_ |
| OLD | NEW |