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

Unified Diff: base/debug/trace_event_internal.h

Issue 12047066: Reland: Add trace event Pepper API (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 7 years, 11 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 | « base/debug/trace_event.cc ('k') | ppapi/api/dev/ppb_trace_event_dev.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/trace_event_internal.h
diff --git a/base/debug/trace_event.h b/base/debug/trace_event_internal.h
similarity index 93%
copy from base/debug/trace_event.h
copy to base/debug/trace_event_internal.h
index fc8897e1e73cf5e928a72552a24a604ed16ba2a5..96224114894a1d02e95abab6ba8c700c35fe9720 100644
--- a/base/debug/trace_event.h
+++ b/base/debug/trace_event_internal.h
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// This header is designed to give you trace_event macros without specifying
+// This header file defines the set of trace_event macros without specifying
// how the events actually get collected and stored. If you need to expose trace
-// event to some other universe, you can copy-and-paste this file,
-// implement the TRACE_EVENT_API macros, and do any other necessary fixup for
-// the target platform. The end result is that multiple libraries can funnel
-// events through to a shared trace event collector.
+// events to some other universe, you can copy-and-paste this file as well as
+// trace_event.h, modifying the macros contained there as necessary for the
+// target platform. The end result is that multiple libraries can funnel events
+// through to a shared trace event collector.
// Trace events are for tracking application performance and resource usage.
// Macros are provided to track:
@@ -148,15 +148,11 @@
// and resolving the category.
-#ifndef BASE_DEBUG_TRACE_EVENT_H_
-#define BASE_DEBUG_TRACE_EVENT_H_
+#ifndef BASE_DEBUG_TRACE_EVENT_INTERNAL_H_
+#define BASE_DEBUG_TRACE_EVENT_INTERNAL_H_
#include <string>
-#include "base/atomicops.h"
-#include "base/debug/trace_event_impl.h"
-#include "build/build_config.h"
-
// By default, const char* argument values are assumed to have long-lived scope
// and will not be copied. Use this macro to force a const char* to be copied.
#define TRACE_STR_COPY(str) \
@@ -545,38 +541,6 @@
arg1_name, arg1_val, arg2_name, arg2_val)
-////////////////////////////////////////////////////////////////////////////////
-// Implementation specific tracing API definitions.
-
-// Get a pointer to the enabled state of the given trace category. Only
-// long-lived literal strings should be given as the category name. The returned
-// pointer can be held permanently in a local static for example. If the
-// unsigned char is non-zero, tracing is enabled. If tracing is enabled,
-// TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled
-// between the load of the tracing state and the call to
-// TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out
-// for best performance when tracing is disabled.
-// const unsigned char*
-// TRACE_EVENT_API_GET_CATEGORY_ENABLED(const char* category_name)
-#define TRACE_EVENT_API_GET_CATEGORY_ENABLED \
- base::debug::TraceLog::GetCategoryEnabled
-
-// Add a trace event to the platform tracing system.
-// 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 \
- base::debug::TraceLog::GetInstance()->AddTraceEvent
-
-////////////////////////////////////////////////////////////////////////////////
-
// Implementation detail: trace event macros create temporary variables
// to keep instrumentation overhead low. These macros give each temporary
// variable a unique name based on the line number to prevent name collissions.
@@ -592,15 +556,15 @@
// even when the unsigned char* points to garbage data (which may be the case
// on processors without cache coherency).
#define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \
- static base::subtle::AtomicWord INTERNAL_TRACE_EVENT_UID(atomic) = 0; \
- const uint8* INTERNAL_TRACE_EVENT_UID(catstatic) = \
- reinterpret_cast<const uint8*>( \
- base::subtle::NoBarrier_Load(&INTERNAL_TRACE_EVENT_UID(atomic))); \
+ static TRACE_EVENT_API_ATOMIC_WORD INTERNAL_TRACE_EVENT_UID(atomic) = 0; \
+ const unsigned char* INTERNAL_TRACE_EVENT_UID(catstatic) = \
+ reinterpret_cast<const unsigned char*>(TRACE_EVENT_API_ATOMIC_LOAD( \
+ INTERNAL_TRACE_EVENT_UID(atomic))); \
if (!INTERNAL_TRACE_EVENT_UID(catstatic)) { \
INTERNAL_TRACE_EVENT_UID(catstatic) = \
TRACE_EVENT_API_GET_CATEGORY_ENABLED(category); \
- base::subtle::NoBarrier_Store(&INTERNAL_TRACE_EVENT_UID(atomic), \
- reinterpret_cast<base::subtle::AtomicWord>( \
+ TRACE_EVENT_API_ATOMIC_STORE(INTERNAL_TRACE_EVENT_UID(atomic), \
+ reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>( \
INTERNAL_TRACE_EVENT_UID(catstatic))); \
}
@@ -842,8 +806,7 @@ static inline void AddTraceEvent(char phase,
unsigned char flags) {
TRACE_EVENT_API_ADD_TRACE_EVENT(
phase, category_enabled, name, id,
- kZeroNumArgs, NULL, NULL, NULL,
- flags);
+ kZeroNumArgs, NULL, NULL, NULL, flags);
}
template<class ARG1_TYPE>
@@ -860,8 +823,7 @@ static inline void AddTraceEvent(char phase,
SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
TRACE_EVENT_API_ADD_TRACE_EVENT(
phase, category_enabled, name, id,
- num_args, &arg1_name, arg_types, arg_values,
- flags);
+ num_args, &arg1_name, arg_types, arg_values, flags);
}
template<class ARG1_TYPE, class ARG2_TYPE>
@@ -882,12 +844,11 @@ static inline void AddTraceEvent(char phase,
SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]);
TRACE_EVENT_API_ADD_TRACE_EVENT(
phase, category_enabled, name, id,
- num_args, arg_names, arg_types, arg_values,
- flags);
+ num_args, arg_names, arg_types, arg_values, flags);
}
// Used by TRACE_EVENTx macro. Do not use directly.
-class BASE_EXPORT TraceEndOnScopeClose {
+class TRACE_EVENT_API_CLASS_EXPORT TraceEndOnScopeClose {
public:
// Note: members of data_ intentionally left uninitialized. See Initialize.
TraceEndOnScopeClose() : p_data_(NULL) {}
@@ -897,11 +858,26 @@ class BASE_EXPORT TraceEndOnScopeClose {
}
void Initialize(const unsigned char* category_enabled,
- const char* name);
+ const char* name) {
+ data_.category_enabled = category_enabled;
+ data_.name = name;
+ p_data_ = &data_;
+ }
+
private:
// Add the end event if the category is still enabled.
- void AddEventIfEnabled();
+ void AddEventIfEnabled() {
+ // Only called when p_data_ is non-null.
+ if (*p_data_->category_enabled) {
+ TRACE_EVENT_API_ADD_TRACE_EVENT(
+ TRACE_EVENT_PHASE_END,
+ p_data_->category_enabled,
+ p_data_->name, kNoEventId,
+ kZeroNumArgs, NULL, NULL, NULL,
+ TRACE_EVENT_FLAG_NONE);
+ }
+ }
// This Data struct workaround is to avoid initializing all the members
// in Data during construction of this object, since this object is always
@@ -916,7 +892,6 @@ class BASE_EXPORT TraceEndOnScopeClose {
Data data_;
};
-
} // namespace trace_event_internal
-#endif // BASE_DEBUG_TRACE_EVENT_H_
+#endif // BASE_DEBUG_TRACE_EVENT_INTERNAL_H_
« no previous file with comments | « base/debug/trace_event.cc ('k') | ppapi/api/dev/ppb_trace_event_dev.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698