1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is Mozilla Corporation code.
16 : *
17 : * The Initial Developer of the Original Code is Mozilla Foundation.
18 : * Portions created by the Initial Developer are Copyright (C) 2011
19 : * the Initial Developer. All Rights Reserved.
20 : *
21 : * Alternatively, the contents of this file may be used under the terms of
22 : * either of the GNU General Public License Version 2 or later (the "GPL"),
23 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
24 : * in which case the provisions of the GPL or the LGPL are applicable instead
25 : * of those above. If you wish to allow use of your version of this file only
26 : * under the terms of either the GPL or the LGPL, and not to allow others to
27 : * use your version of this file under the terms of the MPL, indicate your
28 : * decision by deleting the provisions above and replace them with the notice
29 : * and other provisions required by the GPL or the LGPL. If you do not delete
30 : * the provisions above, a recipient may use your version of this file under
31 : * the terms of any one of the MPL, the GPL or the LGPL.
32 : *
33 : * ***** END LICENSE BLOCK ***** */
34 :
35 : #ifndef gfxCrashReporterUtils_h__
36 : #define gfxCrashReporterUtils_h__
37 :
38 : #include "gfxCore.h"
39 :
40 : namespace mozilla {
41 :
42 : /** \class ScopedGfxFeatureReporter
43 : *
44 : * On creation, adds "FeatureName?" to AppNotes
45 : * On destruction, adds "FeatureName-", or "FeatureName+" if you called SetSuccessful().
46 : *
47 : * Any such string is added at most once to AppNotes, and is subsequently skipped.
48 : *
49 : * This ScopedGfxFeatureReporter class is designed to be fool-proof to use in functions that
50 : * have many exit points. We don't want to encourage having function with many exit points.
51 : * It just happens that our graphics features initialization functions are like that.
52 : */
53 : class NS_GFX ScopedGfxFeatureReporter
54 : {
55 : public:
56 0 : ScopedGfxFeatureReporter(const char *aFeature, bool force = false)
57 0 : : mFeature(aFeature), mStatusChar('-')
58 : {
59 0 : WriteAppNote(force ? '!' : '?');
60 0 : }
61 0 : ~ScopedGfxFeatureReporter() {
62 0 : WriteAppNote(mStatusChar);
63 0 : }
64 0 : void SetSuccessful() { mStatusChar = '+'; }
65 :
66 : protected:
67 : const char *mFeature;
68 : char mStatusChar;
69 :
70 : private:
71 : void WriteAppNote(char statusChar);
72 : };
73 :
74 : } // end namespace mozilla
75 :
76 : #endif // gfxCrashReporterUtils_h__
|