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";
19 const char kPaintLayer
[] = "PaintLayer";
20 const char kRasterTask
[] = "RasterTask";
21 const char kImageDecodeTask
[] = "ImageDecodeTask";
22 const char kPaintSetup
[] = "PaintSetup";
23 const char kUpdateLayer
[] = "UpdateLayer";
25 class ScopedLayerTask
{
27 ScopedLayerTask(const char* event_name
, int layer_id
)
28 : event_name_(event_name
) {
29 TRACE_EVENT_BEGIN1(internal::kCategory
, event_name_
,
30 internal::kLayerId
, layer_id
);
33 TRACE_EVENT_END0(internal::kCategory
, event_name_
);
36 const char* event_name_
;
38 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTask
);
41 class ScopedLayerTreeTask
{
43 ScopedLayerTreeTask(const char* event_name
,
46 : event_name_(event_name
) {
47 TRACE_EVENT_BEGIN2(internal::kCategory
, event_name_
,
48 internal::kLayerId
, layer_id
, internal::kLayerTreeId
, tree_id
);
50 ~ScopedLayerTreeTask() {
51 TRACE_EVENT_END0(internal::kCategory
, event_name_
);
54 const char* event_name_
;
56 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTreeTask
);
59 struct ScopedLayerObjectTracker
60 : public base::debug::TraceScopedTrackableObject
<int> {
61 explicit ScopedLayerObjectTracker(int layer_id
)
62 : base::debug::TraceScopedTrackableObject
<int>(
69 DISALLOW_COPY_AND_ASSIGN(ScopedLayerObjectTracker
);
72 } // namespace devtools_instrumentation
75 #endif // CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_