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_H_ | 5 #ifndef IPC_IPC_CHANNEL_H_ |
6 #define IPC_IPC_CHANNEL_H_ | 6 #define IPC_IPC_CHANNEL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 // Get its own process id. This value is told to the peer. | 173 // Get its own process id. This value is told to the peer. |
174 virtual base::ProcessId GetSelfPID() const = 0; | 174 virtual base::ProcessId GetSelfPID() const = 0; |
175 | 175 |
176 // Send a message over the Channel to the listener on the other end. | 176 // Send a message over the Channel to the listener on the other end. |
177 // | 177 // |
178 // |message| must be allocated using operator new. This object will be | 178 // |message| must be allocated using operator new. This object will be |
179 // deleted once the contents of the Message have been sent. | 179 // deleted once the contents of the Message have been sent. |
180 virtual bool Send(Message* message) = 0; | 180 virtual bool Send(Message* message) = 0; |
181 | 181 |
182 #if defined(OS_POSIX) && !defined(OS_NACL) | 182 // NaCl in Non-SFI mode runs on Linux directly, and the following functions |
| 183 // compiled on Linux are also needed. Please see also comments in |
| 184 // components/nacl_nonsfi.gyp for more details. |
| 185 #if defined(OS_POSIX) && \ |
| 186 (!defined(OS_NACL) || defined(__native_client_nonsfi__)) |
183 // On POSIX an IPC::Channel wraps a socketpair(), this method returns the | 187 // On POSIX an IPC::Channel wraps a socketpair(), this method returns the |
184 // FD # for the client end of the socket. | 188 // FD # for the client end of the socket. |
185 // This method may only be called on the server side of a channel. | 189 // This method may only be called on the server side of a channel. |
186 // This method can be called on any thread. | 190 // This method can be called on any thread. |
187 virtual int GetClientFileDescriptor() const = 0; | 191 virtual int GetClientFileDescriptor() const = 0; |
188 | 192 |
189 // Same as GetClientFileDescriptor, but transfers the ownership of the | 193 // Same as GetClientFileDescriptor, but transfers the ownership of the |
190 // file descriptor to the caller. | 194 // file descriptor to the caller. |
191 // This method can be called on any thread. | 195 // This method can be called on any thread. |
192 virtual base::ScopedFD TakeClientFileDescriptor() = 0; | 196 virtual base::ScopedFD TakeClientFileDescriptor() = 0; |
193 #endif // defined(OS_POSIX) && !defined(OS_NACL) | 197 #endif |
194 | 198 |
195 // Returns true if a named server channel is initialized on the given channel | 199 // Returns true if a named server channel is initialized on the given channel |
196 // ID. Even if true, the server may have already accepted a connection. | 200 // ID. Even if true, the server may have already accepted a connection. |
197 static bool IsNamedServerInitialized(const std::string& channel_id); | 201 static bool IsNamedServerInitialized(const std::string& channel_id); |
198 | 202 |
199 #if !defined(OS_NACL) | 203 #if !defined(OS_NACL) || defined(__native_client_nonsfi__) |
200 // Generates a channel ID that's non-predictable and unique. | 204 // Generates a channel ID that's non-predictable and unique. |
201 static std::string GenerateUniqueRandomChannelID(); | 205 static std::string GenerateUniqueRandomChannelID(); |
202 | 206 |
203 // Generates a channel ID that, if passed to the client as a shared secret, | 207 // Generates a channel ID that, if passed to the client as a shared secret, |
204 // will validate that the client's authenticity. On platforms that do not | 208 // will validate that the client's authenticity. On platforms that do not |
205 // require additional this is simply calls GenerateUniqueRandomChannelID(). | 209 // require additional this is simply calls GenerateUniqueRandomChannelID(). |
206 // For portability the prefix should not include the \ character. | 210 // For portability the prefix should not include the \ character. |
207 static std::string GenerateVerifiedChannelID(const std::string& prefix); | 211 static std::string GenerateVerifiedChannelID(const std::string& prefix); |
208 #endif | 212 #endif |
209 | 213 |
(...skipping 16 matching lines...) Expand all Loading... |
226 | 230 |
227 #if defined(OS_POSIX) | 231 #if defined(OS_POSIX) |
228 // SocketPair() creates a pair of socket FDs suitable for using with | 232 // SocketPair() creates a pair of socket FDs suitable for using with |
229 // IPC::Channel. | 233 // IPC::Channel. |
230 IPC_EXPORT bool SocketPair(int* fd1, int* fd2); | 234 IPC_EXPORT bool SocketPair(int* fd1, int* fd2); |
231 #endif | 235 #endif |
232 | 236 |
233 } // namespace IPC | 237 } // namespace IPC |
234 | 238 |
235 #endif // IPC_IPC_CHANNEL_H_ | 239 #endif // IPC_IPC_CHANNEL_H_ |
OLD | NEW |