Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Unified Diff: dm/DMJsonWriter.cpp

Issue 863093003: add -r to DM (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: small things Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« dm/DM.cpp ('K') | « dm/DMJsonWriter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMJsonWriter.cpp
diff --git a/dm/DMJsonWriter.cpp b/dm/DMJsonWriter.cpp
index 8aea814aed8063341587cfeea84093579070af66..56c1301df166ad1a70c49f54dec7b4c74e51db38 100644
--- a/dm/DMJsonWriter.cpp
+++ b/dm/DMJsonWriter.cpp
@@ -8,6 +8,7 @@
#include "DMJsonWriter.h"
#include "SkCommonFlags.h"
+#include "SkData.h"
#include "SkJSONCPP.h"
#include "SkOSFile.h"
#include "SkStream.h"
@@ -79,4 +80,31 @@ void JsonWriter::DumpJson() {
stream.flush();
}
+bool JsonWriter::ReadJson(const char* path, void(*callback)(BitmapResult)) {
+ SkAutoTUnref<SkData> json(SkData::NewFromFileName(path));
+ if (!json) {
+ return false;
+ }
+
+ Json::Reader reader;
+ Json::Value root;
+ const char* data = (const char*)json->data();
+ if (!reader.parse(data, data+json->size(), root)) {
+ return false;
+ }
+
+ const Json::Value& results = root["results"];
+ BitmapResult br;
+ for (unsigned i = 0; i < results.size(); i++) {
+ const Json::Value& r = results[i];
+ br.name = r["key"]["name"].asCString();
+ br.config = r["key"]["config"].asCString();
+ br.sourceType = r["key"]["source_type"].asCString();
+ br.ext = r["ext"].asCString();
+ br.md5 = r["md5"].asCString();
+ callback(br);
+ }
+ return true;
+}
+
} // namespace DM
« dm/DM.cpp ('K') | « dm/DMJsonWriter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698