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

Side by Side Diff: ipc/ipc_channel.h

Issue 659243002: Non-SFI Mode: Build ipc/ library by PNaCl toolchain for nacl_helper_nonsfi. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Created 6 years, 2 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
OLDNEW
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
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 // The IPC library is built for various platforms, including Win, Mac, Linux
183 // and NaCl in SFI-mode and in Non-SFI mode.
184 // Here, as for NaCl, the IPC library for NaCl in SFI-mode is linked into
Mark Seaborn 2014/10/22 00:35:51 This comment is rather long... We shouldn't have
hidehiko 2014/10/22 13:31:05 Indeed. Added comment in components/nacl_nonsfi.gy
185 // irt.nexe and loaded by nacl_helper (the channel implementation is
186 // ipc_channel_nacl), while the one for NaCl in Non-SFI mode is linked into
187 // nacl_helper_nonsfi and runs directly on Linux platform (the channel
188 // implementation is ipc_channel_posix).
189 // So, since both are built by the NaCl/PNaCl toolchains, OS_NACL macro is
190 // defined (derived from __native_client__ macro) in both cases, but the
191 // latter is closer to Linux build. Actually GetClientFileDescriptor,
192 // TakeClientFileDescriptor GenerateUniqueRandomChannelID,
193 // GenerateVerifiedChannelID and SetGlobalPid are needed and used to
194 // implement nacl_helper_nonsfi.
195 // The compiler defined macro to figure out if this is compiled for NaCl in
196 // SFI-mode or in Non-SFI mode is __native_client_nonsfi__.
197 #if defined(OS_POSIX) && \
198 (!defined(OS_NACL) || defined(__native_client_nonsfi__))
183 // On POSIX an IPC::Channel wraps a socketpair(), this method returns the 199 // On POSIX an IPC::Channel wraps a socketpair(), this method returns the
184 // FD # for the client end of the socket. 200 // FD # for the client end of the socket.
185 // This method may only be called on the server side of a channel. 201 // This method may only be called on the server side of a channel.
186 // This method can be called on any thread. 202 // This method can be called on any thread.
187 virtual int GetClientFileDescriptor() const = 0; 203 virtual int GetClientFileDescriptor() const = 0;
188 204
189 // Same as GetClientFileDescriptor, but transfers the ownership of the 205 // Same as GetClientFileDescriptor, but transfers the ownership of the
190 // file descriptor to the caller. 206 // file descriptor to the caller.
191 // This method can be called on any thread. 207 // This method can be called on any thread.
192 virtual int TakeClientFileDescriptor() = 0; 208 virtual int TakeClientFileDescriptor() = 0;
193 #endif // defined(OS_POSIX) && !defined(OS_NACL) 209 #endif
194 210
195 // Returns true if a named server channel is initialized on the given channel 211 // 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. 212 // ID. Even if true, the server may have already accepted a connection.
197 static bool IsNamedServerInitialized(const std::string& channel_id); 213 static bool IsNamedServerInitialized(const std::string& channel_id);
198 214
199 #if !defined(OS_NACL) 215 #if !defined(OS_NACL) || defined(__native_client_nonsfi__)
200 // Generates a channel ID that's non-predictable and unique. 216 // Generates a channel ID that's non-predictable and unique.
201 static std::string GenerateUniqueRandomChannelID(); 217 static std::string GenerateUniqueRandomChannelID();
202 218
203 // Generates a channel ID that, if passed to the client as a shared secret, 219 // 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 220 // will validate that the client's authenticity. On platforms that do not
205 // require additional this is simply calls GenerateUniqueRandomChannelID(). 221 // require additional this is simply calls GenerateUniqueRandomChannelID().
206 // For portability the prefix should not include the \ character. 222 // For portability the prefix should not include the \ character.
207 static std::string GenerateVerifiedChannelID(const std::string& prefix); 223 static std::string GenerateVerifiedChannelID(const std::string& prefix);
208 #endif 224 #endif
209 225
210 #if defined(OS_LINUX) 226 #if defined(OS_LINUX) || defined(__native_client_nonsfi__)
211 // Sandboxed processes live in a PID namespace, so when sending the IPC hello 227 // Sandboxed processes live in a PID namespace, so when sending the IPC hello
212 // message from client to server we need to send the PID from the global 228 // message from client to server we need to send the PID from the global
213 // PID namespace. 229 // PID namespace.
214 static void SetGlobalPid(int pid); 230 static void SetGlobalPid(int pid);
215 #endif 231 #endif
216 232
217 #if defined(OS_ANDROID) 233 #if defined(OS_ANDROID)
218 // Most tests are single process and work the same on all platforms. However 234 // Most tests are single process and work the same on all platforms. However
219 // in some cases we want to test multi-process, and Android differs in that it 235 // in some cases we want to test multi-process, and Android differs in that it
220 // can't 'exec' after forking. This callback resets any data in the forked 236 // can't 'exec' after forking. This callback resets any data in the forked
221 // process such that it acts similar to if it was exec'd, for tests. 237 // process such that it acts similar to if it was exec'd, for tests.
222 static void NotifyProcessForkedForTesting(); 238 static void NotifyProcessForkedForTesting();
223 #endif 239 #endif
224 240
225 }; 241 };
226 242
227 #if defined(OS_POSIX) 243 #if defined(OS_POSIX)
228 // SocketPair() creates a pair of socket FDs suitable for using with 244 // SocketPair() creates a pair of socket FDs suitable for using with
229 // IPC::Channel. 245 // IPC::Channel.
230 IPC_EXPORT bool SocketPair(int* fd1, int* fd2); 246 IPC_EXPORT bool SocketPair(int* fd1, int* fd2);
231 #endif 247 #endif
232 248
233 } // namespace IPC 249 } // namespace IPC
234 250
235 #endif // IPC_IPC_CHANNEL_H_ 251 #endif // IPC_IPC_CHANNEL_H_
OLDNEW
« no previous file with comments | « components/nacl_nonsfi.gyp ('k') | ipc/ipc_channel.cc » ('j') | ipc/ipc_channel_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698