Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3360)

Unified Diff: base/memory/shared_memory_handle.h

Issue 2654073002: base: Introduce SharedMemoryTracker for POSIX (but not macOS) (Closed)
Patch Set: Add comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/memory/shared_memory_handle.h
diff --git a/base/memory/shared_memory_handle.h b/base/memory/shared_memory_handle.h
index dc33eeafa11faef22f73be0d44dd30447e43118b..f5f1f4d358c1b9c065b046dad43a0e2150aa76e7 100644
--- a/base/memory/shared_memory_handle.h
+++ b/base/memory/shared_memory_handle.h
@@ -186,6 +186,34 @@ class BASE_EXPORT SharedMemoryHandle {
};
#endif
+#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
+
+struct SharedMemoryHandleID {
danakj 2017/01/25 16:58:12 Id instead of ID
hajimehoshi 2017/01/26 10:56:00 Done.
+ dev_t device_id;
+ ino_t file_id;
+};
+
+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
+ SharedMemoryHandleID* id);
+
+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.
+
+struct SharedMemoryHandleIDHash {
+ std::size_t operator()(const SharedMemoryHandleID& id) const {
+ 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.
+ std::hash<int64_t>()(static_cast<int64_t>(id.file_id));
+ }
+};
+
+struct SharedMemoryHandleIDEqual {
danakj 2017/01/25 16:58:13 why not operator==?
hajimehoshi 2017/01/26 10:56:00 Done.
+ bool operator()(const SharedMemoryHandleID& lhs,
+ const SharedMemoryHandleID& rhs) const {
+ return lhs.device_id == rhs.device_id && lhs.file_id == rhs.file_id;
+ }
+};
+
+#endif
+
} // namespace base
#endif // BASE_MEMORY_SHARED_MEMORY_HANDLE_H_

Powered by Google App Engine
This is Rietveld 408576698