[Password Generation] Make sure to dismiss UI after scrolling
[chromium-blink-merge.git] / cc / debug / devtools_instrumentation.h
blob8d19a4b5458330abab9af3605c54926d3cfaead7
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[] = "cc,devtools";
15 const char kFrameId[] = "frameId";
16 const char kLayerId[] = "layerId";
17 const char kLayerTreeId[] = "layerTreeId";
18 const char kPixelRefId[] = "pixelRefId";
20 const char kImageDecodeTask[] = "ImageDecodeTask";
21 const char kBeginFrame[] = "BeginFrame";
22 const char kActivateLayerTree[] = "ActivateLayerTree";
23 const char kRequestMainThreadFrame[] = "RequestMainThreadFrame";
24 const char kDrawFrame[] = "DrawFrame";
25 } // namespace internal
27 const char kRasterTask[] = "RasterTask";
28 const char kPaintSetup[] = "PaintSetup";
30 class ScopedLayerTask {
31 public:
32 ScopedLayerTask(const char* event_name, int layer_id)
33 : event_name_(event_name) {
34 TRACE_EVENT_BEGIN1(internal::kCategory, event_name_,
35 internal::kLayerId, layer_id);
37 ~ScopedLayerTask() {
38 TRACE_EVENT_END0(internal::kCategory, event_name_);
40 private:
41 const char* event_name_;
43 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTask);
46 class ScopedImageDecodeTask {
47 public:
48 explicit ScopedImageDecodeTask(void* pixelRef) {
49 TRACE_EVENT_BEGIN1(internal::kCategory, internal::kImageDecodeTask,
50 internal::kPixelRefId, reinterpret_cast<uint64>(pixelRef));
52 ~ScopedImageDecodeTask() {
53 TRACE_EVENT_END0(internal::kCategory, internal::kImageDecodeTask);
55 private:
56 DISALLOW_COPY_AND_ASSIGN(ScopedImageDecodeTask);
59 class ScopedLayerTreeTask {
60 public:
61 ScopedLayerTreeTask(const char* event_name,
62 int layer_id,
63 int layer_tree_host_id)
64 : event_name_(event_name) {
65 TRACE_EVENT_BEGIN2(internal::kCategory, event_name_,
66 internal::kLayerId, layer_id,
67 internal::kLayerTreeId, layer_tree_host_id);
69 ~ScopedLayerTreeTask() {
70 TRACE_EVENT_END0(internal::kCategory, event_name_);
72 private:
73 const char* event_name_;
75 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTreeTask);
78 struct ScopedLayerObjectTracker
79 : public base::debug::TraceScopedTrackableObject<int> {
80 explicit ScopedLayerObjectTracker(int layer_id)
81 : base::debug::TraceScopedTrackableObject<int>(
82 internal::kCategory,
83 internal::kLayerId,
84 layer_id) {
87 private:
88 DISALLOW_COPY_AND_ASSIGN(ScopedLayerObjectTracker);
91 inline void DidActivateLayerTree(int layer_tree_host_id, int frame_id) {
92 TRACE_EVENT_INSTANT2(internal::kCategory,
93 internal::kActivateLayerTree,
94 TRACE_EVENT_SCOPE_THREAD,
95 internal::kLayerTreeId, layer_tree_host_id,
96 internal::kFrameId, frame_id);
99 inline void DidBeginFrame(int layer_tree_host_id) {
100 TRACE_EVENT_INSTANT1(internal::kCategory,
101 internal::kBeginFrame,
102 TRACE_EVENT_SCOPE_THREAD,
103 internal::kLayerTreeId, layer_tree_host_id);
106 inline void DidDrawFrame(int layer_tree_host_id) {
107 TRACE_EVENT_INSTANT1(internal::kCategory,
108 internal::kDrawFrame,
109 TRACE_EVENT_SCOPE_THREAD,
110 internal::kLayerTreeId,
111 layer_tree_host_id);
114 inline void DidRequestMainThreadFrame(int layer_tree_host_id) {
115 TRACE_EVENT_INSTANT1(internal::kCategory,
116 internal::kRequestMainThreadFrame,
117 TRACE_EVENT_SCOPE_THREAD,
118 internal::kLayerTreeId,
119 layer_tree_host_id);
122 } // namespace devtools_instrumentation
123 } // namespace cc
125 #endif // CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_