blob: 4f4ad432d5186db441b28401f88af11b12c59834 [file] [log] [blame]
mtklein@google.comd36522d2013-10-16 13:02:15 +00001#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
11namespace DM {
12
13class Reporter : SkNoncopyable {
14public:
15 Reporter() : fStarted(0), fFinished(0) {}
16
17 void start() { sk_atomic_inc(&fStarted); }
18 void finish() { sk_atomic_inc(&fFinished); }
19 void fail(SkString name);
20
21 int32_t started() const { return fStarted; }
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
29private:
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