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 // This header file defines the set of trace_event macros without specifying | 5 // This header file defines the set of trace_event macros without specifying |
6 // how the events actually get collected and stored. If you need to expose trace | 6 // how the events actually get collected and stored. If you need to expose trace |
7 // events to some other universe, you can copy-and-paste this file as well as | 7 // events to some other universe, you can copy-and-paste this file as well as |
8 // trace_event.h, modifying the macros contained there as necessary for the | 8 // trace_event.h, modifying the macros contained there as necessary for the |
9 // target platform. The end result is that multiple libraries can funnel events | 9 // target platform. The end result is that multiple libraries can funnel events |
10 // through to a shared trace event collector. | 10 // through to a shared trace event collector. |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
535 | 535 |
536 #define TRACE_EVENT_SAMPLE_WITH_TID_AND_TIMESTAMP2(category_group, name, \ | 536 #define TRACE_EVENT_SAMPLE_WITH_TID_AND_TIMESTAMP2(category_group, name, \ |
537 thread_id, timestamp, \ | 537 thread_id, timestamp, \ |
538 arg1_name, arg1_val, \ | 538 arg1_name, arg1_val, \ |
539 arg2_name, arg2_val) \ | 539 arg2_name, arg2_val) \ |
540 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | 540 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
541 TRACE_EVENT_PHASE_SAMPLE, category_group, name, 0, thread_id, timestamp, \ | 541 TRACE_EVENT_PHASE_SAMPLE, category_group, name, 0, thread_id, timestamp, \ |
542 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val) | 542 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val) |
543 | 543 |
544 // ASYNC_STEP_* APIs should be only used by legacy code. New code should | 544 // ASYNC_STEP_* APIs should be only used by legacy code. New code should |
545 // consider using NESTABLE_ASYNC_* APIs to describe substeps within an async | 545 // consider using NESTABLE_ASYNC* APIs to describe substeps within an async |
546 // event. | 546 // event. |
547 // Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2 | 547 // Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2 |
548 // associated arguments. If the category is not enabled, then this | 548 // associated arguments. If the category is not enabled, then this |
549 // does nothing. | 549 // does nothing. |
550 // - category and name strings must have application lifetime (statics or | 550 // - category and name strings must have application lifetime (statics or |
551 // literals). They may not include " chars. | 551 // literals). They may not include " chars. |
552 // - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event. ASYNC | 552 // - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event. ASYNC |
553 // events are considered to match if their category_group, name and id values | 553 // events are considered to match if their category_group, name and id values |
554 // all match. |id| must either be a pointer or an integer value up to 64 bits. | 554 // all match. |id| must either be a pointer or an integer value up to 64 bits. |
555 // If it's a pointer, the bits will be xored with a hash of the process ID so | 555 // If it's a pointer, the bits will be xored with a hash of the process ID so |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
675 arg1_name, arg1_val, arg2_name, arg2_val) | 675 arg1_name, arg1_val, arg2_name, arg2_val) |
676 | 676 |
677 // Similar to TRACE_EVENT_ASYNC_ENDx but with a custom |at| timestamp provided. | 677 // Similar to TRACE_EVENT_ASYNC_ENDx but with a custom |at| timestamp provided. |
678 #define TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0(category_group, \ | 678 #define TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0(category_group, \ |
679 name, id, timestamp) \ | 679 name, id, timestamp) \ |
680 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | 680 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
681 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, \ | 681 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, \ |
682 static_cast<int>(base::PlatformThread::CurrentId()), \ | 682 static_cast<int>(base::PlatformThread::CurrentId()), \ |
683 timestamp, TRACE_EVENT_FLAG_NONE) | 683 timestamp, TRACE_EVENT_FLAG_NONE) |
684 | 684 |
685 // NESTABLE_ASYNC_* APIs are used to describe an async operation, which can | 685 // NESTABLE_ASYNC* APIs are used to describe an async operation, which can |
686 // be nested within a NESTABLE_ASYNC event and/or have inner NESTABLE_ASYNC | 686 // be nested within a NESTABLE_ASYNC event and/or have inner NESTABLE_ASYNC |
687 // events. | 687 // events. |
688 // - category and name strings must have application lifetime (statics or | 688 // - category and name strings must have application lifetime (statics or |
689 // literals). They may not include " chars. | 689 // literals). They may not include " chars. |
690 // - A pair of NESTABLE_ASYNC_BEGIN event and NESTABLE_ASYNC_END event is | 690 // - A pair of NESTABLE_ASYNC_BEGIN event and NESTABLE_ASYNC_END event is |
691 // considered as a match if their category_group, name and id all match. | 691 // considered as a match if their category_group, name and id all match. |
692 // - |id| must either be a pointer or an integer value up to 64 bits. | 692 // - |id| must either be a pointer or an integer value up to 64 bits. |
693 // If it's a pointer, the bits will be xored with a hash of the process ID so | 693 // If it's a pointer, the bits will be xored with a hash of the process ID so |
694 // that the same pointer on two different processes will not collide. | 694 // that the same pointer on two different processes will not collide. |
695 // - |id| is used to match a child NESTABLE_ASYNC event with its parent | 695 // - |id| is used to match a child NESTABLE_ASYNC event with its parent |
696 // NESTABLE_ASYNC event. Therefore, events in the same nested event tree must | 696 // NESTABLE_ASYNC event. Therefore, events in the same nested event tree must |
697 // be logged using the same id and category_group. | 697 // be logged using the same id and category_group. |
698 // | 698 // |
699 // Unmatched NESTABLE_ASYNC_END event will be parsed as an event that starts | 699 // Unmatched NESTABLE_ASYNC_END event will be parsed as an event that starts |
700 // at the first NESTABLE_ASYNC event of that id, and unmatched | 700 // at the first NESTABLE_ASYNC event of that id, and unmatched |
701 // NESTABLE_ASYNC_BEGIN event will be parsed as an event that ends at the last | 701 // NESTABLE_ASYNC_BEGIN event will be parsed as an event that ends at the last |
702 // NESTABLE_ASYNC event of that id. Corresponding warning messages for | 702 // NESTABLE_ASYNC event of that id. Corresponding warning messages for |
703 // unmatched events will be shown in the analysis view. | 703 // unmatched events will be shown in the analysis view. |
704 | 704 |
705 // Records a single NESTABLE_ASYNC_BEGIN event called "name" immediately, with 2 | 705 // Records a single NESTABLE_ASYNC_BEGIN event called "name" immediately, with 0 |
706 // associated arguments. If the category is not enabled, then this does nothing. | 706 // or 2 associated arguments. If the category is not enabled, then this does |
707 // nothing. | |
708 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(category_group, name, id) \ | |
709 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \ | |
710 category_group, name, id, TRACE_EVENT_FLAG_NONE) | |
707 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(category_group, name, id, arg1_name, \ | 711 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(category_group, name, id, arg1_name, \ |
708 arg1_val, arg2_name, arg2_val) \ | 712 arg1_val, arg2_name, arg2_val) \ |
709 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \ | 713 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \ |
710 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | 714 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
711 arg2_name, arg2_val) | 715 arg2_name, arg2_val) |
712 // Records a single NESTABLE_ASYNC_END event called "name" immediately, with 2 | 716 // Records a single NESTABLE_ASYNC_END event called "name" immediately, with 2 |
713 // associated arguments. If the category is not enabled, then this does nothing. | 717 // associated arguments. If the category is not enabled, then this does nothing. |
718 #define TRACE_EVENT_NESTABLE_ASYNC_END0(category_group, name, id) \ | |
719 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ | |
720 category_group, name, id, TRACE_EVENT_FLAG_NONE) | |
721 #define TRACE_EVENT_NESTABLE_ASYNC_END1(category_group, name, id, arg1_name, \ | |
722 arg1_val) \ | |
723 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ | |
724 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | |
714 #define TRACE_EVENT_NESTABLE_ASYNC_END2(category_group, name, id, arg1_name, \ | 725 #define TRACE_EVENT_NESTABLE_ASYNC_END2(category_group, name, id, arg1_name, \ |
715 arg1_val, arg2_name, arg2_val) \ | 726 arg1_val, arg2_name, arg2_val) \ |
716 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ | 727 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ |
717 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | 728 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
718 arg2_name, arg2_val) | 729 arg2_name, arg2_val) |
719 // Records a single NESTABLE_ASYNC_INSTANT event called "name" immediately, | 730 // Records a single NESTABLE_ASYNC_INSTANT event called "name" immediately, |
720 // with 2 associated arguments. If the category is not enabled, then this | 731 // with 2 associated arguments. If the category is not enabled, then this |
721 // does nothing. | 732 // does nothing. |
722 #define TRACE_EVENT_NESTABLE_ASYNC_INSTANT2(category_group, name, id, \ | 733 #define TRACE_EVENT_NESTABLE_ASYNC_INSTANT2(category_group, name, id, \ |
723 arg1_name, arg1_val, arg2_name, arg2_val) \ | 734 arg1_name, arg1_val, arg2_name, arg2_val) \ |
724 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT, \ | 735 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT, \ |
725 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | 736 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
726 arg2_name, arg2_val) | 737 arg2_name, arg2_val) |
727 | 738 |
739 // Call TRACE_EVENT_NESTABLE_ASYNC_BEGIN* to set up a nestable id before calling | |
740 // TRACE_EVENT_NESTABLE_ASYNC*. Records a nested pair of begin and end events | |
741 // called "name" for the current scope and assocated with the id passed to | |
742 // _BEGIN. Handles 0, 1 or 2 associated arguments. If the category is | |
743 // not enabled, then this does nothing. | |
744 // - category and name strings must have application lifetime (statics or | |
745 // literals). They may not include " chars. | |
746 #define TRACE_EVENT_NESTABLE_ASYNC0(category_group, name, id) \ | |
747 INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_ID( \ | |
748 TRACE_EVENT_PHASE_NESTABLE_ASYNC_COMPLETE, category_group, name, id, \ | |
749 TRACE_EVENT_FLAG_NONE) | |
750 #define TRACE_EVENT_NESTABLE_ASYNC1( \ | |
751 category_group, name, id, arg1_name, arg1_val) \ | |
752 INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_ID( \ | |
753 TRACE_EVENT_PHASE_NESTABLE_ASYNC_COMPLETE, category_group, name, id, \ | |
754 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | |
755 #define TRACE_EVENT_NESTABLE_ASYNC2( \ | |
756 category_group, name, id, arg1_name, arg1_val, arg2_name, arg2_val) \ | |
757 INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_ID( \ | |
758 TRACE_EVENT_PHASE_NESTABLE_ASYNC_COMPLETE, category_group, name, id, \ | |
759 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val) | |
760 | |
728 // Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2 | 761 // Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2 |
729 // associated arguments. If the category is not enabled, then this | 762 // associated arguments. If the category is not enabled, then this |
730 // does nothing. | 763 // does nothing. |
731 // - category and name strings must have application lifetime (statics or | 764 // - category and name strings must have application lifetime (statics or |
732 // literals). They may not include " chars. | 765 // literals). They may not include " chars. |
733 // - |id| is used to match the FLOW_BEGIN event with the FLOW_END event. FLOW | 766 // - |id| is used to match the FLOW_BEGIN event with the FLOW_END event. FLOW |
734 // events are considered to match if their category_group, name and id values | 767 // events are considered to match if their category_group, name and id values |
735 // all match. |id| must either be a pointer or an integer value up to 64 bits. | 768 // all match. |id| must either be a pointer or an integer value up to 64 bits. |
736 // If it's a pointer, the bits will be xored with a hash of the process ID so | 769 // If it's a pointer, the bits will be xored with a hash of the process ID so |
737 // that the same pointer on two different processes will not collide. | 770 // that the same pointer on two different processes will not collide. |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1020 trace_event_internal::TraceID trace_event_trace_id( \ | 1053 trace_event_internal::TraceID trace_event_trace_id( \ |
1021 id, &trace_event_flags); \ | 1054 id, &trace_event_flags); \ |
1022 trace_event_internal::AddTraceEvent( \ | 1055 trace_event_internal::AddTraceEvent( \ |
1023 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | 1056 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ |
1024 name, trace_event_trace_id.data(), trace_event_flags, \ | 1057 name, trace_event_trace_id.data(), trace_event_flags, \ |
1025 ##__VA_ARGS__); \ | 1058 ##__VA_ARGS__); \ |
1026 } \ | 1059 } \ |
1027 } while (0) | 1060 } while (0) |
1028 | 1061 |
1029 // Implementation detail: internal macro to create static category and add | 1062 // Implementation detail: internal macro to create static category and add |
1063 // event if the category is enabled. Also adds the end event when the scope | |
1064 // ends. | |
1065 #define INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_ID( \ | |
1066 phase, category_group, name, id, flags, ...) \ | |
1067 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | |
1068 trace_event_internal::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \ | |
1069 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | |
1070 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | |
1071 trace_event_internal::TraceID trace_event_trace_id( \ | |
1072 id, &trace_event_flags); \ | |
1073 base::trace_event::TraceEventHandle h = \ | |
1074 trace_event_internal::AddTraceEvent( \ | |
1075 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | |
1076 name, trace_event_trace_id.data(), trace_event_flags, \ | |
1077 ##__VA_ARGS__); \ | |
1078 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \ | |
1079 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \ | |
1080 } | |
1081 | |
1082 // Implementation detail: internal macro to create static category and add | |
1030 // event if the category is enabled. | 1083 // event if the category is enabled. |
1031 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, \ | 1084 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, \ |
1032 category_group, name, id, thread_id, timestamp, flags, ...) \ | 1085 category_group, name, id, thread_id, timestamp, flags, ...) \ |
1033 do { \ | 1086 do { \ |
1034 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 1087 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
1035 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | 1088 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
1036 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 1089 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
1037 trace_event_internal::TraceID trace_event_trace_id( \ | 1090 trace_event_internal::TraceID trace_event_trace_id( \ |
1038 id, &trace_event_flags); \ | 1091 id, &trace_event_flags); \ |
1039 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ | 1092 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ |
(...skipping 14 matching lines...) Expand all Loading... | |
1054 #define TRACE_EVENT_PHASE_BEGIN ('B') | 1107 #define TRACE_EVENT_PHASE_BEGIN ('B') |
1055 #define TRACE_EVENT_PHASE_END ('E') | 1108 #define TRACE_EVENT_PHASE_END ('E') |
1056 #define TRACE_EVENT_PHASE_COMPLETE ('X') | 1109 #define TRACE_EVENT_PHASE_COMPLETE ('X') |
1057 #define TRACE_EVENT_PHASE_INSTANT ('I') | 1110 #define TRACE_EVENT_PHASE_INSTANT ('I') |
1058 #define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S') | 1111 #define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S') |
1059 #define TRACE_EVENT_PHASE_ASYNC_STEP_INTO ('T') | 1112 #define TRACE_EVENT_PHASE_ASYNC_STEP_INTO ('T') |
1060 #define TRACE_EVENT_PHASE_ASYNC_STEP_PAST ('p') | 1113 #define TRACE_EVENT_PHASE_ASYNC_STEP_PAST ('p') |
1061 #define TRACE_EVENT_PHASE_ASYNC_END ('F') | 1114 #define TRACE_EVENT_PHASE_ASYNC_END ('F') |
1062 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN ('b') | 1115 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN ('b') |
1063 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_END ('e') | 1116 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_END ('e') |
1117 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_COMPLETE ('x') | |
1064 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT ('n') | 1118 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT ('n') |
1065 #define TRACE_EVENT_PHASE_FLOW_BEGIN ('s') | 1119 #define TRACE_EVENT_PHASE_FLOW_BEGIN ('s') |
1066 #define TRACE_EVENT_PHASE_FLOW_STEP ('t') | 1120 #define TRACE_EVENT_PHASE_FLOW_STEP ('t') |
1067 #define TRACE_EVENT_PHASE_FLOW_END ('f') | 1121 #define TRACE_EVENT_PHASE_FLOW_END ('f') |
1068 #define TRACE_EVENT_PHASE_METADATA ('M') | 1122 #define TRACE_EVENT_PHASE_METADATA ('M') |
1069 #define TRACE_EVENT_PHASE_COUNTER ('C') | 1123 #define TRACE_EVENT_PHASE_COUNTER ('C') |
1070 #define TRACE_EVENT_PHASE_SAMPLE ('P') | 1124 #define TRACE_EVENT_PHASE_SAMPLE ('P') |
1071 #define TRACE_EVENT_PHASE_CREATE_OBJECT ('N') | 1125 #define TRACE_EVENT_PHASE_CREATE_OBJECT ('N') |
1072 #define TRACE_EVENT_PHASE_SNAPSHOT_OBJECT ('O') | 1126 #define TRACE_EVENT_PHASE_SNAPSHOT_OBJECT ('O') |
1073 #define TRACE_EVENT_PHASE_DELETE_OBJECT ('D') | 1127 #define TRACE_EVENT_PHASE_DELETE_OBJECT ('D') |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1514 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, | 1568 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, |
1515 name, id, thread_id, now, flags, | 1569 name, id, thread_id, now, flags, |
1516 arg1_name, arg1_val, | 1570 arg1_name, arg1_val, |
1517 arg2_name, arg2_val); | 1571 arg2_name, arg2_val); |
1518 } | 1572 } |
1519 | 1573 |
1520 // Used by TRACE_EVENTx macros. Do not use directly. | 1574 // Used by TRACE_EVENTx macros. Do not use directly. |
1521 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { | 1575 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { |
1522 public: | 1576 public: |
1523 // Note: members of data_ intentionally left uninitialized. See Initialize. | 1577 // Note: members of data_ intentionally left uninitialized. See Initialize. |
1524 ScopedTracer() : p_data_(NULL) {} | 1578 ScopedTracer() : initialized_(false) {} |
Dan Beam
2015/04/30 04:40:13
forgot i did this. can revert if you want...
| |
1525 | 1579 |
1526 ~ScopedTracer() { | 1580 ~ScopedTracer() { |
1527 if (p_data_ && *data_.category_group_enabled) | 1581 if (initialized_ && *data_.category_group_enabled) |
1528 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( | 1582 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( |
1529 data_.category_group_enabled, data_.name, data_.event_handle); | 1583 data_.category_group_enabled, data_.name, data_.event_handle); |
1530 } | 1584 } |
1531 | 1585 |
1532 void Initialize(const unsigned char* category_group_enabled, | 1586 void Initialize(const unsigned char* category_group_enabled, |
1533 const char* name, | 1587 const char* name, |
1534 base::trace_event::TraceEventHandle event_handle) { | 1588 base::trace_event::TraceEventHandle event_handle) { |
1535 data_.category_group_enabled = category_group_enabled; | 1589 data_.category_group_enabled = category_group_enabled; |
1536 data_.name = name; | 1590 data_.name = name; |
1537 data_.event_handle = event_handle; | 1591 data_.event_handle = event_handle; |
1538 p_data_ = &data_; | 1592 initialized_ = true; |
1539 } | 1593 } |
1540 | 1594 |
1541 private: | 1595 private: |
1542 // This Data struct workaround is to avoid initializing all the members | 1596 // This Data struct workaround is to avoid initializing all the members |
1543 // in Data during construction of this object, since this object is always | 1597 // in Data during construction of this object, since this object is always |
1544 // constructed, even when tracing is disabled. If the members of Data were | 1598 // constructed, even when tracing is disabled. If the members of Data were |
1545 // members of this class instead, compiler warnings occur about potential | 1599 // members of this class instead, compiler warnings occur about potential |
1546 // uninitialized accesses. | 1600 // uninitialized accesses. |
1547 struct Data { | 1601 struct Data { |
1548 const unsigned char* category_group_enabled; | 1602 const unsigned char* category_group_enabled; |
1549 const char* name; | 1603 const char* name; |
1550 base::trace_event::TraceEventHandle event_handle; | 1604 base::trace_event::TraceEventHandle event_handle; |
1551 }; | 1605 }; |
1552 Data* p_data_; | 1606 bool initialized_; |
1553 Data data_; | 1607 Data data_; |
1554 }; | 1608 }; |
1555 | 1609 |
1556 // Used by TRACE_EVENT_BINARY_EFFICIENTx macro. Do not use directly. | 1610 // Used by TRACE_EVENT_BINARY_EFFICIENTx macro. Do not use directly. |
1557 class TRACE_EVENT_API_CLASS_EXPORT ScopedTraceBinaryEfficient { | 1611 class TRACE_EVENT_API_CLASS_EXPORT ScopedTraceBinaryEfficient { |
1558 public: | 1612 public: |
1559 ScopedTraceBinaryEfficient(const char* category_group, const char* name); | 1613 ScopedTraceBinaryEfficient(const char* category_group, const char* name); |
1560 ~ScopedTraceBinaryEfficient(); | 1614 ~ScopedTraceBinaryEfficient(); |
1561 | 1615 |
1562 private: | 1616 private: |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1633 const char* name_; | 1687 const char* name_; |
1634 IDType id_; | 1688 IDType id_; |
1635 | 1689 |
1636 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1690 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
1637 }; | 1691 }; |
1638 | 1692 |
1639 } // namespace trace_event | 1693 } // namespace trace_event |
1640 } // namespace base | 1694 } // namespace base |
1641 | 1695 |
1642 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ | 1696 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ |
OLD | NEW |