Bug 1735252 [wpt PR 31197] - Regenerate WPT certificates, a=testonly
[gecko.git] / toolkit / crashreporter / CrashAnnotations.cpp
blobc488532b5046af7c4b00605f2de9f15fa27c9bac
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 #include "CrashAnnotations.h"
7 #include <algorithm>
8 #include <cstring>
9 #include <iterator>
11 using std::begin;
12 using std::end;
13 using std::find_if;
15 namespace CrashReporter {
17 bool AnnotationFromString(Annotation& aResult, const char* aValue) {
18 auto elem = find_if(
19 begin(kAnnotationStrings), end(kAnnotationStrings),
20 [&aValue](const char* aString) { return strcmp(aString, aValue) == 0; });
22 if (elem == end(kAnnotationStrings)) {
23 return false;
26 aResult = static_cast<Annotation>(elem - begin(kAnnotationStrings));
27 return true;
30 bool IsAnnotationWhitelistedForPing(Annotation aAnnotation) {
31 auto elem = find_if(
32 begin(kCrashPingWhitelist), end(kCrashPingWhitelist),
33 [&aAnnotation](Annotation aElement) { return aElement == aAnnotation; });
35 return elem != end(kCrashPingWhitelist);
38 } // namespace CrashReporter