Revert of Return Windows error code when create-process fails. (patchset #12 id:22000...
[chromium-blink-merge.git] / cc / debug / devtools_instrumentation.h
blob8f03f8c76fcdd3f50cb3550b995d88d3e52d3c40
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(void* pixelRef) {
56 TRACE_EVENT_BEGIN1(internal::kCategory, internal::kImageDecodeTask,
57 internal::kPixelRefId, reinterpret_cast<uint64>(pixelRef));
59 ~ScopedImageDecodeTask() {
60 TRACE_EVENT_END0(internal::kCategory, internal::kImageDecodeTask);
62 private:
63 DISALLOW_COPY_AND_ASSIGN(ScopedImageDecodeTask);
66 class ScopedLayerTreeTask {
67 public:
68 ScopedLayerTreeTask(const char* event_name,
69 int layer_id,
70 int layer_tree_host_id)
71 : event_name_(event_name) {
72 TRACE_EVENT_BEGIN2(internal::kCategory, event_name_,
73 internal::kLayerId, layer_id,
74 internal::kLayerTreeId, layer_tree_host_id);
76 ~ScopedLayerTreeTask() {
77 TRACE_EVENT_END0(internal::kCategory, event_name_);
79 private:
80 const char* event_name_;
82 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTreeTask);
85 struct ScopedCommitTrace {
86 public:
87 explicit ScopedCommitTrace(int layer_tree_host_id) {
88 TRACE_EVENT_BEGIN1(internal::kCategory, internal::kCompositeLayers,
89 internal::kLayerTreeId, layer_tree_host_id);
91 ~ScopedCommitTrace() {
92 TRACE_EVENT_END0(internal::kCategory, internal::kCompositeLayers);
95 private:
96 DISALLOW_COPY_AND_ASSIGN(ScopedCommitTrace);
99 struct ScopedLayerObjectTracker
100 : public base::trace_event::TraceScopedTrackableObject<int> {
101 explicit ScopedLayerObjectTracker(int layer_id)
102 : base::trace_event::TraceScopedTrackableObject<int>(
103 internal::kCategory,
104 internal::kLayerId,
105 layer_id) {
108 private:
109 DISALLOW_COPY_AND_ASSIGN(ScopedLayerObjectTracker);
112 inline void DidActivateLayerTree(int layer_tree_host_id, int frame_id) {
113 TRACE_EVENT_INSTANT2(internal::kCategoryFrame,
114 internal::kActivateLayerTree,
115 TRACE_EVENT_SCOPE_THREAD,
116 internal::kLayerTreeId,
117 layer_tree_host_id,
118 internal::kFrameId,
119 frame_id);
122 inline void DidBeginFrame(int layer_tree_host_id) {
123 TRACE_EVENT_INSTANT1(internal::kCategoryFrame,
124 internal::kBeginFrame,
125 TRACE_EVENT_SCOPE_THREAD,
126 internal::kLayerTreeId,
127 layer_tree_host_id);
130 inline void DidDrawFrame(int layer_tree_host_id) {
131 TRACE_EVENT_INSTANT1(internal::kCategoryFrame,
132 internal::kDrawFrame,
133 TRACE_EVENT_SCOPE_THREAD,
134 internal::kLayerTreeId,
135 layer_tree_host_id);
138 inline void DidRequestMainThreadFrame(int layer_tree_host_id) {
139 TRACE_EVENT_INSTANT1(internal::kCategoryFrame,
140 internal::kRequestMainThreadFrame,
141 TRACE_EVENT_SCOPE_THREAD,
142 internal::kLayerTreeId,
143 layer_tree_host_id);
146 inline scoped_refptr<base::trace_event::ConvertableToTraceFormat>
147 BeginMainThreadFrameData(int frame_id) {
148 scoped_refptr<base::trace_event::TracedValue> value =
149 new base::trace_event::TracedValue();
150 value->SetInteger("frameId", frame_id);
151 return value;
154 inline void WillBeginMainThreadFrame(int layer_tree_host_id, int frame_id) {
155 TRACE_EVENT_INSTANT2(
156 internal::kCategoryFrame, internal::kBeginMainThreadFrame,
157 TRACE_EVENT_SCOPE_THREAD, internal::kLayerTreeId, layer_tree_host_id,
158 internal::kData, BeginMainThreadFrameData(frame_id));
161 inline scoped_refptr<base::trace_event::ConvertableToTraceFormat>
162 NeedsBeginFrameData(bool needs_begin_frame) {
163 scoped_refptr<base::trace_event::TracedValue> value =
164 new base::trace_event::TracedValue();
165 value->SetInteger("needsBeginFrame", needs_begin_frame);
166 return value;
169 inline void NeedsBeginFrameChanged(int layer_tree_host_id, bool new_value) {
170 TRACE_EVENT_INSTANT2(
171 internal::kCategoryFrame, internal::kNeedsBeginFrameChanged,
172 TRACE_EVENT_SCOPE_THREAD, internal::kLayerTreeId, layer_tree_host_id,
173 internal::kData, NeedsBeginFrameData(new_value));
176 } // namespace devtools_instrumentation
177 } // namespace cc
179 #endif // CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_