Bug 1865597 - Add error checking when initializing parallel marking and disable on...
[gecko.git] / gfx / src / gfxCrashReporterUtils.h
blob30b670df61075996b9034d737a816ea06d27c0b4
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef gfxCrashReporterUtils_h__
8 #define gfxCrashReporterUtils_h__
10 #include "nsString.h"
12 namespace mozilla {
14 /** \class ScopedGfxFeatureReporter
16 * On creation, adds "FeatureName?" to AppNotes
17 * On destruction, adds "FeatureName-", or "FeatureName+" if you called
18 * SetSuccessful().
20 * Any such string is added at most once to AppNotes, and is subsequently
21 * skipped.
23 * This ScopedGfxFeatureReporter class is designed to be fool-proof to use in
24 * functions that have many exit points. We don't want to encourage having
25 * function with many exit points. It just happens that our graphics features
26 * initialization functions are like that.
28 class ScopedGfxFeatureReporter {
29 public:
30 explicit ScopedGfxFeatureReporter(const char* aFeature, bool aForce = false)
31 : mFeature(aFeature), mStatusChar('-'), mStatusNumber(0) {
32 WriteAppNote(aForce ? '!' : '?', 0);
34 ~ScopedGfxFeatureReporter() { WriteAppNote(mStatusChar, mStatusNumber); }
35 void SetSuccessful() { mStatusChar = '+'; }
36 void SetSuccessful(int32_t aNumber) {
37 mStatusChar = '+';
38 mStatusNumber = aNumber;
41 static void AppNote(const nsACString& aMessage);
43 class AppNoteWritingRunnable;
45 protected:
46 const char* mFeature;
47 char mStatusChar;
48 int32_t mStatusNumber;
50 private:
51 void WriteAppNote(char statusChar, int32_t statusNumber);
54 } // end namespace mozilla
56 #endif // gfxCrashReporterUtils_h__