| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SHARED_MEMORY_H_ | 5 #ifndef BASE_MEMORY_SHARED_MEMORY_H_ |
| 6 #define BASE_MEMORY_SHARED_MEMORY_H_ | 6 #define BASE_MEMORY_SHARED_MEMORY_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 bool Delete(const std::string& name); | 147 bool Delete(const std::string& name); |
| 148 | 148 |
| 149 // Opens a shared memory segment based on a name. | 149 // Opens a shared memory segment based on a name. |
| 150 // If read_only is true, opens for read-only access. | 150 // If read_only is true, opens for read-only access. |
| 151 // Returns true on success, false on failure. | 151 // Returns true on success, false on failure. |
| 152 bool Open(const std::string& name, bool read_only); | 152 bool Open(const std::string& name, bool read_only); |
| 153 | 153 |
| 154 // Maps the shared memory into the caller's address space. | 154 // Maps the shared memory into the caller's address space. |
| 155 // Returns true on success, false otherwise. The memory address | 155 // Returns true on success, false otherwise. The memory address |
| 156 // is accessed via the memory() accessor. The mapped address is guaranteed to | 156 // is accessed via the memory() accessor. The mapped address is guaranteed to |
| 157 // have an alignment of at least MAP_MINIMUM_ALIGNMENT. | 157 // have an alignment of at least MAP_MINIMUM_ALIGNMENT. This method will fail |
| 158 // if this object is currently mapped. |
| 158 bool Map(size_t bytes) { | 159 bool Map(size_t bytes) { |
| 159 return MapAt(0, bytes); | 160 return MapAt(0, bytes); |
| 160 } | 161 } |
| 161 | 162 |
| 162 // Same as above, but with |offset| to specify from begining of the shared | 163 // Same as above, but with |offset| to specify from begining of the shared |
| 163 // memory block to map. | 164 // memory block to map. |
| 164 // |offset| must be alignent to value of |SysInfo::VMAllocationGranularity()|. | 165 // |offset| must be alignent to value of |SysInfo::VMAllocationGranularity()|. |
| 165 bool MapAt(off_t offset, size_t bytes); | 166 bool MapAt(off_t offset, size_t bytes); |
| 166 enum { MAP_MINIMUM_ALIGNMENT = 32 }; | 167 enum { MAP_MINIMUM_ALIGNMENT = 32 }; |
| 167 | 168 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 } | 308 } |
| 308 | 309 |
| 309 private: | 310 private: |
| 310 SharedMemory* shared_memory_; | 311 SharedMemory* shared_memory_; |
| 311 DISALLOW_COPY_AND_ASSIGN(SharedMemoryAutoLockDeprecated); | 312 DISALLOW_COPY_AND_ASSIGN(SharedMemoryAutoLockDeprecated); |
| 312 }; | 313 }; |
| 313 | 314 |
| 314 } // namespace base | 315 } // namespace base |
| 315 | 316 |
| 316 #endif // BASE_MEMORY_SHARED_MEMORY_H_ | 317 #endif // BASE_MEMORY_SHARED_MEMORY_H_ |
| OLD | NEW |