| 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 under third_party_mods/chromium or at: | 3 // found in the LICENSE file under third_party_mods/chromium or at: |
| 4 // http://src.chromium.org/svn/trunk/src/LICENSE | 4 // http://src.chromium.org/svn/trunk/src/LICENSE |
| 5 | 5 |
| 6 #ifndef WEBRTC_BASE_TRACE_EVENT_H_ | 6 #ifndef WEBRTC_BASE_TRACE_EVENT_H_ |
| 7 #define WEBRTC_BASE_TRACE_EVENT_H_ | 7 #define WEBRTC_BASE_TRACE_EVENT_H_ |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 // macro, because the arg_values could be temporary objects, such as | 813 // macro, because the arg_values could be temporary objects, such as |
| 814 // std::string. In order to store pointers to the internal c_str and pass | 814 // std::string. In order to store pointers to the internal c_str and pass |
| 815 // through to the tracing API, the arg_values must live throughout | 815 // through to the tracing API, the arg_values must live throughout |
| 816 // these procedures. | 816 // these procedures. |
| 817 | 817 |
| 818 static inline void AddTraceEvent(char phase, | 818 static inline void AddTraceEvent(char phase, |
| 819 const unsigned char* category_enabled, | 819 const unsigned char* category_enabled, |
| 820 const char* name, | 820 const char* name, |
| 821 unsigned long long id, | 821 unsigned long long id, |
| 822 unsigned char flags) { | 822 unsigned char flags) { |
| 823 TRACE_EVENT_API_ADD_TRACE_EVENT( | 823 TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_enabled, name, id, |
| 824 phase, category_enabled, name, id, | 824 kZeroNumArgs, nullptr, nullptr, nullptr, |
| 825 kZeroNumArgs, NULL, NULL, NULL, | 825 flags); |
| 826 flags); | |
| 827 } | 826 } |
| 828 | 827 |
| 829 template<class ARG1_TYPE> | 828 template<class ARG1_TYPE> |
| 830 static inline void AddTraceEvent(char phase, | 829 static inline void AddTraceEvent(char phase, |
| 831 const unsigned char* category_enabled, | 830 const unsigned char* category_enabled, |
| 832 const char* name, | 831 const char* name, |
| 833 unsigned long long id, | 832 unsigned long long id, |
| 834 unsigned char flags, | 833 unsigned char flags, |
| 835 const char* arg1_name, | 834 const char* arg1_name, |
| 836 const ARG1_TYPE& arg1_val) { | 835 const ARG1_TYPE& arg1_val) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 863 TRACE_EVENT_API_ADD_TRACE_EVENT( | 862 TRACE_EVENT_API_ADD_TRACE_EVENT( |
| 864 phase, category_enabled, name, id, | 863 phase, category_enabled, name, id, |
| 865 num_args, arg_names, arg_types, arg_values, | 864 num_args, arg_names, arg_types, arg_values, |
| 866 flags); | 865 flags); |
| 867 } | 866 } |
| 868 | 867 |
| 869 // Used by TRACE_EVENTx macro. Do not use directly. | 868 // Used by TRACE_EVENTx macro. Do not use directly. |
| 870 class TraceEndOnScopeClose { | 869 class TraceEndOnScopeClose { |
| 871 public: | 870 public: |
| 872 // Note: members of data_ intentionally left uninitialized. See Initialize. | 871 // Note: members of data_ intentionally left uninitialized. See Initialize. |
| 873 TraceEndOnScopeClose() : p_data_(NULL) {} | 872 TraceEndOnScopeClose() : p_data_(nullptr) {} |
| 874 ~TraceEndOnScopeClose() { | 873 ~TraceEndOnScopeClose() { |
| 875 if (p_data_) | 874 if (p_data_) |
| 876 AddEventIfEnabled(); | 875 AddEventIfEnabled(); |
| 877 } | 876 } |
| 878 | 877 |
| 879 void Initialize(const unsigned char* category_enabled, | 878 void Initialize(const unsigned char* category_enabled, |
| 880 const char* name) { | 879 const char* name) { |
| 881 data_.category_enabled = category_enabled; | 880 data_.category_enabled = category_enabled; |
| 882 data_.name = name; | 881 data_.name = name; |
| 883 p_data_ = &data_; | 882 p_data_ = &data_; |
| 884 } | 883 } |
| 885 | 884 |
| 886 private: | 885 private: |
| 887 // Add the end event if the category is still enabled. | 886 // Add the end event if the category is still enabled. |
| 888 void AddEventIfEnabled() { | 887 void AddEventIfEnabled() { |
| 889 // Only called when p_data_ is non-null. | 888 // Only called when p_data_ is non-null. |
| 890 if (*p_data_->category_enabled) { | 889 if (*p_data_->category_enabled) { |
| 891 TRACE_EVENT_API_ADD_TRACE_EVENT( | 890 TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_END, |
| 892 TRACE_EVENT_PHASE_END, | 891 p_data_->category_enabled, p_data_->name, |
| 893 p_data_->category_enabled, | 892 kNoEventId, kZeroNumArgs, nullptr, |
| 894 p_data_->name, kNoEventId, | 893 nullptr, nullptr, TRACE_EVENT_FLAG_NONE); |
| 895 kZeroNumArgs, NULL, NULL, NULL, | |
| 896 TRACE_EVENT_FLAG_NONE); | |
| 897 } | 894 } |
| 898 } | 895 } |
| 899 | 896 |
| 900 // This Data struct workaround is to avoid initializing all the members | 897 // This Data struct workaround is to avoid initializing all the members |
| 901 // in Data during construction of this object, since this object is always | 898 // in Data during construction of this object, since this object is always |
| 902 // constructed, even when tracing is disabled. If the members of Data were | 899 // constructed, even when tracing is disabled. If the members of Data were |
| 903 // members of this class instead, compiler warnings occur about potential | 900 // members of this class instead, compiler warnings occur about potential |
| 904 // uninitialized accesses. | 901 // uninitialized accesses. |
| 905 struct Data { | 902 struct Data { |
| 906 const unsigned char* category_enabled; | 903 const unsigned char* category_enabled; |
| 907 const char* name; | 904 const char* name; |
| 908 }; | 905 }; |
| 909 Data* p_data_; | 906 Data* p_data_; |
| 910 Data data_; | 907 Data data_; |
| 911 }; | 908 }; |
| 912 | 909 |
| 913 } // namespace trace_event_internal | 910 } // namespace trace_event_internal |
| 914 } // namespace webrtc | 911 } // namespace webrtc |
| 915 | 912 |
| 916 #endif // WEBRTC_BASE_TRACE_EVENT_H_ | 913 #endif // WEBRTC_BASE_TRACE_EVENT_H_ |
| OLD | NEW |