| Index: ipc/attachment_broker.h
|
| diff --git a/ipc/attachment_broker.h b/ipc/attachment_broker.h
|
| index 6bee1b29643aef464132ad9d6decb15ee8c5afb6..efde3c132ead007b978ec14bd0b64cd9ff8f9ce5 100644
|
| --- a/ipc/attachment_broker.h
|
| +++ b/ipc/attachment_broker.h
|
| @@ -27,10 +27,20 @@ class IPC_EXPORT SupportsAttachmentBrokering {
|
| // Responsible for brokering attachments to Chrome IPC messages. On platforms
|
| // that support attachment brokering, every IPC channel should have a reference
|
| // to a AttachmentBroker.
|
| +// This class is not thread safe. The implementation of this class assumes that
|
| +// it is only ever used on the same thread as its consumers.
|
| class IPC_EXPORT AttachmentBroker : public Listener {
|
| public:
|
| - AttachmentBroker() {}
|
| - ~AttachmentBroker() override {}
|
| + // A standard observer interface that allows consumers of the AttachmentBroker
|
| + // to be notified when a new attachment has been received.
|
| + class Observer {
|
| + public:
|
| + virtual void ReceivedBrokerableAttachmentWithId(
|
| + const BrokerableAttachment::AttachmentId& id) = 0;
|
| + };
|
| +
|
| + AttachmentBroker();
|
| + ~AttachmentBroker() override;
|
|
|
| // Sends |attachment| to |destination_process|. The implementation uses an
|
| // IPC::Channel to communicate with the broker process. This may be the same
|
| @@ -40,13 +50,22 @@ class IPC_EXPORT AttachmentBroker : public Listener {
|
| base::ProcessId destination_process) = 0;
|
|
|
| // Returns whether the attachment was available. If the attachment was
|
| - // available, populates the output parameter |attachment|. The caller then
|
| - // becomes the owner of |attachment|.
|
| - virtual bool GetAttachmentWithId(BrokerableAttachment::AttachmentId id,
|
| - BrokerableAttachment* attachment) = 0;
|
| + // available, populates the output parameter |attachment|.
|
| + virtual bool GetAttachmentWithId(
|
| + BrokerableAttachment::AttachmentId id,
|
| + scoped_refptr<BrokerableAttachment>* attachment) = 0;
|
| +
|
| + // Any given observer should only ever add itself once to the observer list.
|
| + void AddObserver(Observer* observer);
|
| + void RemoveObserver(Observer* observer);
|
| +
|
| + protected:
|
| + void NotifyObservers(const BrokerableAttachment::AttachmentId& id);
|
|
|
| private:
|
| DISALLOW_COPY_AND_ASSIGN(AttachmentBroker);
|
| +
|
| + std::vector<Observer*> observers_;
|
| };
|
|
|
| } // namespace IPC
|
|
|