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