| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/gpu/devtools_gpu_agent.h" | 5 #include "content/common/gpu/devtools_gpu_agent.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/common/devtools_messages.h" | 8 #include "content/common/devtools_messages.h" |
| 9 #include "content/common/gpu/gpu_channel.h" | 9 #include "content/common/gpu/gpu_channel.h" |
| 10 #include "content/common/gpu/gpu_channel_manager.h" | 10 #include "content/common/gpu/gpu_channel_manager.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 return; | 41 return; |
| 42 GpuEventsDispatcher* dispatcher = | 42 GpuEventsDispatcher* dispatcher = |
| 43 gpu_channel_->gpu_channel_manager()->gpu_devtools_events_dispatcher(); | 43 gpu_channel_->gpu_channel_manager()->gpu_devtools_events_dispatcher(); |
| 44 dispatcher->RemoveProcessor(this); | 44 dispatcher->RemoveProcessor(this); |
| 45 route_id_ = MSG_ROUTING_NONE; | 45 route_id_ = MSG_ROUTING_NONE; |
| 46 } | 46 } |
| 47 | 47 |
| 48 void DevToolsGpuAgent::ProcessEvent( | 48 void DevToolsGpuAgent::ProcessEvent( |
| 49 TimeTicks timestamp, | 49 TimeTicks timestamp, |
| 50 GpuEventsDispatcher::EventPhase phase, | 50 GpuEventsDispatcher::EventPhase phase, |
| 51 int owner_pid) { | 51 base::ProcessId owner_pid) { |
| 52 DCHECK(CalledOnValidThread()); | 52 DCHECK(CalledOnValidThread()); |
| 53 if (route_id_ == MSG_ROUTING_NONE) | 53 if (route_id_ == MSG_ROUTING_NONE) |
| 54 return; | 54 return; |
| 55 | 55 |
| 56 GpuTaskInfo task; | 56 GpuTaskInfo task; |
| 57 task.timestamp = (timestamp - TimeTicks()).InSecondsF(); | 57 task.timestamp = (timestamp - TimeTicks()).InSecondsF(); |
| 58 task.phase = phase; | 58 task.phase = phase; |
| 59 task.owner_pid = owner_pid; | 59 task.foreign = gpu_channel_->renderer_pid() != owner_pid; |
| 60 | 60 |
| 61 const int kFlushIntervalMs = 100; | 61 const int kFlushIntervalMs = 100; |
| 62 const unsigned kMaxPendingItems = 100; | 62 const unsigned kMaxPendingItems = 100; |
| 63 if (!tasks_->empty() && | 63 if (!tasks_->empty() && |
| 64 ((timestamp - last_flush_time_).InMilliseconds() >= kFlushIntervalMs || | 64 ((timestamp - last_flush_time_).InMilliseconds() >= kFlushIntervalMs || |
| 65 tasks_->size() >= kMaxPendingItems)) { | 65 tasks_->size() >= kMaxPendingItems)) { |
| 66 Send(new DevToolsAgentMsg_GpuTasksChunk(route_id_, *tasks_)); | 66 Send(new DevToolsAgentMsg_GpuTasksChunk(route_id_, *tasks_)); |
| 67 tasks_->clear(); | 67 tasks_->clear(); |
| 68 last_flush_time_ = timestamp; | 68 last_flush_time_ = timestamp; |
| 69 } | 69 } |
| 70 tasks_->push_back(task); | 70 tasks_->push_back(task); |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool DevToolsGpuAgent::Send(IPC::Message* msg) { | 73 bool DevToolsGpuAgent::Send(IPC::Message* msg) { |
| 74 scoped_ptr<IPC::Message> message(msg); | 74 scoped_ptr<IPC::Message> message(msg); |
| 75 return gpu_channel_ && gpu_channel_->Send(message.release()); | 75 return gpu_channel_ && gpu_channel_->Send(message.release()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 } // namespace content | 78 } // namespace content |
| OLD | NEW |