ExtensionInstallDialogView: fix scrolling behavior on Views (Win,Linux)
[chromium-blink-merge.git] / ipc / attachment_broker_win.h
blob5df2c9a2395b9fcba21d7d53307db751112d7148
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_WIN_H_
6 #define IPC_ATTACHMENT_BROKER_WIN_H_
8 #include <vector>
10 #include "base/gtest_prod_util.h"
11 #include "base/memory/ref_counted.h"
12 #include "ipc/attachment_broker.h"
13 #include "ipc/handle_attachment_win.h"
14 #include "ipc/ipc_export.h"
16 namespace IPC {
18 class Sender;
20 // This class is an implementation of AttachmentBroker for the Windows platform.
21 class IPC_EXPORT AttachmentBrokerWin : public IPC::AttachmentBroker {
22 public:
23 AttachmentBrokerWin();
24 ~AttachmentBrokerWin() override;
26 // In a non-broker process, the single instance of this class listens for
27 // an IPC from the broker process indicating that a new attachment has been
28 // duplicated.
29 void OnReceiveDuplicatedHandle(HANDLE, BrokerableAttachment::AttachmentId id);
31 // IPC::AttachmentBroker overrides.
32 bool SendAttachmentToProcess(const BrokerableAttachment* attachment,
33 base::ProcessId destination_process) override;
34 bool GetAttachmentWithId(BrokerableAttachment::AttachmentId id,
35 BrokerableAttachment* attachment) override;
37 // IPC::Listener overrides.
38 bool OnMessageReceived(const Message& message) override;
40 // |sender_| is used to send Messages to the broker. |sender_| must live at
41 // least as long as this instance.
42 void set_sender(IPC::Sender* sender) { sender_ = sender; }
44 private:
45 FRIEND_TEST_ALL_PREFIXES(AttachmentBrokerWinTest, ReceiveValidMessage);
46 FRIEND_TEST_ALL_PREFIXES(AttachmentBrokerWinTest, ReceiveInvalidMessage);
48 // IPC message handlers.
49 void OnWinHandleHasBeenDuplicated(
50 const IPC::internal::HandleAttachmentWin::WireFormat& wire_format);
52 // A vector of BrokerableAttachments that have been received, but not yet
53 // consumed.
54 // A std::vector is used instead of a std::map because this container is
55 // expected to have few elements, for which a std::vector is expected to have
56 // better performance.
57 std::vector<scoped_refptr<BrokerableAttachment>> attachments_;
59 // |sender_| is used to send Messages to the broker. |sender_| must live at
60 // least as long as this instance.
61 IPC::Sender* sender_;
62 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerWin);
65 } // namespace IPC
67 #endif // IPC_ATTACHMENT_BROKER_WIN_H_