ForkServer.h (1265B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 #ifndef __FORKSERVER_H_ 7 #define __FORKSERVER_H_ 8 9 #include "mozilla/UniquePtr.h" 10 #include "mozilla/UniquePtrExtensions.h" 11 #include "base/process_util.h" 12 #include "mozilla/ipc/MiniTransceiver.h" 13 14 namespace mozilla { 15 namespace ipc { 16 17 class ForkServer { 18 public: 19 ForkServer(int* aArgc, char*** aArgv); 20 ~ForkServer() = default; 21 22 void InitProcess(int* aArgc, char*** aArgv); 23 24 static bool RunForkServer(int* aArgc, char*** aArgv); 25 26 private: 27 bool HandleMessages(); 28 bool HandleForkNewSubprocess(UniquePtr<IPC::Message> aMessage); 29 void HandleWaitPid(UniquePtr<IPC::Message> aMessage); 30 31 UniqueFileHandle mIpcFd; 32 UniquePtr<MiniTransceiver> mTcver; 33 34 int* mArgc; 35 char*** mArgv; 36 }; 37 38 enum { 39 Msg_ForkNewSubprocess__ID = 0x7f0, // a random picked number 40 Reply_ForkNewSubprocess__ID, 41 Msg_SubprocessExecInfo__ID, 42 Msg_WaitPid__ID, 43 Reply_WaitPid__ID, 44 }; 45 46 } // namespace ipc 47 } // namespace mozilla 48 49 #endif // __FORKSERVER_H_