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

Unified Diff: base/memory/shared_memory_handle_win.cc

Issue 2847033003: Get rid of SharedMemory::GiveToProcess. (Closed)
Patch Set: Comments from avi. Created 3 years, 8 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_handle.h ('k') | base/memory/shared_memory_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/shared_memory_handle_win.cc
diff --git a/base/memory/shared_memory_handle_win.cc b/base/memory/shared_memory_handle_win.cc
index 277a954daa1cd216c55c3b01333cc0fa4838d58a..82ded3453dd27af6afa76252dbb7f7bc1069a57d 100644
--- a/base/memory/shared_memory_handle_win.cc
+++ b/base/memory/shared_memory_handle_win.cc
@@ -40,6 +40,20 @@ bool SharedMemoryHandle::IsValid() const {
return handle_ != nullptr;
}
+SharedMemoryHandle SharedMemoryHandle::Duplicate() const {
+ DCHECK(BelongsToCurrentProcess());
+ HANDLE duped_handle;
+ ProcessHandle process = GetCurrentProcess();
+ BOOL success = ::DuplicateHandle(process, handle_, process, &duped_handle, 0,
+ FALSE, DUPLICATE_SAME_ACCESS);
+ if (!success)
+ return SharedMemoryHandle();
+
+ base::SharedMemoryHandle handle(duped_handle, GetCurrentProcId());
+ handle.SetOwnershipPassesToIPC(true);
+ return handle;
+}
+
bool SharedMemoryHandle::BelongsToCurrentProcess() const {
return pid_ == base::GetCurrentProcId();
}
« no previous file with comments | « base/memory/shared_memory_handle.h ('k') | base/memory/shared_memory_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698