| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/trace_event/trace_event_impl.h" | 5 #include "base/trace_event/trace_event_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/json/string_escape.h" | 10 #include "base/json/string_escape.h" |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 } // namespace base | 451 } // namespace base |
| 452 | 452 |
| 453 namespace trace_event_internal { | 453 namespace trace_event_internal { |
| 454 | 454 |
| 455 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 455 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 456 TraceID::AsConvertableToTraceFormat() const { | 456 TraceID::AsConvertableToTraceFormat() const { |
| 457 auto value = base::MakeUnique<base::trace_event::TracedValue>(); | 457 auto value = base::MakeUnique<base::trace_event::TracedValue>(); |
| 458 | 458 |
| 459 if (scope_ != kGlobalScope) | 459 if (scope_ != kGlobalScope) |
| 460 value->SetString("scope", scope_); | 460 value->SetString("scope", scope_); |
| 461 switch (id_flags_) { | 461 |
| 462 case TRACE_EVENT_FLAG_HAS_ID: | 462 const char* id_field_name = "id"; |
| 463 value->SetString( | 463 if (id_flags_ == TRACE_EVENT_FLAG_HAS_GLOBAL_ID) { |
| 464 "id", | 464 id_field_name = "global"; |
| 465 base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_))); | 465 value->BeginDictionary("id2"); |
| 466 break; | 466 } else if (id_flags_ == TRACE_EVENT_FLAG_HAS_LOCAL_ID) { |
| 467 case TRACE_EVENT_FLAG_HAS_GLOBAL_ID: | 467 id_field_name = "local"; |
| 468 value->BeginDictionary("id2"); | 468 value->BeginDictionary("id2"); |
| 469 value->SetString( | 469 } else if (id_flags_ != TRACE_EVENT_FLAG_HAS_ID) { |
| 470 "global", | 470 NOTREACHED() << "Unrecognized ID flag"; |
| 471 base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_))); | |
| 472 value->EndDictionary(); | |
| 473 break; | |
| 474 case TRACE_EVENT_FLAG_HAS_LOCAL_ID: | |
| 475 value->BeginDictionary("id2"); | |
| 476 value->SetString( | |
| 477 "local", | |
| 478 base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_))); | |
| 479 value->EndDictionary(); | |
| 480 break; | |
| 481 default: | |
| 482 NOTREACHED() << "Unrecognized ID flag"; | |
| 483 } | 471 } |
| 484 | 472 |
| 473 if (has_prefix_) { |
| 474 value->SetString(id_field_name, |
| 475 base::StringPrintf("0x%" PRIx64 "/0x%" PRIx64, |
| 476 static_cast<uint64_t>(prefix_), |
| 477 static_cast<uint64_t>(raw_id_))); |
| 478 } else { |
| 479 value->SetString( |
| 480 id_field_name, |
| 481 base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_))); |
| 482 } |
| 483 |
| 484 if (id_flags_ != TRACE_EVENT_FLAG_HAS_ID) |
| 485 value->EndDictionary(); |
| 486 |
| 485 return std::move(value); | 487 return std::move(value); |
| 486 } | 488 } |
| 487 | 489 |
| 488 } // namespace trace_event_internal | 490 } // namespace trace_event_internal |
| OLD | NEW |