ProcessType.cpp (1953B)
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/. */ 6 7 #include "ProcessType.h" 8 9 #include <cstring> 10 11 #include "mozilla/Assertions.h" 12 13 using namespace mozilla::startup; 14 15 namespace mozilla { 16 namespace startup { 17 GeckoProcessType sChildProcessType = GeckoProcessType_Default; 18 GeckoChildID sGeckoChildID = 0; 19 } // namespace startup 20 21 void SetGeckoProcessType(const char* aProcessTypeString) { 22 if (sChildProcessType != GeckoProcessType_Default && 23 sChildProcessType != GeckoProcessType_ForkServer) { 24 MOZ_CRASH("Cannot set GeckoProcessType multiple times."); 25 } 26 27 #define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \ 28 process_bin_type, procinfo_typename, \ 29 webidl_typename, allcaps_name) \ 30 if (std::strcmp(aProcessTypeString, string_name) == 0) { \ 31 sChildProcessType = GeckoProcessType::GeckoProcessType_##enum_name; \ 32 return; \ 33 } 34 #define SKIP_PROCESS_TYPE_DEFAULT 35 #if !defined(MOZ_ENABLE_FORKSERVER) 36 # define SKIP_PROCESS_TYPE_FORKSERVER 37 #endif 38 #if !defined(ENABLE_TESTS) 39 # define SKIP_PROCESS_TYPE_IPDLUNITTEST 40 #endif 41 #include "mozilla/GeckoProcessTypes.h" 42 #undef SKIP_PROCESS_TYPE_IPDLUNITTEST 43 #undef SKIP_PROCESS_TYPE_FORKSERVER 44 #undef SKIP_PROCESS_TYPE_DEFAULT 45 #undef GECKO_PROCESS_TYPE 46 47 MOZ_CRASH("aProcessTypeString is not valid."); 48 } 49 50 void SetGeckoChildID(const char* aGeckoChildIDString) { 51 sGeckoChildID = atoi(aGeckoChildIDString); 52 53 if (sGeckoChildID <= 0) { 54 MOZ_CRASH("aGeckoChildIDString is not valid."); 55 } 56 } 57 58 } // namespace mozilla