Line data Source code
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 "nsString.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 ScopedGfxFeatureReporter
25 : {
26 : public:
27 3 : explicit ScopedGfxFeatureReporter(const char *aFeature, bool aForce = false)
28 3 : : mFeature(aFeature), mStatusChar('-')
29 : {
30 3 : WriteAppNote(aForce ? '!' : '?');
31 3 : }
32 6 : ~ScopedGfxFeatureReporter() {
33 3 : WriteAppNote(mStatusChar);
34 3 : }
35 0 : void SetSuccessful() { mStatusChar = '+'; }
36 :
37 : static void AppNote(const nsACString& aMessage);
38 :
39 : class AppNoteWritingRunnable;
40 :
41 : protected:
42 : const char *mFeature;
43 : char mStatusChar;
44 :
45 : private:
46 : void WriteAppNote(char statusChar);
47 : };
48 :
49 : } // end namespace mozilla
50 :
51 : #endif // gfxCrashReporterUtils_h__
|