Chromium Code Reviews| Index: apps/benchmark/event.cc |
| diff --git a/apps/benchmark/event.cc b/apps/benchmark/event.cc |
| index 146d8dfb5b05c68c35896ec51d824c0ceb40db13..4cf8595bce3bcd67478913d20c4ff0c20bf9e33e 100644 |
| --- a/apps/benchmark/event.cc |
| +++ b/apps/benchmark/event.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/json/json_reader.h" |
| #include "base/macros.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/strings/string_number_conversions.h" |
| #include "base/values.h" |
| namespace benchmark { |
| @@ -32,7 +33,7 @@ Event::~Event() {} |
| namespace { |
| // ID uniquely identifying an asynchronous event stack. |
| struct AsyncEventStackId { |
| - int id; |
| + std::string id; |
| std::string cat; |
| }; |
| @@ -47,7 +48,7 @@ typedef int DurationEventStackId; |
| bool GetDurationEventStackId(base::DictionaryValue* event_dict, |
| DurationEventStackId* durationId) { |
| if (!event_dict->GetInteger("tid", durationId)) { |
| - LOG(ERROR) << "Incorrect trace event (missing tid)."; |
| + LOG(ERROR) << "Incorrect trace event (missing tid): " << *event_dict; |
| return false; |
| } |
| return true; |
| @@ -56,12 +57,26 @@ bool GetDurationEventStackId(base::DictionaryValue* event_dict, |
| // Makes a unique key for an async event stack. |
| bool GetAsyncEventStackId(base::DictionaryValue* event_dict, |
| AsyncEventStackId* asyncId) { |
| - if (!event_dict->GetInteger("id", &asyncId->id)) { |
| - LOG(ERROR) << "Incorrect async trace event (missing id)."; |
| + const base::Value* value; |
| + if (!event_dict->Get("id", &value)) { |
| + LOG(ERROR) << "Incorrect async trace event (missing id): " << *event_dict; |
| return false; |
| } |
| - // We can have an empty category, but it is still relevant for event merging, |
| + if (value->IsType(base::Value::TYPE_INTEGER)) { |
| + int id_int; |
| + // We already verified the type, so it should be an integer. |
| + DCHECK(value->GetAsInteger(&id_int)); |
| + asyncId->id = base::IntToString(id_int); |
| + } else if (value->IsType(base::Value::TYPE_STRING)) { |
| + DCHECK(value->GetAsString(&asyncId->id)); |
| + } else { |
| + LOG(ERROR) << "Incorrect async trace event (id of wrong type): " |
|
ppi
2015/10/01 13:09:44
(id of wrong type) -> (id is neither string nor in
etiennej
2015/10/01 13:25:17
Done.
|
| + << *event_dict; |
| + } |
| + |
| + // We can have an empty category, but it is still relevant for event |
| + // merging, |
|
ppi
2015/10/01 13:09:44
the comment block needs re-align
etiennej
2015/10/01 13:25:17
Done.
|
| // per the documentation. |
| std::string cat; |
| event_dict->GetString("cat", &asyncId->cat); |