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 23 matching lines...) Expand all Loading... |
34 RenderViewHost* render_view_host) | 34 RenderViewHost* render_view_host) |
35 : WebContentsObserver(web_contents), | 35 : WebContentsObserver(web_contents), |
36 embedder_render_process_host_(NULL), | 36 embedder_render_process_host_(NULL), |
37 instance_id_(instance_id), | 37 instance_id_(instance_id), |
38 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
39 damage_buffer_size_(0), | 39 damage_buffer_size_(0), |
40 #endif | 40 #endif |
41 damage_buffer_scale_factor_(1.0f), | 41 damage_buffer_scale_factor_(1.0f), |
42 pending_update_counter_(0), | 42 pending_update_counter_(0), |
43 guest_hang_timeout_( | 43 guest_hang_timeout_( |
44 base::TimeDelta::FromMilliseconds(kGuestHangTimeoutMs)) { | 44 base::TimeDelta::FromMilliseconds(kGuestHangTimeoutMs)), |
| 45 swapped_out_embedder_routing_id_(MSG_ROUTING_NONE), |
| 46 swapped_out_guest_routing_id_(MSG_ROUTING_NONE) { |
45 DCHECK(web_contents); | 47 DCHECK(web_contents); |
46 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper. | 48 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper. |
47 new BrowserPluginGuestHelper(this, render_view_host); | 49 new BrowserPluginGuestHelper(this, render_view_host); |
48 } | 50 } |
49 | 51 |
50 BrowserPluginGuest::~BrowserPluginGuest() { | 52 BrowserPluginGuest::~BrowserPluginGuest() { |
51 } | 53 } |
52 | 54 |
53 // static | 55 // static |
54 BrowserPluginGuest* BrowserPluginGuest::Create( | 56 BrowserPluginGuest* BrowserPluginGuest::Create( |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 pending_input_event_reply_.reset(reply_message); | 223 pending_input_event_reply_.reset(reply_message); |
222 // Input events are handled synchronously, meaning it blocks the embedder. We | 224 // Input events are handled synchronously, meaning it blocks the embedder. We |
223 // set a hang monitor here that will kill the guest process (5s timeout) if we | 225 // set a hang monitor here that will kill the guest process (5s timeout) if we |
224 // don't receive an ack. This will kill all the guests that are running in the | 226 // don't receive an ack. This will kill all the guests that are running in the |
225 // same process (undesired behavior). | 227 // same process (undesired behavior). |
226 // TODO(fsamuel,lazyboy): Find a way to get rid of guest process kill | 228 // TODO(fsamuel,lazyboy): Find a way to get rid of guest process kill |
227 // behavior. http://crbug.com/147272. | 229 // behavior. http://crbug.com/147272. |
228 guest_rvh->StartHangMonitorTimeout(guest_hang_timeout_); | 230 guest_rvh->StartHangMonitorTimeout(guest_hang_timeout_); |
229 } | 231 } |
230 | 232 |
| 233 void BrowserPluginGuest::RouteMessageEvent( |
| 234 const ViewMsg_PostMessage_Params& params) { |
| 235 BrowserPluginMsg_ReceiveMessage_Params out_params; |
| 236 out_params.source_routing_id = swapped_out_embedder_routing_id(); |
| 237 out_params.source_origin = params.source_origin; |
| 238 out_params.source_frame_id = params.source_frame_id; |
| 239 out_params.target_frame_id = params.target_frame_id; |
| 240 out_params.data = params.data; |
| 241 SendMessageToEmbedder( |
| 242 new BrowserPluginMsg_ReceiveMessage(instance_id(), out_params)); |
| 243 } |
| 244 |
231 void BrowserPluginGuest::HandleInputEventAck(RenderViewHost* render_view_host, | 245 void BrowserPluginGuest::HandleInputEventAck(RenderViewHost* render_view_host, |
232 bool handled) { | 246 bool handled) { |
233 RenderViewHostImpl* guest_rvh = | 247 RenderViewHostImpl* guest_rvh = |
234 static_cast<RenderViewHostImpl*>(render_view_host); | 248 static_cast<RenderViewHostImpl*>(render_view_host); |
235 guest_rvh->StopHangMonitorTimeout(); | 249 guest_rvh->StopHangMonitorTimeout(); |
236 DCHECK(pending_input_event_reply_.get()); | 250 DCHECK(pending_input_event_reply_.get()); |
237 IPC::Message* reply_message = pending_input_event_reply_.release(); | 251 IPC::Message* reply_message = pending_input_event_reply_.release(); |
238 BrowserPluginHostMsg_HandleInputEvent::WriteReplyParams(reply_message, | 252 BrowserPluginHostMsg_HandleInputEvent::WriteReplyParams(reply_message, |
239 handled, | 253 handled, |
240 cursor_); | 254 cursor_); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 break; | 331 break; |
318 } | 332 } |
319 } | 333 } |
320 | 334 |
321 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { | 335 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { |
322 DCHECK(embedder_render_process_host()); | 336 DCHECK(embedder_render_process_host()); |
323 embedder_render_process_host()->Send(msg); | 337 embedder_render_process_host()->Send(msg); |
324 } | 338 } |
325 | 339 |
326 } // namespace content | 340 } // namespace content |
OLD | NEW |