ProcessType.h (2012B)
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 #ifndef IPC_PROCESSTYPE_H_ 8 #define IPC_PROCESSTYPE_H_ 9 10 #include "mozilla/Attributes.h" 11 #include "mozilla/Types.h" 12 13 #include <cstdint> 14 15 // This enum is not dense. See GeckoProcessTypes.h for details. 16 enum GeckoProcessType { 17 #define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \ 18 process_bin_type, procinfo_typename, \ 19 webidl_typename, allcaps_name) \ 20 GeckoProcessType_##enum_name = (enum_value), 21 #include "mozilla/GeckoProcessTypes.h" 22 #undef GECKO_PROCESS_TYPE 23 GeckoProcessType_End, 24 GeckoProcessType_Invalid = GeckoProcessType_End 25 }; 26 27 // Integral type used for GeckoChildIDs. A ChildID of -1 is used as the invalid 28 // sentinel, and 0 indicates the parent process. 29 using GeckoChildID = int32_t; 30 31 inline constexpr GeckoChildID kInvalidGeckoChildID = -1; 32 33 namespace mozilla { 34 namespace startup { 35 extern MFBT_DATA GeckoProcessType sChildProcessType; 36 extern MFBT_DATA GeckoChildID sGeckoChildID; 37 } // namespace startup 38 39 /** 40 * @return the GeckoProcessType of the current process. 41 */ 42 MOZ_ALWAYS_INLINE GeckoProcessType GetGeckoProcessType() { 43 return startup::sChildProcessType; 44 } 45 46 /** 47 * Set the gecko process type based on a null-terminated byte string. 48 */ 49 MFBT_API void SetGeckoProcessType(const char* aProcessTypeString); 50 51 /** 52 * @return the GeckoChildID of the current process. 53 */ 54 MOZ_ALWAYS_INLINE GeckoChildID GetGeckoChildID() { 55 return startup::sGeckoChildID; 56 } 57 58 /** 59 * Set the gecko child id based on a null-terminated byte string. 60 */ 61 MFBT_API void SetGeckoChildID(const char* aGeckoChildIDString); 62 63 } // namespace mozilla 64 65 #endif // IPC_PROCESSTYPE_H_