OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_IPC_CHANNEL_POSIX_H_ | 5 #ifndef IPC_IPC_CHANNEL_POSIX_H_ |
6 #define IPC_IPC_CHANNEL_POSIX_H_ | 6 #define IPC_IPC_CHANNEL_POSIX_H_ |
7 | 7 |
8 #include "ipc/ipc_channel.h" | 8 #include "ipc/ipc_channel.h" |
9 | 9 |
10 #include <sys/socket.h> // for CMSG macros | 10 #include <sys/socket.h> // for CMSG macros |
11 | 11 |
12 #include <queue> | 12 #include <queue> |
13 #include <set> | 13 #include <set> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/files/scoped_file.h" | 17 #include "base/files/scoped_file.h" |
18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
19 #include "base/process/process.h" | 19 #include "base/process/process.h" |
20 #include "ipc/ipc_channel_reader.h" | 20 #include "ipc/ipc_channel_reader.h" |
21 #include "ipc/ipc_message_attachment_set.h" | 21 #include "ipc/ipc_message_attachment_set.h" |
22 | 22 |
23 namespace IPC { | 23 namespace IPC { |
24 | 24 |
25 class IPC_EXPORT ChannelPosix : public Channel, | 25 class IPC_EXPORT ChannelPosix : public Channel, |
26 public internal::ChannelReader, | 26 public internal::ChannelReader, |
27 public base::MessageLoopForIO::Watcher { | 27 public base::MessageLoopForIO::Watcher { |
28 public: | 28 public: |
29 ChannelPosix(const IPC::ChannelHandle& channel_handle, Mode mode, | 29 // |broker| must outlive the newly created object. |
30 Listener* listener); | 30 ChannelPosix(const IPC::ChannelHandle& channel_handle, |
| 31 Mode mode, |
| 32 Listener* listener, |
| 33 AttachmentBroker* broker); |
31 ~ChannelPosix() override; | 34 ~ChannelPosix() override; |
32 | 35 |
33 // Channel implementation | 36 // Channel implementation |
34 bool Connect() override; | 37 bool Connect() override; |
35 void Close() override; | 38 void Close() override; |
36 bool Send(Message* message) override; | 39 bool Send(Message* message) override; |
| 40 AttachmentBroker* GetAttachmentBroker() override; |
37 base::ProcessId GetPeerPID() const override; | 41 base::ProcessId GetPeerPID() const override; |
38 base::ProcessId GetSelfPID() const override; | 42 base::ProcessId GetSelfPID() const override; |
39 int GetClientFileDescriptor() const override; | 43 int GetClientFileDescriptor() const override; |
40 base::ScopedFD TakeClientFileDescriptor() override; | 44 base::ScopedFD TakeClientFileDescriptor() override; |
41 | 45 |
42 // Returns true if the channel supports listening for connections. | 46 // Returns true if the channel supports listening for connections. |
43 bool AcceptsConnections() const; | 47 bool AcceptsConnections() const; |
44 | 48 |
45 // Returns true if the channel supports listening for connections and is | 49 // Returns true if the channel supports listening for connections and is |
46 // currently connected. | 50 // currently connected. |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 #endif | 172 #endif |
169 | 173 |
170 // True if we are responsible for unlinking the unix domain socket file. | 174 // True if we are responsible for unlinking the unix domain socket file. |
171 bool must_unlink_; | 175 bool must_unlink_; |
172 | 176 |
173 #if defined(OS_LINUX) | 177 #if defined(OS_LINUX) |
174 // If non-zero, overrides the process ID sent in the hello message. | 178 // If non-zero, overrides the process ID sent in the hello message. |
175 static int global_pid_; | 179 static int global_pid_; |
176 #endif // OS_LINUX | 180 #endif // OS_LINUX |
177 | 181 |
| 182 // |broker_| must outlive this instance. |
| 183 AttachmentBroker* broker_; |
| 184 |
178 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelPosix); | 185 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelPosix); |
179 }; | 186 }; |
180 | 187 |
181 } // namespace IPC | 188 } // namespace IPC |
182 | 189 |
183 #endif // IPC_IPC_CHANNEL_POSIX_H_ | 190 #endif // IPC_IPC_CHANNEL_POSIX_H_ |
OLD | NEW |