/src/mozilla-central/toolkit/crashreporter/CrashAnnotations.cpp
Line | Count | Source (jump to first uncovered line) |
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/. */ |
4 | | |
5 | | #include "CrashAnnotations.h" |
6 | | |
7 | | #include <algorithm> |
8 | | #include <cstring> |
9 | | #include <iterator> |
10 | | |
11 | | using std::begin; |
12 | | using std::end; |
13 | | using std::find_if; |
14 | | |
15 | | namespace CrashReporter { |
16 | | |
17 | | bool |
18 | | AnnotationFromString(Annotation& aResult, const char* aValue) |
19 | 0 | { |
20 | 0 | auto elem = find_if( |
21 | 0 | begin(kAnnotationStrings), |
22 | 0 | end(kAnnotationStrings), |
23 | 0 | [&aValue](const char* aString) { |
24 | 0 | return strcmp(aString, aValue) == 0; |
25 | 0 | } |
26 | 0 | ); |
27 | 0 |
|
28 | 0 | if (elem == end(kAnnotationStrings)) { |
29 | 0 | return false; |
30 | 0 | } |
31 | 0 | |
32 | 0 | aResult = static_cast<Annotation>(elem - begin(kAnnotationStrings)); |
33 | 0 | return true; |
34 | 0 | } |
35 | | |
36 | | bool |
37 | 0 | IsAnnotationWhitelistedForPing(Annotation aAnnotation) { |
38 | 0 | auto elem = find_if( |
39 | 0 | begin(kCrashPingWhitelist), |
40 | 0 | end(kCrashPingWhitelist), |
41 | 0 | [&aAnnotation](Annotation aElement) { |
42 | 0 | return aElement == aAnnotation; |
43 | 0 | } |
44 | 0 | ); |
45 | 0 |
|
46 | 0 | return elem != end(kCrashPingWhitelist); |
47 | 0 | } |
48 | | |
49 | | bool |
50 | | IsAnnotationBlacklistedForContent(Annotation aAnnotation) |
51 | 0 | { |
52 | 0 | auto elem = find_if( |
53 | 0 | begin(kContentProcessBlacklist), |
54 | 0 | end(kContentProcessBlacklist), |
55 | 0 | [&aAnnotation](Annotation aElement) { |
56 | 0 | return aElement == aAnnotation; |
57 | 0 | } |
58 | 0 | ); |
59 | 0 |
|
60 | 0 | return elem != end(kContentProcessBlacklist); |
61 | 0 | } |
62 | | |
63 | | } // namespace CrashReporter |