Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Unified Diff: ppapi/cpp/dev/trace_event_dev.h

Issue 12212198: Add C++ Trace Event support to PPAPI/NaCl SDK (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: brettw feedback Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/cpp/DEPS ('k') | ppapi/cpp/dev/trace_event_dev.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/dev/trace_event_dev.h
diff --git a/ppapi/cpp/dev/trace_event_dev.h b/ppapi/cpp/dev/trace_event_dev.h
new file mode 100644
index 0000000000000000000000000000000000000000..a27029994ce3d8ada9eb6ae0d2544ec59c591030
--- /dev/null
+++ b/ppapi/cpp/dev/trace_event_dev.h
@@ -0,0 +1,76 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_DEV_TRACE_EVENT_DEV_H_
+#define PPAPI_CPP_DEV_TRACE_EVENT_DEV_H_
+
+#include "ppapi/c/pp_stdint.h"
+
+/// @file
+/// This file defines the API for Pepper plugins to add trace events. Only
+/// <code>SetThreadName</code> is meant to be called directly by a developer,
+/// the other functions are only used by the macros in trace_event_internal.h.
+/// For details on how to instrument code, see:
+/// http://www.chromium.org/developers/how-tos/trace-event-profiling-tool/tracing-event-instrumentation
+
+namespace pp {
+
+class Trace_Events {
+ public:
+ /// Sets the current thread's name. This name will show up in trace captures
+ /// in chrome://tracing
+ static void SetThreadName(const char* name);
+
+ /// This function returns a pointer to a variable indicated if a particular
+ /// category is enabled. See comments in trace_event_internal.h for more
+ /// details.
+ static const unsigned char* GetCategoryEnabled(const char* category_name);
+
+ /// Add a trace event entry. See comments in trace_event_internal.h for more
+ /// details.
+ static void AddTraceEvent(int8_t phase,
+ const void* category_enabled,
+ const char* name,
+ uint64_t id,
+ uint32_t num_args,
+ const char* arg_names[],
+ const uint8_t arg_types[],
+ const uint64_t arg_values[],
+ uint8_t flags);
+
+};
+
+} // namespace pp
+
+// This header is modified from Chromium's base/debug/trace_event.h to provide
+// tracing through the PPB_Trace_Event_Dev interface.
+
+#define TRACE_EVENT_API_GET_CATEGORY_ENABLED \
+ pp::Trace_Events::GetCategoryEnabled
+
+// void TRACE_EVENT_API_ADD_TRACE_EVENT(
+// 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)
+#define TRACE_EVENT_API_ADD_TRACE_EVENT pp::Trace_Events::AddTraceEvent
+
+// Defines atomic operations used internally by the tracing system.
+// Per comments in trace_event_internal.h these require no memory barrier,
+// and the Chromium gcc versions are defined as plain int load/store.
+#define TRACE_EVENT_API_ATOMIC_WORD intptr_t
+#define TRACE_EVENT_API_ATOMIC_LOAD(var) (var)
+#define TRACE_EVENT_API_ATOMIC_STORE(var, value) ((var) = (value))
+
+// Defines visibility for classes in trace_event_internal.h.
+#define TRACE_EVENT_API_CLASS_EXPORT
+
+#include "base/debug/trace_event_internal.h"
+
+#endif // PPAPI_CPP_DEV_TRACE_EVENT_DEV_H_
« no previous file with comments | « ppapi/cpp/DEPS ('k') | ppapi/cpp/dev/trace_event_dev.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698