• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef DMReporter_DEFINED
2 #define DMReporter_DEFINED
3 
4 #include "SkString.h"
5 #include "SkTArray.h"
6 #include "SkThread.h"
7 #include "SkTypes.h"
8 
9 // Used to report status changes including failures.  All public methods are threadsafe.
10 
11 namespace DM {
12 
13 class Reporter : SkNoncopyable {
14 public:
Reporter()15     Reporter() : fStarted(0), fFinished(0) {}
16 
start()17     void start()  { sk_atomic_inc(&fStarted); }
finish()18     void finish() { sk_atomic_inc(&fFinished); }
19     void fail(SkString name);
20 
started()21     int32_t started()  const { return fStarted; }
finished()22     int32_t finished() const { return fFinished; }
23     int32_t failed()   const;
24 
25     void updateStatusLine() const;
26 
27     void getFailures(SkTArray<SkString>*) const;
28 
29 private:
30     int32_t fStarted, fFinished;
31 
32     mutable SkMutex fMutex;  // Guards fFailures.
33     SkTArray<SkString> fFailures;
34 };
35 
36 
37 }  // namespace DM
38 
39 #endif  // DMReporter_DEFINED
40