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