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_H_ | 5 #ifndef IPC_ATTACHMENT_BROKER_H_ |
6 #define IPC_ATTACHMENT_BROKER_H_ | 6 #define IPC_ATTACHMENT_BROKER_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 // These two methods should only be called by the broker process. | 91 // These two methods should only be called by the broker process. |
92 // | 92 // |
93 // Each unprivileged process should have one IPC channel on which it | 93 // Each unprivileged process should have one IPC channel on which it |
94 // communicates attachment information with the broker process. In the broker | 94 // communicates attachment information with the broker process. In the broker |
95 // process, these channels must be registered and deregistered with the | 95 // process, these channels must be registered and deregistered with the |
96 // Attachment Broker as they are created and destroyed. | 96 // Attachment Broker as they are created and destroyed. |
97 virtual void RegisterCommunicationChannel(Endpoint* endpoint); | 97 virtual void RegisterCommunicationChannel(Endpoint* endpoint); |
98 virtual void DeregisterCommunicationChannel(Endpoint* endpoint); | 98 virtual void DeregisterCommunicationChannel(Endpoint* endpoint); |
99 | 99 |
| 100 // In each unprivileged process, exactly one channel should be used to |
| 101 // communicate brokerable attachments with the broker process. |
| 102 virtual void RegisterBrokerCommunicationChannel(Endpoint* endpoint); |
| 103 virtual void DeregisterBrokerCommunicationChannel(Endpoint* endpoint); |
| 104 |
| 105 // True if and only if this broker is privileged. |
| 106 virtual bool IsPrivilegedBroker(); |
| 107 |
100 protected: | 108 protected: |
101 using AttachmentVector = std::vector<scoped_refptr<BrokerableAttachment>>; | 109 using AttachmentVector = std::vector<scoped_refptr<BrokerableAttachment>>; |
102 | 110 |
103 // Adds |attachment| to |attachments_|, and notifies the observers. | 111 // Adds |attachment| to |attachments_|, and notifies the observers. |
104 void HandleReceivedAttachment( | 112 void HandleReceivedAttachment( |
105 const scoped_refptr<BrokerableAttachment>& attachment); | 113 const scoped_refptr<BrokerableAttachment>& attachment); |
106 | 114 |
107 // Informs the observers that a new BrokerableAttachment has been received. | 115 // Informs the observers that a new BrokerableAttachment has been received. |
108 void NotifyObservers(const BrokerableAttachment::AttachmentId& id); | 116 void NotifyObservers(const BrokerableAttachment::AttachmentId& id); |
109 | 117 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 157 |
150 // The AttachmentBroker can be accessed from any thread, so modifications to | 158 // The AttachmentBroker can be accessed from any thread, so modifications to |
151 // internal state must be guarded by a lock. | 159 // internal state must be guarded by a lock. |
152 base::Lock lock_; | 160 base::Lock lock_; |
153 DISALLOW_COPY_AND_ASSIGN(AttachmentBroker); | 161 DISALLOW_COPY_AND_ASSIGN(AttachmentBroker); |
154 }; | 162 }; |
155 | 163 |
156 } // namespace IPC | 164 } // namespace IPC |
157 | 165 |
158 #endif // IPC_ATTACHMENT_BROKER_H_ | 166 #endif // IPC_ATTACHMENT_BROKER_H_ |
OLD | NEW |