1 // Copyright 2013 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 #ifndef CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_
6 #define CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_
8 #include "base/debug/trace_event.h"
11 namespace devtools_instrumentation
{
14 const char kCategory
[] = "cc,devtools";
15 const char kLayerId
[] = "layerId";
16 const char kLayerTreeId
[] = "layerTreeId";
17 const char kPixelRefId
[] = "pixelRefId";
19 const char kImageDecodeTask
[] = "ImageDecodeTask";
22 const char kPaintLayer
[] = "PaintLayer";
23 const char kRasterTask
[] = "RasterTask";
24 const char kPaintSetup
[] = "PaintSetup";
25 const char kUpdateLayer
[] = "UpdateLayer";
27 class ScopedLayerTask
{
29 ScopedLayerTask(const char* event_name
, int layer_id
)
30 : event_name_(event_name
) {
31 TRACE_EVENT_BEGIN1(internal::kCategory
, event_name_
,
32 internal::kLayerId
, layer_id
);
35 TRACE_EVENT_END0(internal::kCategory
, event_name_
);
38 const char* event_name_
;
40 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTask
);
43 class ScopedImageDecodeTask
{
45 explicit ScopedImageDecodeTask(void* pixelRef
) {
46 TRACE_EVENT_BEGIN1(internal::kCategory
, internal::kImageDecodeTask
,
47 internal::kPixelRefId
, reinterpret_cast<uint64
>(pixelRef
));
49 ~ScopedImageDecodeTask() {
50 TRACE_EVENT_END0(internal::kCategory
, internal::kImageDecodeTask
);
53 DISALLOW_COPY_AND_ASSIGN(ScopedImageDecodeTask
);
56 class ScopedLayerTreeTask
{
58 ScopedLayerTreeTask(const char* event_name
,
61 : event_name_(event_name
) {
62 TRACE_EVENT_BEGIN2(internal::kCategory
, event_name_
,
63 internal::kLayerId
, layer_id
, internal::kLayerTreeId
, tree_id
);
65 ~ScopedLayerTreeTask() {
66 TRACE_EVENT_END0(internal::kCategory
, event_name_
);
69 const char* event_name_
;
71 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTreeTask
);
74 struct ScopedLayerObjectTracker
75 : public base::debug::TraceScopedTrackableObject
<int> {
76 explicit ScopedLayerObjectTracker(int layer_id
)
77 : base::debug::TraceScopedTrackableObject
<int>(
84 DISALLOW_COPY_AND_ASSIGN(ScopedLayerObjectTracker
);
87 } // namespace devtools_instrumentation
90 #endif // CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_