Commit 1265dbe6 by Jordan Bayles Committed by Commit Bot

Update JsonCpp usage

This patch updates usages of the JsonCpp library, including the following changes: 1. Removed unused version variable from the DEPS file. 2. Removed deprecated writer and reader usages, in favor of the new builder pattern inside JsonCpp. 3. Modernized usage of the Json::Value types, including some rewrites to avoid unnecessary heap allocations, and using the new foreach iterators. Bug: chromium:983223 Change-Id: If26abc8be677d905183a23498fbb81256854525c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2265093Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 8804d35c
...@@ -35,6 +35,17 @@ vars = { ...@@ -35,6 +35,17 @@ vars = {
# Note: this dep cannot be auto-rolled b/c of nesting. # Note: this dep cannot be auto-rolled b/c of nesting.
'jsoncpp_revision': '645250b6690785be60ab6780ce4b58698d884d11', 'jsoncpp_revision': '645250b6690785be60ab6780ce4b58698d884d11',
# Current revision of Chrome's third_party jsoncpp directory. This repository
# is mirrored as a separate repository, with separate git hashes that
# don't match the external JsonCpp repository or Chrome. Mirrored patches
# will have a different git hash associated with them.
# To roll, first get the new hash for chromium_jsoncpp_revision from the
# mirror of third_party/jsoncpp located here:
# https://chromium.googlesource.com/chromium/src/third_party/jsoncpp/
# Then get the new hash for jsoncpp_revision from the root Chrome DEPS file:
# https://source.chromium.org/chromium/chromium/src/+/master:DEPS
'chromium_jsoncpp_revision': 'ec647b85b61f525a1a74e4da7477b0c5371c50f4',
# Current revision of patched-yasm. # Current revision of patched-yasm.
# Note: this dep cannot be auto-rolled b/c of nesting. # Note: this dep cannot be auto-rolled b/c of nesting.
'patched_yasm_revision': '720b70524a4424b15fc57e82263568c8ba0496ad', 'patched_yasm_revision': '720b70524a4424b15fc57e82263568c8ba0496ad',
...@@ -136,7 +147,7 @@ deps = { ...@@ -136,7 +147,7 @@ deps = {
}, },
'third_party/jsoncpp': { 'third_party/jsoncpp': {
'url': '{chromium_git}/chromium/src/third_party/jsoncpp@ec647b85b61f525a1a74e4da7477b0c5371c50f4', 'url': '{chromium_git}/chromium/src/third_party/jsoncpp@{chromium_jsoncpp_revision}',
'condition': 'not build_with_chromium', 'condition': 'not build_with_chromium',
}, },
......
...@@ -131,7 +131,7 @@ TEST_F(FeatureSupportUtilTest, TestRuleProcessing) ...@@ -131,7 +131,7 @@ TEST_F(FeatureSupportUtilTest, TestRuleProcessing)
{ {
"Vendor" : "GPUVendorA", "Vendor" : "GPUVendorA",
"DeviceId" : 234, "DeviceId" : 234,
"VerMajor" : 1, "VerMinor" : 2, "VerSubMinor" : 3, "VerPatch" : 4} "VerMajor" : 1, "VerMinor" : 2, "VerSubMinor" : 3, "VerPatch" : 4
} }
] ]
} }
......
...@@ -128,20 +128,16 @@ void DumpTraceEventsToJSONFile(const std::vector<TraceEvent> &traceEvents, ...@@ -128,20 +128,16 @@ void DumpTraceEventsToJSONFile(const std::vector<TraceEvent> &traceEvents,
{ {
Json::Value value(Json::objectValue); Json::Value value(Json::objectValue);
std::stringstream phaseName; const auto microseconds = static_cast<Json::LargestInt>(traceEvent.timestamp) * 1000 * 1000;
phaseName << traceEvent.phase;
const auto microseconds =
static_cast<Json::LargestInt>(traceEvent.timestamp * 1000.0 * 1000.0);
value["name"] = traceEvent.name; value["name"] = traceEvent.name;
value["cat"] = traceEvent.categoryName; value["cat"] = traceEvent.categoryName;
value["ph"] = phaseName.str(); value["ph"] = std::string(1, traceEvent.phase);
value["ts"] = microseconds; value["ts"] = microseconds;
value["pid"] = strcmp(traceEvent.categoryName, "gpu.angle.gpu") == 0 ? "GPU" : "ANGLE"; value["pid"] = strcmp(traceEvent.categoryName, "gpu.angle.gpu") == 0 ? "GPU" : "ANGLE";
value["tid"] = 1; value["tid"] = 1;
eventsValue.append(value); eventsValue.append(std::move(value));
} }
Json::Value root(Json::objectValue); Json::Value root(Json::objectValue);
...@@ -150,8 +146,10 @@ void DumpTraceEventsToJSONFile(const std::vector<TraceEvent> &traceEvents, ...@@ -150,8 +146,10 @@ void DumpTraceEventsToJSONFile(const std::vector<TraceEvent> &traceEvents,
std::ofstream outFile; std::ofstream outFile;
outFile.open(outputFileName); outFile.open(outputFileName);
Json::StyledWriter styledWrite; Json::StreamWriterBuilder factory;
outFile << styledWrite.write(root); std::unique_ptr<Json::StreamWriter> const writer(factory.newStreamWriter());
std::ostringstream stream;
writer->write(root, &outFile);
outFile.close(); outFile.close();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment