| 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 | |
| 113 // Closes the open discardable memory segment. | 110 // Closes the open discardable memory segment. |
| 114 // It is safe to call Close repeatedly. | 111 // It is safe to call Close repeatedly. |
| 115 void Close(); | 112 void Close(); |
| 116 | 113 |
| 117 // Shares the discardable memory segment to another process. Attempts to | 114 // Shares the discardable memory segment to another process. Attempts to |
| 118 // create a platform-specific |new_handle| which can be used in a remote | 115 // create a platform-specific |new_handle| which can be used in a remote |
| 119 // process to access the discardable memory segment. |new_handle| is an | 116 // process to access the discardable memory segment. |new_handle| is an |
| 120 // output parameter to receive the handle for use in the remote process. | 117 // output parameter to receive the handle for use in the remote process. |
| 121 // Returns true on success, false otherwise. | 118 // Returns true on success, false otherwise. |
| 122 bool ShareToProcess(ProcessHandle process_handle, | 119 bool ShareToProcess(ProcessHandle process_handle, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 144 // synchronized somehow. Use a collision warner to detect incorrect usage. | 141 // synchronized somehow. Use a collision warner to detect incorrect usage. |
| 145 DFAKE_MUTEX(thread_collision_warner_); | 142 DFAKE_MUTEX(thread_collision_warner_); |
| 146 Time last_known_usage_; | 143 Time last_known_usage_; |
| 147 | 144 |
| 148 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemory); | 145 DISALLOW_COPY_AND_ASSIGN(DiscardableSharedMemory); |
| 149 }; | 146 }; |
| 150 | 147 |
| 151 } // namespace base | 148 } // namespace base |
| 152 | 149 |
| 153 #endif // BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_ | 150 #endif // BASE_MEMORY_DISCARDABLE_SHARED_MEMORY_H_ |
| OLD | NEW |