Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_HANDLE_H_ | 5 #ifndef BASE_MEMORY_SHARED_MEMORY_HANDLE_H_ |
| 6 #define BASE_MEMORY_SHARED_MEMORY_HANDLE_H_ | 6 #define BASE_MEMORY_SHARED_MEMORY_HANDLE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 // Whether passing this object as a parameter to an IPC message passes | 179 // Whether passing this object as a parameter to an IPC message passes |
| 180 // ownership of |memory_object_| to the IPC stack. This is meant to mimic | 180 // ownership of |memory_object_| to the IPC stack. This is meant to mimic |
| 181 // the behavior of the |auto_close| parameter of FileDescriptor. | 181 // the behavior of the |auto_close| parameter of FileDescriptor. |
| 182 // Defaults to |false|. | 182 // Defaults to |false|. |
| 183 bool ownership_passes_to_ipc_; | 183 bool ownership_passes_to_ipc_; |
| 184 }; | 184 }; |
| 185 }; | 185 }; |
| 186 }; | 186 }; |
| 187 #endif | 187 #endif |
| 188 | 188 |
| 189 #if defined(OS_POSIX) && !(defined(OS_MACOSX) && !defined(OS_IOS)) | |
|
danakj
2017/01/25 16:58:13
can you write this without double negatives? are y
hajimehoshi
2017/01/26 10:56:00
Yeah, as far as I understand correctly, SharedMemo
| |
| 190 | |
| 191 struct SharedMemoryHandleID { | |
|
danakj
2017/01/25 16:58:12
Id instead of ID
hajimehoshi
2017/01/26 10:56:00
Done.
| |
| 192 dev_t device_id; | |
| 193 ino_t file_id; | |
| 194 }; | |
| 195 | |
| 196 bool GetIDFromSharedMemoryHandle(const SharedMemoryHandle& handle, | |
|
danakj
2017/01/25 16:58:13
How about a Populate method on SharedMemoryHandleI
hajimehoshi
2017/01/26 10:56:00
SharedMemoryHandle is FileDescriptor on POSIX. Add
| |
| 197 SharedMemoryHandleID* id); | |
| 198 | |
| 199 std::string GetSharedMemoryHandleIDString(const SharedMemoryHandleID& id); | |
|
danakj
2017/01/25 16:58:13
How about a ToString() method?
hajimehoshi
2017/01/26 10:56:00
Done.
| |
| 200 | |
| 201 struct SharedMemoryHandleIDHash { | |
| 202 std::size_t operator()(const SharedMemoryHandleID& id) const { | |
| 203 return std::hash<int64_t>()(static_cast<int64_t>(id.device_id)) ^ | |
|
danakj
2017/01/25 16:58:13
Use HashInts, not xor. https://cs.chromium.org/chr
hajimehoshi
2017/01/26 10:56:00
Done.
| |
| 204 std::hash<int64_t>()(static_cast<int64_t>(id.file_id)); | |
| 205 } | |
| 206 }; | |
| 207 | |
| 208 struct SharedMemoryHandleIDEqual { | |
|
danakj
2017/01/25 16:58:13
why not operator==?
hajimehoshi
2017/01/26 10:56:00
Done.
| |
| 209 bool operator()(const SharedMemoryHandleID& lhs, | |
| 210 const SharedMemoryHandleID& rhs) const { | |
| 211 return lhs.device_id == rhs.device_id && lhs.file_id == rhs.file_id; | |
| 212 } | |
| 213 }; | |
| 214 | |
| 215 #endif | |
| 216 | |
| 189 } // namespace base | 217 } // namespace base |
| 190 | 218 |
| 191 #endif // BASE_MEMORY_SHARED_MEMORY_HANDLE_H_ | 219 #endif // BASE_MEMORY_SHARED_MEMORY_HANDLE_H_ |
| OLD | NEW |