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" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // purges the object using the updated |last_known_usage_|. | 100 // purges the object using the updated |last_known_usage_|. |
101 // Note: there is no guarantee that multiple calls to this function will | 101 // Note: there is no guarantee that multiple calls to this function will |
102 // successfully purge object. DiscardableSharedMemory object might be locked | 102 // successfully purge object. DiscardableSharedMemory object might be locked |
103 // or another thread/process might be able to lock and unlock it in between | 103 // or another thread/process might be able to lock and unlock it in between |
104 // each call. | 104 // each call. |
105 bool Purge(Time current_time); | 105 bool Purge(Time current_time); |
106 | 106 |
107 // Returns true if memory is still resident. | 107 // Returns true if memory is still resident. |
108 bool IsMemoryResident() const; | 108 bool IsMemoryResident() const; |
109 | 109 |
| 110 // Returns true if memory is locked. |
| 111 bool IsMemoryLocked() const; |
| 112 |
110 // Closes the open discardable memory segment. | 113 // Closes the open discardable memory segment. |
111 // It is safe to call Close repeatedly. | 114 // It is safe to call Close repeatedly. |
112 void Close(); | 115 void Close(); |
113 | 116 |
114 // Shares the discardable memory segment to another process. Attempts to | 117 // Shares the discardable memory segment to another process. Attempts to |
115 // create a platform-specific |new_handle| which can be used in a remote | 118 // create a platform-specific |new_handle| which can be used in a remote |
116 // process to access the discardable memory segment. |new_handle| is an | 119 // process to access the discardable memory segment. |new_handle| is an |
117 // output parameter to receive the handle for use in the remote process. | 120 // output parameter to receive the handle for use in the remote process. |
118 // Returns true on success, false otherwise. | 121 // Returns true on success, false otherwise. |
119 bool ShareToProcess(ProcessHandle process_handle, | 122 bool ShareToProcess(ProcessHandle process_handle, |
(...skipping 21 matching lines...) Expand all Loading... |
141 // synchronized somehow. Use a collision warner to detect incorrect usage. | 144 // synchronized somehow. Use a collision warner to detect incorrect usage. |
142 DFAKE_MUTEX(thread_collision_warner_); | 145 DFAKE_MUTEX(thread_collision_warner_); |
143 Time last_known_usage_; | 146 Time last_known_usage_; |
144 | 147 |
145 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemory); | 148 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemory); |
146 }; | 149 }; |
147 | 150 |
148 } // namespace base | 151 } // namespace base |
149 | 152 |
150 #endif // BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_ | 153 #endif // BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_ |
OLD | NEW |