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" |
commit-bot@chromium.org | a39874b | 2014-03-03 15:44:56 +0000 | [diff] [blame] | 7 | #include "SkTime.h" |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 8 | #include "SkTypes.h" |
| 9 | |
| 10 | // Used to report status changes including failures. All public methods are threadsafe. |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 11 | namespace DM { |
| 12 | |
| 13 | class Reporter : SkNoncopyable { |
| 14 | public: |
| 15 | Reporter() : fStarted(0), fFinished(0) {} |
| 16 | |
| 17 | void start() { sk_atomic_inc(&fStarted); } |
commit-bot@chromium.org | a39874b | 2014-03-03 15:44:56 +0000 | [diff] [blame] | 18 | void finish(SkString name, SkMSec timeMs); |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 19 | void fail(SkString msg); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 20 | |
| 21 | int32_t started() const { return fStarted; } |
| 22 | int32_t finished() const { return fFinished; } |
| 23 | int32_t failed() const; |
| 24 | |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 25 | void getFailures(SkTArray<SkString>*) const; |
| 26 | |
| 27 | private: |
| 28 | int32_t fStarted, fFinished; |
| 29 | |
| 30 | mutable SkMutex fMutex; // Guards fFailures. |
| 31 | SkTArray<SkString> fFailures; |
| 32 | }; |
| 33 | |
| 34 | |
| 35 | } // namespace DM |
| 36 | |
| 37 | #endif // DMReporter_DEFINED |