Move trace_event and associated files to webrtc/base.
Also starting to use TRACE_EVENT from thread.cc in webrtc/base, to track Invoke() calls.
BUG=
R=magjed@webrtc.org, tina.legrand@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/42769004
Cr-Commit-Position: refs/heads/master@{#8755}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8755 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/base/event_tracer.cc b/webrtc/base/event_tracer.cc
new file mode 100644
index 0000000..5c6d39f
--- /dev/null
+++ b/webrtc/base/event_tracer.cc
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/base/event_tracer.h"
+
+namespace webrtc {
+
+namespace {
+
+GetCategoryEnabledPtr g_get_category_enabled_ptr = 0;
+AddTraceEventPtr g_add_trace_event_ptr = 0;
+
+} // namespace
+
+void SetupEventTracer(GetCategoryEnabledPtr get_category_enabled_ptr,
+ AddTraceEventPtr add_trace_event_ptr) {
+ g_get_category_enabled_ptr = get_category_enabled_ptr;
+ g_add_trace_event_ptr = add_trace_event_ptr;
+}
+
+// static
+const unsigned char* EventTracer::GetCategoryEnabled(const char* name) {
+ if (g_get_category_enabled_ptr)
+ return g_get_category_enabled_ptr(name);
+
+ // A string with null terminator means category is disabled.
+ return reinterpret_cast<const unsigned char*>("\0");
+}
+
+// static
+void EventTracer::AddTraceEvent(char phase,
+ const unsigned char* category_enabled,
+ const char* name,
+ unsigned long long id,
+ int num_args,
+ const char** arg_names,
+ const unsigned char* arg_types,
+ const unsigned long long* arg_values,
+ unsigned char flags) {
+ if (g_add_trace_event_ptr) {
+ g_add_trace_event_ptr(phase,
+ category_enabled,
+ name,
+ id,
+ num_args,
+ arg_names,
+ arg_types,
+ arg_values,
+ flags);
+ }
+}
+
+} // namespace webrtc