| 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_win.h" | 5 #include "ipc/attachment_broker_unprivileged_win.h" |
| 6 | 6 |
| 7 #include "base/process/process.h" | 7 #include "base/process/process.h" |
| 8 #include "ipc/attachment_broker_messages.h" | 8 #include "ipc/attachment_broker_messages.h" |
| 9 #include "ipc/brokerable_attachment.h" | 9 #include "ipc/brokerable_attachment.h" |
| 10 #include "ipc/handle_attachment_win.h" | 10 #include "ipc/handle_attachment_win.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 base::ProcessId destination_process) { | 21 base::ProcessId destination_process) { |
| 22 switch (attachment->GetBrokerableType()) { | 22 switch (attachment->GetBrokerableType()) { |
| 23 case BrokerableAttachment::WIN_HANDLE: { | 23 case BrokerableAttachment::WIN_HANDLE: { |
| 24 const internal::HandleAttachmentWin* handle_attachment = | 24 const internal::HandleAttachmentWin* handle_attachment = |
| 25 static_cast<const internal::HandleAttachmentWin*>(attachment); | 25 static_cast<const internal::HandleAttachmentWin*>(attachment); |
| 26 internal::HandleAttachmentWin::WireFormat format = | 26 internal::HandleAttachmentWin::WireFormat format = |
| 27 handle_attachment->GetWireFormat(destination_process); | 27 handle_attachment->GetWireFormat(destination_process); |
| 28 return get_sender()->Send( | 28 return get_sender()->Send( |
| 29 new AttachmentBrokerMsg_DuplicateWinHandle(format)); | 29 new AttachmentBrokerMsg_DuplicateWinHandle(format)); |
| 30 } | 30 } |
| 31 case BrokerableAttachment::MACH_PORT: |
| 31 case BrokerableAttachment::PLACEHOLDER: | 32 case BrokerableAttachment::PLACEHOLDER: |
| 32 NOTREACHED(); | 33 NOTREACHED(); |
| 33 return false; | 34 return false; |
| 34 } | 35 } |
| 35 return false; | 36 return false; |
| 36 } | 37 } |
| 37 | 38 |
| 38 bool AttachmentBrokerUnprivilegedWin::OnMessageReceived(const Message& msg) { | 39 bool AttachmentBrokerUnprivilegedWin::OnMessageReceived(const Message& msg) { |
| 39 bool handled = true; | 40 bool handled = true; |
| 40 IPC_BEGIN_MESSAGE_MAP(AttachmentBrokerUnprivilegedWin, msg) | 41 IPC_BEGIN_MESSAGE_MAP(AttachmentBrokerUnprivilegedWin, msg) |
| 41 IPC_MESSAGE_HANDLER(AttachmentBrokerMsg_WinHandleHasBeenDuplicated, | 42 IPC_MESSAGE_HANDLER(AttachmentBrokerMsg_WinHandleHasBeenDuplicated, |
| 42 OnWinHandleHasBeenDuplicated) | 43 OnWinHandleHasBeenDuplicated) |
| 43 IPC_MESSAGE_UNHANDLED(handled = false) | 44 IPC_MESSAGE_UNHANDLED(handled = false) |
| 44 IPC_END_MESSAGE_MAP() | 45 IPC_END_MESSAGE_MAP() |
| 45 return handled; | 46 return handled; |
| 46 } | 47 } |
| 47 | 48 |
| 48 void AttachmentBrokerUnprivilegedWin::OnWinHandleHasBeenDuplicated( | 49 void AttachmentBrokerUnprivilegedWin::OnWinHandleHasBeenDuplicated( |
| 49 const IPC::internal::HandleAttachmentWin::WireFormat& wire_format) { | 50 const IPC::internal::HandleAttachmentWin::WireFormat& wire_format) { |
| 50 // The IPC message was intended for a different process. Ignore it. | 51 // The IPC message was intended for a different process. Ignore it. |
| 51 if (wire_format.destination_process != base::Process::Current().Pid()) | 52 if (wire_format.destination_process != base::Process::Current().Pid()) |
| 52 return; | 53 return; |
| 53 | 54 |
| 54 scoped_refptr<BrokerableAttachment> attachment( | 55 scoped_refptr<BrokerableAttachment> attachment( |
| 55 new IPC::internal::HandleAttachmentWin(wire_format)); | 56 new IPC::internal::HandleAttachmentWin(wire_format)); |
| 56 HandleReceivedAttachment(attachment); | 57 HandleReceivedAttachment(attachment); |
| 57 } | 58 } |
| 58 | 59 |
| 59 } // namespace IPC | 60 } // namespace IPC |
| OLD | NEW |