mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1313327 - Flatten the Telemetry Event enums. r=janerik
To support a non-templated API for recording events by enum, all the enum values must be of the same type. Inheritence doesn't really seem to be a thing in C++ enums, so that means flattening them all into a single, big enum the way Scalars and Histograms work. Alas. Differential Revision: https://phabricator.services.mozilla.com/D18691 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
fc8592cd08
commit
e2b7d6e230
@ -21,11 +21,11 @@ file_header = """\
|
||||
#define mozilla_TelemetryEventEnums_h
|
||||
namespace mozilla {
|
||||
namespace Telemetry {
|
||||
namespace EventID {
|
||||
enum class EventID : uint32_t {\
|
||||
"""
|
||||
|
||||
file_footer = """\
|
||||
} // namespace EventID
|
||||
};
|
||||
} // namespace mozilla
|
||||
} // namespace Telemetry
|
||||
#endif // mozilla_TelemetryEventEnums_h
|
||||
@ -59,21 +59,16 @@ def main(output, *filenames):
|
||||
for category, indexed in grouped.iteritems():
|
||||
category_cpp = indexed[0][1].category_cpp
|
||||
|
||||
print("// category: %s" % category, file=output)
|
||||
print("enum class %s : uint32_t {" % category_cpp, file=output)
|
||||
print(" // category: %s" % category, file=output)
|
||||
|
||||
for event_index, e in indexed:
|
||||
if e.record_on_os(buildconfig.substs["OS_TARGET"]):
|
||||
for offset, label in enumerate(e.enum_labels):
|
||||
print(" %s = %d," % (label, event_index + offset), file=output)
|
||||
print(" %s_%s = %d,"
|
||||
% (category_cpp, label, event_index + offset), file=output)
|
||||
|
||||
print("};\n", file=output)
|
||||
|
||||
print("#if defined(_MSC_VER) && !defined(__clang__)", file=output)
|
||||
print("const uint32_t EventCount = %d;" % index, file=output)
|
||||
print("#else", file=output)
|
||||
print("constexpr uint32_t EventCount = %d;" % index, file=output)
|
||||
print("#endif\n", file=output)
|
||||
print(" // meta", file=output)
|
||||
print(" EventCount = %d," % index, file=output)
|
||||
|
||||
print(file_footer, file=output)
|
||||
|
||||
|
@ -99,7 +99,8 @@ namespace TelemetryIPCAccumulator = mozilla::TelemetryIPCAccumulator;
|
||||
|
||||
namespace {
|
||||
|
||||
const uint32_t kEventCount = mozilla::Telemetry::EventID::EventCount;
|
||||
const uint32_t kEventCount =
|
||||
static_cast<uint32_t>(mozilla::Telemetry::EventID::EventCount);
|
||||
// This is a special event id used to mark expired events, to make expiry checks
|
||||
// cheap at runtime.
|
||||
const uint32_t kExpiredEventId = std::numeric_limits<uint32_t>::max();
|
||||
|
Loading…
Reference in New Issue
Block a user