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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « ipc/handle_attachment_win.h ('k') | ipc/handle_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ipc/handle_attachment_win.h" 5 #include "ipc/handle_attachment_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 namespace IPC { 9 namespace IPC {
10 namespace internal { 10 namespace internal {
11 11
12 HandleAttachmentWin::HandleAttachmentWin(const HANDLE& handle, 12 HandleAttachmentWin::HandleAttachmentWin(const HANDLE& handle,
13 HandleWin::Permissions permissions) 13 HandleWin::Permissions permissions)
14 : handle_(handle), permissions_(permissions), owns_handle_(true) {} 14 : handle_(INVALID_HANDLE_VALUE),
15 permissions_(HandleWin::INVALID),
16 owns_handle_(true) {
17 HANDLE duplicated_handle;
18 BOOL result =
19 ::DuplicateHandle(GetCurrentProcess(), handle, GetCurrentProcess(),
20 &duplicated_handle, 0, FALSE, DUPLICATE_SAME_ACCESS);
21 if (result) {
22 handle_ = duplicated_handle;
23 permissions_ = permissions;
24 }
25 }
15 26
16 HandleAttachmentWin::HandleAttachmentWin(const WireFormat& wire_format) 27 HandleAttachmentWin::HandleAttachmentWin(const WireFormat& wire_format)
17 : BrokerableAttachment(wire_format.attachment_id), 28 : BrokerableAttachment(wire_format.attachment_id),
18 handle_(LongToHandle(wire_format.handle)), 29 handle_(LongToHandle(wire_format.handle)),
19 permissions_(wire_format.permissions), owns_handle_(false) {} 30 permissions_(wire_format.permissions),
20 31 owns_handle_(true) {}
21 HandleAttachmentWin::HandleAttachmentWin(
22 const BrokerableAttachment::AttachmentId& id)
23 : BrokerableAttachment(id),
24 handle_(INVALID_HANDLE_VALUE),
25 permissions_(HandleWin::INVALID), owns_handle_(false) {}
26 32
27 HandleAttachmentWin::~HandleAttachmentWin() { 33 HandleAttachmentWin::~HandleAttachmentWin() {
28 if (handle_ != INVALID_HANDLE_VALUE && owns_handle_) 34 if (handle_ != INVALID_HANDLE_VALUE && owns_handle_)
29 ::CloseHandle(handle_); 35 ::CloseHandle(handle_);
30 } 36 }
31 37
32 HandleAttachmentWin::BrokerableType HandleAttachmentWin::GetBrokerableType() 38 HandleAttachmentWin::BrokerableType HandleAttachmentWin::GetBrokerableType()
33 const { 39 const {
34 return WIN_HANDLE; 40 return WIN_HANDLE;
35 } 41 }
36 42
37 HandleAttachmentWin::WireFormat HandleAttachmentWin::GetWireFormat( 43 HandleAttachmentWin::WireFormat HandleAttachmentWin::GetWireFormat(
38 const base::ProcessId& destination) const { 44 const base::ProcessId& destination) const {
39 return WireFormat(HandleToLong(handle_), destination, permissions_, 45 return WireFormat(HandleToLong(handle_), destination, permissions_,
40 GetIdentifier()); 46 GetIdentifier());
41 } 47 }
42 48
43 } // namespace internal 49 } // namespace internal
44 } // namespace IPC 50 } // namespace IPC
OLDNEW
« 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