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

Side by Side Diff: ipc/attachment_broker_unprivileged_mac.cc

Issue 1385143002: ipc: Update MachPortMac ownership semantics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase errors. Created 5 years, 2 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/attachment_broker_unprivileged_mac.h ('k') | ipc/attachment_broker_unprivileged_win.h » ('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/attachment_broker_unprivileged_mac.h" 5 #include "ipc/attachment_broker_unprivileged_mac.h"
6 6
7 #include <mach/mach.h> 7 #include <mach/mach.h>
8 8
9 #include "base/mac/scoped_mach_port.h" 9 #include "base/mac/scoped_mach_port.h"
10 #include "base/process/process.h" 10 #include "base/process/process.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 } // namespace 44 } // namespace
45 45
46 namespace IPC { 46 namespace IPC {
47 47
48 AttachmentBrokerUnprivilegedMac::AttachmentBrokerUnprivilegedMac() {} 48 AttachmentBrokerUnprivilegedMac::AttachmentBrokerUnprivilegedMac() {}
49 49
50 AttachmentBrokerUnprivilegedMac::~AttachmentBrokerUnprivilegedMac() {} 50 AttachmentBrokerUnprivilegedMac::~AttachmentBrokerUnprivilegedMac() {}
51 51
52 bool AttachmentBrokerUnprivilegedMac::SendAttachmentToProcess( 52 bool AttachmentBrokerUnprivilegedMac::SendAttachmentToProcess(
53 const BrokerableAttachment* attachment, 53 BrokerableAttachment* attachment,
54 base::ProcessId destination_process) { 54 base::ProcessId destination_process) {
55 switch (attachment->GetBrokerableType()) { 55 switch (attachment->GetBrokerableType()) {
56 case BrokerableAttachment::MACH_PORT: { 56 case BrokerableAttachment::MACH_PORT: {
57 const internal::MachPortAttachmentMac* mach_port_attachment = 57 internal::MachPortAttachmentMac* mach_port_attachment =
58 static_cast<const internal::MachPortAttachmentMac*>(attachment); 58 static_cast<internal::MachPortAttachmentMac*>(attachment);
59 internal::MachPortAttachmentMac::WireFormat format = 59 internal::MachPortAttachmentMac::WireFormat format =
60 mach_port_attachment->GetWireFormat(destination_process); 60 mach_port_attachment->GetWireFormat(destination_process);
61 return get_sender()->Send( 61 bool success =
62 new AttachmentBrokerMsg_DuplicateMachPort(format)); 62 get_sender()->Send(new AttachmentBrokerMsg_DuplicateMachPort(format));
63 if (success)
64 mach_port_attachment->reset_mach_port_ownership();
65 return success;
63 } 66 }
64 default: 67 default:
65 NOTREACHED(); 68 NOTREACHED();
66 return false; 69 return false;
67 } 70 }
68 return false; 71 return false;
69 } 72 }
70 73
71 bool AttachmentBrokerUnprivilegedMac::OnMessageReceived(const Message& msg) { 74 bool AttachmentBrokerUnprivilegedMac::OnMessageReceived(const Message& msg) {
72 bool handled = true; 75 bool handled = true;
(...skipping 18 matching lines...) Expand all
91 IPC::internal::MachPortAttachmentMac::WireFormat translated_wire_format( 94 IPC::internal::MachPortAttachmentMac::WireFormat translated_wire_format(
92 memory_object.release(), wire_format.destination_process, 95 memory_object.release(), wire_format.destination_process,
93 wire_format.attachment_id); 96 wire_format.attachment_id);
94 97
95 scoped_refptr<BrokerableAttachment> attachment( 98 scoped_refptr<BrokerableAttachment> attachment(
96 new IPC::internal::MachPortAttachmentMac(translated_wire_format)); 99 new IPC::internal::MachPortAttachmentMac(translated_wire_format));
97 HandleReceivedAttachment(attachment); 100 HandleReceivedAttachment(attachment);
98 } 101 }
99 102
100 } // namespace IPC 103 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/attachment_broker_unprivileged_mac.h ('k') | ipc/attachment_broker_unprivileged_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698