Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: ipc/attachment_broker_win.h

Issue 1205713002: Make attachment broker a subclass of IPC::Listener. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@attachment_broker3_listener_base
Patch Set: Update copyright date. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/attachment_broker_messages.h ('k') | ipc/attachment_broker_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_WIN_H_ 5 #ifndef IPC_ATTACHMENT_BROKER_WIN_H_
6 #define IPC_ATTACHMENT_BROKER_WIN_H_ 6 #define IPC_ATTACHMENT_BROKER_WIN_H_
7 7
8 #include <vector>
9
10 #include "base/gtest_prod_util.h"
11 #include "base/memory/ref_counted.h"
8 #include "ipc/attachment_broker.h" 12 #include "ipc/attachment_broker.h"
13 #include "ipc/handle_attachment_win.h"
9 #include "ipc/ipc_export.h" 14 #include "ipc/ipc_export.h"
10 15
11 namespace IPC { 16 namespace IPC {
12 17
13 class Sender; 18 class Sender;
14 19
15 // This class is an implementation of AttachmentBroker for the Windows platform. 20 // This class is an implementation of AttachmentBroker for the Windows platform.
16 class IPC_EXPORT AttachmentBrokerWin : public IPC::AttachmentBroker { 21 class IPC_EXPORT AttachmentBrokerWin : public IPC::AttachmentBroker {
17 public: 22 public:
18 AttachmentBrokerWin(); 23 AttachmentBrokerWin();
19 ~AttachmentBrokerWin() override; 24 ~AttachmentBrokerWin() override;
20 25
21 // In a non-broker process, the single instance of this class listens for 26 // In a non-broker process, the single instance of this class listens for
22 // an IPC from the broker process indicating that a new attachment has been 27 // an IPC from the broker process indicating that a new attachment has been
23 // duplicated. 28 // duplicated.
24 void OnReceiveDuplicatedHandle(HANDLE, BrokerableAttachment::AttachmentId id); 29 void OnReceiveDuplicatedHandle(HANDLE, BrokerableAttachment::AttachmentId id);
25 30
26 // IPC::AttachmentBroker overrides. 31 // IPC::AttachmentBroker overrides.
27 bool SendAttachmentToProcess(const BrokerableAttachment* attachment, 32 bool SendAttachmentToProcess(const BrokerableAttachment* attachment,
28 base::ProcessId destination_process) override; 33 base::ProcessId destination_process) override;
29 bool GetAttachmentWithId(BrokerableAttachment::AttachmentId id, 34 bool GetAttachmentWithId(BrokerableAttachment::AttachmentId id,
30 BrokerableAttachment* attachment) override; 35 BrokerableAttachment* attachment) override;
31 36
37 // IPC::Listener overrides.
38 bool OnMessageReceived(const Message& message) override;
39
32 // |sender_| is used to send Messages to the broker. |sender_| must live at 40 // |sender_| is used to send Messages to the broker. |sender_| must live at
33 // least as long as this instance. 41 // least as long as this instance.
34 void set_sender(IPC::Sender* sender) { sender_ = sender; } 42 void set_sender(IPC::Sender* sender) { sender_ = sender; }
35 43
36 private: 44 private:
45 FRIEND_TEST_ALL_PREFIXES(AttachmentBrokerWinTest, ReceiveValidMessage);
46 FRIEND_TEST_ALL_PREFIXES(AttachmentBrokerWinTest, ReceiveInvalidMessage);
47
48 // IPC message handlers.
49 void OnWinHandleHasBeenDuplicated(
50 const IPC::internal::HandleAttachmentWin::WireFormat& wire_format);
51
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_;
58
37 // |sender_| is used to send Messages to the broker. |sender_| must live at 59 // |sender_| is used to send Messages to the broker. |sender_| must live at
38 // least as long as this instance. 60 // least as long as this instance.
39 IPC::Sender* sender_; 61 IPC::Sender* sender_;
40 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerWin); 62 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerWin);
41 }; 63 };
42 64
43 } // namespace IPC 65 } // namespace IPC
44 66
45 #endif // IPC_ATTACHMENT_BROKER_WIN_H_ 67 #endif // IPC_ATTACHMENT_BROKER_WIN_H_
OLDNEW
« no previous file with comments | « ipc/attachment_broker_messages.h ('k') | ipc/attachment_broker_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698