mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 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: |
| 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 | |
| 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 |