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 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // this switch 'on' on the Mac as well. | 42 // this switch 'on' on the Mac as well. |
43 // | 43 // |
44 // The HELLO message from the client to the server is always sent using | 44 // The HELLO message from the client to the server is always sent using |
45 // sendmsg because it will contain the file descriptor that the server | 45 // sendmsg because it will contain the file descriptor that the server |
46 // needs to send file descriptors in later messages. | 46 // needs to send file descriptors in later messages. |
47 #define IPC_USES_READWRITE 1 | 47 #define IPC_USES_READWRITE 1 |
48 #endif | 48 #endif |
49 | 49 |
50 namespace IPC { | 50 namespace IPC { |
51 | 51 |
52 class ChannelPosix : public Channel, | 52 class IPC_EXPORT ChannelPosix : public Channel, |
53 public internal::ChannelReader, | 53 public internal::ChannelReader, |
54 public base::MessageLoopForIO::Watcher { | 54 public base::MessageLoopForIO::Watcher { |
55 public: | 55 public: |
56 // Mirror methods of Channel, see ipc_channel.h for description. | |
57 ChannelPosix(const IPC::ChannelHandle& channel_handle, Mode mode, | 56 ChannelPosix(const IPC::ChannelHandle& channel_handle, Mode mode, |
58 Listener* listener); | 57 Listener* listener); |
59 virtual ~ChannelPosix(); | 58 virtual ~ChannelPosix(); |
60 | 59 |
61 // Channel implementation | 60 // Channel implementation |
62 virtual bool Connect() OVERRIDE; | 61 virtual bool Connect() OVERRIDE; |
63 virtual void Close() OVERRIDE; | 62 virtual void Close() OVERRIDE; |
64 virtual bool Send(Message* message) OVERRIDE; | 63 virtual bool Send(Message* message) OVERRIDE; |
65 virtual base::ProcessId GetPeerPID() const OVERRIDE; | 64 virtual base::ProcessId GetPeerPID() const OVERRIDE; |
66 virtual int GetClientFileDescriptor() const OVERRIDE; | 65 virtual int GetClientFileDescriptor() const OVERRIDE; |
67 virtual int TakeClientFileDescriptor() OVERRIDE; | 66 virtual int TakeClientFileDescriptor() OVERRIDE; |
68 virtual bool AcceptsConnections() const OVERRIDE; | 67 |
69 virtual bool HasAcceptedConnection() const OVERRIDE; | 68 // Returns true if the channel supports listening for connections. |
70 virtual bool GetPeerEuid(uid_t* peer_euid) const OVERRIDE; | 69 bool AcceptsConnections() const; |
71 virtual void ResetToAcceptingConnectionState() OVERRIDE; | 70 |
| 71 // Returns true if the channel supports listening for connections and is |
| 72 // currently connected. |
| 73 bool HasAcceptedConnection() const; |
| 74 |
| 75 // Closes any currently connected socket, and returns to a listening state |
| 76 // for more connections. |
| 77 void ResetToAcceptingConnectionState(); |
| 78 |
| 79 // Returns true if the peer process' effective user id can be determined, in |
| 80 // which case the supplied peer_euid is updated with it. |
| 81 bool GetPeerEuid(uid_t* peer_euid) const; |
72 | 82 |
73 void CloseClientFileDescriptor(); | 83 void CloseClientFileDescriptor(); |
74 | 84 |
75 static bool IsNamedServerInitialized(const std::string& channel_id); | 85 static bool IsNamedServerInitialized(const std::string& channel_id); |
76 #if defined(OS_LINUX) | 86 #if defined(OS_LINUX) |
77 static void SetGlobalPid(int pid); | 87 static void SetGlobalPid(int pid); |
78 #endif // OS_LINUX | 88 #endif // OS_LINUX |
79 | 89 |
80 private: | 90 private: |
81 bool CreatePipe(const IPC::ChannelHandle& channel_handle); | 91 bool CreatePipe(const IPC::ChannelHandle& channel_handle); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 // If non-zero, overrides the process ID sent in the hello message. | 216 // If non-zero, overrides the process ID sent in the hello message. |
207 static int global_pid_; | 217 static int global_pid_; |
208 #endif // OS_LINUX | 218 #endif // OS_LINUX |
209 | 219 |
210 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelPosix); | 220 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelPosix); |
211 }; | 221 }; |
212 | 222 |
213 } // namespace IPC | 223 } // namespace IPC |
214 | 224 |
215 #endif // IPC_IPC_CHANNEL_POSIX_H_ | 225 #endif // IPC_IPC_CHANNEL_POSIX_H_ |
OLD | NEW |