#include "platform/EventTracer.h"
#include "public/platform/Platform.h"
+#include "public/platform/WebConvertableToTraceFormat.h"
#include "wtf/Assertions.h"
#include <stdio.h>
-namespace WebCore {
+namespace blink {
-COMPILE_ASSERT(sizeof(WebKit::Platform::TraceEventHandle) == sizeof(TraceEvent::TraceEventHandle), TraceEventHandle_types_must_be_compatible);
+COMPILE_ASSERT(sizeof(Platform::TraceEventHandle) == sizeof(TraceEvent::TraceEventHandle), TraceEventHandle_types_must_be_compatible);
// The dummy variable is needed to avoid a crash when someone updates the state variables
// before EventTracer::initialize() is called.
void EventTracer::initialize()
{
- traceSamplingState[0] = WebKit::Platform::current()->getTraceSamplingState(0);
+ // current() might not exist in unit tests.
+ if (!Platform::current())
+ return;
+
+ traceSamplingState[0] = Platform::current()->getTraceSamplingState(0);
// FIXME: traceSamplingState[0] can be 0 in split-dll build. http://crbug.com/256965
if (!traceSamplingState[0])
traceSamplingState[0] = &dummyTraceSamplingState;
- traceSamplingState[1] = WebKit::Platform::current()->getTraceSamplingState(1);
+ traceSamplingState[1] = Platform::current()->getTraceSamplingState(1);
if (!traceSamplingState[1])
traceSamplingState[1] = &dummyTraceSamplingState;
- traceSamplingState[2] = WebKit::Platform::current()->getTraceSamplingState(2);
+ traceSamplingState[2] = Platform::current()->getTraceSamplingState(2);
if (!traceSamplingState[2])
traceSamplingState[2] = &dummyTraceSamplingState;
}
const unsigned char* EventTracer::getTraceCategoryEnabledFlag(const char* categoryName)
{
- return WebKit::Platform::current()->getTraceCategoryEnabledFlag(categoryName);
+ static const char* dummyCategoryEnabledFlag = "*";
+ // current() might not exist in unit tests.
+ if (!Platform::current())
+ return reinterpret_cast<const unsigned char*>(dummyCategoryEnabledFlag);
+
+ return Platform::current()->getTraceCategoryEnabledFlag(categoryName);
+}
+
+TraceEvent::TraceEventHandle EventTracer::addTraceEvent(char phase, const unsigned char* categoryEnabledFlag,
+ const char* name, unsigned long long id, int numArgs, const char* argNames[],
+ const unsigned char argTypes[], const unsigned long long argValues[],
+ TraceEvent::ConvertableToTraceFormat* convertableValues[],
+ unsigned char flags)
+{
+ WebConvertableToTraceFormat webConvertableValues[2];
+ if (numArgs <= static_cast<int>(WTF_ARRAY_LENGTH(webConvertableValues))) {
+ for (int i = 0; i < numArgs; ++i) {
+ if (convertableValues[i])
+ webConvertableValues[i] = WebConvertableToTraceFormat(convertableValues[i]);
+ }
+ } else {
+ ASSERT_NOT_REACHED();
+ }
+ return Platform::current()->addTraceEvent(phase, categoryEnabledFlag, name, id, numArgs, argNames, argTypes, argValues, webConvertableValues, flags);
}
TraceEvent::TraceEventHandle EventTracer::addTraceEvent(char phase, const unsigned char* categoryEnabledFlag,
const char* name, unsigned long long id, int numArgs, const char** argNames,
- const unsigned char* argTypes, const unsigned long long* argValues, unsigned char flags)
+ const unsigned char* argTypes, const unsigned long long* argValues,
+ unsigned char flags)
{
- return WebKit::Platform::current()->addTraceEvent(phase, categoryEnabledFlag, name, id, numArgs, argNames, argTypes, argValues, flags);
+ return Platform::current()->addTraceEvent(phase, categoryEnabledFlag, name, id, numArgs, argNames, argTypes, argValues, 0, flags);
}
-void EventTracer::updateTraceEventDuration(TraceEvent::TraceEventHandle handle)
+void EventTracer::updateTraceEventDuration(const unsigned char* categoryEnabledFlag, const char* name, TraceEvent::TraceEventHandle handle)
{
- WebKit::Platform::current()->updateTraceEventDuration(handle);
+ Platform::current()->updateTraceEventDuration(categoryEnabledFlag, name, handle);
}
-} // namespace WebCore
+} // namespace blink