From 39c08ac3be30f9956cea7c5e4fd9a1d86e993a65 Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Wed, 26 Jul 2017 09:36:09 -0400 Subject: Automatically prepend "disabled-by-default-" to TRACE categories Ensures that all Skia events are disabled by default in Chrome, and eliminates redundant typing. Bug: skia: Change-Id: I289c5e5a01084fcf4cccf512da65a4727f4aeca2 Reviewed-on: https://skia-review.googlesource.com/26880 Commit-Queue: Mike Klein Reviewed-by: Mike Klein --- tools/trace/SkEventTracingPriv.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'tools/trace') diff --git a/tools/trace/SkEventTracingPriv.cpp b/tools/trace/SkEventTracingPriv.cpp index 42d992cb13..7a9ca2ee80 100644 --- a/tools/trace/SkEventTracingPriv.cpp +++ b/tools/trace/SkEventTracingPriv.cpp @@ -12,7 +12,7 @@ #include "SkCommandLineFlags.h" #include "SkDebugfTracer.h" #include "SkEventTracer.h" -#include "SkTraceEventCommon.h" +#include "SkTraceEvent.h" DEFINE_string(trace, "", "Log trace events in one of several modes:\n" @@ -42,17 +42,17 @@ void initializeEventTracingForTools(const char* traceFlag) { SkAssertResult(SkEventTracer::SetInstance(eventTracer)); } -uint8_t* SkEventTracingCategories::getCategoryGroupEnabled(const char* name) { - static_assert(0 == offsetof(CategoryState, fEnabled), "CategoryState"); - - // We ignore the "disabled-by-default-" prefix in our internal tools (though we could honor it) - if (SkStrStartsWith(name, TRACE_DISABLED_BY_DEFAULT_PREFIX)) { - name += strlen(TRACE_DISABLED_BY_DEFAULT_PREFIX); - } - - // Chrome's implementation of this API does a two-phase lookup (once without a lock, then again - // with a lock. But the tracing macros avoid calling these functions more than once per site, - // so just do something simple (and easier to reason about): +uint8_t* SkEventTracingCategories::getCategoryGroupEnabled(const char* name) { + static_assert(0 == offsetof(CategoryState, fEnabled), "CategoryState"); + + // We ignore the "disabled-by-default-" prefix in our internal tools + if (SkStrStartsWith(name, TRACE_CATEGORY_PREFIX)) { + name += strlen(TRACE_CATEGORY_PREFIX); + } + + // Chrome's implementation of this API does a two-phase lookup (once without a lock, then again + // with a lock. But the tracing macros avoid calling these functions more than once per site, + // so just do something simple (and easier to reason about): SkAutoMutexAcquire lock(&fMutex); for (int i = 0; i < fNumCategories; ++i) { if (0 == strcmp(name, fCategories[i].fName)) { @@ -71,7 +71,7 @@ uint8_t* SkEventTracingCategories::getCategoryGroupEnabled(const char* name) { return reinterpret_cast(&fCategories[fNumCategories++]); } -const char* SkEventTracingCategories::getCategoryGroupName(const uint8_t* categoryEnabledFlag) { +const char* SkEventTracingCategories::getCategoryGroupName(const uint8_t* categoryEnabledFlag) { if (categoryEnabledFlag) { return reinterpret_cast(categoryEnabledFlag)->fName; } -- cgit v1.2.3