| 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 #ifndef IPC_ATTACHMENT_BROKER_PRIVILEGED_MAC_H_ | 5 #ifndef IPC_ATTACHMENT_BROKER_PRIVILEGED_MAC_H_ |
| 6 #define IPC_ATTACHMENT_BROKER_PRIVILEGED_MAC_H_ | 6 #define IPC_ATTACHMENT_BROKER_PRIVILEGED_MAC_H_ |
| 7 | 7 |
| 8 #include <mach/mach.h> | 8 #include <mach/mach.h> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/mac/scoped_mach_port.h" | 11 #include "base/mac/scoped_mach_port.h" |
| 12 #include "base/process/port_provider_mac.h" | 12 #include "base/process/port_provider_mac.h" |
| 13 #include "ipc/attachment_broker_privileged.h" | 13 #include "ipc/attachment_broker_privileged.h" |
| 14 #include "ipc/ipc_export.h" | 14 #include "ipc/ipc_export.h" |
| 15 #include "ipc/mach_port_attachment_mac.h" | 15 #include "ipc/mach_port_attachment_mac.h" |
| 16 | 16 |
| 17 namespace base { |
| 18 class PortProvider; |
| 19 } // namespace base |
| 20 |
| 17 namespace IPC { | 21 namespace IPC { |
| 18 | 22 |
| 19 // This class is a concrete subclass of AttachmentBrokerPrivileged for the | 23 // This class is a concrete subclass of AttachmentBrokerPrivileged for the |
| 20 // OSX platform. | 24 // OSX platform. |
| 21 // | 25 // |
| 22 // An example of the typical process by which a Mach port gets brokered. | 26 // An example of the typical process by which a Mach port gets brokered. |
| 23 // Definitions: | 27 // Definitions: |
| 24 // 1. Let there be three processes P1, U2, U3. P1 is privileged. | 28 // 1. Let there be three processes P1, U2, U3. P1 is privileged. |
| 25 // 2. U2 wants to send a Mach port M2 to U3. If this port is inserted into P1, | 29 // 2. U2 wants to send a Mach port M2 to U3. If this port is inserted into P1, |
| 26 // it will be called M1. If it is inserted into U3, it will be called M3. | 30 // it will be called M1. If it is inserted into U3, it will be called M3. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 40 // | 44 // |
| 41 // The logic of this class is a little bit more complex becauese any or all of | 45 // The logic of this class is a little bit more complex becauese any or all of |
| 42 // P1, U2 and U3 may be the same, and depending on the exact configuration, | 46 // P1, U2 and U3 may be the same, and depending on the exact configuration, |
| 43 // the creation of R may not be necessary. | 47 // the creation of R may not be necessary. |
| 44 // | 48 // |
| 45 // For the rest of this file, and the corresponding implementation file, R will | 49 // For the rest of this file, and the corresponding implementation file, R will |
| 46 // be called the "intermediate Mach port" and M3 the "final Mach port". | 50 // be called the "intermediate Mach port" and M3 the "final Mach port". |
| 47 class IPC_EXPORT AttachmentBrokerPrivilegedMac | 51 class IPC_EXPORT AttachmentBrokerPrivilegedMac |
| 48 : public AttachmentBrokerPrivileged { | 52 : public AttachmentBrokerPrivileged { |
| 49 public: | 53 public: |
| 50 AttachmentBrokerPrivilegedMac(); | 54 explicit AttachmentBrokerPrivilegedMac(base::PortProvider* port_provider); |
| 51 ~AttachmentBrokerPrivilegedMac() override; | 55 ~AttachmentBrokerPrivilegedMac() override; |
| 52 | 56 |
| 53 // IPC::AttachmentBroker overrides. | 57 // IPC::AttachmentBroker overrides. |
| 54 bool SendAttachmentToProcess(BrokerableAttachment* attachment, | 58 bool SendAttachmentToProcess(BrokerableAttachment* attachment, |
| 55 base::ProcessId destination_process) override; | 59 base::ProcessId destination_process) override; |
| 56 | 60 |
| 57 // IPC::Listener overrides. | 61 // IPC::Listener overrides. |
| 58 bool OnMessageReceived(const Message& message) override; | 62 bool OnMessageReceived(const Message& message) override; |
| 59 | 63 |
| 60 private: | 64 private: |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // passed to the consumer of the Chrome IPC message. | 115 // passed to the consumer of the Chrome IPC message. |
| 112 // Makes an attachment, queues it, and notifies the observers. | 116 // Makes an attachment, queues it, and notifies the observers. |
| 113 void RouteWireFormatToSelf(const MachPortWireFormat& wire_format); | 117 void RouteWireFormatToSelf(const MachPortWireFormat& wire_format); |
| 114 | 118 |
| 115 // |wire_format.destination_process| must be another process. | 119 // |wire_format.destination_process| must be another process. |
| 116 // |wire_format.mach_port| must be the intermediate Mach port. | 120 // |wire_format.mach_port| must be the intermediate Mach port. |
| 117 // Ownership of |wire_format.mach_port| is implicitly passed to the process | 121 // Ownership of |wire_format.mach_port| is implicitly passed to the process |
| 118 // that receives the Chrome IPC message. | 122 // that receives the Chrome IPC message. |
| 119 void RouteWireFormatToAnother(const MachPortWireFormat& wire_format); | 123 void RouteWireFormatToAnother(const MachPortWireFormat& wire_format); |
| 120 | 124 |
| 125 // The port provider must live at least as long as the AttachmentBroker. |
| 126 base::PortProvider* port_provider_; |
| 127 |
| 121 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerPrivilegedMac); | 128 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerPrivilegedMac); |
| 122 }; | 129 }; |
| 123 | 130 |
| 124 } // namespace IPC | 131 } // namespace IPC |
| 125 | 132 |
| 126 #endif // IPC_ATTACHMENT_BROKER_PRIVILEGED_MAC_H_ | 133 #endif // IPC_ATTACHMENT_BROKER_PRIVILEGED_MAC_H_ |
| OLD | NEW |