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

Unified Diff: ipc/handle_attachment_win.cc

Issue 1493413004: ipc: Allow attachment brokering for shared memory handles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp1
Patch Set: Fix more tests. Created 4 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
« no previous file with comments | « ipc/handle_attachment_win.h ('k') | ipc/handle_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/handle_attachment_win.cc
diff --git a/ipc/handle_attachment_win.cc b/ipc/handle_attachment_win.cc
index 5afd7fa593cc51ea1b378c2f1bcebab26c30d002..39c4ef78c7fa2e62315b1252de7b8b35c44e80ce 100644
--- a/ipc/handle_attachment_win.cc
+++ b/ipc/handle_attachment_win.cc
@@ -11,18 +11,24 @@ namespace internal {
HandleAttachmentWin::HandleAttachmentWin(const HANDLE& handle,
HandleWin::Permissions permissions)
- : handle_(handle), permissions_(permissions), owns_handle_(true) {}
+ : handle_(INVALID_HANDLE_VALUE),
+ permissions_(HandleWin::INVALID),
+ owns_handle_(true) {
+ HANDLE duplicated_handle;
+ BOOL result =
+ ::DuplicateHandle(GetCurrentProcess(), handle, GetCurrentProcess(),
+ &duplicated_handle, 0, FALSE, DUPLICATE_SAME_ACCESS);
+ if (result) {
+ handle_ = duplicated_handle;
+ permissions_ = permissions;
+ }
+}
HandleAttachmentWin::HandleAttachmentWin(const WireFormat& wire_format)
: BrokerableAttachment(wire_format.attachment_id),
handle_(LongToHandle(wire_format.handle)),
- permissions_(wire_format.permissions), owns_handle_(false) {}
-
-HandleAttachmentWin::HandleAttachmentWin(
- const BrokerableAttachment::AttachmentId& id)
- : BrokerableAttachment(id),
- handle_(INVALID_HANDLE_VALUE),
- permissions_(HandleWin::INVALID), owns_handle_(false) {}
+ permissions_(wire_format.permissions),
+ owns_handle_(true) {}
HandleAttachmentWin::~HandleAttachmentWin() {
if (handle_ != INVALID_HANDLE_VALUE && owns_handle_)
« no previous file with comments | « ipc/handle_attachment_win.h ('k') | ipc/handle_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698