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

Unified Diff: base/memory/shared_memory_posix.cc

Issue 1164473003: Add methods to base::SharedMemory to replace common SharedMemoryHandle operations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add relevant methods to shared_memory_win. Created 5 years, 7 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
« no previous file with comments | « base/memory/shared_memory.h ('k') | base/memory/shared_memory_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/shared_memory_posix.cc
diff --git a/base/memory/shared_memory_posix.cc b/base/memory/shared_memory_posix.cc
index ec4f01f35a3fdfa4132db9577fcc632ab306a406..904c95d6dddb801bf66aa67dc0bf724953e79987 100644
--- a/base/memory/shared_memory_posix.cc
+++ b/base/memory/shared_memory_posix.cc
@@ -176,6 +176,24 @@ size_t SharedMemory::GetHandleLimit() {
return base::GetMaxFds();
}
+// static
+SharedMemoryHandle SharedMemory::ShallowCopyHandle(
+ const SharedMemoryHandle& handle) {
+ SharedMemoryHandle new_handle = handle;
+ new_handle.auto_close = false;
+ return new_handle;
+}
+
+// static
+SharedMemoryHandle SharedMemory::DeepCopyHandle(
+ const SharedMemoryHandle& handle,
+ bool clean_up_resources_on_destruction) {
+ int duped_handle = HANDLE_EINTR(dup(handle.fd));
+ if (duped_handle < 0)
+ return base::SharedMemory::NULLHandle();
+ return base::FileDescriptor(duped_handle, clean_up_resources_on_destruction);
+}
+
bool SharedMemory::CreateAndMapAnonymous(size_t size) {
return CreateAnonymous(size) && Map(size);
}
« no previous file with comments | « base/memory/shared_memory.h ('k') | base/memory/shared_memory_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698