OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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. |
| 4 |
| 5 #include "content/common/browser_plugin_messages.h" |
| 6 #include "content/renderer/browser_plugin/browser_plugin_compositing_filter.h" |
| 7 |
| 8 namespace content { |
| 9 |
| 10 BrowserPluginCompositingFilter::BrowserPluginCompositingFilter( |
| 11 base::TaskRunner* target_task_runner, |
| 12 int instance_id, |
| 13 const Handler& handler) |
| 14 : target_task_runner_(target_task_runner), |
| 15 instance_id_(instance_id), |
| 16 handler_(handler){ |
| 17 |
| 18 DCHECK(target_task_runner_); |
| 19 message_ids_to_filter_.insert(BrowserPluginMsg_BuffersSwapped::ID); |
| 20 message_ids_to_filter_.insert(BrowserPluginMsg_SurfaceResize::ID); |
| 21 } |
| 22 |
| 23 int BrowserPluginCompositingFilter::GetPluginInstanceID( |
| 24 const IPC::Message& message) { |
| 25 int instance_id; |
| 26 DCHECK(!message.is_sync()); |
| 27 PickleIterator iter(message); |
| 28 bool success = iter.ReadInt(&instance_id); |
| 29 DCHECK(success); |
| 30 return instance_id; |
| 31 } |
| 32 |
| 33 bool BrowserPluginCompositingFilter::OnMessageReceived( |
| 34 const IPC::Message& message) { |
| 35 if (message_ids_to_filter_.find(message.type()) == |
| 36 message_ids_to_filter_.end() || |
| 37 GetPluginInstanceID(message) != instance_id_) |
| 38 return false; |
| 39 |
| 40 target_task_runner_->PostTask(FROM_HERE, base::Bind(handler_, message)); |
| 41 return true; |
| 42 } |
| 43 |
| 44 BrowserPluginCompositingFilter::~BrowserPluginCompositingFilter() { |
| 45 } |
| 46 |
| 47 } // namespace IPC |
OLD | NEW |