| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/browser/browser_plugin/browser_plugin_message_filter.h" | 5 #include "content/browser/browser_plugin/browser_plugin_message_filter.h" |
| 6 | 6 |
| 7 #include "base/supports_user_data.h" | 7 #include "base/supports_user_data.h" |
| 8 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 8 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 9 #include "content/browser/gpu/gpu_process_host.h" | 9 #include "content/browser/gpu/gpu_process_host.h" |
| 10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
| 11 #include "content/common/browser_plugin/browser_plugin_constants.h" | 11 #include "content/common/browser_plugin/browser_plugin_constants.h" |
| 12 #include "content/common/browser_plugin/browser_plugin_messages.h" | 12 #include "content/common/browser_plugin/browser_plugin_messages.h" |
| 13 #include "content/common/gpu/gpu_messages.h" | |
| 14 #include "content/common/view_messages.h" | 13 #include "content/common/view_messages.h" |
| 15 #include "content/public/browser/browser_context.h" | 14 #include "content/public/browser/browser_context.h" |
| 16 #include "content/public/browser/browser_plugin_guest_manager.h" | 15 #include "content/public/browser/browser_plugin_guest_manager.h" |
| 17 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
| 19 | 18 |
| 20 namespace content { | 19 namespace content { |
| 21 | 20 |
| 22 BrowserPluginMessageFilter::BrowserPluginMessageFilter(int render_process_id) | 21 BrowserPluginMessageFilter::BrowserPluginMessageFilter(int render_process_id) |
| 23 : BrowserMessageFilter(BrowserPluginMsgStart), | 22 : BrowserMessageFilter(BrowserPluginMsgStart), |
| 24 render_process_id_(render_process_id) { | 23 render_process_id_(render_process_id) { |
| 25 } | 24 } |
| 26 | 25 |
| 27 BrowserPluginMessageFilter::~BrowserPluginMessageFilter() { | 26 BrowserPluginMessageFilter::~BrowserPluginMessageFilter() { |
| 28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 29 } | 28 } |
| 30 | 29 |
| 31 bool BrowserPluginMessageFilter::OnMessageReceived( | 30 bool BrowserPluginMessageFilter::OnMessageReceived( |
| 32 const IPC::Message& message) { | 31 const IPC::Message& message) { |
| 33 // Any message requested by a BrowserPluginGuest should be routed through | 32 // Any message requested by a BrowserPluginGuest should be routed through |
| 34 // a BrowserPluginGuestManager. | 33 // a BrowserPluginGuestManager. |
| 35 if (BrowserPluginGuest::ShouldForwardToBrowserPluginGuest(message)) { | 34 if (BrowserPluginGuest::ShouldForwardToBrowserPluginGuest(message)) { |
| 36 ForwardMessageToGuest(message); | 35 ForwardMessageToGuest(message); |
| 37 // We always swallow messages destined for BrowserPluginGuestManager because | 36 // We always swallow messages destined for BrowserPluginGuestManager because |
| 38 // we're on the UI thread and fallback code is expected to be run on the IO | 37 // we're on the UI thread and fallback code is expected to be run on the IO |
| 39 // thread. | 38 // thread. |
| 40 return true; | 39 return true; |
| 41 } | 40 } |
| 42 bool handled = true; | 41 return false; |
| 43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 44 IPC_BEGIN_MESSAGE_MAP(BrowserPluginMessageFilter, message) | |
| 45 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_BuffersSwappedACK, | |
| 46 OnSwapBuffersACK) | |
| 47 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 48 IPC_END_MESSAGE_MAP() | |
| 49 return handled; | |
| 50 } | 42 } |
| 51 | 43 |
| 52 void BrowserPluginMessageFilter::OnDestruct() const { | 44 void BrowserPluginMessageFilter::OnDestruct() const { |
| 53 BrowserThread::DeleteOnIOThread::Destruct(this); | 45 BrowserThread::DeleteOnIOThread::Destruct(this); |
| 54 } | 46 } |
| 55 | 47 |
| 56 void BrowserPluginMessageFilter::OverrideThreadForMessage( | 48 void BrowserPluginMessageFilter::OverrideThreadForMessage( |
| 57 const IPC::Message& message, BrowserThread::ID* thread) { | 49 const IPC::Message& message, BrowserThread::ID* thread) { |
| 58 if (BrowserPluginGuest::ShouldForwardToBrowserPluginGuest(message)) | 50 if (BrowserPluginGuest::ShouldForwardToBrowserPluginGuest(message)) |
| 59 *thread = BrowserThread::UI; | 51 *thread = BrowserThread::UI; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 80 ->GetGuestByInstanceID(embedder_web_contents, | 72 ->GetGuestByInstanceID(embedder_web_contents, |
| 81 browser_plugin_instance_id); | 73 browser_plugin_instance_id); |
| 82 if (!guest_web_contents) | 74 if (!guest_web_contents) |
| 83 return; | 75 return; |
| 84 | 76 |
| 85 static_cast<WebContentsImpl*>(guest_web_contents) | 77 static_cast<WebContentsImpl*>(guest_web_contents) |
| 86 ->GetBrowserPluginGuest() | 78 ->GetBrowserPluginGuest() |
| 87 ->OnMessageReceivedFromEmbedder(message); | 79 ->OnMessageReceivedFromEmbedder(message); |
| 88 } | 80 } |
| 89 | 81 |
| 90 void BrowserPluginMessageFilter::OnSwapBuffersACK( | |
| 91 const FrameHostMsg_BuffersSwappedACK_Params& params) { | |
| 92 GpuProcessHost* gpu_host = GpuProcessHost::FromID(params.gpu_host_id); | |
| 93 if (!gpu_host) | |
| 94 return; | |
| 95 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | |
| 96 ack_params.mailbox = params.mailbox; | |
| 97 ack_params.sync_point = params.sync_point; | |
| 98 gpu_host->Send(new AcceleratedSurfaceMsg_BufferPresented(params.gpu_route_id, | |
| 99 ack_params)); | |
| 100 } | |
| 101 | |
| 102 } // namespace content | 82 } // namespace content |
| OLD | NEW |