blob: 3f8e953a71af71e7906f5e7c4bd60f9fa11933e8 [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"
commit-bot@chromium.orga39874b2014-03-03 15:44:56 +00007#include "SkTime.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00008#include "SkTypes.h"
9
10// Used to report status changes including failures. All public methods are threadsafe.
mtklein@google.comd36522d2013-10-16 13:02:15 +000011namespace DM {
12
13class Reporter : SkNoncopyable {
14public:
15 Reporter() : fStarted(0), fFinished(0) {}
16
17 void start() { sk_atomic_inc(&fStarted); }
commit-bot@chromium.orga39874b2014-03-03 15:44:56 +000018 void finish(SkString name, SkMSec timeMs);
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000019 void fail(SkString msg);
mtklein@google.comd36522d2013-10-16 13:02:15 +000020
21 int32_t started() const { return fStarted; }
22 int32_t finished() const { return fFinished; }
23 int32_t failed() const;
24
mtklein@google.comd36522d2013-10-16 13:02:15 +000025 void getFailures(SkTArray<SkString>*) const;
26
27private:
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