Bug 1869043 allow a device to be specified with MediaTrackGraph::NotifyWhenDeviceStar...
[gecko.git] / toolkit / crashreporter / CrashAnnotations.h.in
blobc87ad4a2eab6325085f2d662bc26517ca0868ea3
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef CrashAnnotations_h
6 #define CrashAnnotations_h
8 #include <cstddef>
9 #include <cstdint>
11 namespace CrashReporter {
13 // Typed enum representing all crash annotations
14 enum class Annotation : uint32_t {
15 ${enum}
18 // Stringified crash annotation names
19 const char* const kAnnotationStrings[] = {
20 ${strings}
23 // Allowlist of crash annotations that can be included in a crash ping
24 const Annotation kCrashPingAllowlist[] = {
25 ${allowlist}
28 /**
29 * Return the string representation of a crash annotation.
31 * @param aAnnotation a crash annotation
32 * @returns A constant string holding the annotation name
34 static inline const char* AnnotationToString(Annotation aAnnotation) {
35 return kAnnotationStrings[static_cast<uint32_t>(aAnnotation)];
38 /**
39 * Converts a string to its corresponding crash annotation.
41 * @param aResult a reference where the annotation will be stored
42 * @param aValue the string to be converted
43 * @return true if the string was successfully converted, false if it did not
44 * correspond to any known annotation
46 bool AnnotationFromString(Annotation& aResult, const char* aValue);
48 /**
49 * Checks if the given crash annotation is allowlisted for inclusion in the
50 * crash ping.
52 * @param aAnnotation the crash annotation to be checked
53 * @return true if the annotation can be included in the crash ping, false
54 * otherwise
56 bool IsAnnotationAllowlistedForPing(Annotation aAnnotation);
58 /**
59 * Abstract annotation writer, this is needed only for code that writes out
60 * annotations in the exception handler.
62 class AnnotationWriter {
63 public:
64 virtual void Write(Annotation aAnnotation, const char* aValue,
65 size_t aLen = 0) = 0;
66 virtual void Write(Annotation aAnnotation, uint64_t aValue) = 0;
69 } // namespace CrashReporter
71 #endif // CrashAnnotations_h