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/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 class IPC_EXPORT AttachmentBroker : public Listener { | 43 class IPC_EXPORT AttachmentBroker : public Listener { |
44 public: | 44 public: |
45 // A standard observer interface that allows consumers of the AttachmentBroker | 45 // A standard observer interface that allows consumers of the AttachmentBroker |
46 // to be notified when a new attachment has been received. | 46 // to be notified when a new attachment has been received. |
47 class Observer { | 47 class Observer { |
48 public: | 48 public: |
49 virtual void ReceivedBrokerableAttachmentWithId( | 49 virtual void ReceivedBrokerableAttachmentWithId( |
50 const BrokerableAttachment::AttachmentId& id) = 0; | 50 const BrokerableAttachment::AttachmentId& id) = 0; |
51 }; | 51 }; |
52 | 52 |
| 53 // Each process has at most one attachment broker. The process is responsible |
| 54 // for ensuring that |broker| stays alive for as long as the process is |
| 55 // sending/receiving ipc messages. |
| 56 static void SetGlobal(AttachmentBroker* broker); |
| 57 static AttachmentBroker* GetGlobal(); |
| 58 |
53 AttachmentBroker(); | 59 AttachmentBroker(); |
54 ~AttachmentBroker() override; | 60 ~AttachmentBroker() override; |
55 | 61 |
56 // Sends |attachment| to |destination_process|. The implementation uses an | 62 // Sends |attachment| to |destination_process|. The implementation uses an |
57 // IPC::Channel to communicate with the broker process. This may be the same | 63 // IPC::Channel to communicate with the broker process. This may be the same |
58 // IPC::Channel that is requesting the brokering of an attachment. | 64 // IPC::Channel that is requesting the brokering of an attachment. |
59 // Returns true on success and false otherwise. | 65 // Returns true on success and false otherwise. |
60 virtual bool SendAttachmentToProcess(const BrokerableAttachment* attachment, | 66 virtual bool SendAttachmentToProcess(const BrokerableAttachment* attachment, |
61 base::ProcessId destination_process) = 0; | 67 base::ProcessId destination_process) = 0; |
62 | 68 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // better performance. | 103 // better performance. |
98 AttachmentVector attachments_; | 104 AttachmentVector attachments_; |
99 | 105 |
100 std::vector<Observer*> observers_; | 106 std::vector<Observer*> observers_; |
101 DISALLOW_COPY_AND_ASSIGN(AttachmentBroker); | 107 DISALLOW_COPY_AND_ASSIGN(AttachmentBroker); |
102 }; | 108 }; |
103 | 109 |
104 } // namespace IPC | 110 } // namespace IPC |
105 | 111 |
106 #endif // IPC_ATTACHMENT_BROKER_H_ | 112 #endif // IPC_ATTACHMENT_BROKER_H_ |
OLD | NEW |