Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/gfxCrashReporterUtils.h
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
#ifndef gfxCrashReporterUtils_h__
8
#define gfxCrashReporterUtils_h__
9
10
#include "nsString.h"
11
12
namespace mozilla {
13
14
/** \class ScopedGfxFeatureReporter
15
  *
16
  * On creation, adds "FeatureName?" to AppNotes
17
  * On destruction, adds "FeatureName-", or "FeatureName+" if you called SetSuccessful().
18
  *
19
  * Any such string is added at most once to AppNotes, and is subsequently skipped.
20
  *
21
  * This ScopedGfxFeatureReporter class is designed to be fool-proof to use in functions that
22
  * have many exit points. We don't want to encourage having function with many exit points.
23
  * It just happens that our graphics features initialization functions are like that.
24
  */
25
class ScopedGfxFeatureReporter
26
{
27
public:
28
  explicit ScopedGfxFeatureReporter(const char *aFeature, bool aForce = false)
29
    : mFeature(aFeature), mStatusChar('-'), mStatusNumber(0)
30
0
  {
31
0
    WriteAppNote(aForce ? '!' : '?', 0);
32
0
  }
33
0
  ~ScopedGfxFeatureReporter() {
34
0
    WriteAppNote(mStatusChar, mStatusNumber);
35
0
  }
36
0
  void SetSuccessful() { mStatusChar = '+'; }
37
  void SetSuccessful(int32_t aNumber)
38
0
  {
39
0
    mStatusChar = '+';
40
0
    mStatusNumber = aNumber;
41
0
  }
42
43
  static void AppNote(const nsACString& aMessage);
44
45
  class AppNoteWritingRunnable;
46
47
protected:
48
  const char *mFeature;
49
  char mStatusChar;
50
  int32_t mStatusNumber;
51
52
private:
53
  void WriteAppNote(char statusChar, int32_t statusNumber);
54
};
55
56
} // end namespace mozilla
57
58
#endif // gfxCrashReporterUtils_h__