Implement operations used in the DeviceToDevice protocol.
[chromium-blink-merge.git] / ipc / attachment_broker.h
blob6bee1b29643aef464132ad9d6decb15ee8c5afb6
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
3 // found in the LICENSE file.
5 #ifndef IPC_ATTACHMENT_BROKER_H_
6 #define IPC_ATTACHMENT_BROKER_H_
8 #include "base/macros.h"
9 #include "base/process/process_handle.h"
10 #include "ipc/brokerable_attachment.h"
11 #include "ipc/ipc_export.h"
12 #include "ipc/ipc_listener.h"
14 namespace IPC {
16 class AttachmentBroker;
17 // Classes that inherit from this abstract base class are capable of
18 // communicating with a broker to send and receive attachments to Chrome IPC
19 // messages.
20 class IPC_EXPORT SupportsAttachmentBrokering {
21 public:
22 // Returns an AttachmentBroker used to broker attachments of IPC messages to
23 // other processes. There must be exactly one AttachmentBroker per process.
24 virtual AttachmentBroker* GetAttachmentBroker() = 0;
27 // Responsible for brokering attachments to Chrome IPC messages. On platforms
28 // that support attachment brokering, every IPC channel should have a reference
29 // to a AttachmentBroker.
30 class IPC_EXPORT AttachmentBroker : public Listener {
31 public:
32 AttachmentBroker() {}
33 ~AttachmentBroker() override {}
35 // Sends |attachment| to |destination_process|. The implementation uses an
36 // IPC::Channel to communicate with the broker process. This may be the same
37 // IPC::Channel that is requesting the brokering of an attachment.
38 // Returns true on success and false otherwise.
39 virtual bool SendAttachmentToProcess(const BrokerableAttachment* attachment,
40 base::ProcessId destination_process) = 0;
42 // Returns whether the attachment was available. If the attachment was
43 // available, populates the output parameter |attachment|. The caller then
44 // becomes the owner of |attachment|.
45 virtual bool GetAttachmentWithId(BrokerableAttachment::AttachmentId id,
46 BrokerableAttachment* attachment) = 0;
48 private:
49 DISALLOW_COPY_AND_ASSIGN(AttachmentBroker);
52 } // namespace IPC
54 #endif // IPC_ATTACHMENT_BROKER_H_