| 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 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_ | 5 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_ |
| 6 #define BASE_TRACE_EVENT_TRACE_EVENT_H_ | 6 #define BASE_TRACE_EVENT_TRACE_EVENT_H_ |
| 7 | 7 |
| 8 // This header file defines implementation details of how the trace macros in | 8 // This header file defines implementation details of how the trace macros in |
| 9 // trace_event_common.h collect and store trace events. Anything not | 9 // trace_event_common.h collect and store trace events. Anything not |
| 10 // implementation-specific should go in trace_macros_common.h instead of here. | 10 // implementation-specific should go in trace_macros_common.h instead of here. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // const unsigned char* arg_types, | 101 // const unsigned char* arg_types, |
| 102 // const unsigned long long* arg_values, | 102 // const unsigned long long* arg_values, |
| 103 // const scoped_refptr<ConvertableToTraceFormat>* | 103 // const scoped_refptr<ConvertableToTraceFormat>* |
| 104 // convertable_values, | 104 // convertable_values, |
| 105 // unsigned int flags) | 105 // unsigned int flags) |
| 106 #define TRACE_EVENT_API_ADD_TRACE_EVENT \ | 106 #define TRACE_EVENT_API_ADD_TRACE_EVENT \ |
| 107 base::trace_event::TraceLog::GetInstance()->AddTraceEvent | 107 base::trace_event::TraceLog::GetInstance()->AddTraceEvent |
| 108 | 108 |
| 109 // Add a trace event to the platform tracing system. | 109 // Add a trace event to the platform tracing system. |
| 110 // base::trace_event::TraceEventHandle | 110 // base::trace_event::TraceEventHandle |
| 111 // TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_CONTEXT_ID( | 111 // TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_BIND_ID( |
| 112 // char phase, | 112 // char phase, |
| 113 // const unsigned char* category_group_enabled, | 113 // const unsigned char* category_group_enabled, |
| 114 // const char* name, | 114 // const char* name, |
| 115 // unsigned long long id, | 115 // unsigned long long id, |
| 116 // unsigned long long context_id, | 116 // unsigned long long bind_id, |
| 117 // int num_args, | 117 // int num_args, |
| 118 // const char** arg_names, | 118 // const char** arg_names, |
| 119 // const unsigned char* arg_types, | 119 // const unsigned char* arg_types, |
| 120 // const unsigned long long* arg_values, | 120 // const unsigned long long* arg_values, |
| 121 // const scoped_refptr<ConvertableToTraceFormat>* | 121 // const scoped_refptr<ConvertableToTraceFormat>* |
| 122 // convertable_values, | 122 // convertable_values, |
| 123 // unsigned int flags) | 123 // unsigned int flags) |
| 124 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_CONTEXT_ID \ | 124 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_BIND_ID \ |
| 125 base::trace_event::TraceLog::GetInstance()->AddTraceEventWithContextId | 125 base::trace_event::TraceLog::GetInstance()->AddTraceEventWithBindId |
| 126 | 126 |
| 127 // Add a trace event to the platform tracing system overriding the pid. | 127 // Add a trace event to the platform tracing system overriding the pid. |
| 128 // The resulting event will have tid = pid == (process_id passed here). | 128 // The resulting event will have tid = pid == (process_id passed here). |
| 129 // base::trace_event::TraceEventHandle | 129 // base::trace_event::TraceEventHandle |
| 130 // TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_PROCESS_ID( | 130 // TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_PROCESS_ID( |
| 131 // char phase, | 131 // char phase, |
| 132 // const unsigned char* category_group_enabled, | 132 // const unsigned char* category_group_enabled, |
| 133 // const char* name, | 133 // const char* name, |
| 134 // unsigned long long id, | 134 // unsigned long long id, |
| 135 // unsigned long long context_id, | |
| 136 // int process_id, | 135 // int process_id, |
| 137 // int num_args, | 136 // int num_args, |
| 138 // const char** arg_names, | 137 // const char** arg_names, |
| 139 // const unsigned char* arg_types, | 138 // const unsigned char* arg_types, |
| 140 // const unsigned long long* arg_values, | 139 // const unsigned long long* arg_values, |
| 141 // const scoped_refptr<ConvertableToTraceFormat>* | 140 // const scoped_refptr<ConvertableToTraceFormat>* |
| 142 // convertable_values, | 141 // convertable_values, |
| 143 // unsigned int flags) | 142 // unsigned int flags) |
| 144 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_PROCESS_ID \ | 143 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_PROCESS_ID \ |
| 145 base::trace_event::TraceLog::GetInstance()->AddTraceEventWithProcessId | 144 base::trace_event::TraceLog::GetInstance()->AddTraceEventWithProcessId |
| 146 | 145 |
| 147 // Add a trace event to the platform tracing system. | 146 // Add a trace event to the platform tracing system. |
| 148 // base::trace_event::TraceEventHandle | 147 // base::trace_event::TraceEventHandle |
| 149 // TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP( | 148 // TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP( |
| 150 // char phase, | 149 // char phase, |
| 151 // const unsigned char* category_group_enabled, | 150 // const unsigned char* category_group_enabled, |
| 152 // const char* name, | 151 // const char* name, |
| 153 // unsigned long long id, | 152 // unsigned long long id, |
| 154 // unsigned long long context_id, | |
| 155 // int thread_id, | 153 // int thread_id, |
| 156 // const TimeTicks& timestamp, | 154 // const TimeTicks& timestamp, |
| 157 // int num_args, | 155 // int num_args, |
| 158 // const char** arg_names, | 156 // const char** arg_names, |
| 159 // const unsigned char* arg_types, | 157 // const unsigned char* arg_types, |
| 160 // const unsigned long long* arg_values, | 158 // const unsigned long long* arg_values, |
| 161 // const scoped_refptr<ConvertableToTraceFormat>* | 159 // const scoped_refptr<ConvertableToTraceFormat>* |
| 162 // convertable_values, | 160 // convertable_values, |
| 163 // unsigned int flags) | 161 // unsigned int flags) |
| 164 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP \ | 162 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP \ |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 299 |
| 302 // Implementation detail: internal macro to create static category and add | 300 // Implementation detail: internal macro to create static category and add |
| 303 // event if the category is enabled. | 301 // event if the category is enabled. |
| 304 #define INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP(phase, category_group, name, \ | 302 #define INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP(phase, category_group, name, \ |
| 305 timestamp, flags, ...) \ | 303 timestamp, flags, ...) \ |
| 306 do { \ | 304 do { \ |
| 307 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 305 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
| 308 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | 306 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
| 309 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ | 307 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ |
| 310 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ | 308 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ |
| 311 trace_event_internal::kNoId, trace_event_internal::kNoId, \ | 309 trace_event_internal::kNoId, TRACE_EVENT_API_CURRENT_THREAD_ID, \ |
| 312 TRACE_EVENT_API_CURRENT_THREAD_ID, \ | |
| 313 base::TimeTicks::FromInternalValue(timestamp), \ | 310 base::TimeTicks::FromInternalValue(timestamp), \ |
| 314 flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ | 311 flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ |
| 315 trace_event_internal::kNoId, ##__VA_ARGS__); \ | 312 trace_event_internal::kNoId, ##__VA_ARGS__); \ |
| 316 } \ | 313 } \ |
| 317 } while (0) | 314 } while (0) |
| 318 | 315 |
| 319 // Implementation detail: internal macro to create static category and add | 316 // Implementation detail: internal macro to create static category and add |
| 320 // event if the category is enabled. | 317 // event if the category is enabled. |
| 321 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, \ | 318 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
| 322 category_group, name, id, thread_id, timestamp, flags, ...) \ | 319 phase, category_group, name, id, thread_id, timestamp, flags, ...) \ |
| 323 do { \ | 320 do { \ |
| 324 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 321 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
| 325 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | 322 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
| 326 unsigned int trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 323 unsigned int trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
| 327 trace_event_internal::TraceID trace_event_trace_id( \ | 324 trace_event_internal::TraceID trace_event_trace_id(id, \ |
| 328 id, &trace_event_flags); \ | 325 &trace_event_flags); \ |
| 329 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ | 326 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ |
| 330 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | 327 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ |
| 331 name, trace_event_trace_id.data(), trace_event_internal::kNoId, \ | 328 trace_event_trace_id.data(), thread_id, \ |
| 332 thread_id, base::TimeTicks::FromInternalValue(timestamp), \ | 329 base::TimeTicks::FromInternalValue(timestamp), \ |
| 333 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ | 330 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ |
| 334 trace_event_internal::kNoId, ##__VA_ARGS__); \ | 331 trace_event_internal::kNoId, ##__VA_ARGS__); \ |
| 335 } \ | 332 } \ |
| 336 } while (0) | 333 } while (0) |
| 337 | |
| 338 | 334 |
| 339 namespace trace_event_internal { | 335 namespace trace_event_internal { |
| 340 | 336 |
| 341 // Specify these values when the corresponding argument of AddTraceEvent is not | 337 // Specify these values when the corresponding argument of AddTraceEvent is not |
| 342 // used. | 338 // used. |
| 343 const int kZeroNumArgs = 0; | 339 const int kZeroNumArgs = 0; |
| 344 const unsigned long long kNoId = 0; | 340 const unsigned long long kNoId = 0; |
| 345 | 341 |
| 346 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers | 342 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers |
| 347 // are by default mangled with the Process ID so that they are unlikely to | 343 // are by default mangled with the Process ID so that they are unlikely to |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 // could be temporary objects, such as std::string. In order to store | 534 // could be temporary objects, such as std::string. In order to store |
| 539 // pointers to the internal c_str and pass through to the tracing API, | 535 // pointers to the internal c_str and pass through to the tracing API, |
| 540 // the arg_values must live throughout these procedures. | 536 // the arg_values must live throughout these procedures. |
| 541 | 537 |
| 542 static inline base::trace_event::TraceEventHandle | 538 static inline base::trace_event::TraceEventHandle |
| 543 AddTraceEventWithThreadIdAndTimestamp( | 539 AddTraceEventWithThreadIdAndTimestamp( |
| 544 char phase, | 540 char phase, |
| 545 const unsigned char* category_group_enabled, | 541 const unsigned char* category_group_enabled, |
| 546 const char* name, | 542 const char* name, |
| 547 unsigned long long id, | 543 unsigned long long id, |
| 548 unsigned long long context_id, | |
| 549 int thread_id, | 544 int thread_id, |
| 550 const base::TimeTicks& timestamp, | 545 const base::TimeTicks& timestamp, |
| 551 unsigned int flags, | 546 unsigned int flags, |
| 552 unsigned long long bind_id, | 547 unsigned long long bind_id, |
| 553 const char* arg1_name, | 548 const char* arg1_name, |
| 554 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& | 549 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& |
| 555 arg1_val) { | 550 arg1_val) { |
| 556 const int num_args = 1; | 551 const int num_args = 1; |
| 557 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE }; | 552 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE }; |
| 558 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 553 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 559 phase, category_group_enabled, name, id, context_id, bind_id, thread_id, | 554 phase, category_group_enabled, name, id, bind_id, thread_id, timestamp, |
| 560 timestamp, num_args, &arg1_name, arg_types, NULL, &arg1_val, flags); | 555 num_args, &arg1_name, arg_types, NULL, &arg1_val, flags); |
| 561 } | 556 } |
| 562 | 557 |
| 563 template<class ARG1_TYPE> | 558 template<class ARG1_TYPE> |
| 564 static inline base::trace_event::TraceEventHandle | 559 static inline base::trace_event::TraceEventHandle |
| 565 AddTraceEventWithThreadIdAndTimestamp( | 560 AddTraceEventWithThreadIdAndTimestamp( |
| 566 char phase, | 561 char phase, |
| 567 const unsigned char* category_group_enabled, | 562 const unsigned char* category_group_enabled, |
| 568 const char* name, | 563 const char* name, |
| 569 unsigned long long id, | 564 unsigned long long id, |
| 570 unsigned long long context_id, | |
| 571 int thread_id, | 565 int thread_id, |
| 572 const base::TimeTicks& timestamp, | 566 const base::TimeTicks& timestamp, |
| 573 unsigned int flags, | 567 unsigned int flags, |
| 574 unsigned long long bind_id, | 568 unsigned long long bind_id, |
| 575 const char* arg1_name, | 569 const char* arg1_name, |
| 576 const ARG1_TYPE& arg1_val, | 570 const ARG1_TYPE& arg1_val, |
| 577 const char* arg2_name, | 571 const char* arg2_name, |
| 578 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& | 572 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& |
| 579 arg2_val) { | 573 arg2_val) { |
| 580 const int num_args = 2; | 574 const int num_args = 2; |
| 581 const char* arg_names[2] = { arg1_name, arg2_name }; | 575 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 582 | 576 |
| 583 unsigned char arg_types[2]; | 577 unsigned char arg_types[2]; |
| 584 unsigned long long arg_values[2]; | 578 unsigned long long arg_values[2]; |
| 585 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 579 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
| 586 arg_types[1] = TRACE_VALUE_TYPE_CONVERTABLE; | 580 arg_types[1] = TRACE_VALUE_TYPE_CONVERTABLE; |
| 587 | 581 |
| 588 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 582 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 589 convertable_values[2]; | 583 convertable_values[2]; |
| 590 convertable_values[1] = arg2_val; | 584 convertable_values[1] = arg2_val; |
| 591 | 585 |
| 592 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 586 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 593 phase, category_group_enabled, name, id, context_id, bind_id, thread_id, | 587 phase, category_group_enabled, name, id, bind_id, thread_id, timestamp, |
| 594 timestamp, num_args, arg_names, arg_types, arg_values, | 588 num_args, arg_names, arg_types, arg_values, convertable_values, flags); |
| 595 convertable_values, flags); | |
| 596 } | 589 } |
| 597 | 590 |
| 598 template<class ARG2_TYPE> | 591 template<class ARG2_TYPE> |
| 599 static inline base::trace_event::TraceEventHandle | 592 static inline base::trace_event::TraceEventHandle |
| 600 AddTraceEventWithThreadIdAndTimestamp( | 593 AddTraceEventWithThreadIdAndTimestamp( |
| 601 char phase, | 594 char phase, |
| 602 const unsigned char* category_group_enabled, | 595 const unsigned char* category_group_enabled, |
| 603 const char* name, | 596 const char* name, |
| 604 unsigned long long id, | 597 unsigned long long id, |
| 605 unsigned long long context_id, | |
| 606 int thread_id, | 598 int thread_id, |
| 607 const base::TimeTicks& timestamp, | 599 const base::TimeTicks& timestamp, |
| 608 unsigned int flags, | 600 unsigned int flags, |
| 609 unsigned long long bind_id, | 601 unsigned long long bind_id, |
| 610 const char* arg1_name, | 602 const char* arg1_name, |
| 611 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, | 603 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, |
| 612 const char* arg2_name, | 604 const char* arg2_name, |
| 613 const ARG2_TYPE& arg2_val) { | 605 const ARG2_TYPE& arg2_val) { |
| 614 const int num_args = 2; | 606 const int num_args = 2; |
| 615 const char* arg_names[2] = { arg1_name, arg2_name }; | 607 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 616 | 608 |
| 617 unsigned char arg_types[2]; | 609 unsigned char arg_types[2]; |
| 618 unsigned long long arg_values[2]; | 610 unsigned long long arg_values[2]; |
| 619 arg_types[0] = TRACE_VALUE_TYPE_CONVERTABLE; | 611 arg_types[0] = TRACE_VALUE_TYPE_CONVERTABLE; |
| 620 arg_values[0] = 0; | 612 arg_values[0] = 0; |
| 621 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); | 613 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); |
| 622 | 614 |
| 623 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 615 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 624 convertable_values[2]; | 616 convertable_values[2]; |
| 625 convertable_values[0] = arg1_val; | 617 convertable_values[0] = arg1_val; |
| 626 | 618 |
| 627 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 619 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 628 phase, category_group_enabled, name, id, context_id, bind_id, thread_id, | 620 phase, category_group_enabled, name, id, bind_id, thread_id, timestamp, |
| 629 timestamp, num_args, arg_names, arg_types, arg_values, | 621 num_args, arg_names, arg_types, arg_values, convertable_values, flags); |
| 630 convertable_values, flags); | |
| 631 } | 622 } |
| 632 | 623 |
| 633 static inline base::trace_event::TraceEventHandle | 624 static inline base::trace_event::TraceEventHandle |
| 634 AddTraceEventWithThreadIdAndTimestamp( | 625 AddTraceEventWithThreadIdAndTimestamp( |
| 635 char phase, | 626 char phase, |
| 636 const unsigned char* category_group_enabled, | 627 const unsigned char* category_group_enabled, |
| 637 const char* name, | 628 const char* name, |
| 638 unsigned long long id, | 629 unsigned long long id, |
| 639 unsigned long long context_id, | |
| 640 int thread_id, | 630 int thread_id, |
| 641 const base::TimeTicks& timestamp, | 631 const base::TimeTicks& timestamp, |
| 642 unsigned int flags, | 632 unsigned int flags, |
| 643 unsigned long long bind_id, | 633 unsigned long long bind_id, |
| 644 const char* arg1_name, | 634 const char* arg1_name, |
| 645 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, | 635 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, |
| 646 const char* arg2_name, | 636 const char* arg2_name, |
| 647 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& | 637 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& |
| 648 arg2_val) { | 638 arg2_val) { |
| 649 const int num_args = 2; | 639 const int num_args = 2; |
| 650 const char* arg_names[2] = { arg1_name, arg2_name }; | 640 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 651 unsigned char arg_types[2] = | 641 unsigned char arg_types[2] = |
| 652 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE }; | 642 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE }; |
| 653 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 643 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 654 convertable_values[2] = {arg1_val, arg2_val}; | 644 convertable_values[2] = {arg1_val, arg2_val}; |
| 655 | 645 |
| 656 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 646 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 657 phase, category_group_enabled, name, id, context_id, bind_id, thread_id, | 647 phase, category_group_enabled, name, id, bind_id, thread_id, timestamp, |
| 658 timestamp, num_args, arg_names, arg_types, NULL, convertable_values, | 648 num_args, arg_names, arg_types, NULL, convertable_values, flags); |
| 659 flags); | |
| 660 } | 649 } |
| 661 | 650 |
| 662 static inline base::trace_event::TraceEventHandle | 651 static inline base::trace_event::TraceEventHandle |
| 663 AddTraceEventWithThreadIdAndTimestamp( | 652 AddTraceEventWithThreadIdAndTimestamp( |
| 664 char phase, | 653 char phase, |
| 665 const unsigned char* category_group_enabled, | 654 const unsigned char* category_group_enabled, |
| 666 const char* name, | 655 const char* name, |
| 667 unsigned long long id, | 656 unsigned long long id, |
| 668 unsigned long long context_id, | |
| 669 int thread_id, | 657 int thread_id, |
| 670 const base::TimeTicks& timestamp, | 658 const base::TimeTicks& timestamp, |
| 671 unsigned int flags, | 659 unsigned int flags, |
| 672 unsigned long long bind_id) { | 660 unsigned long long bind_id) { |
| 673 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 661 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 674 phase, category_group_enabled, name, id, context_id, bind_id, thread_id, | 662 phase, category_group_enabled, name, id, bind_id, thread_id, timestamp, |
| 675 timestamp, kZeroNumArgs, NULL, NULL, NULL, NULL, flags); | 663 kZeroNumArgs, NULL, NULL, NULL, NULL, flags); |
| 676 } | 664 } |
| 677 | 665 |
| 678 static inline base::trace_event::TraceEventHandle AddTraceEvent( | 666 static inline base::trace_event::TraceEventHandle AddTraceEvent( |
| 679 char phase, | 667 char phase, |
| 680 const unsigned char* category_group_enabled, | 668 const unsigned char* category_group_enabled, |
| 681 const char* name, | 669 const char* name, |
| 682 unsigned long long id, | 670 unsigned long long id, |
| 683 unsigned int flags, | 671 unsigned int flags, |
| 684 unsigned long long bind_id) { | 672 unsigned long long bind_id) { |
| 685 const int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 673 const int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
| 686 const base::TimeTicks now = base::TimeTicks::Now(); | 674 const base::TimeTicks now = base::TimeTicks::Now(); |
| 687 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, | 675 return AddTraceEventWithThreadIdAndTimestamp( |
| 688 name, id, kNoId, thread_id, now, | 676 phase, category_group_enabled, name, id, thread_id, now, flags, bind_id); |
| 689 flags, bind_id); | |
| 690 } | 677 } |
| 691 | 678 |
| 692 template<class ARG1_TYPE> | 679 template<class ARG1_TYPE> |
| 693 static inline base::trace_event::TraceEventHandle | 680 static inline base::trace_event::TraceEventHandle |
| 694 AddTraceEventWithThreadIdAndTimestamp( | 681 AddTraceEventWithThreadIdAndTimestamp( |
| 695 char phase, | 682 char phase, |
| 696 const unsigned char* category_group_enabled, | 683 const unsigned char* category_group_enabled, |
| 697 const char* name, | 684 const char* name, |
| 698 unsigned long long id, | 685 unsigned long long id, |
| 699 unsigned long long context_id, | |
| 700 int thread_id, | 686 int thread_id, |
| 701 const base::TimeTicks& timestamp, | 687 const base::TimeTicks& timestamp, |
| 702 unsigned int flags, | 688 unsigned int flags, |
| 703 unsigned long long bind_id, | 689 unsigned long long bind_id, |
| 704 const char* arg1_name, | 690 const char* arg1_name, |
| 705 const ARG1_TYPE& arg1_val) { | 691 const ARG1_TYPE& arg1_val) { |
| 706 const int num_args = 1; | 692 const int num_args = 1; |
| 707 unsigned char arg_types[1]; | 693 unsigned char arg_types[1]; |
| 708 unsigned long long arg_values[1]; | 694 unsigned long long arg_values[1]; |
| 709 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 695 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
| 710 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 696 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 711 phase, category_group_enabled, name, id, context_id, bind_id, thread_id, | 697 phase, category_group_enabled, name, id, bind_id, thread_id, timestamp, |
| 712 timestamp, num_args, &arg1_name, arg_types, arg_values, NULL, flags); | 698 num_args, &arg1_name, arg_types, arg_values, NULL, flags); |
| 713 } | 699 } |
| 714 | 700 |
| 715 template<class ARG1_TYPE> | 701 template<class ARG1_TYPE> |
| 716 static inline base::trace_event::TraceEventHandle AddTraceEvent( | 702 static inline base::trace_event::TraceEventHandle AddTraceEvent( |
| 717 char phase, | 703 char phase, |
| 718 const unsigned char* category_group_enabled, | 704 const unsigned char* category_group_enabled, |
| 719 const char* name, | 705 const char* name, |
| 720 unsigned long long id, | 706 unsigned long long id, |
| 721 unsigned int flags, | 707 unsigned int flags, |
| 722 unsigned long long bind_id, | 708 unsigned long long bind_id, |
| 723 const char* arg1_name, | 709 const char* arg1_name, |
| 724 const ARG1_TYPE& arg1_val) { | 710 const ARG1_TYPE& arg1_val) { |
| 725 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 711 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
| 726 base::TimeTicks now = base::TimeTicks::Now(); | 712 base::TimeTicks now = base::TimeTicks::Now(); |
| 727 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, | 713 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, |
| 728 name, id, kNoId, thread_id, now, | 714 name, id, thread_id, now, flags, |
| 729 flags, bind_id, | 715 bind_id, arg1_name, arg1_val); |
| 730 arg1_name, arg1_val); | |
| 731 } | 716 } |
| 732 | 717 |
| 733 template<class ARG1_TYPE, class ARG2_TYPE> | 718 template<class ARG1_TYPE, class ARG2_TYPE> |
| 734 static inline base::trace_event::TraceEventHandle | 719 static inline base::trace_event::TraceEventHandle |
| 735 AddTraceEventWithThreadIdAndTimestamp( | 720 AddTraceEventWithThreadIdAndTimestamp( |
| 736 char phase, | 721 char phase, |
| 737 const unsigned char* category_group_enabled, | 722 const unsigned char* category_group_enabled, |
| 738 const char* name, | 723 const char* name, |
| 739 unsigned long long id, | 724 unsigned long long id, |
| 740 unsigned long long context_id, | |
| 741 int thread_id, | 725 int thread_id, |
| 742 const base::TimeTicks& timestamp, | 726 const base::TimeTicks& timestamp, |
| 743 unsigned int flags, | 727 unsigned int flags, |
| 744 unsigned long long bind_id, | 728 unsigned long long bind_id, |
| 745 const char* arg1_name, | 729 const char* arg1_name, |
| 746 const ARG1_TYPE& arg1_val, | 730 const ARG1_TYPE& arg1_val, |
| 747 const char* arg2_name, | 731 const char* arg2_name, |
| 748 const ARG2_TYPE& arg2_val) { | 732 const ARG2_TYPE& arg2_val) { |
| 749 const int num_args = 2; | 733 const int num_args = 2; |
| 750 const char* arg_names[2] = { arg1_name, arg2_name }; | 734 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 751 unsigned char arg_types[2]; | 735 unsigned char arg_types[2]; |
| 752 unsigned long long arg_values[2]; | 736 unsigned long long arg_values[2]; |
| 753 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 737 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
| 754 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); | 738 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); |
| 755 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 739 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 756 phase, category_group_enabled, name, id, context_id, bind_id, thread_id, | 740 phase, category_group_enabled, name, id, bind_id, thread_id, timestamp, |
| 757 timestamp, num_args, arg_names, arg_types, arg_values, NULL, flags); | 741 num_args, arg_names, arg_types, arg_values, NULL, flags); |
| 758 } | 742 } |
| 759 | 743 |
| 760 template<class ARG1_TYPE, class ARG2_TYPE> | 744 template<class ARG1_TYPE, class ARG2_TYPE> |
| 761 static inline base::trace_event::TraceEventHandle AddTraceEvent( | 745 static inline base::trace_event::TraceEventHandle AddTraceEvent( |
| 762 char phase, | 746 char phase, |
| 763 const unsigned char* category_group_enabled, | 747 const unsigned char* category_group_enabled, |
| 764 const char* name, | 748 const char* name, |
| 765 unsigned long long id, | 749 unsigned long long id, |
| 766 unsigned int flags, | 750 unsigned int flags, |
| 767 unsigned long long bind_id, | 751 unsigned long long bind_id, |
| 768 const char* arg1_name, | 752 const char* arg1_name, |
| 769 const ARG1_TYPE& arg1_val, | 753 const ARG1_TYPE& arg1_val, |
| 770 const char* arg2_name, | 754 const char* arg2_name, |
| 771 const ARG2_TYPE& arg2_val) { | 755 const ARG2_TYPE& arg2_val) { |
| 772 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 756 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
| 773 base::TimeTicks now = base::TimeTicks::Now(); | 757 base::TimeTicks now = base::TimeTicks::Now(); |
| 774 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, | 758 return AddTraceEventWithThreadIdAndTimestamp( |
| 775 name, id, kNoId, thread_id, now, | 759 phase, category_group_enabled, name, id, thread_id, now, flags, bind_id, |
| 776 flags, bind_id, | 760 arg1_name, arg1_val, arg2_name, arg2_val); |
| 777 arg1_name, arg1_val, | |
| 778 arg2_name, arg2_val); | |
| 779 } | 761 } |
| 780 | 762 |
| 781 static inline void AddMetadataEvent( | 763 static inline void AddMetadataEvent( |
| 782 const char* event_name, | 764 const char* event_name, |
| 783 const char* arg_name, | 765 const char* arg_name, |
| 784 scoped_refptr<base::trace_event::ConvertableToTraceFormat> arg_value) { | 766 scoped_refptr<base::trace_event::ConvertableToTraceFormat> arg_value) { |
| 785 const char* arg_names[1] = {arg_name}; | 767 const char* arg_names[1] = {arg_name}; |
| 786 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 768 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 787 convertable_values[1] = {arg_value}; | 769 convertable_values[1] = {arg_value}; |
| 788 unsigned char arg_types[1] = {TRACE_VALUE_TYPE_CONVERTABLE}; | 770 unsigned char arg_types[1] = {TRACE_VALUE_TYPE_CONVERTABLE}; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 const char* name_; | 907 const char* name_; |
| 926 IDType id_; | 908 IDType id_; |
| 927 | 909 |
| 928 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 910 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
| 929 }; | 911 }; |
| 930 | 912 |
| 931 } // namespace trace_event | 913 } // namespace trace_event |
| 932 } // namespace base | 914 } // namespace base |
| 933 | 915 |
| 934 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ | 916 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ |
| OLD | NEW |