Merge mozilla-central to autoland. CLOSED TREE
[gecko.git] / mozglue / misc / ProcessType.cpp
blob031d2423289cec89f60006dff9286539eed748b0
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "ProcessType.h"
9 #include <cstring>
11 #include "mozilla/Assertions.h"
13 using namespace mozilla::startup;
15 namespace mozilla {
16 namespace startup {
17 GeckoProcessType sChildProcessType = GeckoProcessType_Default;
18 } // namespace startup
20 void SetGeckoProcessType(const char* aProcessTypeString) {
21 #if !defined(DEBUG)
22 // If not a DEBUG build then just return if sChildProcessType has already been
23 // set and is not fork server. In DEBUG builds we will check that process type
24 // matches the one already set if it is not fork server.
25 if (sChildProcessType != GeckoProcessType_Default &&
26 sChildProcessType != GeckoProcessType_ForkServer) {
27 return;
29 #endif
31 #define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
32 process_bin_type, procinfo_typename, \
33 webidl_typename, allcaps_name) \
34 if (std::strcmp(aProcessTypeString, string_name) == 0) { \
35 MOZ_ASSERT_IF( \
36 sChildProcessType != GeckoProcessType_Default && \
37 sChildProcessType != GeckoProcessType_ForkServer, \
38 sChildProcessType == GeckoProcessType::GeckoProcessType_##enum_name); \
39 sChildProcessType = GeckoProcessType::GeckoProcessType_##enum_name; \
40 return; \
42 #define SKIP_PROCESS_TYPE_DEFAULT
43 #if !defined(MOZ_ENABLE_FORKSERVER)
44 # define SKIP_PROCESS_TYPE_FORKSERVER
45 #endif
46 #if !defined(ENABLE_TESTS)
47 # define SKIP_PROCESS_TYPE_IPDLUNITTEST
48 #endif
49 #include "mozilla/GeckoProcessTypes.h"
50 #undef SKIP_PROCESS_TYPE_IPDLUNITTEST
51 #undef SKIP_PROCESS_TYPE_FORKSERVER
52 #undef SKIP_PROCESS_TYPE_DEFAULT
53 #undef GECKO_PROCESS_TYPE
55 MOZ_CRASH("aProcessTypeString is not valid.");
58 } // namespace mozilla