|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef gfxCrashReporterUtils_h__ |
|
7 #define gfxCrashReporterUtils_h__ |
|
8 |
|
9 #include "gfxCore.h" |
|
10 |
|
11 namespace mozilla { |
|
12 |
|
13 /** \class ScopedGfxFeatureReporter |
|
14 * |
|
15 * On creation, adds "FeatureName?" to AppNotes |
|
16 * On destruction, adds "FeatureName-", or "FeatureName+" if you called SetSuccessful(). |
|
17 * |
|
18 * Any such string is added at most once to AppNotes, and is subsequently skipped. |
|
19 * |
|
20 * This ScopedGfxFeatureReporter class is designed to be fool-proof to use in functions that |
|
21 * have many exit points. We don't want to encourage having function with many exit points. |
|
22 * It just happens that our graphics features initialization functions are like that. |
|
23 */ |
|
24 class NS_GFX ScopedGfxFeatureReporter |
|
25 { |
|
26 public: |
|
27 ScopedGfxFeatureReporter(const char *aFeature, bool force = false) |
|
28 : mFeature(aFeature), mStatusChar('-') |
|
29 { |
|
30 WriteAppNote(force ? '!' : '?'); |
|
31 } |
|
32 ~ScopedGfxFeatureReporter() { |
|
33 WriteAppNote(mStatusChar); |
|
34 } |
|
35 void SetSuccessful() { mStatusChar = '+'; } |
|
36 |
|
37 class AppNoteWritingRunnable; |
|
38 |
|
39 protected: |
|
40 const char *mFeature; |
|
41 char mStatusChar; |
|
42 |
|
43 private: |
|
44 void WriteAppNote(char statusChar); |
|
45 }; |
|
46 |
|
47 } // end namespace mozilla |
|
48 |
|
49 #endif // gfxCrashReporterUtils_h__ |