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

Unified Diff: base/memory/shared_memory_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_posix.cc ('k') | content/browser/renderer_host/render_message_filter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/shared_memory_win.cc
diff --git a/base/memory/shared_memory_win.cc b/base/memory/shared_memory_win.cc
index 881e0609378565e4386234ff2a60347a68296d63..ffa7bd72bd1530d3f3180de8c73f328fc1663d24 100644
--- a/base/memory/shared_memory_win.cc
+++ b/base/memory/shared_memory_win.cc
@@ -185,18 +185,7 @@ size_t SharedMemory::GetHandleLimit() {
// static
SharedMemoryHandle SharedMemory::DuplicateHandle(
const SharedMemoryHandle& handle) {
- DCHECK(handle.BelongsToCurrentProcess());
- HANDLE duped_handle;
- ProcessHandle process = GetCurrentProcess();
- BOOL success =
- ::DuplicateHandle(process, handle.GetHandle(), process, &duped_handle, 0,
- FALSE, DUPLICATE_SAME_ACCESS);
- if (success) {
- base::SharedMemoryHandle handle(duped_handle, GetCurrentProcId());
- handle.SetOwnershipPassesToIPC(true);
- return handle;
- }
- return SharedMemoryHandle();
+ return handle.Duplicate();
}
bool SharedMemory::CreateAndMapAnonymous(size_t size) {
@@ -352,8 +341,7 @@ SharedMemoryHandle SharedMemory::GetReadOnlyHandle() {
}
bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
- SharedMemoryHandle* new_handle,
- bool close_self) {
+ SharedMemoryHandle* new_handle) {
*new_handle = SharedMemoryHandle();
DWORD access = FILE_MAP_READ | SECTION_QUERY;
DWORD options = 0;
@@ -361,18 +349,6 @@ bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
HANDLE result;
if (!read_only_)
access |= FILE_MAP_WRITE;
- if (close_self) {
- // DUPLICATE_CLOSE_SOURCE causes DuplicateHandle to close mapped_file.
- options = DUPLICATE_CLOSE_SOURCE;
- HANDLE detached_handle = mapped_file_.Take();
- DCHECK_EQ(detached_handle, mapped_file);
- Unmap();
- }
-
- if (process == GetCurrentProcess() && close_self) {
- *new_handle = SharedMemoryHandle(mapped_file, base::GetCurrentProcId());
- return true;
- }
if (!::DuplicateHandle(GetCurrentProcess(), mapped_file, process, &result,
access, FALSE, options)) {
« no previous file with comments | « base/memory/shared_memory_posix.cc ('k') | content/browser/renderer_host/render_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698