service-worker: Directly use the thread's TaskRunner instead of WorkerThreadTaskRunner.
[chromium-blink-merge.git] / skia / ext / event_tracer_impl.cc
blobe28381450865ba93665a02e248886c7c6ec7b337
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/trace_event/trace_event.h"
6 #include "skia/ext/event_tracer_impl.h"
7 #include "third_party/skia/include/utils/SkEventTracer.h"
9 namespace skia {
11 class SkChromiumEventTracer: public SkEventTracer {
12 const uint8_t* getCategoryGroupEnabled(const char* name) override;
13 const char* getCategoryGroupName(const uint8_t* categoryEnabledFlag) override;
14 SkEventTracer::Handle addTraceEvent(char phase,
15 const uint8_t* categoryEnabledFlag,
16 const char* name,
17 uint64_t id,
18 int32_t numArgs,
19 const char** argNames,
20 const uint8_t* argTypes,
21 const uint64_t* argValues,
22 uint8_t flags) override;
23 void updateTraceEventDuration(const uint8_t* categoryEnabledFlag,
24 const char* name,
25 SkEventTracer::Handle handle) override;
28 const uint8_t*
29 SkChromiumEventTracer::getCategoryGroupEnabled(const char* name) {
30 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(name);
33 const char* SkChromiumEventTracer::getCategoryGroupName(
34 const uint8_t* categoryEnabledFlag) {
35 return base::debug::TraceLog::GetCategoryGroupName(
36 categoryEnabledFlag);
39 SkEventTracer::Handle
40 SkChromiumEventTracer::addTraceEvent(char phase,
41 const uint8_t* categoryEnabledFlag,
42 const char* name,
43 uint64_t id,
44 int32_t numArgs,
45 const char** argNames,
46 const uint8_t* argTypes,
47 const uint64_t* argValues,
48 uint8_t flags) {
49 base::debug::TraceEventHandle handle = TRACE_EVENT_API_ADD_TRACE_EVENT(
50 phase, categoryEnabledFlag, name, id, numArgs, argNames,
51 argTypes, (const long long unsigned int*) argValues, NULL, flags);
52 SkEventTracer::Handle result;
53 memcpy(&result, &handle, sizeof(result));
54 return result;
57 void
58 SkChromiumEventTracer::updateTraceEventDuration(
59 const uint8_t* categoryEnabledFlag,
60 const char *name,
61 SkEventTracer::Handle handle) {
62 base::debug::TraceEventHandle traceEventHandle;
63 memcpy(&traceEventHandle, &handle, sizeof(handle));
64 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
65 categoryEnabledFlag, name, traceEventHandle);
68 } // namespace skia
71 void InitSkiaEventTracer() {
72 // Initialize the binding to Skia's tracing events. Skia will
73 // take ownership of and clean up the memory allocated here.
74 SkEventTracer::SetInstance(new skia::SkChromiumEventTracer());