Mac Remote CoreAnimation: Fix flashing at tab-switch
[chromium-blink-merge.git] / content / common / gpu / devtools_gpu_instrumentation.h
blob1296625860bfe280fa1c31e3cc3795169d9a5189
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 CONTENT_COMMON_GPU_DEVTOOLS_GPU_INSTRUMENTATION_H_
6 #define CONTENT_COMMON_GPU_DEVTOOLS_GPU_INSTRUMENTATION_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/threading/non_thread_safe.h"
13 namespace content {
15 class DevToolsGpuAgent;
16 class GpuChannel;
18 class GpuEventsDispatcher : public base::NonThreadSafe {
19 public:
20 enum EventPhase {
21 kEventStart,
22 kEventFinish
25 GpuEventsDispatcher();
26 ~GpuEventsDispatcher();
28 void AddProcessor(DevToolsGpuAgent* processor);
29 void RemoveProcessor(DevToolsGpuAgent* processor);
31 static void FireEvent(EventPhase phase, GpuChannel* channel) {
32 if (!IsEnabled())
33 return;
34 DoFireEvent(phase, channel);
37 private:
38 static bool IsEnabled() { return enabled_; }
39 static void DoFireEvent(EventPhase, GpuChannel* channel);
41 static bool enabled_;
42 std::vector<DevToolsGpuAgent*> processors_;
45 namespace devtools_gpu_instrumentation {
47 class ScopedGpuTask {
48 public:
49 explicit ScopedGpuTask(GpuChannel* channel) :
50 channel_(channel) {
51 GpuEventsDispatcher::FireEvent(GpuEventsDispatcher::kEventStart, channel_);
53 ~ScopedGpuTask() {
54 GpuEventsDispatcher::FireEvent(GpuEventsDispatcher::kEventFinish, channel_);
56 private:
57 GpuChannel* channel_;
58 DISALLOW_COPY_AND_ASSIGN(ScopedGpuTask);
61 } // namespace devtools_gpu_instrumentation
63 } // namespace content
65 #endif // CONTENT_COMMON_GPU_DEVTOOLS_GPU_INSTRUMENTATION_H_