| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "DMJsonWriter.h" | 8 #include "DMJsonWriter.h" |
| 9 | 9 |
| 10 #include "ProcStats.h" | 10 #include "ProcStats.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 | 89 |
| 90 SkString path = SkOSPath::Join(FLAGS_writePath[0], "dm.json"); | 90 SkString path = SkOSPath::Join(FLAGS_writePath[0], "dm.json"); |
| 91 sk_mkdir(FLAGS_writePath[0]); | 91 sk_mkdir(FLAGS_writePath[0]); |
| 92 SkFILEWStream stream(path.c_str()); | 92 SkFILEWStream stream(path.c_str()); |
| 93 stream.writeText(Json::StyledWriter().write(root).c_str()); | 93 stream.writeText(Json::StyledWriter().write(root).c_str()); |
| 94 stream.flush(); | 94 stream.flush(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool JsonWriter::ReadJson(const char* path, void(*callback)(BitmapResult)) { | 97 bool JsonWriter::ReadJson(const char* path, void(*callback)(BitmapResult)) { |
| 98 SkAutoTUnref<SkData> json(SkData::NewFromFileName(path)); | 98 sk_sp<SkData> json(SkData::MakeFromFileName(path)); |
| 99 if (!json) { | 99 if (!json) { |
| 100 return false; | 100 return false; |
| 101 } | 101 } |
| 102 | 102 |
| 103 Json::Reader reader; | 103 Json::Reader reader; |
| 104 Json::Value root; | 104 Json::Value root; |
| 105 const char* data = (const char*)json->data(); | 105 const char* data = (const char*)json->data(); |
| 106 if (!reader.parse(data, data+json->size(), root)) { | 106 if (!reader.parse(data, data+json->size(), root)) { |
| 107 return false; | 107 return false; |
| 108 } | 108 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 120 | 120 |
| 121 if (!r["key"]["source_options"].isNull()) { | 121 if (!r["key"]["source_options"].isNull()) { |
| 122 br.sourceOptions = r["key"]["source_options"].asCString(); | 122 br.sourceOptions = r["key"]["source_options"].asCString(); |
| 123 } | 123 } |
| 124 callback(br); | 124 callback(br); |
| 125 } | 125 } |
| 126 return true; | 126 return true; |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace DM | 129 } // namespace DM |
| OLD | NEW |