blob: 0fd83e5bb656a1406cd6842a55185a4df8b96f45 [file] [log] [blame]
mtklein@google.comd36522d2013-10-16 13:02:15 +00001#include "DMReporter.h"
2
commit-bot@chromium.org0caa68a2013-10-29 15:02:17 +00003#include "SkCommandLineFlags.h"
commit-bot@chromium.org261c6662014-01-02 16:19:53 +00004#include "OverwriteLine.h"
commit-bot@chromium.org0caa68a2013-10-29 15:02:17 +00005
6DEFINE_bool(quiet, false, "If true, don't print status updates.");
7
mtklein@google.comd36522d2013-10-16 13:02:15 +00008namespace DM {
9
10void Reporter::updateStatusLine() const {
commit-bot@chromium.org0caa68a2013-10-29 15:02:17 +000011 if (FLAGS_quiet) {
12 return;
13 }
14
mtklein@google.coma7a9f372013-10-18 20:52:44 +000015 SkString status;
commit-bot@chromium.org261c6662014-01-02 16:19:53 +000016 status.printf("%s%d tasks left", kSkOverwriteLine, this->started() - this->finished());
mtklein@google.coma7a9f372013-10-18 20:52:44 +000017 const int failed = this->failed();
18 if (failed > 0) {
19 status.appendf(", %d failed", failed);
20 }
21 SkDebugf(status.c_str());
mtklein@google.comd36522d2013-10-16 13:02:15 +000022}
23
24int32_t Reporter::failed() const {
25 SkAutoMutexAcquire reader(&fMutex);
26 return fFailures.count();
27}
28
29void Reporter::fail(SkString name) {
30 SkAutoMutexAcquire writer(&fMutex);
31 fFailures.push_back(name);
32}
33
34void Reporter::getFailures(SkTArray<SkString>* failures) const {
35 SkAutoMutexAcquire reader(&fMutex);
36 *failures = fFailures;
37}
38
39} // namespace DM