| OLD | NEW |
| 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 Loading... |
| 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 BrokerableAttachment* attachment, | 53 const scoped_refptr<IPC::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 internal::MachPortAttachmentMac* mach_port_attachment = | 57 internal::MachPortAttachmentMac* mach_port_attachment = |
| 58 static_cast<internal::MachPortAttachmentMac*>(attachment); | 58 static_cast<internal::MachPortAttachmentMac*>(attachment.get()); |
| 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 bool success = | 61 bool success = |
| 62 get_sender()->Send(new AttachmentBrokerMsg_DuplicateMachPort(format)); | 62 get_sender()->Send(new AttachmentBrokerMsg_DuplicateMachPort(format)); |
| 63 if (success) | 63 if (success) |
| 64 mach_port_attachment->reset_mach_port_ownership(); | 64 mach_port_attachment->reset_mach_port_ownership(); |
| 65 return success; | 65 return success; |
| 66 } | 66 } |
| 67 default: | 67 default: |
| 68 NOTREACHED(); | 68 NOTREACHED(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 95 IPC::internal::MachPortAttachmentMac::WireFormat translated_wire_format( | 95 IPC::internal::MachPortAttachmentMac::WireFormat translated_wire_format( |
| 96 memory_object.release(), wire_format.destination_process, | 96 memory_object.release(), wire_format.destination_process, |
| 97 wire_format.attachment_id); | 97 wire_format.attachment_id); |
| 98 | 98 |
| 99 scoped_refptr<BrokerableAttachment> attachment( | 99 scoped_refptr<BrokerableAttachment> attachment( |
| 100 new IPC::internal::MachPortAttachmentMac(translated_wire_format)); | 100 new IPC::internal::MachPortAttachmentMac(translated_wire_format)); |
| 101 HandleReceivedAttachment(attachment); | 101 HandleReceivedAttachment(attachment); |
| 102 } | 102 } |
| 103 | 103 |
| 104 } // namespace IPC | 104 } // namespace IPC |
| OLD | NEW |