1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/src/gfxCrashReporterUtils.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef gfxCrashReporterUtils_h__ 1.10 +#define gfxCrashReporterUtils_h__ 1.11 + 1.12 +#include "gfxCore.h" 1.13 + 1.14 +namespace mozilla { 1.15 + 1.16 +/** \class ScopedGfxFeatureReporter 1.17 + * 1.18 + * On creation, adds "FeatureName?" to AppNotes 1.19 + * On destruction, adds "FeatureName-", or "FeatureName+" if you called SetSuccessful(). 1.20 + * 1.21 + * Any such string is added at most once to AppNotes, and is subsequently skipped. 1.22 + * 1.23 + * This ScopedGfxFeatureReporter class is designed to be fool-proof to use in functions that 1.24 + * have many exit points. We don't want to encourage having function with many exit points. 1.25 + * It just happens that our graphics features initialization functions are like that. 1.26 + */ 1.27 +class NS_GFX ScopedGfxFeatureReporter 1.28 +{ 1.29 +public: 1.30 + ScopedGfxFeatureReporter(const char *aFeature, bool force = false) 1.31 + : mFeature(aFeature), mStatusChar('-') 1.32 + { 1.33 + WriteAppNote(force ? '!' : '?'); 1.34 + } 1.35 + ~ScopedGfxFeatureReporter() { 1.36 + WriteAppNote(mStatusChar); 1.37 + } 1.38 + void SetSuccessful() { mStatusChar = '+'; } 1.39 + 1.40 + class AppNoteWritingRunnable; 1.41 + 1.42 +protected: 1.43 + const char *mFeature; 1.44 + char mStatusChar; 1.45 + 1.46 +private: 1.47 + void WriteAppNote(char statusChar); 1.48 +}; 1.49 + 1.50 +} // end namespace mozilla 1.51 + 1.52 +#endif // gfxCrashReporterUtils_h__