1 /* 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "webrtc/system_wrappers/interface/event_tracer.h" 12 13 namespace webrtc { 14 15 namespace { 16 17 GetCategoryEnabledPtr g_get_category_enabled_ptr = 0; 18 AddTraceEventPtr g_add_trace_event_ptr = 0; 19 20 } // namespace 21 22 void SetupEventTracer(GetCategoryEnabledPtr get_category_enabled_ptr, 23 AddTraceEventPtr add_trace_event_ptr) { 24 g_get_category_enabled_ptr = get_category_enabled_ptr; 25 g_add_trace_event_ptr = add_trace_event_ptr; 26 } 27 28 // static 29 const unsigned char* EventTracer::GetCategoryEnabled(const char* name) { 30 if (g_get_category_enabled_ptr) 31 return g_get_category_enabled_ptr(name); 32 33 // A string with null terminator means category is disabled. 34 return reinterpret_cast<const unsigned char*>("\0"); 35 } 36 37 // static 38 void EventTracer::AddTraceEvent(char phase, 39 const unsigned char* category_enabled, 40 const char* name, 41 unsigned long long id, 42 int num_args, 43 const char** arg_names, 44 const unsigned char* arg_types, 45 const unsigned long long* arg_values, 46 unsigned char flags) { 47 if (g_add_trace_event_ptr) { 48 g_add_trace_event_ptr(phase, 49 category_enabled, 50 name, 51 id, 52 num_args, 53 arg_names, 54 arg_types, 55 arg_values, 56 flags); 57 } 58 } 59 60 } // namespace webrtc 61