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 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 convertable_values[1] = {arg_value}; | 758 convertable_values[1] = {arg_value}; |
759 unsigned char arg_types[1] = {TRACE_VALUE_TYPE_CONVERTABLE}; | 759 unsigned char arg_types[1] = {TRACE_VALUE_TYPE_CONVERTABLE}; |
760 base::trace_event::TraceLog::GetInstance()->AddMetadataEvent( | 760 base::trace_event::TraceLog::GetInstance()->AddMetadataEvent( |
761 event_name, | 761 event_name, |
762 1, // num_args | 762 1, // num_args |
763 arg_names, arg_types, | 763 arg_names, arg_types, |
764 nullptr, // arg_values | 764 nullptr, // arg_values |
765 convertable_values, TRACE_EVENT_FLAG_NONE); | 765 convertable_values, TRACE_EVENT_FLAG_NONE); |
766 } | 766 } |
767 | 767 |
| 768 template <class ARG1_TYPE> |
| 769 static void AddMetadataEvent(const char* event_name, |
| 770 const char* arg_name, |
| 771 const ARG1_TYPE& arg_val) { |
| 772 const int num_args = 1; |
| 773 const char* arg_names[1] = {arg_name}; |
| 774 unsigned char arg_types[1]; |
| 775 unsigned long long arg_values[1]; |
| 776 SetTraceValue(arg_val, &arg_types[0], &arg_values[0]); |
| 777 |
| 778 base::trace_event::TraceLog::GetInstance()->AddMetadataEvent( |
| 779 event_name, num_args, arg_names, arg_types, arg_values, nullptr, |
| 780 TRACE_EVENT_FLAG_NONE); |
| 781 } |
| 782 |
768 // Used by TRACE_EVENTx macros. Do not use directly. | 783 // Used by TRACE_EVENTx macros. Do not use directly. |
769 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { | 784 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { |
770 public: | 785 public: |
771 // Note: members of data_ intentionally left uninitialized. See Initialize. | 786 // Note: members of data_ intentionally left uninitialized. See Initialize. |
772 ScopedTracer() : p_data_(NULL) {} | 787 ScopedTracer() : p_data_(NULL) {} |
773 | 788 |
774 ~ScopedTracer() { | 789 ~ScopedTracer() { |
775 if (p_data_ && *data_.category_group_enabled) | 790 if (p_data_ && *data_.category_group_enabled) |
776 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( | 791 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( |
777 data_.category_group_enabled, data_.name, data_.event_handle); | 792 data_.category_group_enabled, data_.name, data_.event_handle); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 const char* name_; | 896 const char* name_; |
882 IDType id_; | 897 IDType id_; |
883 | 898 |
884 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 899 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
885 }; | 900 }; |
886 | 901 |
887 } // namespace trace_event | 902 } // namespace trace_event |
888 } // namespace base | 903 } // namespace base |
889 | 904 |
890 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ | 905 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ |
OLD | NEW |