| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_ | 5 #ifndef CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_ |
| 6 #define CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_ | 6 #define CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_ |
| 7 | 7 |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 | 9 |
| 10 namespace cc { | 10 namespace cc { |
| 11 namespace devtools_instrumentation { | 11 namespace devtools_instrumentation { |
| 12 | 12 |
| 13 namespace internal { | 13 namespace internal { |
| 14 const char kCategory[] = "cc,devtools"; | 14 const char kCategory[] = "cc,devtools"; |
| 15 const char kFrameId[] = "frameId"; |
| 15 const char kLayerId[] = "layerId"; | 16 const char kLayerId[] = "layerId"; |
| 16 const char kLayerTreeId[] = "layerTreeId"; | 17 const char kLayerTreeId[] = "layerTreeId"; |
| 17 const char kPixelRefId[] = "pixelRefId"; | 18 const char kPixelRefId[] = "pixelRefId"; |
| 18 | 19 |
| 19 const char kImageDecodeTask[] = "ImageDecodeTask"; | 20 const char kImageDecodeTask[] = "ImageDecodeTask"; |
| 20 } | 21 const char kBeginFrame[] = "BeginFrame"; |
| 22 const char kActivateLayerTree[] = "ActivateLayerTree"; |
| 23 } // namespace internal |
| 21 | 24 |
| 22 const char kPaintLayer[] = "PaintLayer"; | 25 const char kPaintLayer[] = "PaintLayer"; |
| 23 const char kRasterTask[] = "RasterTask"; | 26 const char kRasterTask[] = "RasterTask"; |
| 24 const char kPaintSetup[] = "PaintSetup"; | 27 const char kPaintSetup[] = "PaintSetup"; |
| 25 const char kUpdateLayer[] = "UpdateLayer"; | 28 const char kUpdateLayer[] = "UpdateLayer"; |
| 26 | 29 |
| 27 class ScopedLayerTask { | 30 class ScopedLayerTask { |
| 28 public: | 31 public: |
| 29 ScopedLayerTask(const char* event_name, int layer_id) | 32 ScopedLayerTask(const char* event_name, int layer_id) |
| 30 : event_name_(event_name) { | 33 : event_name_(event_name) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 50 TRACE_EVENT_END0(internal::kCategory, internal::kImageDecodeTask); | 53 TRACE_EVENT_END0(internal::kCategory, internal::kImageDecodeTask); |
| 51 } | 54 } |
| 52 private: | 55 private: |
| 53 DISALLOW_COPY_AND_ASSIGN(ScopedImageDecodeTask); | 56 DISALLOW_COPY_AND_ASSIGN(ScopedImageDecodeTask); |
| 54 }; | 57 }; |
| 55 | 58 |
| 56 class ScopedLayerTreeTask { | 59 class ScopedLayerTreeTask { |
| 57 public: | 60 public: |
| 58 ScopedLayerTreeTask(const char* event_name, | 61 ScopedLayerTreeTask(const char* event_name, |
| 59 int layer_id, | 62 int layer_id, |
| 60 uint64 tree_id) | 63 int layer_tree_host_id) |
| 61 : event_name_(event_name) { | 64 : event_name_(event_name) { |
| 62 TRACE_EVENT_BEGIN2(internal::kCategory, event_name_, | 65 TRACE_EVENT_BEGIN2(internal::kCategory, event_name_, |
| 63 internal::kLayerId, layer_id, internal::kLayerTreeId, tree_id); | 66 internal::kLayerId, layer_id, |
| 67 internal::kLayerTreeId, layer_tree_host_id); |
| 64 } | 68 } |
| 65 ~ScopedLayerTreeTask() { | 69 ~ScopedLayerTreeTask() { |
| 66 TRACE_EVENT_END0(internal::kCategory, event_name_); | 70 TRACE_EVENT_END0(internal::kCategory, event_name_); |
| 67 } | 71 } |
| 68 private: | 72 private: |
| 69 const char* event_name_; | 73 const char* event_name_; |
| 70 | 74 |
| 71 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTreeTask); | 75 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTreeTask); |
| 72 }; | 76 }; |
| 73 | 77 |
| 74 struct ScopedLayerObjectTracker | 78 struct ScopedLayerObjectTracker |
| 75 : public base::debug::TraceScopedTrackableObject<int> { | 79 : public base::debug::TraceScopedTrackableObject<int> { |
| 76 explicit ScopedLayerObjectTracker(int layer_id) | 80 explicit ScopedLayerObjectTracker(int layer_id) |
| 77 : base::debug::TraceScopedTrackableObject<int>( | 81 : base::debug::TraceScopedTrackableObject<int>( |
| 78 internal::kCategory, | 82 internal::kCategory, |
| 79 internal::kLayerId, | 83 internal::kLayerId, |
| 80 layer_id) { | 84 layer_id) { |
| 81 } | 85 } |
| 82 | 86 |
| 83 private: | 87 private: |
| 84 DISALLOW_COPY_AND_ASSIGN(ScopedLayerObjectTracker); | 88 DISALLOW_COPY_AND_ASSIGN(ScopedLayerObjectTracker); |
| 85 }; | 89 }; |
| 86 | 90 |
| 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); |
| 97 } |
| 98 |
| 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); |
| 104 } |
| 105 |
| 87 } // namespace devtools_instrumentation | 106 } // namespace devtools_instrumentation |
| 88 } // namespace cc | 107 } // namespace cc |
| 89 | 108 |
| 90 #endif // CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_ | 109 #endif // CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_ |
| OLD | NEW |