| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 // A vector of BrokerableAttachments that have been received, but not yet | 136 // A vector of BrokerableAttachments that have been received, but not yet |
| 137 // consumed. | 137 // consumed. |
| 138 // A std::vector is used instead of a std::map because this container is | 138 // A std::vector is used instead of a std::map because this container is |
| 139 // expected to have few elements, for which a std::vector is expected to have | 139 // expected to have few elements, for which a std::vector is expected to have |
| 140 // better performance. | 140 // better performance. |
| 141 AttachmentVector attachments_; | 141 AttachmentVector attachments_; |
| 142 | 142 |
| 143 struct ObserverInfo { | 143 struct ObserverInfo { |
| 144 ObserverInfo(); | 144 ObserverInfo(); |
| 145 ObserverInfo(const ObserverInfo& other); |
| 145 ~ObserverInfo(); | 146 ~ObserverInfo(); |
| 146 | 147 |
| 147 Observer* observer; | 148 Observer* observer; |
| 148 int unique_id; | 149 int unique_id; |
| 149 | 150 |
| 150 // Notifications must be dispatched onto |runner|. | 151 // Notifications must be dispatched onto |runner|. |
| 151 scoped_refptr<base::SequencedTaskRunner> runner; | 152 scoped_refptr<base::SequencedTaskRunner> runner; |
| 152 }; | 153 }; |
| 153 std::vector<ObserverInfo> observers_; | 154 std::vector<ObserverInfo> observers_; |
| 154 | 155 |
| 155 // This member holds the last id given to an ObserverInfo. | 156 // This member holds the last id given to an ObserverInfo. |
| 156 int last_unique_id_; | 157 int last_unique_id_; |
| 157 | 158 |
| 158 // The AttachmentBroker can be accessed from any thread, so modifications to | 159 // The AttachmentBroker can be accessed from any thread, so modifications to |
| 159 // internal state must be guarded by a lock. | 160 // internal state must be guarded by a lock. |
| 160 base::Lock lock_; | 161 base::Lock lock_; |
| 161 DISALLOW_COPY_AND_ASSIGN(AttachmentBroker); | 162 DISALLOW_COPY_AND_ASSIGN(AttachmentBroker); |
| 162 }; | 163 }; |
| 163 | 164 |
| 164 } // namespace IPC | 165 } // namespace IPC |
| 165 | 166 |
| 166 #endif // IPC_ATTACHMENT_BROKER_H_ | 167 #endif // IPC_ATTACHMENT_BROKER_H_ |
| OLD | NEW |