Fix missing .Pass() on returning scoped_ptr<SdchManager::DictionarySet>
[chromium-blink-merge.git] / cc / debug / devtools_instrumentation.h
blob96fa3a523ae90c5b53e5c8d7f19e6bef8351b471
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 kPaintSetup[] = "PaintSetup";
30 const char kUpdateLayer[] = "UpdateLayer";
32 class ScopedLayerTask {
33 public:
34 ScopedLayerTask(const char* event_name, int layer_id)
35 : event_name_(event_name) {
36 TRACE_EVENT_BEGIN1(internal::kCategory, event_name_,
37 internal::kLayerId, layer_id);
39 ~ScopedLayerTask() {
40 TRACE_EVENT_END0(internal::kCategory, event_name_);
42 private:
43 const char* event_name_;
45 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTask);
48 class ScopedImageDecodeTask {
49 public:
50 explicit ScopedImageDecodeTask(void* pixelRef) {
51 TRACE_EVENT_BEGIN1(internal::kCategory, internal::kImageDecodeTask,
52 internal::kPixelRefId, reinterpret_cast<uint64>(pixelRef));
54 ~ScopedImageDecodeTask() {
55 TRACE_EVENT_END0(internal::kCategory, internal::kImageDecodeTask);
57 private:
58 DISALLOW_COPY_AND_ASSIGN(ScopedImageDecodeTask);
61 class ScopedLayerTreeTask {
62 public:
63 ScopedLayerTreeTask(const char* event_name,
64 int layer_id,
65 int layer_tree_host_id)
66 : event_name_(event_name) {
67 TRACE_EVENT_BEGIN2(internal::kCategory, event_name_,
68 internal::kLayerId, layer_id,
69 internal::kLayerTreeId, layer_tree_host_id);
71 ~ScopedLayerTreeTask() {
72 TRACE_EVENT_END0(internal::kCategory, event_name_);
74 private:
75 const char* event_name_;
77 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTreeTask);
80 struct ScopedLayerObjectTracker
81 : public base::debug::TraceScopedTrackableObject<int> {
82 explicit ScopedLayerObjectTracker(int layer_id)
83 : base::debug::TraceScopedTrackableObject<int>(
84 internal::kCategory,
85 internal::kLayerId,
86 layer_id) {
89 private:
90 DISALLOW_COPY_AND_ASSIGN(ScopedLayerObjectTracker);
93 inline void DidActivateLayerTree(int layer_tree_host_id, int frame_id) {
94 TRACE_EVENT_INSTANT2(internal::kCategoryFrame,
95 internal::kActivateLayerTree,
96 TRACE_EVENT_SCOPE_THREAD,
97 internal::kLayerTreeId,
98 layer_tree_host_id,
99 internal::kFrameId,
100 frame_id);
103 inline void DidBeginFrame(int layer_tree_host_id) {
104 TRACE_EVENT_INSTANT1(internal::kCategoryFrame,
105 internal::kBeginFrame,
106 TRACE_EVENT_SCOPE_THREAD,
107 internal::kLayerTreeId,
108 layer_tree_host_id);
111 inline void DidDrawFrame(int layer_tree_host_id) {
112 TRACE_EVENT_INSTANT1(internal::kCategoryFrame,
113 internal::kDrawFrame,
114 TRACE_EVENT_SCOPE_THREAD,
115 internal::kLayerTreeId,
116 layer_tree_host_id);
119 inline void DidRequestMainThreadFrame(int layer_tree_host_id) {
120 TRACE_EVENT_INSTANT1(internal::kCategoryFrame,
121 internal::kRequestMainThreadFrame,
122 TRACE_EVENT_SCOPE_THREAD,
123 internal::kLayerTreeId,
124 layer_tree_host_id);
127 } // namespace devtools_instrumentation
128 } // namespace cc
130 #endif // CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_