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"
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());
32 std::remove(processors_
.begin(), processors_
.end(), processor
),
34 enabled_
= !processors_
.empty();
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
);