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_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "content/browser/browser_plugin/browser_plugin_guest_helper.h" | 9 #include "content/browser/browser_plugin/browser_plugin_guest_helper.h" |
10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" | 10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 WebContentsImpl* web_contents, | 32 WebContentsImpl* web_contents, |
33 RenderViewHost* render_view_host) | 33 RenderViewHost* render_view_host) |
34 : WebContentsObserver(web_contents), | 34 : WebContentsObserver(web_contents), |
35 embedder_render_process_host_(NULL), | 35 embedder_render_process_host_(NULL), |
36 instance_id_(instance_id), | 36 instance_id_(instance_id), |
37 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
38 damage_buffer_size_(0), | 38 damage_buffer_size_(0), |
39 #endif | 39 #endif |
40 pending_update_counter_(0), | 40 pending_update_counter_(0), |
41 guest_hang_timeout_( | 41 guest_hang_timeout_( |
42 base::TimeDelta::FromMilliseconds(kGuestHangTimeoutMs)) { | 42 base::TimeDelta::FromMilliseconds(kGuestHangTimeoutMs)), |
| 43 swapped_out_embedder_routing_id_(MSG_ROUTING_NONE), |
| 44 swapped_out_guest_routing_id_(MSG_ROUTING_NONE) { |
43 DCHECK(web_contents); | 45 DCHECK(web_contents); |
44 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper. | 46 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper. |
45 new BrowserPluginGuestHelper(this, render_view_host); | 47 new BrowserPluginGuestHelper(this, render_view_host); |
46 } | 48 } |
47 | 49 |
48 BrowserPluginGuest::~BrowserPluginGuest() { | 50 BrowserPluginGuest::~BrowserPluginGuest() { |
49 } | 51 } |
50 | 52 |
51 // static | 53 // static |
52 BrowserPluginGuest* BrowserPluginGuest::Create( | 54 BrowserPluginGuest* BrowserPluginGuest::Create( |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 pending_input_event_reply_.reset(reply_message); | 219 pending_input_event_reply_.reset(reply_message); |
218 // Input events are handled synchronously, meaning it blocks the embedder. We | 220 // Input events are handled synchronously, meaning it blocks the embedder. We |
219 // set a hang monitor here that will kill the guest process (5s timeout) if we | 221 // set a hang monitor here that will kill the guest process (5s timeout) if we |
220 // don't receive an ack. This will kill all the guests that are running in the | 222 // don't receive an ack. This will kill all the guests that are running in the |
221 // same process (undesired behavior). | 223 // same process (undesired behavior). |
222 // TODO(fsamuel,lazyboy): Find a way to get rid of guest process kill | 224 // TODO(fsamuel,lazyboy): Find a way to get rid of guest process kill |
223 // behavior. http://crbug.com/147272. | 225 // behavior. http://crbug.com/147272. |
224 guest_rvh->StartHangMonitorTimeout(guest_hang_timeout_); | 226 guest_rvh->StartHangMonitorTimeout(guest_hang_timeout_); |
225 } | 227 } |
226 | 228 |
| 229 void BrowserPluginGuest::RouteMessageEvent( |
| 230 const ViewMsg_PostMessage_Params& params) { |
| 231 BrowserPluginMsg_ReceiveMessage_Params out_params; |
| 232 out_params.source_routing_id = swapped_out_embedder_routing_id(); |
| 233 out_params.source_origin = params.source_origin; |
| 234 out_params.source_frame_id = params.source_frame_id; |
| 235 out_params.target_frame_id = params.target_frame_id; |
| 236 out_params.data = params.data; |
| 237 SendMessageToEmbedder( |
| 238 new BrowserPluginMsg_ReceiveMessage(instance_id(), out_params)); |
| 239 } |
| 240 |
227 void BrowserPluginGuest::HandleInputEventAck(RenderViewHost* render_view_host, | 241 void BrowserPluginGuest::HandleInputEventAck(RenderViewHost* render_view_host, |
228 bool handled) { | 242 bool handled) { |
229 RenderViewHostImpl* guest_rvh = | 243 RenderViewHostImpl* guest_rvh = |
230 static_cast<RenderViewHostImpl*>(render_view_host); | 244 static_cast<RenderViewHostImpl*>(render_view_host); |
231 guest_rvh->StopHangMonitorTimeout(); | 245 guest_rvh->StopHangMonitorTimeout(); |
232 DCHECK(pending_input_event_reply_.get()); | 246 DCHECK(pending_input_event_reply_.get()); |
233 IPC::Message* reply_message = pending_input_event_reply_.release(); | 247 IPC::Message* reply_message = pending_input_event_reply_.release(); |
234 BrowserPluginHostMsg_HandleInputEvent::WriteReplyParams(reply_message, | 248 BrowserPluginHostMsg_HandleInputEvent::WriteReplyParams(reply_message, |
235 handled, | 249 handled, |
236 cursor_); | 250 cursor_); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 iter.Advance(); | 311 iter.Advance(); |
298 } | 312 } |
299 } | 313 } |
300 | 314 |
301 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { | 315 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { |
302 DCHECK(embedder_render_process_host()); | 316 DCHECK(embedder_render_process_host()); |
303 embedder_render_process_host()->Send(msg); | 317 embedder_render_process_host()->Send(msg); |
304 } | 318 } |
305 | 319 |
306 } // namespace content | 320 } // namespace content |
OLD | NEW |