| 549 | } |
| 550 | |
| 551 | void TraceEvent::Initialize( |
| 552 | int thread_id, |
| 553 | MicrosecondsInt64 timestamp, |
| 554 | MicrosecondsInt64 thread_timestamp, |
| 555 | char phase, |
| 556 | const unsigned char* category_group_enabled, |
| 557 | const char* name, |
| 558 | uint64_t id, |
| 559 | int num_args, |
| 560 | const char** arg_names, |
| 561 | const unsigned char* arg_types, |
| 562 | const uint64_t* arg_values, |
| 563 | const scoped_refptr<ConvertableToTraceFormat>* convertable_values, |
| 564 | unsigned char flags) { |
| 565 | timestamp_ = timestamp; |
| 566 | thread_timestamp_ = thread_timestamp; |
| 567 | duration_ = -1; |
| 568 | id_ = id; |
| 569 | category_group_enabled_ = category_group_enabled; |
| 570 | name_ = name; |
| 571 | thread_id_ = thread_id; |
| 572 | phase_ = phase; |
| 573 | flags_ = flags; |
| 574 | |
| 575 | // Clamp num_args since it may have been set by a third_party library. |
| 576 | num_args = (num_args > kTraceMaxNumArgs) ? kTraceMaxNumArgs : num_args; |
| 577 | int i = 0; |
| 578 | for (; i < num_args; ++i) { |
| 579 | arg_names_[i] = arg_names[i]; |
| 580 | arg_types_[i] = arg_types[i]; |
| 581 | |
| 582 | if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) |
| 583 | convertable_values_[i] = convertable_values[i]; |
| 584 | else |
| 585 | arg_values_[i].as_uint = arg_values[i]; |
| 586 | } |
| 587 | for (; i < kTraceMaxNumArgs; ++i) { |
| 588 | arg_names_[i] = nullptr; |
| 589 | arg_values_[i].as_uint = 0u; |
| 590 | convertable_values_[i] = nullptr; |
| 591 | arg_types_[i] = TRACE_VALUE_TYPE_UINT; |
| 592 | } |
| 593 | |
| 594 | bool copy = !!(flags & TRACE_EVENT_FLAG_COPY); |
| 595 | size_t alloc_size = 0; |
| 596 | if (copy) { |
| 597 | alloc_size += GetAllocLength(name); |
| 598 | for (i = 0; i < num_args; ++i) { |
| 599 | alloc_size += GetAllocLength(arg_names_[i]); |
| 600 | if (arg_types_[i] == TRACE_VALUE_TYPE_STRING) |
| 601 | arg_types_[i] = TRACE_VALUE_TYPE_COPY_STRING; |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | bool arg_is_copy[kTraceMaxNumArgs]; |
| 606 | for (i = 0; i < num_args; ++i) { |
| 607 | // No copying of convertable types, we retain ownership. |
| 608 | if (arg_types_[i] == TRACE_VALUE_TYPE_CONVERTABLE) |
no test coverage detected