Chromium Code Reviews| Index: base/trace_event/trace_event_impl.cc |
| diff --git a/base/trace_event/trace_event_impl.cc b/base/trace_event/trace_event_impl.cc |
| index f9792d0d6df6aea004447b3bf2a293f50d08e646..0da94758dcc0d40df01660d277fb7506356a54fd 100644 |
| --- a/base/trace_event/trace_event_impl.cc |
| +++ b/base/trace_event/trace_event_impl.cc |
| @@ -458,30 +458,34 @@ TraceID::AsConvertableToTraceFormat() const { |
| if (scope_ != kGlobalScope) |
| value->SetString("scope", scope_); |
| - switch (id_flags_) { |
| - case TRACE_EVENT_FLAG_HAS_ID: |
| - value->SetString( |
| - "id", |
| - base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_))); |
| - break; |
| - case TRACE_EVENT_FLAG_HAS_GLOBAL_ID: |
| - value->BeginDictionary("id2"); |
| - value->SetString( |
| - "global", |
| - base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_))); |
| - value->EndDictionary(); |
| - break; |
| - case TRACE_EVENT_FLAG_HAS_LOCAL_ID: |
| - value->BeginDictionary("id2"); |
| - value->SetString( |
| - "local", |
| - base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_))); |
| - value->EndDictionary(); |
| - break; |
| - default: |
| - NOTREACHED() << "Unrecognized ID flag"; |
| + |
| + const char* id_field_name = "id"; |
| + if (id_flags_ == TRACE_EVENT_FLAG_HAS_GLOBAL_ID) { |
| + id_field_name = "global"; |
| + value->BeginDictionary("id2"); |
| + } else if (id_flags_ == TRACE_EVENT_FLAG_HAS_LOCAL_ID) { |
| + id_field_name = "local"; |
| + value->BeginDictionary("id2"); |
| + } else if (id_flags_ != TRACE_EVENT_FLAG_HAS_ID) { |
| + NOTREACHED() << "Unrecognized ID flag"; |
| } |
| + if (has_prefix_) { |
| + value->BeginArray(id_field_name); |
|
Primiano Tucci (use gerrit)
2017/01/17 12:25:47
by looking at the else case below this value can b
chiniforooshan1
2017/01/17 16:44:09
Done.
|
| + value->AppendString( |
| + base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(prefix_))); |
| + value->AppendString( |
| + base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_))); |
| + value->EndArray(); |
| + } else { |
| + value->SetString( |
| + id_field_name, |
| + base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_))); |
| + } |
| + |
| + if (id_flags_ != TRACE_EVENT_FLAG_HAS_ID) |
| + value->EndDictionary(); |
| + |
| return std::move(value); |
| } |