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 | |
108 protected: | 100 protected: |
109 using AttachmentVector = std::vector<scoped_refptr<BrokerableAttachment>>; | 101 using AttachmentVector = std::vector<scoped_refptr<BrokerableAttachment>>; |
110 | 102 |
111 // Adds |attachment| to |attachments_|, and notifies the observers. | 103 // Adds |attachment| to |attachments_|, and notifies the observers. |
112 void HandleReceivedAttachment( | 104 void HandleReceivedAttachment( |
113 const scoped_refptr<BrokerableAttachment>& attachment); | 105 const scoped_refptr<BrokerableAttachment>& attachment); |
114 | 106 |
115 // Informs the observers that a new BrokerableAttachment has been received. | 107 // Informs the observers that a new BrokerableAttachment has been received. |
116 void NotifyObservers(const BrokerableAttachment::AttachmentId& id); | 108 void NotifyObservers(const BrokerableAttachment::AttachmentId& id); |
117 | 109 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 149 |
158 // The AttachmentBroker can be accessed from any thread, so modifications to | 150 // The AttachmentBroker can be accessed from any thread, so modifications to |
159 // internal state must be guarded by a lock. | 151 // internal state must be guarded by a lock. |
160 base::Lock lock_; | 152 base::Lock lock_; |
161 DISALLOW_COPY_AND_ASSIGN(AttachmentBroker); | 153 DISALLOW_COPY_AND_ASSIGN(AttachmentBroker); |
162 }; | 154 }; |
163 | 155 |
164 } // namespace IPC | 156 } // namespace IPC |
165 | 157 |
166 #endif // IPC_ATTACHMENT_BROKER_H_ | 158 #endif // IPC_ATTACHMENT_BROKER_H_ |
OLD | NEW |