Mac Remote CoreAnimation: Fix flashing at tab-switch
[chromium-blink-merge.git] / content / common / gpu / devtools_gpu_instrumentation.cc
blob0167cf8547af4365c8708a4895dc034edd1c6c30
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 #include "content/common/gpu/devtools_gpu_instrumentation.h"
7 #include "base/logging.h"
8 #include "base/time/time.h"
9 #include "content/common/gpu/devtools_gpu_agent.h"
10 #include "content/common/gpu/gpu_channel.h"
11 #include "content/common/gpu/gpu_channel_manager.h"
13 namespace content {
15 bool GpuEventsDispatcher::enabled_ = false;
17 GpuEventsDispatcher::GpuEventsDispatcher() {
20 GpuEventsDispatcher::~GpuEventsDispatcher() {
23 void GpuEventsDispatcher::AddProcessor(DevToolsGpuAgent* processor) {
24 DCHECK(CalledOnValidThread());
25 processors_.push_back(processor);
26 enabled_ = !processors_.empty();
29 void GpuEventsDispatcher::RemoveProcessor(DevToolsGpuAgent* processor) {
30 DCHECK(CalledOnValidThread());
31 processors_.erase(
32 std::remove(processors_.begin(), processors_.end(), processor),
33 processors_.end());
34 enabled_ = !processors_.empty();
37 // static
38 void GpuEventsDispatcher::DoFireEvent(EventPhase phase,
39 GpuChannel* channel) {
40 TimeTicks timestamp = base::TimeTicks::NowFromSystemTraceTime();
41 GpuEventsDispatcher* self =
42 channel->gpu_channel_manager()->gpu_devtools_events_dispatcher();
43 DCHECK(self->CalledOnValidThread());
44 std::vector<DevToolsGpuAgent*>::iterator it;
45 for (it = self->processors_.begin(); it != self->processors_.end(); ++it) {
46 (*it)->ProcessEvent(timestamp, phase, channel);
50 } // namespace