tommi@webrtc.org | 7c64ed2 | 2015-03-17 14:25:37 +0000 | [diff] [blame] | 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 | // This file defines the interface for event tracing in WebRTC. |
| 12 | // |
| 13 | // Event log handlers are set through SetupEventTracer(). User of this API will |
| 14 | // provide two function pointers to handle event tracing calls. |
| 15 | // |
| 16 | // * GetCategoryEnabledPtr |
| 17 | // Event tracing system calls this function to determine if a particular |
| 18 | // event category is enabled. |
| 19 | // |
| 20 | // * AddTraceEventPtr |
| 21 | // Adds a tracing event. It is the user's responsibility to log the data |
| 22 | // provided. |
| 23 | // |
| 24 | // Parameters for the above two functions are described in trace_event.h. |
| 25 | |
| 26 | #ifndef WEBRTC_BASE_EVENT_TRACER_H_ |
| 27 | #define WEBRTC_BASE_EVENT_TRACER_H_ |
| 28 | |
| 29 | namespace webrtc { |
| 30 | |
| 31 | typedef const unsigned char* (*GetCategoryEnabledPtr)(const char* name); |
| 32 | typedef void (*AddTraceEventPtr)(char phase, |
| 33 | const unsigned char* category_enabled, |
| 34 | const char* name, |
| 35 | unsigned long long id, |
| 36 | int num_args, |
| 37 | const char** arg_names, |
| 38 | const unsigned char* arg_types, |
| 39 | const unsigned long long* arg_values, |
| 40 | unsigned char flags); |
| 41 | |
| 42 | // User of WebRTC can call this method to setup event tracing. |
| 43 | // |
| 44 | // This method must be called before any WebRTC methods. Functions |
| 45 | // provided should be thread-safe. |
| 46 | void SetupEventTracer( |
| 47 | GetCategoryEnabledPtr get_category_enabled_ptr, |
| 48 | AddTraceEventPtr add_trace_event_ptr); |
| 49 | |
| 50 | // This class defines interface for the event tracing system to call |
| 51 | // internally. Do not call these methods directly. |
| 52 | class EventTracer { |
| 53 | public: |
| 54 | static const unsigned char* GetCategoryEnabled( |
| 55 | const char* name); |
| 56 | |
| 57 | static void AddTraceEvent( |
| 58 | char phase, |
| 59 | const unsigned char* category_enabled, |
| 60 | const char* name, |
| 61 | unsigned long long id, |
| 62 | int num_args, |
| 63 | const char** arg_names, |
| 64 | const unsigned char* arg_types, |
| 65 | const unsigned long long* arg_values, |
| 66 | unsigned char flags); |
| 67 | }; |
| 68 | |
| 69 | } // namespace webrtc |
| 70 | |
| 71 | #endif // WEBRTC_BASE_EVENT_TRACER_H_ |