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

Unified Diff: apps/benchmark/event.cc

Issue 1343413002: Make `benchmark.mojo` resilient to incorrect trace events. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | mojo/devtools/common/mojo_benchmark » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/benchmark/event.cc
diff --git a/apps/benchmark/event.cc b/apps/benchmark/event.cc
index e782b57ba472bbaa6a20cf6a894e88740c1aae5e..74dc83b699e2149484113e1911c18ed6034cdb87 100644
--- a/apps/benchmark/event.cc
+++ b/apps/benchmark/event.cc
@@ -100,15 +100,17 @@ bool ParseEvents(base::ListValue* event_list, std::vector<Event>* result) {
for (base::Value* val : *event_list) {
base::DictionaryValue* event_dict;
- if (!val->GetAsDictionary(&event_dict))
- return false;
+ if (!val->GetAsDictionary(&event_dict)) {
+ LOG(WARNING) << "Ignoring incorrect trace event (not a dictionary)";
+ continue;
+ }
Event event;
std::string phase;
if (!event_dict->GetString("ph", &phase)) {
- LOG(ERROR) << "Incorrect trace event (missing phase)";
- return false;
+ LOG(WARNING) << "Ignoring incorrect trace event (missing phase)";
+ continue;
}
if (phase == "X") {
event.type = EventType::COMPLETE;
@@ -125,22 +127,22 @@ bool ParseEvents(base::ListValue* event_list, std::vector<Event>* result) {
}
if (!event_dict->GetString("cat", &event.categories)) {
- LOG(ERROR) << "Incorrect trace event (no categories)";
- return false;
+ LOG(WARNING) << "Ignoring incorrect trace event (no categories)";
+ continue;
}
double timestamp;
if (!event_dict->GetDouble("ts", &timestamp)) {
- LOG(ERROR) << "Incorrect trace event (no timestamp)";
- return false;
+ LOG(WARNING) << "Ingoring incorrect trace event (no timestamp)";
+ continue;
}
event.timestamp = base::TimeTicks::FromInternalValue(timestamp);
if (event.type == EventType::COMPLETE) {
double duration;
if (!event_dict->GetDouble("dur", &duration)) {
- LOG(ERROR) << "Incorrect complete or duration event (no duration)";
- return false;
+ LOG(WARNING) << "Ignoring incorrect complete event (no duration)";
+ continue;
}
event.duration = base::TimeDelta::FromInternalValue(duration);
« no previous file with comments | « no previous file | mojo/devtools/common/mojo_benchmark » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698