michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef gfxCrashReporterUtils_h__ michael@0: #define gfxCrashReporterUtils_h__ michael@0: michael@0: #include "gfxCore.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: /** \class ScopedGfxFeatureReporter michael@0: * michael@0: * On creation, adds "FeatureName?" to AppNotes michael@0: * On destruction, adds "FeatureName-", or "FeatureName+" if you called SetSuccessful(). michael@0: * michael@0: * Any such string is added at most once to AppNotes, and is subsequently skipped. michael@0: * michael@0: * This ScopedGfxFeatureReporter class is designed to be fool-proof to use in functions that michael@0: * have many exit points. We don't want to encourage having function with many exit points. michael@0: * It just happens that our graphics features initialization functions are like that. michael@0: */ michael@0: class NS_GFX ScopedGfxFeatureReporter michael@0: { michael@0: public: michael@0: ScopedGfxFeatureReporter(const char *aFeature, bool force = false) michael@0: : mFeature(aFeature), mStatusChar('-') michael@0: { michael@0: WriteAppNote(force ? '!' : '?'); michael@0: } michael@0: ~ScopedGfxFeatureReporter() { michael@0: WriteAppNote(mStatusChar); michael@0: } michael@0: void SetSuccessful() { mStatusChar = '+'; } michael@0: michael@0: class AppNoteWritingRunnable; michael@0: michael@0: protected: michael@0: const char *mFeature; michael@0: char mStatusChar; michael@0: michael@0: private: michael@0: void WriteAppNote(char statusChar); michael@0: }; michael@0: michael@0: } // end namespace mozilla michael@0: michael@0: #endif // gfxCrashReporterUtils_h__