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 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 public base::PortProvider::Observer { | 59 public base::PortProvider::Observer { |
60 public: | 60 public: |
61 explicit AttachmentBrokerPrivilegedMac(base::PortProvider* port_provider); | 61 explicit AttachmentBrokerPrivilegedMac(base::PortProvider* port_provider); |
62 ~AttachmentBrokerPrivilegedMac() override; | 62 ~AttachmentBrokerPrivilegedMac() override; |
63 | 63 |
64 // IPC::AttachmentBroker overrides. | 64 // IPC::AttachmentBroker overrides. |
65 bool SendAttachmentToProcess( | 65 bool SendAttachmentToProcess( |
66 const scoped_refptr<IPC::BrokerableAttachment>& attachment, | 66 const scoped_refptr<IPC::BrokerableAttachment>& attachment, |
67 base::ProcessId destination_process) override; | 67 base::ProcessId destination_process) override; |
68 void DeregisterCommunicationChannel(Endpoint* endpoint) override; | 68 void DeregisterCommunicationChannel(Endpoint* endpoint) override; |
| 69 void ReceivedPeerPid(base::ProcessId peer_pid) override; |
69 | 70 |
70 // IPC::Listener overrides. | 71 // IPC::Listener overrides. |
71 bool OnMessageReceived(const Message& message) override; | 72 bool OnMessageReceived(const Message& message) override; |
72 | 73 |
73 // base::PortProvider::Observer override. | 74 // base::PortProvider::Observer override. |
74 void OnReceivedTaskPort(base::ProcessHandle process) override; | 75 void OnReceivedTaskPort(base::ProcessHandle process) override; |
75 | 76 |
76 private: | 77 private: |
77 FRIEND_TEST_ALL_PREFIXES(AttachmentBrokerPrivilegedMacMultiProcessTest, | 78 FRIEND_TEST_ALL_PREFIXES(AttachmentBrokerPrivilegedMacMultiProcessTest, |
78 InsertRight); | 79 InsertRight); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 161 |
161 // |wire_format.destination_process| must be another process. | 162 // |wire_format.destination_process| must be another process. |
162 // |wire_format.mach_port| must be the intermediate Mach port. | 163 // |wire_format.mach_port| must be the intermediate Mach port. |
163 // Ownership of |wire_format.mach_port| is implicitly passed to the process | 164 // Ownership of |wire_format.mach_port| is implicitly passed to the process |
164 // that receives the Chrome IPC message. | 165 // that receives the Chrome IPC message. |
165 // Returns |false| on irrecoverable error. | 166 // Returns |false| on irrecoverable error. |
166 bool RouteWireFormatToAnother(const MachPortWireFormat& wire_format); | 167 bool RouteWireFormatToAnother(const MachPortWireFormat& wire_format); |
167 | 168 |
168 // Atempts to broker all precursors whose destination is |pid|. Has no effect | 169 // Atempts to broker all precursors whose destination is |pid|. Has no effect |
169 // if |port_provider_| does not have the task port for |pid|. | 170 // if |port_provider_| does not have the task port for |pid|. |
170 void SendPrecursorsForProcess(base::ProcessId pid); | 171 // If a communication channel has not been established from the destination |
| 172 // process, and |store_on_failure| is true, then the precursor is kept for |
| 173 // later reuse. If |store_on_failure| is false, then the precursor is deleted. |
| 174 void SendPrecursorsForProcess(base::ProcessId pid, bool store_on_failure); |
171 | 175 |
172 // Brokers a single precursor into the task represented by |task_port|. | 176 // Brokers a single precursor into the task represented by |task_port|. |
173 // Returns |false| on irrecoverable error. | 177 // Returns |false| on irrecoverable error. |
174 bool SendPrecursor(AttachmentPrecursor* precursor, mach_port_t task_port); | 178 bool SendPrecursor(AttachmentPrecursor* precursor, mach_port_t task_port); |
175 | 179 |
176 // Add a precursor to |precursors_|. Takes ownership of |port|. | 180 // Add a precursor to |precursors_|. Takes ownership of |port|. |
177 void AddPrecursor(base::ProcessId pid, | 181 void AddPrecursor(base::ProcessId pid, |
178 base::mac::ScopedMachSendRight port, | 182 base::mac::ScopedMachSendRight port, |
179 const BrokerableAttachment::AttachmentId& id); | 183 const BrokerableAttachment::AttachmentId& id); |
180 | 184 |
181 // Atempts to process all extractors whose source is |pid|. Has no effect | 185 // Atempts to process all extractors whose source is |pid|. Has no effect |
182 // if |port_provider_| does not have the task port for |pid|. | 186 // if |port_provider_| does not have the task port for |pid|. |
183 void ProcessExtractorsForProcess(base::ProcessId pid); | 187 // If a communication channel has not been established from the source |
| 188 // process, and |store_on_failure| is true, then the extractor is kept for |
| 189 // later reuse. If |store_on_failure| is false, then the extractor is deleted. |
| 190 void ProcessExtractorsForProcess(base::ProcessId pid, bool store_on_failure); |
184 | 191 |
185 // Processes a single extractor whose source pid is represented by | 192 // Processes a single extractor whose source pid is represented by |
186 // |task_port|. | 193 // |task_port|. |
187 void ProcessExtractor(AttachmentExtractor* extractor, mach_port_t task_port); | 194 void ProcessExtractor(AttachmentExtractor* extractor, mach_port_t task_port); |
188 | 195 |
189 // Add an extractor to |extractors_|. | 196 // Add an extractor to |extractors_|. |
190 void AddExtractor(base::ProcessId source_pid, | 197 void AddExtractor(base::ProcessId source_pid, |
191 base::ProcessId dest_pid, | 198 base::ProcessId dest_pid, |
192 mach_port_name_t port, | 199 mach_port_name_t port, |
193 const BrokerableAttachment::AttachmentId& id); | 200 const BrokerableAttachment::AttachmentId& id); |
(...skipping 10 matching lines...) Expand all Loading... |
204 // processed. | 211 // processed. |
205 std::map<base::ProcessId, ScopedVector<AttachmentExtractor>*> extractors_; | 212 std::map<base::ProcessId, ScopedVector<AttachmentExtractor>*> extractors_; |
206 base::Lock extractors_lock_; | 213 base::Lock extractors_lock_; |
207 | 214 |
208 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerPrivilegedMac); | 215 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerPrivilegedMac); |
209 }; | 216 }; |
210 | 217 |
211 } // namespace IPC | 218 } // namespace IPC |
212 | 219 |
213 #endif // IPC_ATTACHMENT_BROKER_PRIVILEGED_MAC_H_ | 220 #endif // IPC_ATTACHMENT_BROKER_PRIVILEGED_MAC_H_ |
OLD | NEW |