no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / ipc / glue / ProcessChild.h
blobf881b316cf032eb4e36ace59a02dfd1d23f0b049
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/. */
7 #ifndef mozilla_ipc_ProcessChild_h
8 #define mozilla_ipc_ProcessChild_h
10 #include "Endpoint.h"
11 #include "base/message_loop.h"
12 #include "base/process.h"
14 #include "chrome/common/child_process.h"
16 #include "mozilla/ipc/ProcessUtils.h"
18 // ProcessChild is the base class for all subprocesses of the main
19 // browser process. Its code runs on the thread that started in
20 // main().
22 namespace mozilla {
23 namespace ipc {
25 class ProcessChild : public ChildProcess {
26 protected:
27 typedef base::ProcessId ProcessId;
29 public:
30 explicit ProcessChild(ProcessId aParentPid, const nsID& aMessageChannelId);
32 ProcessChild(const ProcessChild&) = delete;
33 ProcessChild& operator=(const ProcessChild&) = delete;
35 virtual ~ProcessChild();
37 virtual bool Init(int aArgc, char* aArgv[]) = 0;
39 static void AddPlatformBuildID(std::vector<std::string>& aExtraArgs);
41 static bool InitPrefs(int aArgc, char* aArgv[]);
43 virtual void CleanUp() {}
45 static MessageLoop* message_loop() { return gProcessChild->mUILoop; }
47 static void NotifiedImpendingShutdown();
49 static bool ExpectingShutdown();
51 static void AppendToIPCShutdownStateAnnotation(const nsCString& aStr) {
52 StaticMutexAutoLock lock(gIPCShutdownStateLock);
53 gIPCShutdownStateAnnotation.Append(" - "_ns);
54 gIPCShutdownStateAnnotation.Append(aStr);
57 /**
58 * Exit *now*. Do not shut down XPCOM, do not pass Go, do not run
59 * static destructors, do not collect $200.
61 static void QuickExit();
63 protected:
64 static ProcessChild* current() { return gProcessChild; }
66 ProcessId ParentPid() { return mParentPid; }
68 UntypedEndpoint TakeInitialEndpoint();
70 private:
71 static ProcessChild* gProcessChild;
72 static StaticMutex gIPCShutdownStateLock;
73 static nsCString gIPCShutdownStateAnnotation
74 MOZ_GUARDED_BY(gIPCShutdownStateLock);
76 MessageLoop* mUILoop;
77 ProcessId mParentPid;
78 nsID mMessageChannelId;
81 } // namespace ipc
82 } // namespace mozilla
84 #endif // ifndef mozilla_ipc_ProcessChild_h