Index: content/common/gpu/gpu_channel.cc |
diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc |
index 7bf61344c8fb2029e179fd21b2a92e5a9219f7c6..44746f465df334bdf205899f35555af0d8c6115f 100644 |
--- a/content/common/gpu/gpu_channel.cc |
+++ b/content/common/gpu/gpu_channel.cc |
@@ -98,53 +98,79 @@ class GpuChannelMessageFilter : public IPC::MessageFilter { |
sender_ = NULL; |
} |
- bool OnMessageReceived(const IPC::Message& message) override { |
- DCHECK(sender_); |
+ struct MessageStatus { |
+ int routing_id; |
+ bool forwarded; |
+ bool handled; |
+ }; |
- bool handled = false; |
- if ((message.type() == GpuCommandBufferMsg_RetireSyncPoint::ID) && |
- !future_sync_points_) { |
+ void OnRetireSyncPoint(uint32 sync_point) { |
+ if (future_sync_points_) { |
+ current_status_.handled = false; |
+ } else { |
DLOG(ERROR) << "Untrusted client should not send " |
"GpuCommandBufferMsg_RetireSyncPoint message"; |
- return true; |
+ current_status_.forwarded = false; |
} |
+ } |
- if (message.type() == GpuCommandBufferMsg_InsertSyncPoint::ID) { |
- Tuple1<bool> retire; |
- IPC::Message* reply = IPC::SyncMessage::GenerateReply(&message); |
- if (!GpuCommandBufferMsg_InsertSyncPoint::ReadSendParam(&message, |
- &retire)) { |
- reply->set_reply_error(); |
- Send(reply); |
- return true; |
- } |
- if (!future_sync_points_ && !retire.a) { |
- LOG(ERROR) << "Untrusted contexts can't create future sync points"; |
- reply->set_reply_error(); |
- Send(reply); |
- return true; |
- } |
- uint32 sync_point = sync_point_manager_->GenerateSyncPoint(); |
- GpuCommandBufferMsg_InsertSyncPoint::WriteReplyParams(reply, sync_point); |
- Send(reply); |
- message_loop_->PostTask( |
- FROM_HERE, |
- base::Bind(&GpuChannelMessageFilter::InsertSyncPointOnMainThread, |
- gpu_channel_, |
- sync_point_manager_, |
- message.routing_id(), |
- retire.a, |
- sync_point)); |
- handled = true; |
+ void OnAsyncFlush(int32 put_offset, |
+ uint32 flush_count, |
+ const std::vector<uint32>& sync_points, |
+ const std::vector<ui::LatencyInfo>& latency_info) { |
+ std::vector<uint32> sanitized_sync_points; |
+ for (uint32 sync_point : sync_points) { |
+ if (sync_point_manager_->WasSyncPointGenerated(sync_point)) |
+ sanitized_sync_points.push_back(sync_point); |
} |
+ message_loop_->PostTask( |
+ FROM_HERE, |
+ base::Bind(base::IgnoreResult(&GpuChannel::OnMessageReceived), |
+ gpu_channel_, |
+ GpuCommandBufferMsg_AsyncFlush( |
+ current_status_.routing_id, put_offset, flush_count, |
+ sanitized_sync_points, latency_info))); |
+ } |
+ |
+ void OnInsertSyncPoint(bool retire, uint32* sync_point) { |
+ if (!future_sync_points_ && !retire) { |
+ *sync_point = 0; |
+ LOG(ERROR) << "Untrusted contexts can't create future sync points"; |
+ current_status_.forwarded = false; |
+ return; |
+ } |
+ *sync_point = sync_point_manager_->GenerateSyncPoint(); |
+ message_loop_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&GpuChannelMessageFilter::InsertSyncPointOnMainThread, |
+ gpu_channel_, sync_point_manager_, |
+ current_status_.routing_id, retire, *sync_point)); |
+ } |
- // All other messages get processed by the GpuChannel. |
- messages_forwarded_to_channel_++; |
- if (preempting_flag_.get()) |
- pending_messages_.push(PendingMessage(messages_forwarded_to_channel_)); |
- UpdatePreemptionState(); |
+ bool OnMessageReceived(const IPC::Message& message) override { |
+ DCHECK(sender_); |
+ |
+ current_status_.routing_id = message.routing_id(); |
+ current_status_.forwarded = true; |
+ current_status_.handled = true; |
+ IPC_BEGIN_MESSAGE_MAP(GpuChannelMessageFilter, message) |
+ IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RetireSyncPoint, |
+ OnRetireSyncPoint) |
+ IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush) |
+ IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_InsertSyncPoint, |
+ OnInsertSyncPoint) |
+ IPC_MESSAGE_UNHANDLED(current_status_.handled = false) |
+ IPC_END_MESSAGE_MAP() |
+ |
+ if (current_status_.forwarded) { |
+ // All other messages get processed by the GpuChannel. |
+ messages_forwarded_to_channel_++; |
+ if (preempting_flag_.get()) |
+ pending_messages_.push(PendingMessage(messages_forwarded_to_channel_)); |
+ UpdatePreemptionState(); |
+ } |
- return handled; |
+ return current_status_.handled; |
} |
void MessageProcessed(uint64 messages_processed) { |
@@ -382,6 +408,7 @@ class GpuChannelMessageFilter : public IPC::MessageFilter { |
// passed through - therefore the WeakPtr assumptions are respected. |
base::WeakPtr<GpuChannel> gpu_channel_; |
IPC::Sender* sender_; |
+ MessageStatus current_status_; |
scoped_refptr<gpu::SyncPointManager> sync_point_manager_; |
scoped_refptr<base::MessageLoopProxy> message_loop_; |
scoped_refptr<gpu::PreemptionFlag> preempting_flag_; |