| 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_privileged_win.h" | 5 #include "ipc/attachment_broker_privileged_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include <tuple> | 9 #include <tuple> |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 if (wire_format.destination_process == base::Process::Current().Pid()) { | 79 if (wire_format.destination_process == base::Process::Current().Pid()) { |
| 80 scoped_refptr<BrokerableAttachment> attachment( | 80 scoped_refptr<BrokerableAttachment> attachment( |
| 81 new internal::HandleAttachmentWin(wire_format)); | 81 new internal::HandleAttachmentWin(wire_format)); |
| 82 HandleReceivedAttachment(attachment); | 82 HandleReceivedAttachment(attachment); |
| 83 return; | 83 return; |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Another process is the destination. | 86 // Another process is the destination. |
| 87 base::ProcessId dest = wire_format.destination_process; | 87 base::ProcessId dest = wire_format.destination_process; |
| 88 base::AutoLock auto_lock(*get_lock()); | 88 base::AutoLock auto_lock(*get_lock()); |
| 89 Sender* sender = GetSenderWithProcessId(dest); | 89 AttachmentBrokerPrivileged::EndpointRunnerPair pair = |
| 90 if (!sender) { | 90 GetSenderWithProcessId(dest); |
| 91 if (!pair.first) { |
| 91 // Assuming that this message was not sent from a malicious process, the | 92 // Assuming that this message was not sent from a malicious process, the |
| 92 // channel endpoint that would have received this message will block | 93 // channel endpoint that would have received this message will block |
| 93 // forever. | 94 // forever. |
| 94 LOG(ERROR) << "Failed to deliver brokerable attachment to process with id: " | 95 LOG(ERROR) << "Failed to deliver brokerable attachment to process with id: " |
| 95 << dest; | 96 << dest; |
| 96 LogError(DESTINATION_NOT_FOUND); | 97 LogError(DESTINATION_NOT_FOUND); |
| 97 return; | 98 return; |
| 98 } | 99 } |
| 99 | 100 |
| 100 LogError(DESTINATION_FOUND); | 101 LogError(DESTINATION_FOUND); |
| 101 sender->Send(new AttachmentBrokerMsg_WinHandleHasBeenDuplicated(wire_format)); | 102 SendMessageToEndpoint( |
| 103 pair, new AttachmentBrokerMsg_WinHandleHasBeenDuplicated(wire_format)); |
| 102 } | 104 } |
| 103 | 105 |
| 104 AttachmentBrokerPrivilegedWin::HandleWireFormat | 106 AttachmentBrokerPrivilegedWin::HandleWireFormat |
| 105 AttachmentBrokerPrivilegedWin::DuplicateWinHandle( | 107 AttachmentBrokerPrivilegedWin::DuplicateWinHandle( |
| 106 const HandleWireFormat& wire_format, | 108 const HandleWireFormat& wire_format, |
| 107 base::ProcessId source_pid) { | 109 base::ProcessId source_pid) { |
| 108 // If the source process is the destination process, then no additional work | 110 // If the source process is the destination process, then no additional work |
| 109 // is required. | 111 // is required. |
| 110 if (source_pid == wire_format.destination_process) | 112 if (source_pid == wire_format.destination_process) |
| 111 return wire_format; | 113 return wire_format; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 151 |
| 150 AttachmentBrokerPrivilegedWin::HandleWireFormat | 152 AttachmentBrokerPrivilegedWin::HandleWireFormat |
| 151 AttachmentBrokerPrivilegedWin::CopyWireFormat( | 153 AttachmentBrokerPrivilegedWin::CopyWireFormat( |
| 152 const HandleWireFormat& wire_format, | 154 const HandleWireFormat& wire_format, |
| 153 int handle) { | 155 int handle) { |
| 154 return HandleWireFormat(handle, wire_format.destination_process, | 156 return HandleWireFormat(handle, wire_format.destination_process, |
| 155 wire_format.permissions, wire_format.attachment_id); | 157 wire_format.permissions, wire_format.attachment_id); |
| 156 } | 158 } |
| 157 | 159 |
| 158 } // namespace IPC | 160 } // namespace IPC |
| OLD | NEW |