Update V8 to version 4.7.44.
[chromium-blink-merge.git] / cc / debug / devtools_instrumentation.h
blob3a285799840c54577af3a15a381ba0e8c798f187
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/trace_event/trace_event.h"
9 #include "base/trace_event/trace_event_argument.h"
11 namespace cc {
12 namespace devtools_instrumentation {
14 namespace internal {
15 const char kCategory[] = TRACE_DISABLED_BY_DEFAULT("devtools.timeline");
16 const char kCategoryFrame[] =
17 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.frame");
18 const char kData[] = "data";
19 const char kFrameId[] = "frameId";
20 const char kLayerId[] = "layerId";
21 const char kLayerTreeId[] = "layerTreeId";
22 const char kPixelRefId[] = "pixelRefId";
24 const char kImageDecodeTask[] = "ImageDecodeTask";
25 const char kBeginFrame[] = "BeginFrame";
26 const char kNeedsBeginFrameChanged[] = "NeedsBeginFrameChanged";
27 const char kActivateLayerTree[] = "ActivateLayerTree";
28 const char kRequestMainThreadFrame[] = "RequestMainThreadFrame";
29 const char kBeginMainThreadFrame[] = "BeginMainThreadFrame";
30 const char kDrawFrame[] = "DrawFrame";
31 const char kCompositeLayers[] = "CompositeLayers";
32 } // namespace internal
34 const char kPaintSetup[] = "PaintSetup";
35 const char kUpdateLayer[] = "UpdateLayer";
37 class ScopedLayerTask {
38 public:
39 ScopedLayerTask(const char* event_name, int layer_id)
40 : event_name_(event_name) {
41 TRACE_EVENT_BEGIN1(internal::kCategory, event_name_,
42 internal::kLayerId, layer_id);
44 ~ScopedLayerTask() {
45 TRACE_EVENT_END0(internal::kCategory, event_name_);
47 private:
48 const char* event_name_;
50 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTask);
53 class ScopedImageDecodeTask {
54 public:
55 explicit ScopedImageDecodeTask(const void* imagePtr) {
56 TRACE_EVENT_BEGIN1(internal::kCategory, internal::kImageDecodeTask,
57 internal::kPixelRefId,
58 reinterpret_cast<uint64>(imagePtr));
60 ~ScopedImageDecodeTask() {
61 TRACE_EVENT_END0(internal::kCategory, internal::kImageDecodeTask);
63 private:
64 DISALLOW_COPY_AND_ASSIGN(ScopedImageDecodeTask);
67 class ScopedLayerTreeTask {
68 public:
69 ScopedLayerTreeTask(const char* event_name,
70 int layer_id,
71 int layer_tree_host_id)
72 : event_name_(event_name) {
73 TRACE_EVENT_BEGIN2(internal::kCategory, event_name_,
74 internal::kLayerId, layer_id,
75 internal::kLayerTreeId, layer_tree_host_id);
77 ~ScopedLayerTreeTask() {
78 TRACE_EVENT_END0(internal::kCategory, event_name_);
80 private:
81 const char* event_name_;
83 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTreeTask);
86 struct ScopedCommitTrace {
87 public:
88 explicit ScopedCommitTrace(int layer_tree_host_id) {
89 TRACE_EVENT_BEGIN1(internal::kCategory, internal::kCompositeLayers,
90 internal::kLayerTreeId, layer_tree_host_id);
92 ~ScopedCommitTrace() {
93 TRACE_EVENT_END0(internal::kCategory, internal::kCompositeLayers);
96 private:
97 DISALLOW_COPY_AND_ASSIGN(ScopedCommitTrace);
100 struct ScopedLayerObjectTracker
101 : public base::trace_event::TraceScopedTrackableObject<int> {
102 explicit ScopedLayerObjectTracker(int layer_id)
103 : base::trace_event::TraceScopedTrackableObject<int>(
104 internal::kCategory,
105 internal::kLayerId,
106 layer_id) {
109 private:
110 DISALLOW_COPY_AND_ASSIGN(ScopedLayerObjectTracker);
113 inline void DidActivateLayerTree(int layer_tree_host_id, int frame_id) {
114 TRACE_EVENT_INSTANT2(internal::kCategoryFrame,
115 internal::kActivateLayerTree,
116 TRACE_EVENT_SCOPE_THREAD,
117 internal::kLayerTreeId,
118 layer_tree_host_id,
119 internal::kFrameId,
120 frame_id);
123 inline void DidBeginFrame(int layer_tree_host_id) {
124 TRACE_EVENT_INSTANT1(internal::kCategoryFrame,
125 internal::kBeginFrame,
126 TRACE_EVENT_SCOPE_THREAD,
127 internal::kLayerTreeId,
128 layer_tree_host_id);
131 inline void DidDrawFrame(int layer_tree_host_id) {
132 TRACE_EVENT_INSTANT1(internal::kCategoryFrame,
133 internal::kDrawFrame,
134 TRACE_EVENT_SCOPE_THREAD,
135 internal::kLayerTreeId,
136 layer_tree_host_id);
139 inline void DidRequestMainThreadFrame(int layer_tree_host_id) {
140 TRACE_EVENT_INSTANT1(internal::kCategoryFrame,
141 internal::kRequestMainThreadFrame,
142 TRACE_EVENT_SCOPE_THREAD,
143 internal::kLayerTreeId,
144 layer_tree_host_id);
147 inline scoped_refptr<base::trace_event::ConvertableToTraceFormat>
148 BeginMainThreadFrameData(int frame_id) {
149 scoped_refptr<base::trace_event::TracedValue> value =
150 new base::trace_event::TracedValue();
151 value->SetInteger("frameId", frame_id);
152 return value;
155 inline void WillBeginMainThreadFrame(int layer_tree_host_id, int frame_id) {
156 TRACE_EVENT_INSTANT2(
157 internal::kCategoryFrame, internal::kBeginMainThreadFrame,
158 TRACE_EVENT_SCOPE_THREAD, internal::kLayerTreeId, layer_tree_host_id,
159 internal::kData, BeginMainThreadFrameData(frame_id));
162 inline scoped_refptr<base::trace_event::ConvertableToTraceFormat>
163 NeedsBeginFrameData(bool needs_begin_frame) {
164 scoped_refptr<base::trace_event::TracedValue> value =
165 new base::trace_event::TracedValue();
166 value->SetInteger("needsBeginFrame", needs_begin_frame);
167 return value;
170 inline void NeedsBeginFrameChanged(int layer_tree_host_id, bool new_value) {
171 TRACE_EVENT_INSTANT2(
172 internal::kCategoryFrame, internal::kNeedsBeginFrameChanged,
173 TRACE_EVENT_SCOPE_THREAD, internal::kLayerTreeId, layer_tree_host_id,
174 internal::kData, NeedsBeginFrameData(new_value));
177 } // namespace devtools_instrumentation
178 } // namespace cc
180 #endif // CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_