Lots of random cleanups, mostly for native_theme_win.cc:
[chromium-blink-merge.git] / cc / debug / devtools_instrumentation.h
blob85a9850f20b92600c0b769830259ee68a09d04f4
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"
10 namespace cc {
11 namespace devtools_instrumentation {
13 namespace internal {
14 const char kCategory[] = TRACE_DISABLED_BY_DEFAULT("devtools.timeline");
15 const char kCategoryFrame[] =
16 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.frame");
17 const char kFrameId[] = "frameId";
18 const char kLayerId[] = "layerId";
19 const char kLayerTreeId[] = "layerTreeId";
20 const char kPixelRefId[] = "pixelRefId";
22 const char kImageDecodeTask[] = "ImageDecodeTask";
23 const char kBeginFrame[] = "BeginFrame";
24 const char kActivateLayerTree[] = "ActivateLayerTree";
25 const char kRequestMainThreadFrame[] = "RequestMainThreadFrame";
26 const char kDrawFrame[] = "DrawFrame";
27 } // namespace internal
29 const char kRasterTask[] = "RasterTask";
30 const char kPaintSetup[] = "PaintSetup";
31 const char kUpdateLayer[] = "UpdateLayer";
33 class ScopedLayerTask {
34 public:
35 ScopedLayerTask(const char* event_name, int layer_id)
36 : event_name_(event_name) {
37 TRACE_EVENT_BEGIN1(internal::kCategory, event_name_,
38 internal::kLayerId, layer_id);
40 ~ScopedLayerTask() {
41 TRACE_EVENT_END0(internal::kCategory, event_name_);
43 private:
44 const char* event_name_;
46 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTask);
49 class ScopedImageDecodeTask {
50 public:
51 explicit ScopedImageDecodeTask(void* pixelRef) {
52 TRACE_EVENT_BEGIN1(internal::kCategory, internal::kImageDecodeTask,
53 internal::kPixelRefId, reinterpret_cast<uint64>(pixelRef));
55 ~ScopedImageDecodeTask() {
56 TRACE_EVENT_END0(internal::kCategory, internal::kImageDecodeTask);
58 private:
59 DISALLOW_COPY_AND_ASSIGN(ScopedImageDecodeTask);
62 class ScopedLayerTreeTask {
63 public:
64 ScopedLayerTreeTask(const char* event_name,
65 int layer_id,
66 int layer_tree_host_id)
67 : event_name_(event_name) {
68 TRACE_EVENT_BEGIN2(internal::kCategory, event_name_,
69 internal::kLayerId, layer_id,
70 internal::kLayerTreeId, layer_tree_host_id);
72 ~ScopedLayerTreeTask() {
73 TRACE_EVENT_END0(internal::kCategory, event_name_);
75 private:
76 const char* event_name_;
78 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTreeTask);
81 struct ScopedLayerObjectTracker
82 : public base::debug::TraceScopedTrackableObject<int> {
83 explicit ScopedLayerObjectTracker(int layer_id)
84 : base::debug::TraceScopedTrackableObject<int>(
85 internal::kCategory,
86 internal::kLayerId,
87 layer_id) {
90 private:
91 DISALLOW_COPY_AND_ASSIGN(ScopedLayerObjectTracker);
94 inline void DidActivateLayerTree(int layer_tree_host_id, int frame_id) {
95 TRACE_EVENT_INSTANT2(internal::kCategoryFrame,
96 internal::kActivateLayerTree,
97 TRACE_EVENT_SCOPE_THREAD,
98 internal::kLayerTreeId,
99 layer_tree_host_id,
100 internal::kFrameId,
101 frame_id);
104 inline void DidBeginFrame(int layer_tree_host_id) {
105 TRACE_EVENT_INSTANT1(internal::kCategoryFrame,
106 internal::kBeginFrame,
107 TRACE_EVENT_SCOPE_THREAD,
108 internal::kLayerTreeId,
109 layer_tree_host_id);
112 inline void DidDrawFrame(int layer_tree_host_id) {
113 TRACE_EVENT_INSTANT1(internal::kCategoryFrame,
114 internal::kDrawFrame,
115 TRACE_EVENT_SCOPE_THREAD,
116 internal::kLayerTreeId,
117 layer_tree_host_id);
120 inline void DidRequestMainThreadFrame(int layer_tree_host_id) {
121 TRACE_EVENT_INSTANT1(internal::kCategoryFrame,
122 internal::kRequestMainThreadFrame,
123 TRACE_EVENT_SCOPE_THREAD,
124 internal::kLayerTreeId,
125 layer_tree_host_id);
128 } // namespace devtools_instrumentation
129 } // namespace cc
131 #endif // CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_