Lots of random cleanups, mostly for native_theme_win.cc:
[chromium-blink-merge.git] / cc / debug / frame_viewer_instrumentation.h
blob16cf4335ac2bb20f6fcbbbd8183aa6b4fd29142a
1 // Copyright 2014 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_FRAME_VIEWER_INSTRUMENTATION_H_
6 #define CC_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_
8 #include "base/debug/trace_event.h"
9 #include "cc/resources/tile.h"
11 namespace cc {
12 namespace frame_viewer_instrumentation {
13 namespace internal {
15 const char kCategory[] = "cc";
16 const char kTileData[] = "tileData";
17 const char kLayerId[] = "layerId";
18 const char kTileId[] = "tileId";
19 const char kTileResolution[] = "tileResolution";
20 const char kSourceFrameNumber[] = "sourceFrameNumber";
21 const char kRasterMode[] = "rasterMode";
23 const char kAnalyzeTask[] = "AnalyzeTask";
24 const char kRasterTask[] = "RasterTask";
26 scoped_ptr<base::Value> TileDataAsValue(const void* tile_id,
27 TileResolution tile_resolution,
28 int source_frame_number,
29 int layer_id) {
30 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue);
31 res->Set(internal::kTileId, TracedValue::CreateIDRef(tile_id).release());
32 res->Set(internal::kTileResolution,
33 TileResolutionAsValue(tile_resolution).release());
34 res->SetInteger(internal::kSourceFrameNumber, source_frame_number);
35 res->SetInteger(internal::kLayerId, layer_id);
36 return res.PassAs<base::Value>();
39 } // namespace internal
41 class ScopedAnalyzeTask {
42 public:
43 ScopedAnalyzeTask(const void* tile_id,
44 TileResolution tile_resolution,
45 int source_frame_number,
46 int layer_id) {
47 TRACE_EVENT_BEGIN1(
48 internal::kCategory,
49 internal::kAnalyzeTask,
50 internal::kTileData,
51 TracedValue::FromValue(internal::TileDataAsValue(tile_id,
52 tile_resolution,
53 source_frame_number,
54 layer_id).release()));
56 ~ScopedAnalyzeTask() {
57 TRACE_EVENT_END0(internal::kCategory, internal::kAnalyzeTask);
60 private:
61 DISALLOW_COPY_AND_ASSIGN(ScopedAnalyzeTask);
64 class ScopedRasterTask {
65 public:
66 ScopedRasterTask(const void* tile_id,
67 TileResolution tile_resolution,
68 int source_frame_number,
69 int layer_id,
70 RasterMode raster_mode) {
71 TRACE_EVENT_BEGIN2(
72 internal::kCategory,
73 internal::kRasterTask,
74 internal::kTileData,
75 TracedValue::FromValue(internal::TileDataAsValue(tile_id,
76 tile_resolution,
77 source_frame_number,
78 layer_id).release()),
79 internal::kRasterMode,
80 TracedValue::FromValue(RasterModeAsValue(raster_mode).release()));
82 ~ScopedRasterTask() {
83 TRACE_EVENT_END0(internal::kCategory, internal::kRasterTask);
86 private:
87 DISALLOW_COPY_AND_ASSIGN(ScopedRasterTask);
90 } // namespace frame_viewer_instrumentation
91 } // namespace cc
93 #endif // CC_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_