summaryrefslogtreecommitdiffstats
path: root/cc/debug/devtools_instrumentation.h
blob: 4b2136672b34e50afe24ce7666e49385f5174f7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_
#define CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_

#include "base/debug/trace_event.h"

namespace cc {
namespace devtools_instrumentation {

namespace internal {
const char kCategory[] = "cc,devtools";
const char kLayerId[] = "layerId";
const char kPaintLayer[] = "PaintLayer";
const char kRasterTask[] = "RasterTask";
}

struct ScopedPaintLayer {
  explicit ScopedPaintLayer(int layer_id) {
    TRACE_EVENT_BEGIN1(internal::kCategory, internal::kPaintLayer,
        internal::kLayerId, layer_id);
  }
  ~ScopedPaintLayer() {
    TRACE_EVENT_END0(internal::kCategory, internal::kPaintLayer);
  }

  DISALLOW_COPY_AND_ASSIGN(ScopedPaintLayer);
};

struct ScopedRasterTask {
  explicit ScopedRasterTask(int layer_id) {
    TRACE_EVENT_BEGIN1(internal::kCategory, internal::kRasterTask,
        internal::kLayerId, layer_id);
  }
  ~ScopedRasterTask() {
    TRACE_EVENT_END0(internal::kCategory, internal::kRasterTask);
  }

  DISALLOW_COPY_AND_ASSIGN(ScopedRasterTask);
};

struct ScopedLayerObjectTracker
    : public base::debug::TraceScopedTrackableObject<int> {
  explicit ScopedLayerObjectTracker(int layer_id)
      : base::debug::TraceScopedTrackableObject<int>(
            internal::kCategory,
            internal::kLayerId,
            layer_id) {
  }

  DISALLOW_COPY_AND_ASSIGN(ScopedLayerObjectTracker);
};

}  // namespace devtools_instrumentation
}  // namespace cc

#endif  // CC_DEBUG_DEVTOOLS_INSTRUMENTATION_H_