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_H_ | 5 #ifndef IPC_ATTACHMENT_BROKER_PRIVILEGED_H_ |
6 #define IPC_ATTACHMENT_BROKER_PRIVILEGED_H_ | 6 #define IPC_ATTACHMENT_BROKER_PRIVILEGED_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "ipc/attachment_broker.h" | 11 #include "ipc/attachment_broker.h" |
12 #include "ipc/ipc_export.h" | 12 #include "ipc/ipc_export.h" |
13 | 13 |
| 14 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 15 namespace base { |
| 16 class PortProvider; |
| 17 } // namespace base |
| 18 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 19 |
14 namespace IPC { | 20 namespace IPC { |
15 | 21 |
16 class Endpoint; | 22 class Endpoint; |
17 class Sender; | 23 class Sender; |
18 | 24 |
19 // This abstract subclass of AttachmentBroker is intended for use in a | 25 // This abstract subclass of AttachmentBroker is intended for use in a |
20 // privileged process . When unprivileged processes want to send attachments, | 26 // privileged process . When unprivileged processes want to send attachments, |
21 // the attachments get routed through the privileged process, and more | 27 // the attachments get routed through the privileged process, and more |
22 // specifically, an instance of this class. | 28 // specifically, an instance of this class. |
23 class IPC_EXPORT AttachmentBrokerPrivileged : public IPC::AttachmentBroker { | 29 class IPC_EXPORT AttachmentBrokerPrivileged : public IPC::AttachmentBroker { |
24 public: | 30 public: |
25 AttachmentBrokerPrivileged(); | 31 AttachmentBrokerPrivileged(); |
26 ~AttachmentBrokerPrivileged() override; | 32 ~AttachmentBrokerPrivileged() override; |
27 | 33 |
28 // On platforms that support attachment brokering, returns a new instance of | 34 // If there is no global attachment broker, makes a new |
29 // a platform-specific attachment broker. Otherwise returns |nullptr|. | 35 // AttachmentBrokerPrivileged and sets it as the global attachment broker. |
30 // The caller takes ownership of the newly created instance, and is | 36 // This method is thread safe. |
31 // responsible for ensuring that the attachment broker lives longer than | 37 #if defined(OS_MACOSX) && !defined(OS_IOS) |
32 // every IPC::Channel. The new instance automatically registers itself as the | 38 static void CreateBrokerIfNeeded(base::PortProvider* provider); |
33 // global attachment broker. | 39 #else |
34 static scoped_ptr<AttachmentBrokerPrivileged> CreateBroker(); | 40 static void CreateBrokerIfNeeded(); |
| 41 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
35 | 42 |
36 // AttachmentBroker overrides. | 43 // AttachmentBroker overrides. |
37 void RegisterCommunicationChannel(Endpoint* endpoint) override; | 44 void RegisterCommunicationChannel(Endpoint* endpoint) override; |
38 void DeregisterCommunicationChannel(Endpoint* endpoint) override; | 45 void DeregisterCommunicationChannel(Endpoint* endpoint) override; |
39 | 46 |
40 protected: | 47 protected: |
41 // Returns the sender whose peer's process id is |id|. | 48 // Returns the sender whose peer's process id is |id|. |
42 // Returns nullptr if no sender is found. | 49 // Returns nullptr if no sender is found. |
43 Sender* GetSenderWithProcessId(base::ProcessId id); | 50 Sender* GetSenderWithProcessId(base::ProcessId id); |
44 | 51 |
(...skipping 16 matching lines...) Expand all Loading... |
61 void LogError(UMAError error); | 68 void LogError(UMAError error); |
62 | 69 |
63 private: | 70 private: |
64 std::vector<Endpoint*> endpoints_; | 71 std::vector<Endpoint*> endpoints_; |
65 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerPrivileged); | 72 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerPrivileged); |
66 }; | 73 }; |
67 | 74 |
68 } // namespace IPC | 75 } // namespace IPC |
69 | 76 |
70 #endif // IPC_ATTACHMENT_BROKER_PRIVILEGED_H_ | 77 #endif // IPC_ATTACHMENT_BROKER_PRIVILEGED_H_ |
OLD | NEW |